Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.Set;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;

import org.eclipse.jface.operation.IRunnableContext;
Expand Down Expand Up @@ -64,38 +63,26 @@ public static Set<String> findTestMethods(IRunnableContext context, IJavaProject
var result= new HashSet<String>();
context.run(true, true, (progressMonitor) -> {
String message= Messages.format(JUnitMessages.TestSearchEngine_search_message_progress_monitor, type.getElementName());
SubMonitor subMonitor= SubMonitor.convert(progressMonitor, message, 1);
SubMonitor subMonitor= SubMonitor.convert(progressMonitor, message, 2);
try {
collectMethodNames(type, javaProject, testKind.getId(), result, subMonitor);
IType[] types= type.newSupertypeHierarchy(subMonitor.split(1)).getAllTypes();
Comment thread
trancexpress marked this conversation as resolved.

subMonitor= subMonitor.split(1);
subMonitor.setWorkRemaining(types.length);

for (IType it : types) {
if (!"java.lang.Object".equals(it.getFullyQualifiedName())) {//$NON-NLS-1$
collectDeclaredMethodNames(it, javaProject, testKind.getId(), result);
}
subMonitor.worked(1);
}
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
});
return result;
}

private static void collectMethodNames(IType type, IJavaProject javaProject, String testKindId, Set<String> methodNames, IProgressMonitor monitor) throws JavaModelException {
if (type == null) {
return;
}

SubMonitor subMonitor= SubMonitor.convert(monitor, 3);

collectDeclaredMethodNames(type, javaProject, testKindId, methodNames);
subMonitor.split(1);

String superclassName= type.getSuperclassName();
IType superType= getResolvedType(superclassName, type, javaProject);
collectMethodNames(superType, javaProject, testKindId, methodNames, subMonitor.split(1));

String[] superInterfaceNames= type.getSuperInterfaceNames();
subMonitor.setWorkRemaining(superInterfaceNames.length);
for (String interfaceName : superInterfaceNames) {
superType= getResolvedType(interfaceName, type, javaProject);
collectMethodNames(superType, javaProject, testKindId, methodNames, subMonitor.split(1));
}
}

private static IType getResolvedType(String typeName, IType type, IJavaProject javaProject) throws JavaModelException {
IType resolvedType= null;
if (typeName != null) {
Expand Down
Loading