public void process()

in language/ide/indexing/src/org/netbeans/modules/jackpot30/indexing/index/Indexer.java [81:149]


    public void process (@NonNull CompilationUnitTree toProcess, @NonNull Indexable indexable, @NonNull Lookup services) {
        IndexWriter luceneWriter = access.getIndexWriter(root, cacheRoot, INDEX_NAME);
        String relative = access.getRelativePath(indexable);
        ByteArrayOutputStream out = null;
        EncodingContext ec;

        try {
            out = new ByteArrayOutputStream();

            ec = new EncodingContext(out, false);

            BulkSearch.getDefault().encode(toProcess, ec, new AtomicBoolean());

            luceneWriter.deleteDocuments(new Term("languagePath", relative));

            Document doc = new Document();

            doc.add(new Field("languageContent", new TokenStreamImpl(ec.getContent())));
            out.close();
            doc.add(new Field("languageEncoded", CompressionTools.compress(out.toByteArray()), Field.Store.YES));
            doc.add(new Field("languagePath", relative, Field.Store.YES, Field.Index.NOT_ANALYZED));

            if (services != null) {
                final Set<String> erased = new HashSet<String>();
                final Trees trees = services.lookup(Trees.class);
                final Types types = services.lookup(Types.class);

                new TreePathScanner<Void, Void>() {
                    @Override
                    public Void scan(Tree tree, Void p) {
                        if (tree != null) {
                            TreePath tp = new TreePath(getCurrentPath(), tree);
                            TypeMirror type = trees.getTypeMirror(tp);

                            if (type != null) {
                                if (type.getKind() == TypeKind.ARRAY) {
                                    erased.add(types.erasure(type).toString());
                                    type = ((ArrayType) type).getComponentType();
                                }

                                if (type.getKind().isPrimitive() || type.getKind() == TypeKind.DECLARED) {
                                    addErasedTypeAndSuperTypes(types, erased, type);
                                }
                            }

                            //bounds for type variables!!!
                        }
                        return super.scan(tree, p);
                    }
                }.scan(toProcess, null);

                doc.add(new Field("languageErasedTypes", new TokenStreamImpl(erased)));
            }
            
            luceneWriter.addDocument(doc);
        } catch (ThreadDeath td) {
            throw td;
        } catch (Throwable t) {
            Logger.getLogger(Indexer.class.getName()).log(Level.WARNING, null, t);
        } finally {
            if (out != null) {
                try {
                    out.close();
                } catch (IOException ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
        }
    }