Skip to content

Commit

Permalink
GH-1461: including the type hierarchy of events when finding referenc…
Browse files Browse the repository at this point in the history
…es from listeners to publishers
  • Loading branch information
martinlippert committed Feb 3, 2025
1 parent 6b5d482 commit 4d7c8d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public List<? extends Location> provideReferences(CancelChecker cancelToken, IJa
.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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,18 @@ public class CustomEventListener {
}""", 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
Expand Down

0 comments on commit 4d7c8d9

Please sign in to comment.