Skip to content

Commit 35d2546

Browse files
Jörg Kubitzjukzi
authored andcommitted
fix slow Quick Outline View eclipse-jdt#1922
don't visit redundant superinterfaces more then once eclipse-jdt#1922
1 parent 662e63e commit 35d2546

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/MethodOverrideTester.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,26 +164,33 @@ public IMethod findOverriddenMethod(IMethod overriding, boolean testVisibility)
164164
* @throws JavaModelException if a problem occurs
165165
*/
166166
public IMethod findOverriddenMethodInHierarchy(IType type, IMethod overriding) throws JavaModelException {
167+
return findOverriddenMethodInHierarchy(type, overriding, new HashSet<>());
168+
}
169+
170+
private IMethod findOverriddenMethodInHierarchy(IType type, IMethod overriding, Set<IType> visitedTypes) throws JavaModelException {
171+
if (!visitedTypes.add(type)) {
172+
return null;
173+
}
167174
IMethod method= findOverriddenMethodInType(type, overriding);
168175
if (method != null) {
169176
return method;
170177
}
171178
IType superClass= fHierarchy.getSuperclass(type);
172179
if (superClass != null) {
173-
IMethod res= findOverriddenMethodInHierarchy(superClass, overriding);
180+
IMethod res= findOverriddenMethodInHierarchy(superClass, overriding, visitedTypes);
174181
if (res != null) {
175182
return res;
176183
}
177184
}
178185
for (IType superInterface : fHierarchy.getSuperInterfaces(type)) {
179-
IMethod res= findOverriddenMethodInHierarchy(superInterface, overriding);
186+
IMethod res= findOverriddenMethodInHierarchy(superInterface, overriding, visitedTypes);
180187
if (res != null) {
181188
return res;
182189
}
183190
}
184191
return method;
185192
}
186-
193+
187194
/**
188195
* Finds all overridden methods in a type and its super types. First the super class is examined and then the implemented interfaces.
189196
* 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
@@ -228,7 +235,7 @@ public IMethod findOverriddenMethodInType(IType overriddenType, IMethod overridi
228235
}
229236
return null;
230237
}
231-
238+
232239
/**
233240
* 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.
234241
* In that case all overridden methods found are returned.

0 commit comments

Comments
 (0)