Skip to content

Commit

Permalink
Fix for #508 and #509: return accurate matches for Call Hierarchy search
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Sep 2, 2018
1 parent 0029b10 commit 213c240
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;

import org.codehaus.groovy.ast.ASTNode;
import org.codehaus.groovy.ast.AnnotatedNode;
Expand Down Expand Up @@ -388,24 +389,17 @@ private ClassNode findWrappedNode(ClassNode declaringType) {
}

private int getAccuracy(TypeConfidence confidence) {
if (shouldAlwaysBeAccurate() || confidence == TypeConfidence.EXACT) {
// improves call hierarchy and prevents "possible matches" warnings in refactoring wizard
if (confidence == TypeConfidence.EXACT || ACCURATE_REQUESTOR.matcher(requestor.getClass().getName()).find()) {
return SearchMatch.A_ACCURATE;
}
return SearchMatch.A_INACCURATE;
}

/**
* Checks to see if this requestor has something to do with refactoring, if
* so, we always want an accurate match otherwise we get complaints in the
* refactoring wizard of "possible matches"
*/
private boolean shouldAlwaysBeAccurate() {
return (requestor.getClass().getPackage().getName().indexOf("refactoring") != -1);
}
private static final Pattern ACCURATE_REQUESTOR = Pattern.compile("\\.(?:callhierarchy|refactoring)\\.");

private static boolean supportsOverride(IMethod method) throws JavaModelException {
int flags = method.getFlags();
return !(Flags.isPrivate(flags) || Flags.isStatic(flags));
return !(Flags.isPrivate(method.getFlags()) || Flags.isStatic(method.getFlags()));
}

private static boolean isNotSynthetic(String name, ClassNode type) {
Expand Down

0 comments on commit 213c240

Please sign in to comment.