GH-1461: including the type hierarchy of events when finding references from listeners to publishers
This commit is contained in:
@@ -73,7 +73,7 @@ public class EventReferenceProvider implements ReferenceProvider {
|
||||
.flatMap(bean -> bean.getChildren().stream())
|
||||
.filter(element -> element instanceof EventPublisherIndexElement)
|
||||
.map(element -> (EventPublisherIndexElement) element)
|
||||
.filter(publisher -> publisher.getEventType().equals(eventType))
|
||||
.filter(publisher -> publisher.getEventType().equals(eventType) || publisher.getEventTypesFromHierarchy().contains(eventType))
|
||||
.map(publisher -> publisher.getLocation())
|
||||
.toList();
|
||||
|
||||
|
||||
@@ -84,12 +84,18 @@ public class EventsReferencesProviderTest {
|
||||
}""", tempJavaDocUri);
|
||||
|
||||
List<? extends Location> references = editor.getReferences();
|
||||
assertEquals(1, references.size());
|
||||
assertEquals(2, references.size());
|
||||
|
||||
String expectedDefinitionUri1 = directory.toPath().resolve("src/main/java/com/example/events/demo/CustomEventPublisher.java").toUri().toString();
|
||||
Location expectedLocation1 = new Location(expectedDefinitionUri1, new Range(new Position(15, 2), new Position(15, 48)));
|
||||
|
||||
assertTrue(references.contains(expectedLocation1));
|
||||
|
||||
// from type hierarchy of specialzed custom event
|
||||
String expectedDefinitionUri2 = directory.toPath().resolve("src/main/java/com/example/events/demo/SpecializedCustomEventPublisher.java").toUri().toString();
|
||||
Location expectedLocation2 = new Location(expectedDefinitionUri2, new Range(new Position(15, 2), new Position(15, 59)));
|
||||
|
||||
assertTrue(references.contains(expectedLocation2));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user