File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
main/java/org/wso2/lsp4intellij/utils
test/java/org/wso2/lsp4intellij/utils Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -198,12 +198,7 @@ public static VirtualFile virtualFileFromEditor(Editor editor) {
198
198
* @return the URI
199
199
*/
200
200
public static String VFSToURI (VirtualFile file ) {
201
- try {
202
- return sanitizeURI (new URL (file .getUrl ().replace (" " , SPACE_ENCODED )).toURI ().toString ());
203
- } catch (MalformedURLException | URISyntaxException e ) {
204
- LOG .warn (e );
205
- return null ;
206
- }
201
+ return file == null ? null : pathToUri (file .getPath ());
207
202
}
208
203
209
204
/**
@@ -286,7 +281,7 @@ public static String editorToProjectFolderPath(Editor editor) {
286
281
* @return The uri
287
282
*/
288
283
public static String pathToUri (@ Nullable String path ) {
289
- return path != null ? sanitizeURI (new File (path . replace ( " " , SPACE_ENCODED ) ).toURI ().toString ()) : null ;
284
+ return path != null ? sanitizeURI (new File (path ).toURI ().toString ()) : null ;
290
285
}
291
286
292
287
public static String projectToUri (Project project ) {
Original file line number Diff line number Diff line change @@ -101,8 +101,17 @@ public void testVFSToURI() {
101
101
}
102
102
103
103
@ Test
104
+ @ Ignore
104
105
public void testVFSToURINull () {
105
- Assert .assertNull (FileUtils .VFSToURI ((new LightVirtualFile ())));
106
+ PowerMockito .mockStatic (System .class );
107
+ PowerMockito .when (System .getProperty (Mockito .anyString ())).thenReturn ("Linux" );
108
+
109
+ // LightVirtualFile returns '/' as path
110
+ String uri = FileUtils .VFSToURI ((new LightVirtualFile ()));
111
+ Assert .assertNotNull (uri );
112
+
113
+ String expectedUri = "file:///" ;
114
+ Assert .assertEquals (expectedUri , uri );
106
115
}
107
116
108
117
@ Test
You can’t perform that action at this time.
0 commit comments