Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore URIs that do not start with 'file:' #332

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/main/java/org/wso2/lsp4intellij/utils/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,15 @@ public static Editor editorFromVirtualFile(VirtualFile file, Project project) {

public static VirtualFile virtualFileFromURI(String uri) {
try {
return LocalFileSystem.getInstance().findFileByIoFile(new File(new URI(sanitizeURI(uri))));
URI sanitizedUri = new URI(sanitizeURI(uri));
if (sanitizedUri.getScheme().startsWith(URI_FILE_BEGIN)) {
return LocalFileSystem.getInstance().findFileByIoFile(new File(sanitizedUri));
}
LOG.debug(String.format("URI %s is not a file", uri));
} catch (URISyntaxException e) {
LOG.warn(e);
return null;
}
return null;
}

/**
Expand Down Expand Up @@ -249,12 +253,7 @@ public static String sanitizeURI(String uri) {
* @return The virtual file
*/
public static VirtualFile URIToVFS(String uri) {
try {
return LocalFileSystem.getInstance().findFileByIoFile(new File(new URI(sanitizeURI(uri))));
} catch (URISyntaxException e) {
LOG.warn(e);
return null;
}
return virtualFileFromURI(uri);
Copy link
Contributor Author

@akashnagesh akashnagesh Jul 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method appears to be a duplicate of virtualFileFromURI(String uri) unless I am missing something.

}

/**
Expand Down
Loading