@@ -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