|
10 | 10 | *******************************************************************************/
|
11 | 11 | package org.springframework.ide.vscode.boot.java.events;
|
12 | 12 |
|
| 13 | +import org.eclipse.lsp4j.DocumentSymbol; |
13 | 14 | import org.eclipse.lsp4j.Location;
|
| 15 | +import org.eclipse.lsp4j.SymbolKind; |
14 | 16 | import org.springframework.ide.vscode.commons.protocol.spring.AbstractSpringIndexElement;
|
15 | 17 | import org.springframework.ide.vscode.commons.protocol.spring.AnnotationMetadata;
|
| 18 | +import org.springframework.ide.vscode.commons.protocol.spring.SymbolElement; |
16 | 19 |
|
17 | 20 | /**
|
18 | 21 | * @author Martin Lippert
|
19 | 22 | */
|
20 |
| -public class EventListenerIndexElement extends AbstractSpringIndexElement { |
| 23 | +public class EventListenerIndexElement extends AbstractSpringIndexElement implements SymbolElement { |
21 | 24 |
|
22 | 25 | private final String eventType;
|
23 | 26 | private final Location location;
|
@@ -47,4 +50,25 @@ public String getContainerBeanType() {
|
47 | 50 | return containerBeanType;
|
48 | 51 | }
|
49 | 52 |
|
| 53 | + @Override |
| 54 | + public DocumentSymbol getDocumentSymbol() { |
| 55 | + DocumentSymbol symbol = new DocumentSymbol(); |
| 56 | + symbol.setName("listens on: " + getSimpleType(eventType)); |
| 57 | + symbol.setKind(SymbolKind.Event); |
| 58 | + symbol.setRange(location.getRange()); |
| 59 | + symbol.setSelectionRange(location.getRange()); |
| 60 | + |
| 61 | + return symbol; |
| 62 | + } |
| 63 | + |
| 64 | + private String getSimpleType(String fullyQualifiedType) { |
| 65 | + int index = fullyQualifiedType.lastIndexOf('.'); |
| 66 | + if (index > 0 && index < fullyQualifiedType.length()) { |
| 67 | + return fullyQualifiedType.substring(index + 1); |
| 68 | + } |
| 69 | + else { |
| 70 | + return fullyQualifiedType; |
| 71 | + } |
| 72 | + } |
| 73 | + |
50 | 74 | }
|
0 commit comments