use of org.jetbrains.jps.backwardRefs.index.CompiledFileData in project intellij-community by JetBrains.
the class BackwardReferenceIndexUtil method registerFile.
static void registerFile(String filePath, Collection<? extends JavacRef> refs, List<JavacDef> defs, final BackwardReferenceIndexWriter writer) {
try {
final int fileId = writer.enumeratePath(filePath);
int funExprId = 0;
final Map<LightRef, Void> definitions = new HashMap<>(defs.size());
final Map<LightRef, Collection<LightRef>> backwardHierarchyMap = new HashMap<>();
for (JavacDef def : defs) {
if (def instanceof JavacDef.JavacClassDef) {
JavacRef.JavacClass sym = (JavacRef.JavacClass) def.getDefinedElement();
final LightRef.JavaLightClassRef aClass = writer.asClassUsage(sym);
definitions.put(aClass, null);
final JavacRef[] superClasses = ((JavacDef.JavacClassDef) def).getSuperClasses();
for (JavacRef superClass : superClasses) {
LightRef.JavaLightClassRef superClassRef = writer.asClassUsage(superClass);
Collection<LightRef> children = backwardHierarchyMap.get(superClassRef);
if (children == null) {
backwardHierarchyMap.put(superClassRef, children = new SmartList<>());
}
children.add(aClass);
}
} else if (def instanceof JavacDef.JavacFunExprDef) {
final LightRef.JavaLightClassRef functionalType = writer.asClassUsage(def.getDefinedElement());
int id = funExprId++;
LightRef.JavaLightFunExprDef result = new LightRef.JavaLightFunExprDef(id);
definitions.put(result, null);
ContainerUtil.getOrCreate(backwardHierarchyMap, functionalType, (Factory<Collection<LightRef>>) () -> new SmartList<>()).add(result);
}
}
Map<LightRef, Void> convertedRefs = new HashMap<>(refs.size());
for (JavacRef ref : refs) {
LightRef key = writer.enumerateNames(ref);
if (key != null) {
convertedRefs.put(key, null);
}
}
writer.writeData(fileId, new CompiledFileData(backwardHierarchyMap, convertedRefs, definitions));
} catch (IOException e) {
writer.setRebuildCause(e);
}
}
use of org.jetbrains.jps.backwardRefs.index.CompiledFileData in project intellij-community by JetBrains.
the class CompilerBackwardReferenceIndex method close.
public void close() {
myLowMemoryWatcher.stop();
final CommonProcessors.FindFirstProcessor<Exception> exceptionProc = new CommonProcessors.FindFirstProcessor<>();
close(myFilePathEnumerator, exceptionProc);
close(myNameEnumerator, exceptionProc);
for (InvertedIndex<?, ?, CompiledFileData> index : myIndices.values()) {
close(index, exceptionProc);
}
final Exception exception = exceptionProc.getFoundValue();
if (exception != null) {
removeIndexFiles(myIndicesDir);
if (myRebuildRequestCause == null) {
throw new RuntimeException(exception);
}
return;
}
if (myRebuildRequestCause != null) {
removeIndexFiles(myIndicesDir);
}
}
Aggregations