|
12 | 12 |
|
13 | 13 | import java.util.Set; |
14 | 14 |
|
| 15 | +import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; |
15 | 16 | import org.eclipse.jdt.core.dom.ClassInstanceCreation; |
16 | 17 | import org.eclipse.jdt.core.dom.IBinding; |
17 | 18 | import org.eclipse.jdt.core.dom.ITypeBinding; |
@@ -43,12 +44,15 @@ public LocatorResponse match(org.eclipse.jdt.core.dom.LambdaExpression node, Nod |
43 | 44 |
|
44 | 45 | @Override |
45 | 46 | public LocatorResponse match(Type node, NodeSetWrapper nodeSet, MatchLocator locator) { |
46 | | - if (Set.of(TypeDeclaration.SUPERCLASS_TYPE_PROPERTY, TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY, ClassInstanceCreation.TYPE_PROPERTY).contains(node)) { |
| 47 | + if (!Set.of(TypeDeclaration.SUPERCLASS_TYPE_PROPERTY, TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY, ClassInstanceCreation.TYPE_PROPERTY).contains(node.getLocationInParent())) { |
47 | 48 | return toResponse(IMPOSSIBLE_MATCH); |
48 | 49 | } |
49 | 50 | if (node.getLocationInParent() == ClassInstanceCreation.TYPE_PROPERTY && node.getParent() instanceof ClassInstanceCreation newInst && newInst.getAnonymousClassDeclaration() == null) { |
50 | 51 | return toResponse(IMPOSSIBLE_MATCH); |
51 | 52 | } |
| 53 | + if (node.getParent() instanceof AbstractTypeDeclaration decl && !DOMTypeDeclarationLocator.matchSearchForTypeSuffix(decl, this.locator.pattern.typeSuffix)) { |
| 54 | + return toResponse(IMPOSSIBLE_MATCH); |
| 55 | + } |
52 | 56 | if (this.locator.pattern.superSimpleName == null) { |
53 | 57 | int level = nodeSet.addMatch(node, this.locator.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); |
54 | 58 | return toResponse(level, true); |
@@ -82,23 +86,18 @@ public LocatorResponse resolveLevel(org.eclipse.jdt.core.dom.ASTNode node, IBind |
82 | 86 |
|
83 | 87 | var type = (ITypeBinding) binding; |
84 | 88 | int level = IMPOSSIBLE_MATCH; |
85 | | - if (this.locator.pattern.superRefKind != SuperTypeReferencePattern.ONLY_SUPER_INTERFACES) { |
| 89 | + if (this.locator.pattern.superRefKind != SuperTypeReferencePattern.ONLY_SUPER_INTERFACES || node.getLocationInParent() == TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY) { |
86 | 90 | level = this.resolveLevelForType(this.locator.pattern.superSimpleName, this.locator.pattern.superQualification, |
87 | | - type.getSuperclass()); |
| 91 | + type); |
88 | 92 | if (level == ACCURATE_MATCH) |
89 | 93 | return toResponse(ACCURATE_MATCH); |
90 | 94 | } |
91 | 95 |
|
92 | | - if (this.locator.pattern.superRefKind != SuperTypeReferencePattern.ONLY_SUPER_CLASSES) { |
93 | | - for (ITypeBinding superInterface : type.getInterfaces()) { |
94 | | - int newLevel = this.resolveLevelForType(this.locator.pattern.superSimpleName, this.locator.pattern.superQualification, |
95 | | - superInterface); |
96 | | - if (newLevel > level) { |
97 | | - if (newLevel == ACCURATE_MATCH) |
98 | | - return toResponse(ACCURATE_MATCH); |
99 | | - level = newLevel; |
100 | | - } |
101 | | - } |
| 96 | + if (this.locator.pattern.superRefKind != SuperTypeReferencePattern.ONLY_SUPER_CLASSES || node.getLocationInParent() == TypeDeclaration.SUPERCLASS_TYPE_PROPERTY) { |
| 97 | + level = this.resolveLevelForType(this.locator.pattern.superSimpleName, this.locator.pattern.superQualification, |
| 98 | + type); |
| 99 | + if (level == ACCURATE_MATCH) |
| 100 | + return toResponse(ACCURATE_MATCH); |
102 | 101 | } |
103 | 102 | return toResponse(level); |
104 | 103 | } |
|
0 commit comments