Skip to content

Commit

Permalink
Improve UsesField a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Mar 6, 2024
1 parent 7cc8089 commit 487d97c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public boolean matches(@Nullable JavaType type) {

private boolean matchesTargetTypeName(String fullyQualifiedTypeName) {
return this.targetType != null && fullyQualifiedNamesAreEqual(this.targetType, fullyQualifiedTypeName) ||
this.targetTypePattern != null && this.targetTypePattern.matcher(fullyQualifiedTypeName).matches();
this.targetTypePattern.matcher(fullyQualifiedTypeName).matches();
}

private static boolean isPlainIdentifier(MethodSignatureParser.TargetTypePatternContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ public J visit(@Nullable Tree tree, P p) {
boolean isGlob = field.contains("*") || field.contains("?");
TypeMatcher typeMatcher = null;
for (JavaType.Variable variable : cu.getTypesInUse().getVariables()) {
if ((variable.getName().equals(field) || isGlob && StringUtils.matchesGlob(variable.getName(), field)) &&
if (isGlob && (typeMatcher = typeMatcher == null ? new TypeMatcher(owner, true) : typeMatcher).matches(variable.getOwner()) &&
StringUtils.matchesGlob(variable.getName(), field)) {
return SearchResult.found(cu);
} else if (!isGlob && variable.getName().equals(field) &&
(typeMatcher = typeMatcher == null ? new TypeMatcher(owner, true) : typeMatcher).matches(variable.getOwner())) {
return SearchResult.found(cu);
}
Expand Down

0 comments on commit 487d97c

Please sign in to comment.