Skip to content

Commit

Permalink
fix slow Quick Outline View #1922
Browse files Browse the repository at this point in the history
don't visit redundant superinterfaces more then once

#1922
  • Loading branch information
jukzi committed Jan 13, 2025
1 parent 662e63e commit 35d2546
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,26 +164,33 @@ public IMethod findOverriddenMethod(IMethod overriding, boolean testVisibility)
* @throws JavaModelException if a problem occurs
*/
public IMethod findOverriddenMethodInHierarchy(IType type, IMethod overriding) throws JavaModelException {
return findOverriddenMethodInHierarchy(type, overriding, new HashSet<>());
}

private IMethod findOverriddenMethodInHierarchy(IType type, IMethod overriding, Set<IType> visitedTypes) throws JavaModelException {
if (!visitedTypes.add(type)) {
return null;
}
IMethod method= findOverriddenMethodInType(type, overriding);
if (method != null) {
return method;
}
IType superClass= fHierarchy.getSuperclass(type);
if (superClass != null) {
IMethod res= findOverriddenMethodInHierarchy(superClass, overriding);
IMethod res= findOverriddenMethodInHierarchy(superClass, overriding, visitedTypes);
if (res != null) {
return res;
}
}
for (IType superInterface : fHierarchy.getSuperInterfaces(type)) {
IMethod res= findOverriddenMethodInHierarchy(superInterface, overriding);
IMethod res= findOverriddenMethodInHierarchy(superInterface, overriding, visitedTypes);
if (res != null) {
return res;
}
}
return method;
}

/**
* Finds all overridden methods in a type and its super types. First the super class is examined and then the implemented interfaces.
* With generics it is possible that 2 methods in the same type are overidden at the same time. In that case all overrides are returned
Expand Down Expand Up @@ -228,7 +235,7 @@ public IMethod findOverriddenMethodInType(IType overriddenType, IMethod overridi
}
return null;
}

/**
* Finds all overridden methods in a type. With generics it is possible that 2 methods in the same type are overridden at the same time.
* In that case all overridden methods found are returned.
Expand Down

0 comments on commit 35d2546

Please sign in to comment.