Skip to content

Commit a498abe

Browse files
committed
Add test case for reproducing a windows path parsing issue
1 parent 266c22d commit a498abe

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 Advantest GmbH and others.
3+
* This program and the accompanying materials are made
4+
* available under the terms of the Eclipse Public License 2.0
5+
* which is available at https://www.eclipse.org/legal/epl-2.0/
6+
*
7+
* SPDX-License-Identifier: EPL-2.0
8+
*
9+
* Contributors:
10+
* Dietrich Travkin (Solunar GmbH) - initial implementation
11+
*******************************************************************************/
12+
package org.eclipse.lsp4e.test.operations.symbols;
13+
14+
import static org.junit.jupiter.api.Assertions.*;
15+
16+
import java.lang.reflect.Method;
17+
import java.net.URI;
18+
19+
import org.eclipse.lsp4e.operations.symbols.internal.SymbolIconProviderRegistry;
20+
import org.eclipse.lsp4e.outline.SymbolsModel.DocumentSymbolWithURI;
21+
import org.eclipse.lsp4e.ui.SymbolIconProvider;
22+
import org.eclipse.lsp4j.DocumentSymbol;
23+
import org.junit.jupiter.params.ParameterizedTest;
24+
import org.junit.jupiter.params.provider.CsvSource;
25+
26+
public class SymbolIconProviderRegistryTest {
27+
28+
@ParameterizedTest
29+
@CsvSource({
30+
"file:///C:/Users/username/path/to/SomeDir/SomeType.hpp, SomeType.hpp",
31+
"file:///home/username/path/to/SomeDir/SomeType.hpp, SomeType.hpp",
32+
"file://C:/Users/username/path/to/SomeDir/SomeType.hpp, SomeType.hpp",
33+
"file://home/username/path/to/SomeDir/SomeType.hpp, SomeType.hpp"
34+
})
35+
public void testReadingFileNameFromUri(String uriText, String expectedFileName) throws Exception {
36+
URI uri = URI.create(uriText);
37+
38+
// Call the private getFileName(URI) method via reflection to verify it does
39+
// not throw any exception and returns the correct file name.
40+
Method getInstance = SymbolIconProviderRegistry.class.getDeclaredMethod("get");
41+
getInstance.setAccessible(true);
42+
Object registry = getInstance.invoke(null);
43+
44+
Method getFileName = SymbolIconProviderRegistry.class.getDeclaredMethod("getFileName", URI.class);
45+
getFileName.setAccessible(true);
46+
String actualFileName = (String) getFileName.invoke(registry, uri);
47+
assertEquals(expectedFileName, actualFileName);
48+
49+
// Also verify that the registry itself handles the URI without exceptions
50+
// and returns a non-null provider.
51+
DocumentSymbolWithURI symbol = new DocumentSymbolWithURI(new DocumentSymbol(), uri);
52+
SymbolIconProvider provider = SymbolIconProviderRegistry.getSymbolIconProviderFor(symbol);
53+
assertNotNull(provider);
54+
}
55+
56+
}

0 commit comments

Comments
 (0)