in language/ide/indexing/src/org/netbeans/modules/jackpot30/indexing/batch/EnhancedScopes.java [199:263]
private static IndexQuery createOrUpdateIndex(final FileObject src, File indexRoot, boolean update, ProgressHandleWrapper progress, boolean recursive) throws IOException {
final JavaIndexerPlugin index = new Indexer.FactoryImpl().create(src.toURL(), FileUtil.toFileObject(indexRoot));
File timeStampsFile = new File(indexRoot, "timestamps.properties");
Properties timeStamps = new Properties();
if (timeStampsFile.exists()) {
if (!update) {
progress.startNextPart(1);
return IndexQuery.open(src.toURL());
}
InputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream(timeStampsFile));
timeStamps.load(in);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
} finally {
try {
if (in != null)
in.close();
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
}
Collection<FileObject> collected = new LinkedList<FileObject>();
Set<String> removed = new HashSet<String>(timeStamps.stringPropertyNames());
org.netbeans.modules.java.hints.spiimpl.batch.BatchUtilities.recursive(src, src, collected, progress, 0, timeStamps, removed, recursive);
for (String r : removed) {
index.delete(SPIAccessor.getInstance().create(new FakeIndexableImpl(r)));
}
JavaSource js = JavaSource.create(ClasspathInfo.create(ClassPath.EMPTY, ClassPath.EMPTY, ClassPath.EMPTY), collected);
js.runUserActionTask(new Task<CompilationController>() {
@Override public void run(CompilationController parameter) throws Exception {
if (parameter.toPhase(JavaSource.Phase.PARSED).compareTo(JavaSource.Phase.PARSED) < 0) return;
index.process(parameter.getCompilationUnit(), SPIAccessor.getInstance().create(new FileObjectIndexable(src, parameter.getFileObject())), null);
}
}, true);
OutputStream out = null;
try {
out = new BufferedOutputStream(new FileOutputStream(timeStampsFile));
timeStamps.store(out, null);
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
return IndexQuery.open(src.toURL());
}