Skip to content

Commit 090064b

Browse files
committed
LazyTextDocument for local files
Signed-off-by: BoykoAlex <alex.boyko@broadcom.com>
1 parent 2f65beb commit 090064b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • headless-services/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/text

headless-services/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/text/LazyTextDocument.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@ public LazyTextDocument(String uri, LanguageId languageId, Supplier<String> load
3030

3131
public LazyTextDocument(String uri, LanguageId languageId) {
3232
this(uri, languageId, () -> {
33+
URI parsed = URI.create(uri);
34+
if (!"file".equalsIgnoreCase(parsed.getScheme())) {
35+
// Only local files are loaded this way
36+
throw new IllegalArgumentException("Cannot create document for non 'file' URI: " + uri);
37+
}
3338
try {
34-
InputStream stream = URI.create(uri).toURL().openStream();
39+
InputStream stream = parsed.toURL().openStream();
3540
return IOUtil.toString(stream);
3641
} catch (Exception e) {
3742
return null;

0 commit comments

Comments
 (0)