Skip to content

Commit 718d8c6

Browse files
committed
Continue work
Signed-off-by: Rob Stryker <[email protected]>
1 parent 4bdf93a commit 718d8c6

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/core/search/matching/DOMConstructorLocator.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,21 +179,9 @@ && matchesTypeReference(this.locator.pattern.declaringSimpleName, typeDecl.getSu
179179
filter(x -> x instanceof MethodDeclaration md && md.isConstructor()).findAny().orElse(null);
180180
if( constructor == null ) {
181181
// We are searching for a constructor but this type doesn't have one
182-
// Check it manually
183-
// constructor name is stored in selector field
184-
if (this.locator.pattern.declaringSimpleName != null &&
185-
!this.locator.matchesName(this.locator.pattern.declaringSimpleName, node.getName().toString().toCharArray()))
186-
return toResponse(IMPOSSIBLE_MATCH);
187-
188-
if (this.locator.pattern.parameterSimpleNames != null) {
189-
int length = this.locator.pattern.parameterSimpleNames.length;
190-
if( length > 0 ) return toResponse(IMPOSSIBLE_MATCH);
191-
}
192-
193-
return toResponse(ACCURATE_MATCH);
182+
IBinding b = DOMASTNodeUtils.getBinding(node);
183+
return resolveLevel(node, b, locator);
194184
}
195-
196-
197185
}
198186

199187
return toResponse(IMPOSSIBLE_MATCH);
@@ -239,8 +227,16 @@ public LocatorResponse resolveLevel(org.eclipse.jdt.core.dom.ASTNode node, IBind
239227
return toResponse(level);
240228
}
241229
if (binding instanceof ITypeBinding type) {
242-
// matched a direct subtype without explicit constructor
243-
return toResponse(resolveLevelForType(this.locator.pattern.declaringSimpleName, this.locator.pattern.declaringQualification, type.getSuperclass()));
230+
// matching a type without explicit constructor...
231+
int level = IMPOSSIBLE_MATCH;
232+
if( this.locator.pattern.findDeclarations) {
233+
level = resolveLevelForType(this.locator.pattern.declaringSimpleName, this.locator.pattern.declaringQualification, type);
234+
}
235+
if( level == IMPOSSIBLE_MATCH && this.locator.pattern.findReferences) {
236+
// or a direct subtype without explicit constructor
237+
level = resolveLevelForType(this.locator.pattern.declaringSimpleName, this.locator.pattern.declaringQualification, type.getSuperclass());
238+
}
239+
return toResponse(level);
244240
}
245241
return toResponse(IMPOSSIBLE_MATCH);
246242
}

0 commit comments

Comments
 (0)