fix issue with special characters in docURIs and converting those to path objects

This commit is contained in:
Martin Lippert
2020-11-16 13:09:34 +01:00
parent ad7a2a2e39
commit 17482b6316
3 changed files with 16 additions and 11 deletions

View File

@@ -13,9 +13,9 @@ package org.springframework.ide.vscode.boot.java.utils;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -162,11 +162,16 @@ public class SpringIndexerJava implements SpringIndexer {
}
private boolean shouldProcessDocument(IJavaProject project, String docURI) {
Path path = Paths.get(URI.create(docURI));
return foldersToScan(project)
.filter(sourceFolder -> path.startsWith(sourceFolder.toPath()))
.findFirst()
.isPresent();
try {
Path path = new File(new URI(docURI)).toPath();
return foldersToScan(project)
.filter(sourceFolder -> path.startsWith(sourceFolder.toPath()))
.findFirst()
.isPresent();
} catch (URISyntaxException e) {
log.info("shouldProcessDocument - docURI syntax problem: {}", docURI);
return false;
}
}
private boolean isCacheOutdated(SymbolCacheKey cacheKey, String docURI, long modifiedTimestamp) {

View File

@@ -15,7 +15,6 @@ import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -246,7 +245,7 @@ public class SpringIndexerXML implements SpringIndexer {
private String[] getFiles(IJavaProject project) throws Exception {
long start = System.currentTimeMillis();
Path projectPath = Paths.get(project.getLocationUri());
Path projectPath = new File(project.getLocationUri()).toPath();
String[] xmlFiles = Arrays.stream(scanFolders)
.map(folder -> projectPath.resolve(folder))
.filter(Files::isDirectory)