File tree Expand file tree Collapse file tree
org.eclipse.lsp4e/src/org/eclipse/lsp4e
operations/symbols/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -130,17 +130,14 @@ private SymbolIconProvider getIconProvider(Object symbol) {
130130 }
131131
132132 private @ Nullable URI getUri (Object symbol ) {
133- if (symbol instanceof SymbolInformation info )
134- return toUri (info .getLocation ().getUri ());
135- if (symbol instanceof WorkspaceSymbol ws )
136- return toUri (ws .getLocation ().map (Location ::getUri , WorkspaceSymbolLocation ::getUri ));
137- if (symbol instanceof DocumentSymbolWithURI s )
138- return s .uri ;
139- if (symbol instanceof TypeHierarchyItem item ) // for subclasses handling TH
140- return toUri (item .getUri ());
141- if (symbol instanceof CallHierarchyItem item ) // for subclasses handling CH
142- return toUri (item .getUri ());
143- return null ; // plain DocumentSymbol — no URI
133+ return switch (symbol ) {
134+ case SymbolInformation info -> toUri (info .getLocation ().getUri ());
135+ case WorkspaceSymbol ws -> toUri (ws .getLocation ().map (Location ::getUri , WorkspaceSymbolLocation ::getUri ));
136+ case DocumentSymbolWithURI s -> s .uri ;
137+ case TypeHierarchyItem item -> toUri (item .getUri ());
138+ case CallHierarchyItem item -> toUri (item .getUri ());
139+ default -> null ; // plain DocumentSymbol — no URI
140+ };
144141 }
145142
146143 private @ Nullable URI toUri (String uri ) {
Original file line number Diff line number Diff line change @@ -50,22 +50,15 @@ public class SymbolIconProvider {
5050 * @return the symbol's name or <code>null</code>.
5151 */
5252 protected @ Nullable String getName (Object symbol ) {
53- String name = null ;
54- if (symbol instanceof SymbolInformation info ) {
55- name = info .getName ();
56- } else if (symbol instanceof WorkspaceSymbol wpSymbol ) {
57- name = wpSymbol .getName ();
58- } else if (symbol instanceof DocumentSymbol docSymbol ) {
59- name = docSymbol .getName ();
60- } else if (symbol instanceof DocumentSymbolWithURI symbolWithURI ) {
61- name = symbolWithURI .symbol .getName ();
62- } else if (symbol instanceof CallHierarchyItem callHierItem ) {
63- name = callHierItem .getName ();
64- } else if (symbol instanceof TypeHierarchyItem typeHierItem ) {
65- name = typeHierItem .getName ();
66- }
67-
68- return name ;
53+ return switch (symbol ) {
54+ case SymbolInformation info -> info .getName ();
55+ case WorkspaceSymbol wpSymbol -> wpSymbol .getName ();
56+ case DocumentSymbol docSymbol -> docSymbol .getName ();
57+ case DocumentSymbolWithURI symbolWithURI -> symbolWithURI .symbol .getName ();
58+ case CallHierarchyItem callHierItem -> callHierItem .getName ();
59+ case TypeHierarchyItem typeHierItem -> typeHierItem .getName ();
60+ default -> null ;
61+ };
6962 }
7063
7164 /**
You can’t perform that action at this time.
0 commit comments