GH-1463: support for concatenated strings for more reference providers
This commit is contained in:
@@ -120,6 +120,24 @@ public class NamedReferencesProviderTest {
|
||||
assertEquals(locationNamedAnnotation1, foundLocation);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNamedRefersToNamedBeanWithConcatenatedString() throws Exception {
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA, """
|
||||
package org.test;
|
||||
|
||||
import jakarta.inject.Named;
|
||||
|
||||
@Named("na" + "m<*>ed1")
|
||||
public class TestDependsOnClass {
|
||||
}""", tempJavaDocUri);
|
||||
|
||||
List<? extends Location> references = editor.getReferences();
|
||||
assertEquals(1, references.size());
|
||||
|
||||
Location foundLocation = references.get(0);
|
||||
assertEquals(locationNamedAnnotation1, foundLocation);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNamedNotRefersToPureSpringBean() throws Exception {
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA, """
|
||||
|
||||
@@ -95,6 +95,37 @@ public class ProfileReferencesProviderTest {
|
||||
assertTrue(references.contains(expectedLocation2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProfileRefersToOtherProfilesWithConcatenatedString() throws Exception {
|
||||
String tempJavaDocUri = directory.toPath().resolve("src/main/java/org/test/TempClass.java").toUri().toString();
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA, """
|
||||
package org.test;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@Component
|
||||
@Profile("pro" + "f<*>ile1")
|
||||
public class TestDependsOnClass {
|
||||
}""", tempJavaDocUri);
|
||||
|
||||
List<? extends Location> references = editor.getReferences();
|
||||
assertEquals(2, references.size());
|
||||
|
||||
String expectedDefinitionUri1 = directory.toPath().resolve("src/main/java/org/test/profiles/ProfilesClass1.java").toUri().toString();
|
||||
Location expectedLocation1 = new Location(expectedDefinitionUri1,
|
||||
new Range(new Position(6, 9), new Position(6, 19)));
|
||||
|
||||
assertTrue(references.contains(expectedLocation1));
|
||||
|
||||
String expectedDefinitionUri2 = directory.toPath().resolve("src/main/java/org/test/profiles/ProfilesClassWithArray.java").toUri().toString();
|
||||
Location expectedLocation2 = new Location(expectedDefinitionUri2,
|
||||
new Range(new Position(6, 18), new Position(6, 28)));
|
||||
|
||||
assertTrue(references.contains(expectedLocation2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProfileWithinArrayRefersToOtherProfiles() throws Exception {
|
||||
String tempJavaDocUri = directory.toPath().resolve("src/main/java/org/test/TempClass.java").toUri().toString();
|
||||
|
||||
Reference in New Issue
Block a user