mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
method chains search: do not create large number of index requests
This commit is contained in:
+6
-3
@@ -62,7 +62,7 @@ class CompilerReferenceReader {
|
||||
}
|
||||
else {
|
||||
LightRef.LightClassHierarchyElementDef hierarchyElement = ((LightRef.LightMember)ref).getOwner();
|
||||
hierarchy = getWholeHierarchy(hierarchyElement, checkBaseClassAmbiguity);
|
||||
hierarchy = getWholeHierarchy(hierarchyElement, checkBaseClassAmbiguity, -1);
|
||||
}
|
||||
if (hierarchy == null) return null;
|
||||
TIntHashSet set = new TIntHashSet();
|
||||
@@ -222,13 +222,16 @@ class CompilerReferenceReader {
|
||||
}
|
||||
|
||||
@Nullable("return null if the class hierarchy contains ambiguous qualified names")
|
||||
LightRef.NamedLightRef[] getWholeHierarchy(LightRef.LightClassHierarchyElementDef hierarchyElement, boolean checkBaseClassAmbiguity) {
|
||||
LightRef.NamedLightRef[] getWholeHierarchy(LightRef.LightClassHierarchyElementDef hierarchyElement, boolean checkBaseClassAmbiguity, int interruptNumber) {
|
||||
try {
|
||||
Set<LightRef.NamedLightRef> result = new THashSet<>();
|
||||
Queue<LightRef.NamedLightRef> q = new Queue<>(10);
|
||||
q.addLast(hierarchyElement);
|
||||
while (!q.isEmpty()) {
|
||||
LightRef.NamedLightRef curClass = q.pullFirst();
|
||||
if (interruptNumber != -1 && result.size() > interruptNumber) {
|
||||
break;
|
||||
}
|
||||
if (result.add(curClass)) {
|
||||
if (checkBaseClassAmbiguity || curClass != hierarchyElement) {
|
||||
if (hasMultipleDefinitions(curClass)) {
|
||||
@@ -245,7 +248,7 @@ class CompilerReferenceReader {
|
||||
});
|
||||
}
|
||||
}
|
||||
return result.toArray(new LightRef.NamedLightRef[result.size()]);
|
||||
return result.toArray(LightRef.NamedLightRef.EMPTY_ARRAY);
|
||||
}
|
||||
catch (StorageException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
+2
-1
@@ -234,9 +234,10 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceServiceEx imp
|
||||
.filter(r -> r instanceof LightRef.JavaLightMethodRef)
|
||||
.map(r -> (LightRef.JavaLightMethodRef) r)
|
||||
.flatMap(r -> {
|
||||
LightRef.NamedLightRef[] hierarchy = myReader.getWholeHierarchy(r.getOwner(), false);
|
||||
LightRef.NamedLightRef[] hierarchy = myReader.getWholeHierarchy(r.getOwner(), false, 10);
|
||||
return hierarchy == null ? Stream.empty() : Arrays.stream(hierarchy).map(c -> r.override(c.getName()));
|
||||
})
|
||||
.distinct()
|
||||
.map(r -> {
|
||||
int count = myReader.getOccurrenceCount(r);
|
||||
return count <= 1 ? null : new OccurrencesAware<>(
|
||||
|
||||
@@ -35,6 +35,8 @@ public interface LightRef extends RW.Savable {
|
||||
LightRef override(int newOwner);
|
||||
|
||||
interface NamedLightRef extends LightRef {
|
||||
NamedLightRef[] EMPTY_ARRAY = new NamedLightRef[0];
|
||||
|
||||
int getName();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user