identify property when cursor is on prefix
This commit is contained in:
@@ -61,6 +61,10 @@ public class PropertyExtractor {
|
||||
String prefix = extractAnnotationParameter(annotation, PARAM_PREFIX);
|
||||
String name = stringLiteral.getLiteralValue();
|
||||
return prefix != null && !prefix.isBlank() ? prefix + "." + name : name;
|
||||
case PARAM_PREFIX:
|
||||
name = extractAnnotationParameter(annotation, PARAM_NAME);
|
||||
prefix = stringLiteral.getLiteralValue();
|
||||
return prefix != null && !prefix.isBlank() ? prefix + "." + name : name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -118,6 +118,22 @@ public class ConditionalOnPropertyReferenceFinderTest {
|
||||
assertEquals(7, location.getRange().getEnd().getCharacter());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindReferencesToPropertyFromAnnotationWithPrefixOnPrefix() throws Exception {
|
||||
harness.getServer().getWorkspaceService().setWorkspaceFolders(List.of(new WorkspaceFolder(directory.toURI().toString())));
|
||||
|
||||
List<? extends Location> references = getReferences("@ConditionalOnProperty(prefix=\"<*>my\", name=\"prop\")");
|
||||
|
||||
assertEquals(1, references.size());
|
||||
|
||||
Location location = references.get(0);
|
||||
assertEquals(directory.toPath().resolve("src/main/java/application.properties").toUri().toString(), location.getUri());
|
||||
assertEquals(0, location.getRange().getStart().getLine());
|
||||
assertEquals(0, location.getRange().getStart().getCharacter());
|
||||
assertEquals(0, location.getRange().getEnd().getLine());
|
||||
assertEquals(7, location.getRange().getEnd().getCharacter());
|
||||
}
|
||||
|
||||
private List<? extends Location> getReferences(String completionLine) throws Exception {
|
||||
harness.getServer().getWorkspaceService().setWorkspaceFolders(List.of(new WorkspaceFolder(directory.toURI().toString())));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user