Skip to content

Commit 51d4c8d

Browse files
committed
fix: Avoid Windows path parsing issue
Extract path resolving and file name retrieval into a testable method. Keep it private to avoid revealing internal API.
1 parent a498abe commit 51d4c8d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/symbols/internal/SymbolIconProviderRegistry.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private SymbolIconProvider getIconProvider(Object symbol) {
108108

109109
String fileName = null;
110110
try {
111-
fileName = Path.of(uri.getPath()).getFileName().toString();
111+
fileName = getFileName(uri);
112112
} catch (Exception e) {
113113
LanguageServerPlugin.logWarning("Failed to parse file name from URI " + uri, e); //$NON-NLS-1$
114114
return defaultIconProvider;
@@ -129,6 +129,10 @@ private SymbolIconProvider getIconProvider(Object symbol) {
129129
return defaultIconProvider;
130130
}
131131

132+
private String getFileName(URI uri) {
133+
return Path.of(uri).getFileName().toString();
134+
}
135+
132136
private @Nullable URI getUri(Object symbol) {
133137
return switch (symbol) {
134138
case SymbolInformation info -> toUri(info.getLocation().getUri());

0 commit comments

Comments
 (0)