Switch to URI#toASCIIString()
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2019 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -119,6 +119,6 @@ public class ResourceListener implements IResourceChangeListener {
|
||||
throw new IllegalStateException("Unsupported resource delta kind: " + delta.getKind()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
return new FileEvent(locationURI.toString(), changeType);
|
||||
return new FileEvent(locationURI.toASCIIString(), changeType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2022 VMware, Inc.
|
||||
* Copyright (c) 2022, 2023 VMware, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -109,7 +109,7 @@ public class RewriteRefactoringsHandler extends AbstractHandler {
|
||||
Assert.isLegal(def != null, "No definition found for Boot Language Server");
|
||||
LanguageServerWrapper wrapper = LanguageServiceAccessor.getLSWrapper(project, def);
|
||||
|
||||
final String uri = project.getLocationURI().toString();
|
||||
final String uri = project.getLocationURI().toASCIIString();
|
||||
ExecuteCommandParams commandParams = new ExecuteCommandParams();
|
||||
commandParams.setCommand(REWRITE_REFACTORINGS_LIST);
|
||||
commandParams.setArguments(List.of(uri, recipeFilter.toString()));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018, 2019 Pivotal, Inc.
|
||||
* Copyright (c) 2018, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -79,7 +79,7 @@ public class HighlightsCodeLensProvider extends AbstractCodeMiningProvider {
|
||||
List<LSPDocumentInfo> docInfos = LanguageServiceAccessor.getLSPDocumentInfosFor(document, (x) -> true);
|
||||
if (!docInfos.isEmpty()) {
|
||||
LSPDocumentInfo info = docInfos.get(0);
|
||||
HighlightParams highlights = STS4LanguageClientImpl.currentHighlights.get(info.getFileUri().toString());
|
||||
HighlightParams highlights = STS4LanguageClientImpl.currentHighlights.get(info.getFileUri().toASCIIString());
|
||||
if (highlights != null) {
|
||||
return highlights.getCodeLenses().stream()
|
||||
.filter(codeLens -> codeLens.getCommand() != null)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2022 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -213,7 +213,7 @@ public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4La
|
||||
} else {
|
||||
URI uri = Utils.findDocUri(doc);
|
||||
if (uri != null) {
|
||||
updateHighlightAnnotations(editor, sourceViewer, annotationModel, uri.toString(), updateCodeMinings);
|
||||
updateHighlightAnnotations(editor, sourceViewer, annotationModel, uri.toASCIIString(), updateCodeMinings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -472,7 +472,7 @@ public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4La
|
||||
IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
|
||||
if (doc!=null) {
|
||||
URI uri = Utils.findDocUri(doc);
|
||||
if (cursorMovement.getUri().equals(uri.toString())) {
|
||||
if (cursorMovement.getUri().equals(uri.toASCIIString())) {
|
||||
org.eclipse.lsp4j.Position pos = cursorMovement.getPosition();
|
||||
int offset = LSPEclipseUtils.toOffset(pos, doc);
|
||||
Display.getDefault().asyncExec(() -> {
|
||||
@@ -520,7 +520,7 @@ public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4La
|
||||
if (project != null) {
|
||||
Location location = new Location();
|
||||
String label = javaLabelProvider.getText(element);
|
||||
location.setUri(Utils.eclipseIntroUri(project.getElementName(), params.getBindingKey(), label).toString());
|
||||
location.setUri(Utils.eclipseIntroUri(project.getElementName(), params.getBindingKey(), label).toASCIIString());
|
||||
// Set the range because LocationLink needs it to be non-null. The target range
|
||||
// would highlighted by the eclipse intro URL navigation anyway
|
||||
location.setRange(new Range());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018, 2020 Pivotal, Inc.
|
||||
* Copyright (c) 2018, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -78,7 +78,7 @@ public class Utils {
|
||||
for (LSPDocumentInfo info : LanguageServiceAccessor.getLSPDocumentInfosFor(doc, (x) -> true)) {
|
||||
if (info.getVersion() == id.getVersion()) {
|
||||
URI uri = info.getFileUri();
|
||||
if (uri != null && uri.toString().equals(id.getUri())) {
|
||||
if (uri != null && uri.toASCIIString().equals(id.getUri())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2022 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -74,7 +74,7 @@ public class InFileSymbolsProvider implements SymbolsProvider {
|
||||
if (this.info != null) {
|
||||
LSPDocumentInfo info = this.info.get();
|
||||
if (info != null) {
|
||||
return info.getFileUri().toString();
|
||||
return info.getFileUri().toASCIIString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2019, 2022 Pivotal, Inc.
|
||||
* Copyright (c) 2019, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -88,7 +88,7 @@ public class InProjectSymbolsProvider implements SymbolsProvider {
|
||||
IProject project = this.project.get();
|
||||
|
||||
if (project != null) {
|
||||
String projectLocationPrefix = LSPEclipseUtils.toUri(project).toString();
|
||||
String projectLocationPrefix = LSPEclipseUtils.toUri(project).toASCIIString();
|
||||
query = "locationPrefix:" + projectLocationPrefix + "?" + query;
|
||||
|
||||
WorkspaceSymbolParams params = new WorkspaceSymbolParams(query);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2022 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -124,18 +124,18 @@ public class GradleProjectTest {
|
||||
List<File> nonSystemClasspathEntries = IClasspathUtil.getBinaryRoots(cachedProject.getClasspath(), (cpe) -> !cpe.isSystem());
|
||||
assertEquals(69, nonSystemClasspathEntries.size());
|
||||
|
||||
fileObserver.notifyFileChanged(gradleFile.toURI().toString());
|
||||
fileObserver.notifyFileChanged(gradleFile.toURI().toASCIIString());
|
||||
assertNull(projectChanged[0]);
|
||||
|
||||
writeContent(gradleFile, Files.contentOf(testProjectPath.resolve("build.newgradle").toFile(), Charset.defaultCharset()));
|
||||
fileObserver.notifyFileChanged(gradleFile.toURI().toString());
|
||||
fileObserver.notifyFileChanged(gradleFile.toURI().toASCIIString());
|
||||
assertNotNull(projectChanged[0]);
|
||||
assertEquals(cachedProject, projectChanged[0]);
|
||||
nonSystemClasspathEntries = IClasspathUtil.getBinaryRoots(cachedProject.getClasspath(), (cpe) -> !cpe.isSystem());
|
||||
assertEquals(70, nonSystemClasspathEntries.size());
|
||||
|
||||
|
||||
fileObserver.notifyFileDeleted(gradleFile.toURI().toString());
|
||||
fileObserver.notifyFileDeleted(gradleFile.toURI().toASCIIString());
|
||||
assertEquals(cachedProject, projectDeleted[0]);
|
||||
} finally {
|
||||
writeContent(gradleFile, gradelFileContents);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class JavaProject extends AbstractJavaProject {
|
||||
this.fileObserver = fileObserver;
|
||||
this.javadocProviderFactory = (classpathResource) -> {
|
||||
CPE cpe = IClasspathUtil.findEntryForBinaryRoot(classpath, classpathResource);
|
||||
return javadocService.javadocProvider(uri.toString(), cpe);
|
||||
return javadocService.javadocProvider(uri, cpe);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.javadoc;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
@@ -33,9 +34,9 @@ public class JdtLsJavadocProvider implements IJavadocProvider {
|
||||
private static final Logger log = LoggerFactory.getLogger(JdtLsJavadocProvider.class);
|
||||
|
||||
private STS4LanguageClient client;
|
||||
private String projectUri;
|
||||
private URI projectUri;
|
||||
|
||||
public JdtLsJavadocProvider(STS4LanguageClient client, String projectUri) {
|
||||
public JdtLsJavadocProvider(STS4LanguageClient client, URI projectUri) {
|
||||
super();
|
||||
this.client = client;
|
||||
this.projectUri = projectUri;
|
||||
@@ -60,7 +61,7 @@ public class JdtLsJavadocProvider implements IJavadocProvider {
|
||||
long start = System.currentTimeMillis();
|
||||
try {
|
||||
log.info("Fetching javadoc {}", element.getBindingKey());
|
||||
MarkupContent md = client.javadoc(new JavaDataParams(projectUri, element.getBindingKey(), false)).get(10, TimeUnit.SECONDS);
|
||||
MarkupContent md = client.javadoc(new JavaDataParams(projectUri.toASCIIString(), element.getBindingKey(), false)).get(10, TimeUnit.SECONDS);
|
||||
log.info("Fetching javadoc {} took {} ms", element.getBindingKey(), System.currentTimeMillis()-start);
|
||||
return produceJavadocFromMd(md == null ? null : md.getValue());
|
||||
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2019, 2020 Pivotal, Inc.
|
||||
* Copyright (c) 2019, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -71,7 +71,7 @@ public class JdtLsIndex implements ClasspathIndex {
|
||||
this.client = client;
|
||||
this.projectUri = projectUri;
|
||||
this.projectObserver = projectObserver;
|
||||
this.javadocProvider = new JdtLsJavadocProvider(client, projectUri.toString());
|
||||
this.javadocProvider = new JdtLsJavadocProvider(client, projectUri);
|
||||
|
||||
this.projectListener = ProjectObserver.onAny(project -> {
|
||||
if (Objects.equals(project.getLocationUri(), projectUri)) {
|
||||
@@ -103,7 +103,7 @@ public class JdtLsIndex implements ClasspathIndex {
|
||||
}
|
||||
|
||||
private TypeData findTypeData(String fqName) throws InterruptedException, ExecutionException {
|
||||
JavaDataParams params = new JavaDataParams(projectUri.toString(), "L" + fqName.replace('.', '/') + ";", false);
|
||||
JavaDataParams params = new JavaDataParams(projectUri.toASCIIString(), "L" + fqName.replace('.', '/') + ";", false);
|
||||
return client.javaType(params).get();
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class JdtLsIndex implements ClasspathIndex {
|
||||
|
||||
@Override
|
||||
public Flux<Tuple2<IType, Double>> fuzzySearchTypes(String searchTerm, boolean includeBinaries, boolean includeSystemLibs) {
|
||||
JavaSearchParams searchParams = new JavaSearchParams(projectUri.toString(), searchTerm, SearchType.FUZZY, includeBinaries, includeSystemLibs, SEARCH_TIMEOUT);
|
||||
JavaSearchParams searchParams = new JavaSearchParams(projectUri.toASCIIString(), searchTerm, SearchType.FUZZY, includeBinaries, includeSystemLibs, SEARCH_TIMEOUT);
|
||||
return Mono.fromFuture(client.javaSearchTypes(searchParams))
|
||||
.flatMapMany(results -> Flux.fromIterable(results).publishOn(Schedulers.parallel()))
|
||||
.filter(Objects::nonNull)
|
||||
@@ -148,7 +148,7 @@ public class JdtLsIndex implements ClasspathIndex {
|
||||
|
||||
@Override
|
||||
public Flux<Tuple2<String, Double>> fuzzySearchPackages(String searchTerm, boolean includeBinaries, boolean includeSystemLibs) {
|
||||
JavaSearchParams searchParams = new JavaSearchParams(projectUri.toString(), searchTerm, SearchType.FUZZY, includeBinaries, includeSystemLibs, SEARCH_TIMEOUT);
|
||||
JavaSearchParams searchParams = new JavaSearchParams(projectUri.toASCIIString(), searchTerm, SearchType.FUZZY, includeBinaries, includeSystemLibs, SEARCH_TIMEOUT);
|
||||
return Mono.fromFuture(client.javaSearchPackages(searchParams))
|
||||
.flatMapMany(results -> Flux.fromIterable(results).publishOn(Schedulers.parallel()))
|
||||
.filter(Objects::nonNull)
|
||||
@@ -159,7 +159,7 @@ public class JdtLsIndex implements ClasspathIndex {
|
||||
@Override
|
||||
public Flux<Tuple2<IType, Double>> camelcaseSearchTypes(String searchTerm, boolean includeBinaries,
|
||||
boolean includeSystemLibs) {
|
||||
JavaSearchParams searchParams = new JavaSearchParams(projectUri.toString(), searchTerm, SearchType.CAMELCASE, includeBinaries, includeSystemLibs, SEARCH_TIMEOUT);
|
||||
JavaSearchParams searchParams = new JavaSearchParams(projectUri.toASCIIString(), searchTerm, SearchType.CAMELCASE, includeBinaries, includeSystemLibs, SEARCH_TIMEOUT);
|
||||
return Mono.fromFuture(client.javaSearchTypes(searchParams))
|
||||
.flatMapMany(results -> Flux.fromIterable(results).publishOn(Schedulers.parallel()))
|
||||
.filter(Objects::nonNull)
|
||||
@@ -169,7 +169,7 @@ public class JdtLsIndex implements ClasspathIndex {
|
||||
|
||||
@Override
|
||||
public Flux<IType> allSubtypesOf(String fqName, boolean includeFocusType, boolean detailed) {
|
||||
JavaTypeHierarchyParams searchParams = new JavaTypeHierarchyParams(projectUri.toString(), fqName, includeFocusType, detailed);
|
||||
JavaTypeHierarchyParams searchParams = new JavaTypeHierarchyParams(projectUri.toASCIIString(), fqName, includeFocusType, detailed);
|
||||
try {
|
||||
CompletableFuture<List<IType>> future = subtypesCache.get(searchParams, () -> client
|
||||
.javaSubTypes(searchParams)
|
||||
@@ -184,7 +184,7 @@ public class JdtLsIndex implements ClasspathIndex {
|
||||
|
||||
@Override
|
||||
public Flux<IType> allSuperTypesOf(String fqName, boolean includeFocusType, boolean detailed) {
|
||||
JavaTypeHierarchyParams searchParams = new JavaTypeHierarchyParams(projectUri.toString(), fqName, includeFocusType, detailed);
|
||||
JavaTypeHierarchyParams searchParams = new JavaTypeHierarchyParams(projectUri.toASCIIString(), fqName, includeFocusType, detailed);
|
||||
try {
|
||||
CompletableFuture<List<IType>> future = supertypesCache.get(searchParams, () -> client
|
||||
.javaSuperTypes(searchParams)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2021, 2022 VMware, Inc.
|
||||
* Copyright (c) 2021, 2023 VMware, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -65,7 +65,7 @@ public class FutureProjectFinder implements DisposableBean {
|
||||
private void resolveAllPendingRquests() {
|
||||
synchronized(LOCK) {
|
||||
for (Map.Entry<URI, CompletableFuture<IJavaProject>> e : pendingFindProjectRequests.entrySet()) {
|
||||
Optional<IJavaProject> jp = projectFinder.find(new TextDocumentIdentifier(e.getKey().toString()));
|
||||
Optional<IJavaProject> jp = projectFinder.find(new TextDocumentIdentifier(e.getKey().toASCIIString()));
|
||||
e.getValue().complete(jp.orElse(null));
|
||||
pendingFindProjectRequests.remove(e.getKey());
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class FutureProjectFinder implements DisposableBean {
|
||||
private void resolvePendingRequests(IJavaProject project) {
|
||||
synchronized(LOCK) {
|
||||
for (Map.Entry<URI, CompletableFuture<IJavaProject>> e : pendingFindProjectRequests.entrySet()) {
|
||||
Optional<IJavaProject> jp = projectFinder.find(new TextDocumentIdentifier(e.getKey().toString()));
|
||||
Optional<IJavaProject> jp = projectFinder.find(new TextDocumentIdentifier(e.getKey().toASCIIString()));
|
||||
if (jp.isPresent()) {
|
||||
e.getValue().complete(jp.get());
|
||||
pendingFindProjectRequests.remove(e.getKey());
|
||||
@@ -92,7 +92,7 @@ public class FutureProjectFinder implements DisposableBean {
|
||||
}
|
||||
|
||||
public CompletableFuture<IJavaProject> findFuture(URI uri) {
|
||||
TextDocumentIdentifier id = new TextDocumentIdentifier(uri.toString());
|
||||
TextDocumentIdentifier id = new TextDocumentIdentifier(uri.toASCIIString());
|
||||
Optional<IJavaProject> jp = projectFinder.find(id);
|
||||
if (jp.isPresent()) {
|
||||
return CompletableFuture.completedFuture(jp.get());
|
||||
|
||||
@@ -10,11 +10,13 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.languageserver.java;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.springframework.ide.vscode.commons.java.IJavadocProvider;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.Classpath.CPE;
|
||||
|
||||
public interface JavadocService {
|
||||
|
||||
IJavadocProvider javadocProvider(String projectUri, CPE classpathEntry);
|
||||
IJavadocProvider javadocProvider(URI projectUri, CPE classpathEntry);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018, 2019 Pivotal, Inc.
|
||||
* Copyright (c) 2018, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -57,7 +57,7 @@ public class JandexClasspathTest {
|
||||
File target = new File(outputFolder, relativePath);
|
||||
target.getParentFile().mkdirs();
|
||||
Files.copy(classFile, target);
|
||||
fileObserver.notifyFileCreated(target.toURI().toString());
|
||||
fileObserver.notifyFileCreated(target.toURI().toASCIIString());
|
||||
}
|
||||
|
||||
ClasspathData getClasspath() {
|
||||
@@ -74,7 +74,7 @@ public class JandexClasspathTest {
|
||||
String relativePath = fqName.replace('.', '/')+".class";
|
||||
File classFile = new File(outputFolder, relativePath);
|
||||
classFile.delete();
|
||||
eventNoficator.accept(fileObserver, classFile.toURI().toString());
|
||||
eventNoficator.accept(fileObserver, classFile.toURI().toASCIIString());
|
||||
}
|
||||
|
||||
public void deleteClass(String fqName) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2022 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -139,18 +139,18 @@ public class MavenProjectCacheTest {
|
||||
ImmutableList<CPE> calculatedClassPath = cachedProject.getClasspath().getClasspathEntries();
|
||||
assertEquals(51, calculatedClassPath.stream().filter(cpe -> !cpe.isSystem()).count());
|
||||
|
||||
fileObserver.notifyFileChanged(pomFile.toURI().toString());
|
||||
fileObserver.notifyFileChanged(pomFile.toURI().toASCIIString());
|
||||
assertNull(projectChanged[0]);
|
||||
|
||||
writeContent(pomFile,
|
||||
new String(Files.readAllBytes(testProjectPath.resolve("pom.newxml")), Charset.defaultCharset()));
|
||||
fileObserver.notifyFileChanged(pomFile.toURI().toString());
|
||||
fileObserver.notifyFileChanged(pomFile.toURI().toASCIIString());
|
||||
assertNotNull(projectChanged[0]);
|
||||
assertEquals(cachedProject, projectChanged[0]);
|
||||
calculatedClassPath = cachedProject.getClasspath().getClasspathEntries();
|
||||
assertEquals(52, calculatedClassPath.stream().filter(cpe -> !cpe.isSystem()).count());
|
||||
|
||||
fileObserver.notifyFileDeleted(pomFile.toURI().toString());
|
||||
fileObserver.notifyFileDeleted(pomFile.toURI().toASCIIString());
|
||||
assertEquals(cachedProject, projectDeleted[0]);
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ public class MavenProjectCacheTest {
|
||||
verify(diagnosticService, never()).diagnosticEvent(any(ShowMessageException.class));
|
||||
|
||||
writeContent(pomFile, "");
|
||||
fileObserver.notifyFileChanged(pomFile.toURI().toString());
|
||||
fileObserver.notifyFileChanged(pomFile.toURI().toASCIIString());
|
||||
CompletableFuture.runAsync(() -> {
|
||||
while (!progressDone.get()) {
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2022 VMware, Inc.
|
||||
* Copyright (c) 2022, 2023 VMware, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -43,7 +43,7 @@ public class HelloMethodRenameProblemDescriptor implements RecipeCodeActionDescr
|
||||
public MethodDeclaration visitMethodDeclaration(MethodDeclaration method, ExecutionContext p) {
|
||||
MethodDeclaration m = super.visitMethodDeclaration(method, p);
|
||||
if ("hello".equals(method.getSimpleName())) {
|
||||
String uri = getCursor().firstEnclosing(SourceFile.class).getSourcePath().toUri().toString();
|
||||
String uri = getCursor().firstEnclosing(SourceFile.class).getSourcePath().toUri().toASCIIString();
|
||||
FixAssistMarker marker = new FixAssistMarker(Tree.randomId(), getId())
|
||||
.withFixes(
|
||||
new FixDescriptor(RECIPE_ID, List.of(uri), RecipeCodeActionDescriptor.buildLabel(LABEL, RecipeScope.NODE))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2022 VMware, Inc.
|
||||
* Copyright (c) 2023 VMware, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -159,7 +159,7 @@ public class ORDocUtils {
|
||||
we.setDocumentChanges(new ArrayList<>());
|
||||
for (Result result : results) {
|
||||
if (result.getBefore() == null) {
|
||||
String docUri = absoluteProjectDir.resolve(result.getAfter().getSourcePath()).toUri().toString();
|
||||
String docUri = absoluteProjectDir.resolve(result.getAfter().getSourcePath()).toUri().toASCIIString();
|
||||
CreateFile ro = new CreateFile();
|
||||
ro.setUri(docUri);
|
||||
we.getDocumentChanges().add(Either.forRight(ro));
|
||||
@@ -170,10 +170,10 @@ public class ORDocUtils {
|
||||
te.setEdits(List.of(new TextEdit(new Range(cursor, cursor), result.getAfter().printAll())));
|
||||
we.getDocumentChanges().add(Either.forLeft(te));
|
||||
} else if (result.getAfter() == null) {
|
||||
String docUri = absoluteProjectDir.resolve(result.getBefore().getSourcePath()).toUri().toString();
|
||||
String docUri = absoluteProjectDir.resolve(result.getBefore().getSourcePath()).toUri().toASCIIString();
|
||||
we.getDocumentChanges().add(Either.forRight(new DeleteFile(docUri)));
|
||||
} else {
|
||||
String docUri = absoluteProjectDir.resolve(result.getBefore().getSourcePath()).toUri().toString();
|
||||
String docUri = absoluteProjectDir.resolve(result.getBefore().getSourcePath()).toUri().toASCIIString();
|
||||
TextDocument doc = documents.getLatestSnapshot(docUri);
|
||||
if (doc == null) {
|
||||
doc = new TextDocument(docUri, null, 0, result.getBefore().printAll());
|
||||
|
||||
@@ -256,7 +256,7 @@ public class ORAstUtils {
|
||||
}
|
||||
return Stream.empty();
|
||||
}).filter(Files::isRegularFile).filter(p -> p.getFileName().toString().endsWith(".java")).map(p -> {
|
||||
TextDocument doc = documents.getLatestSnapshot(p.toUri().toString());
|
||||
TextDocument doc = documents.getLatestSnapshot(p.toUri().toASCIIString());
|
||||
if (doc == null) {
|
||||
return new Parser.Input(p, () -> {
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016, 2018 Pivotal, Inc.
|
||||
* Copyright (c) 2016, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -29,7 +29,7 @@ public class UriUtil {
|
||||
try {
|
||||
if (uriVal != null && uriVal.startsWith("file:")) {
|
||||
File file = new File(URI.create(uriVal)).getCanonicalFile();
|
||||
uriVal = file.toURI().toString();
|
||||
uriVal = file.toURI().toASCIIString();
|
||||
//Careful!!! If the project uri points to a existing project... then it will be
|
||||
//a directory and then the uri we computed will get a slash at the end.
|
||||
//If, on the other hand, it doesn't exist because it got deleted. Then it will not get a slash
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018 Pivotal, Inc.
|
||||
* Copyright (c) 2018, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -29,13 +29,13 @@ public class UriUtilTest {
|
||||
File folder = temp;
|
||||
assertTrue(folder.exists());
|
||||
|
||||
String folderUri = folder.toURI().toString();
|
||||
String folderUri = folder.toURI().toASCIIString();
|
||||
assertTrue(folderUri.endsWith("/"));
|
||||
folderUri = UriUtil.normalize(folderUri);
|
||||
|
||||
folder.delete();
|
||||
assertFalse(folder.exists());
|
||||
String deletedFolderUri = folder.toURI().toString();
|
||||
String deletedFolderUri = folder.toURI().toASCIIString();
|
||||
assertFalse(deletedFolderUri.endsWith("/"));
|
||||
deletedFolderUri = UriUtil.normalize(deletedFolderUri);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016, 2022 Pivotal, Inc.
|
||||
* Copyright (c) 2016, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -181,7 +181,7 @@ public class LanguageServerHarness {
|
||||
// }
|
||||
|
||||
public synchronized TextDocumentInfo getOrReadFile(File file, String languageId) throws Exception {
|
||||
String uri = file.toURI().toString();
|
||||
String uri = file.toURI().toASCIIString();
|
||||
TextDocumentInfo d = documents.get(uri);
|
||||
if (d==null) {
|
||||
documents.put(uri, d = readFile(file, languageId));
|
||||
@@ -194,7 +194,7 @@ public class LanguageServerHarness {
|
||||
String content = new String(encoded, getEncoding());
|
||||
TextDocumentItem document = new TextDocumentItem();
|
||||
document.setText(content);
|
||||
document.setUri(file.toURI().toString());
|
||||
document.setUri(file.toURI().toASCIIString());
|
||||
document.setVersion(getFirstVersion());
|
||||
document.setLanguageId(languageId);
|
||||
return new TextDocumentInfo(document);
|
||||
@@ -254,7 +254,7 @@ public class LanguageServerHarness {
|
||||
InitializeParams initParams = new InitializeParams();
|
||||
if (workspaceRoot!=null) {
|
||||
initParams.setRootPath(workspaceRoot.toString());
|
||||
initParams.setRootUri(UriUtil.toUri(workspaceRoot).toString());
|
||||
initParams.setRootUri(UriUtil.toUri(workspaceRoot).toASCIIString());
|
||||
}
|
||||
initParams.setProcessId(parentPid);
|
||||
ClientCapabilities clientCap = new ClientCapabilities();
|
||||
@@ -690,7 +690,7 @@ public class LanguageServerHarness {
|
||||
if (extension == null) {
|
||||
extension = getFileExtension();
|
||||
}
|
||||
return File.createTempFile("workingcopy", extension).toURI().toString();
|
||||
return File.createTempFile("workingcopy", extension).toURI().toASCIIString();
|
||||
}
|
||||
|
||||
public void assertCompletion(String textBefore, String expectTextAfter) throws Exception {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018, 2022 Pivotal, Inc.
|
||||
* Copyright (c) 2018, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -224,13 +224,13 @@ public class ClasspathUtil {
|
||||
switch (e.getPath().segment(0)) {
|
||||
case MAVEN_CONTAINER_ID:
|
||||
IFile f = jp.getProject().getFile("pom.xml");
|
||||
return new ProjectBuild(ProjectBuild.MAVEN_PROJECT_TYPE, f.exists() ? f.getLocationURI().toString() : null);
|
||||
return new ProjectBuild(ProjectBuild.MAVEN_PROJECT_TYPE, f.exists() ? f.getLocationURI().toASCIIString() : null);
|
||||
case GRADLE_CONTAINER_ID:
|
||||
IFile g = jp.getProject().getFile("build.gradle");
|
||||
if (!g.exists()) {
|
||||
g = jp.getProject().getFile("build.gradle.kts");
|
||||
}
|
||||
return new ProjectBuild(ProjectBuild.GRADLE_PROJECT_TYPE, g.exists() ? g.getLocationURI().toString() : null);
|
||||
return new ProjectBuild(ProjectBuild.GRADLE_PROJECT_TYPE, g.exists() ? g.getLocationURI().toASCIIString() : null);
|
||||
}
|
||||
}
|
||||
} catch (JavaModelException e) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018, 2022 Pivotal, Inc.
|
||||
* Copyright (c) 2018, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -157,11 +157,11 @@ public class SendClasspathNotificationsJob extends Job {
|
||||
protected void bufferMessage(URI projectLoc, boolean deleted, String projectName, Classpath classpath, ProjectBuild projectBuild) {
|
||||
if (buffer!=null) {
|
||||
logger.debug("buffering callback "+callbackCommandId+" "+projectName+" "+deleted+" "+ classpath.getEntries().size());
|
||||
buffer.add(ImmutableList.of(projectLoc.toString(), projectName, deleted, classpath, projectBuild));
|
||||
buffer.add(ImmutableList.of(projectLoc.toASCIIString(), projectName, deleted, classpath, projectBuild));
|
||||
} else {
|
||||
try {
|
||||
logger.debug("executing callback "+callbackCommandId+" "+projectName+" "+deleted+" "+ classpath.getEntries().size());
|
||||
Object r = conn.executeClientCommand(callbackCommandId, projectLoc.toString(), projectName, deleted, classpath, projectBuild);
|
||||
Object r = conn.executeClientCommand(callbackCommandId, projectLoc.toASCIIString(), projectName, deleted, classpath, projectBuild);
|
||||
notificationsSentForProjects = ImmutableList.of(projectName);
|
||||
logger.debug("executing callback "+callbackCommandId+" SUCCESS ["+r+"]");
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -225,7 +225,7 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
.publishOn(projectReconcileScheduler)
|
||||
.doOnSuccess(l -> {
|
||||
if (projectReconcileRequests.remove(uri) != null) {
|
||||
projectFinder.find(new TextDocumentIdentifier(uri.toString())).ifPresent(p -> {
|
||||
projectFinder.find(new TextDocumentIdentifier(uri.toASCIIString())).ifPresent(p -> {
|
||||
projectReconciler.reconcile(p, doc -> server.createProblemCollector(doc));
|
||||
});
|
||||
}
|
||||
@@ -265,7 +265,7 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
components.getReconcileEngine().ifPresent(reconcileEngine -> {
|
||||
for (String f : files) {
|
||||
URI uri = URI.create(f);
|
||||
TextDocumentIdentifier docId = new TextDocumentIdentifier(uri.toString());
|
||||
TextDocumentIdentifier docId = new TextDocumentIdentifier(uri.toASCIIString());
|
||||
TextDocument doc = server.getTextDocumentService().getLatestSnapshot(docId.getUri());
|
||||
if (doc == null) {
|
||||
projectFinder.find(docId).ifPresent(project -> {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class BootVersionValidator {
|
||||
DiagnosticResult result = diagnosticProvider.getDiagnostics(project);
|
||||
if (result != null && !result.getDiagnostics().isEmpty()) {
|
||||
server.getTextDocumentService().publishDiagnostics(
|
||||
new TextDocumentIdentifier(result.getDocumentUri().toString()),
|
||||
new TextDocumentIdentifier(result.getDocumentUri().toASCIIString()),
|
||||
result.getDiagnostics());
|
||||
|
||||
}
|
||||
|
||||
@@ -484,7 +484,7 @@ public class SpringSymbolIndex implements InitializingBean {
|
||||
try {
|
||||
File file = new File(new URI(docURI));
|
||||
long lastModified = file.lastModified();
|
||||
return new DocumentDescriptor(UriUtil.toUri(file).toString(), lastModified);
|
||||
return new DocumentDescriptor(UriUtil.toUri(file).toASCIIString(), lastModified);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -589,7 +589,7 @@ public class SpringSymbolIndex implements InitializingBean {
|
||||
}
|
||||
} else {
|
||||
// Take symbols from the index if there is no opened document.
|
||||
List<EnhancedSymbolInformation> docSymbols = this.symbolsByDoc.get(uri.toString());
|
||||
List<EnhancedSymbolInformation> docSymbols = this.symbolsByDoc.get(uri.toASCIIString());
|
||||
if (docSymbols != null) {
|
||||
synchronized (docSymbols) {
|
||||
for (EnhancedSymbolInformation enhanced : docSymbols) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016, 2022 Pivotal, Inc.
|
||||
* Copyright (c) 2016, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -132,7 +132,7 @@ public class BootJavaReconcileEngine implements IReconcileEngine, IJavaProjectRe
|
||||
|
||||
Stream<TextDocumentIdentifier> docIds = files
|
||||
.filter(f -> f.getFileName().toString().endsWith(".java"))
|
||||
.map(f -> new TextDocumentIdentifier(f.toUri().toString()));
|
||||
.map(f -> new TextDocumentIdentifier(f.toUri().toASCIIString()));
|
||||
|
||||
List<TextDocument> docs = docIds.filter(docId -> documents.getLatestSnapshot(docId.getUri()) == null)
|
||||
.map(docId -> new LazyTextDocument(docId.getUri(), LanguageId.JAVA)).collect(Collectors.toList());
|
||||
@@ -163,7 +163,7 @@ public class BootJavaReconcileEngine implements IReconcileEngine, IJavaProjectRe
|
||||
public void clear(IJavaProject project) {
|
||||
// Build file
|
||||
if (project.getProjectBuild() != null && project.getProjectBuild().getBuildFile() != null) {
|
||||
documents.publishDiagnostics(new TextDocumentIdentifier(project.getProjectBuild().getBuildFile().toString()), Collections.emptyList());
|
||||
documents.publishDiagnostics(new TextDocumentIdentifier(project.getProjectBuild().getBuildFile().toASCIIString()), Collections.emptyList());
|
||||
}
|
||||
// Rest of the files
|
||||
IClasspathUtil.getProjectJavaSourceFolders(project.getClasspath()).flatMap(folder -> {
|
||||
@@ -174,7 +174,7 @@ public class BootJavaReconcileEngine implements IReconcileEngine, IJavaProjectRe
|
||||
}
|
||||
})
|
||||
.filter(f -> f.getFileName().toString().endsWith(".java"))
|
||||
.forEach(p -> documents.publishDiagnostics(new TextDocumentIdentifier(p.toUri().toString()), Collections.emptyList()));
|
||||
.forEach(p -> documents.publishDiagnostics(new TextDocumentIdentifier(p.toUri().toASCIIString()), Collections.emptyList()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class DefaultJavaElementLocationProvider implements JavaElementLocationPr
|
||||
String fqName = member.getDeclaringType().getFullyQualifiedName();
|
||||
URI docUri = javaDocUriProvider.docUri(project, fqName);
|
||||
if (docUri != null) {
|
||||
loc.setUri(docUri.toString());
|
||||
loc.setUri(docUri.toASCIIString());
|
||||
Optional<URL> url = SourceLinks.source(project, fqName);
|
||||
if (url.isPresent()) {
|
||||
String memberBindingKey = member.getBindingKey();
|
||||
|
||||
@@ -26,7 +26,7 @@ public class EclipseJavaElementLocationProvider implements JavaElementLocationPr
|
||||
return null;
|
||||
} else {
|
||||
Location location = new Location();
|
||||
location.setUri(uri.toString());
|
||||
location.setUri(uri.toASCIIString());
|
||||
location.setRange(new Range());
|
||||
return location;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class EclipseSourceLinks implements SourceLinks {
|
||||
|
||||
@Override
|
||||
public Optional<String> sourceLinkUrlForFQName(IJavaProject project, String fqName) {
|
||||
return findProjectForFQName(project, fqName).map(p -> eclipseIntroUri(p, fqName)).map(uri -> uri.toString());
|
||||
return findProjectForFQName(project, fqName).map(p -> eclipseIntroUri(p, fqName)).map(uri -> uri.toASCIIString());
|
||||
}
|
||||
|
||||
private Optional<IJavaProject> findProjectForFQName(IJavaProject project, String fqName) {
|
||||
@@ -79,7 +79,7 @@ public class EclipseSourceLinks implements SourceLinks {
|
||||
|
||||
@Override
|
||||
public Optional<String> sourceLinkForResourcePath(Path path) {
|
||||
return Optional.ofNullable(eclipseIntroUri(path)).map(uri -> uri.toString());
|
||||
return Optional.ofNullable(eclipseIntroUri(path)).map(uri -> uri.toASCIIString());
|
||||
}
|
||||
|
||||
public static URI eclipseIntroUri(Path path) {
|
||||
|
||||
@@ -34,7 +34,7 @@ public class JavaServerElementLocationProvider implements JavaElementLocationPro
|
||||
|
||||
@Override
|
||||
public Location findLocation(IJavaProject project, IMember member) {
|
||||
String projectUri = project == null ? null : project.getLocationUri().toString();
|
||||
String projectUri = project == null ? null : project.getLocationUri().toASCIIString();
|
||||
String bindingKey = member.getBindingKey();
|
||||
try {
|
||||
Location location = server.getClient().javaLocation(new JavaDataParams(projectUri, bindingKey, true)).get(500, TimeUnit.MILLISECONDS);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class JavaServerSourceLinks implements SourceLinks {
|
||||
bindingKey.append('L');
|
||||
bindingKey.append(fqName.replace('.', '/'));
|
||||
bindingKey.append(';');
|
||||
String projectUri = project == null ? null : project.getLocationUri().toString();
|
||||
String projectUri = project == null ? null : project.getLocationUri().toASCIIString();
|
||||
CompletableFuture<Optional<String>> link = server.getClient().javadocHoverLink(new JavaDataParams(projectUri, bindingKey.toString(), true))
|
||||
.thenApply(l -> Optional.ofNullable(l));
|
||||
try {
|
||||
@@ -56,7 +56,7 @@ public class JavaServerSourceLinks implements SourceLinks {
|
||||
|
||||
@Override
|
||||
public Optional<String> sourceLinkForResourcePath(Path path) {
|
||||
return Optional.ofNullable(path).map(p -> p.toUri().toString());
|
||||
return Optional.ofNullable(path).map(p -> p.toUri().toASCIIString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ public interface SourceLinks {
|
||||
return sourceLinkUrlForClasspathResourceOnTomcat(sourceLinks, projectFinder, path);
|
||||
}
|
||||
Path filePath = Paths.get(path.substring(0, idx));
|
||||
IJavaProject project = projectFinder.find(new TextDocumentIdentifier(filePath.toUri().toString())).orElse(null);
|
||||
IJavaProject project = projectFinder.find(new TextDocumentIdentifier(filePath.toUri().toASCIIString())).orElse(null);
|
||||
if (project == null) {
|
||||
try {
|
||||
// URL for CF resources looks like jar:file:/home/vcap/app/lib/gs-rest-service-complete.jar!/hello/MyService.class
|
||||
|
||||
@@ -34,7 +34,7 @@ public class VSCodeSourceLinks extends AbstractSourceLinks {
|
||||
|
||||
@Override
|
||||
public Optional<String> sourceLinkForResourcePath(Path path) {
|
||||
return Optional.of(path.toUri().toString());
|
||||
return Optional.of(path.toUri().toASCIIString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,7 +57,7 @@ public class VSCodeSourceLinks extends AbstractSourceLinks {
|
||||
|
||||
@Override
|
||||
protected Optional<String> jarLinkUrl(IJavaProject project, String fqName, IJavaModuleData jarModuleData) {
|
||||
return Optional.ofNullable(JdtJavaDocumentUriProvider.uri(project, fqName)).map(uri -> uri.toString());
|
||||
return Optional.ofNullable(JdtJavaDocumentUriProvider.uri(project, fqName)).map(uri -> uri.toASCIIString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class RewriteCompilationUnitCache implements DocumentContentProvider, Dis
|
||||
if (!future.isCancelled()) {
|
||||
future.cancel(true);
|
||||
}
|
||||
Optional<IJavaProject> project = projectFinder.find(new TextDocumentIdentifier(uri.toString()));
|
||||
Optional<IJavaProject> project = projectFinder.find(new TextDocumentIdentifier(uri.toASCIIString()));
|
||||
if (project.isPresent()) {
|
||||
|
||||
JavaParser parser = javaParsers.getIfPresent(project.get().getLocationUri());
|
||||
@@ -180,7 +180,7 @@ public class RewriteCompilationUnitCache implements DocumentContentProvider, Dis
|
||||
@Override
|
||||
public String fetchContent(URI uri) throws Exception {
|
||||
if (documentService != null) {
|
||||
TextDocument document = documentService.getLatestSnapshot(uri.toString());
|
||||
TextDocument document = documentService.getLatestSnapshot(uri.toASCIIString());
|
||||
if (document != null) {
|
||||
return document.get();
|
||||
}
|
||||
@@ -256,18 +256,18 @@ public class RewriteCompilationUnitCache implements DocumentContentProvider, Dis
|
||||
* Does not need to be via callback - kept the same in order to keep the same API to replace JDT with Rewrite in distant future
|
||||
*/
|
||||
public <T> T withCompilationUnit(IJavaProject project, URI uri, Function<CompilationUnit, T> requestor) {
|
||||
logger.info("CU Cache: work item submitted for doc {}", uri.toString());
|
||||
logger.info("CU Cache: work item submitted for doc {}", uri.toASCIIString());
|
||||
CompilationUnit cu = getCU(project, uri);
|
||||
if (cu != null) {
|
||||
try {
|
||||
logger.info("CU Cache: start work on AST for {}", uri.toString());
|
||||
logger.info("CU Cache: start work on AST for {}", uri.toASCIIString());
|
||||
return requestor.apply(cu);
|
||||
} catch (CancellationException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
} finally {
|
||||
logger.info("CU Cache: end work on AST for {}", uri.toString());
|
||||
logger.info("CU Cache: end work on AST for {}", uri.toASCIIString());
|
||||
}
|
||||
}
|
||||
return requestor.apply(null);
|
||||
|
||||
@@ -416,7 +416,7 @@ public class RewriteRecipeRepository implements ApplicationContextAware {
|
||||
server.getProgressService().progressEvent(progressToken, "Parsing files...");
|
||||
MavenProjectParser projectParser = createRewriteMavenParser(absoluteProjectDir,
|
||||
new InMemoryExecutionContext(), p -> {
|
||||
TextDocument doc = server.getTextDocumentService().getLatestSnapshot(p.toUri().toString());
|
||||
TextDocument doc = server.getTextDocumentService().getLatestSnapshot(p.toUri().toASCIIString());
|
||||
if (doc != null) {
|
||||
return new Parser.Input(p, () -> new ByteArrayInputStream(doc.get().getBytes()));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2022 VMware, Inc.
|
||||
* Copyright (c) 2022, 2023 VMware, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -120,9 +120,9 @@ public class RewriteRefactorings implements CodeActionResolver, QuickfixHandler
|
||||
List<Result> results = reciperun.getResults();
|
||||
List<Either<TextDocumentEdit, ResourceOperation>> edits = results.stream().filter(res -> res.getAfter() != null).map(res -> {
|
||||
URI docUri = res.getAfter().getSourcePath().isAbsolute() ? res.getAfter().getSourcePath().toUri() : project.getLocationUri().resolve(res.getAfter().getSourcePath().toString());
|
||||
TextDocument doc = documents.getLatestSnapshot(docUri.toString());
|
||||
TextDocument doc = documents.getLatestSnapshot(docUri.toASCIIString());
|
||||
if (doc == null) {
|
||||
doc = new TextDocument(docUri.toString(), LanguageId.JAVA, 0, res.getBefore() == null ? "" : res.getBefore().printAll());
|
||||
doc = new TextDocument(docUri.toASCIIString(), LanguageId.JAVA, 0, res.getBefore() == null ? "" : res.getBefore().printAll());
|
||||
}
|
||||
return ORDocUtils.computeTextDocEdit(doc, res);
|
||||
}).filter(e -> e.isPresent()).map(e -> e.get()).map(e -> Either.<TextDocumentEdit, ResourceOperation>forLeft(e)).collect(Collectors.toList());
|
||||
|
||||
@@ -77,7 +77,7 @@ public class AutowiredFieldIntoConstructorParameterCodeAction implements RecipeC
|
||||
if (fqType != null && isApplicableType(fqType)) {
|
||||
List<MethodDeclaration> constructors = ORAstUtils.getMethods(classDeclaration).stream().filter(c -> c.isConstructor()).limit(2).collect(Collectors.toList());
|
||||
String fieldName = multiVariable.getVariables().get(0).getSimpleName();
|
||||
String uri = getCursor().firstEnclosing(SourceFile.class).getSourcePath().toUri().toString();
|
||||
String uri = getCursor().firstEnclosing(SourceFile.class).getSourcePath().toUri().toASCIIString();
|
||||
FixAssistMarker marker = new FixAssistMarker(Tree.randomId(), getId())
|
||||
.withFix(
|
||||
new FixDescriptor(ID, List.of(uri), LABEL)
|
||||
|
||||
@@ -50,7 +50,7 @@ public class BeanMethodNotPublicProblem implements RecipeCodeActionDescriptor {
|
||||
if (m.getAllAnnotations().stream().anyMatch(BEAN_ANNOTATION_MATCHER::matches)
|
||||
&& Boolean.FALSE.equals(TypeUtils.isOverride(method.getMethodType()))) {
|
||||
// mark public modifier
|
||||
String uri = getCursor().firstEnclosing(SourceFile.class).getSourcePath().toUri().toString();
|
||||
String uri = getCursor().firstEnclosing(SourceFile.class).getSourcePath().toUri().toASCIIString();
|
||||
FixAssistMarker fixAssistMarker = new FixAssistMarker(Tree.randomId(), getId())
|
||||
.withFixes(
|
||||
new FixDescriptor(ID, List.of(uri), LABEL)
|
||||
|
||||
@@ -50,7 +50,7 @@ public class BeanPostProcessingIgnoreInAotProblem implements RecipeCodeActionDes
|
||||
.filter(MethodDeclaration.class::isInstance).map(MethodDeclaration.class::cast)
|
||||
.filter(BeanPostProcessingIgnoreInAot::isApplicableMethod)
|
||||
.collect(Collectors.toList());
|
||||
String uri = getCursor().firstEnclosing(SourceFile.class).getSourcePath().toUri().toString();
|
||||
String uri = getCursor().firstEnclosing(SourceFile.class).getSourcePath().toUri().toASCIIString();
|
||||
FixAssistMarker marker = new FixAssistMarker(Tree.randomId(), getId())
|
||||
.withFixes(
|
||||
new FixDescriptor(RECIPE_ID, List.of(uri), RecipeCodeActionDescriptor.buildLabel(LABEL, RecipeScope.NODE))
|
||||
|
||||
@@ -66,7 +66,7 @@ public class NoAutowiredOnConstructorProblem implements RecipeCodeActionDescript
|
||||
return s;
|
||||
}
|
||||
MethodDeclaration constructor = (MethodDeclaration) s;
|
||||
String uri = getCursor().firstEnclosing(SourceFile.class).getSourcePath().toUri().toString();
|
||||
String uri = getCursor().firstEnclosing(SourceFile.class).getSourcePath().toUri().toASCIIString();
|
||||
FixAssistMarker fixAssistMarker = new FixAssistMarker(Tree.randomId(), getId())
|
||||
.withFix(
|
||||
new FixDescriptor(ID, List.of(uri), LABEL)
|
||||
|
||||
@@ -62,7 +62,7 @@ public class NoRepoAnnotationProblem implements RecipeCodeActionDescriptor {
|
||||
c = c.withLeadingAnnotations(ListUtils.map(c.getLeadingAnnotations(), a -> {
|
||||
if (a == repoAnnotation) {
|
||||
String uri = getCursor().firstEnclosing(SourceFile.class).getSourcePath().toUri()
|
||||
.toString();
|
||||
.toASCIIString();
|
||||
FixAssistMarker fixAssistMarker = new FixAssistMarker(Tree.randomId(), getId()).withFixes(
|
||||
new FixDescriptor(ID, List.of(uri), LABEL)
|
||||
.withRangeScope(classDecl.getMarkers().findFirst(Range.class).get())
|
||||
|
||||
@@ -44,7 +44,7 @@ public class NoRequestMappingAnnotationCodeAction implements RecipeCodeActionDes
|
||||
public J.Annotation visitAnnotation(J.Annotation annotation, ExecutionContext ctx) {
|
||||
J.Annotation a = super.visitAnnotation(annotation, ctx);
|
||||
if (REQUEST_MAPPING_ANNOTATION_MATCHER.matches(a) && getCursor().getParentOrThrow().getValue() instanceof J.MethodDeclaration) {
|
||||
String uri = getCursor().firstEnclosing(SourceFile.class).getSourcePath().toUri().toString();
|
||||
String uri = getCursor().firstEnclosing(SourceFile.class).getSourcePath().toUri().toASCIIString();
|
||||
FixAssistMarker fixAssistMarker = new FixAssistMarker(Tree.randomId(), getId())
|
||||
.withFixes(
|
||||
new FixDescriptor(ID, List.of(uri), RecipeCodeActionDescriptor.buildLabel(LABEL, RecipeScope.NODE))
|
||||
|
||||
@@ -87,7 +87,7 @@ public class NotRegisteredBeansProblem implements RecipeCodeActionDescriptor {
|
||||
List<JavaType.Method> constructors = c.getType().getMethods().stream().filter(m -> m.isConstructor()).collect(Collectors.toList());
|
||||
if (beanSymbols.isEmpty()) {
|
||||
SourceFile source = getCursor().firstEnclosing(SourceFile.class);
|
||||
String uri = source.getSourcePath().toUri().toString();
|
||||
String uri = source.getSourcePath().toUri().toASCIIString();
|
||||
FixAssistMarker marker = new FixAssistMarker(Tree.randomId(), getId());
|
||||
JavaProjectFinder projectFinder = applicationContext.getBean(JavaProjectFinder.class);
|
||||
if (projectFinder != null) {
|
||||
|
||||
@@ -53,7 +53,7 @@ public class PreciseBeanTypeProblem implements RecipeCodeActionDescriptor {
|
||||
if ((o instanceof JavaType.FullyQualified && m.getReturnTypeExpression().getType() instanceof JavaType.FullyQualified)
|
||||
|| (o instanceof JavaType.Array && m.getReturnTypeExpression().getType() instanceof JavaType.Array)) {
|
||||
|
||||
String uri = getCursor().firstEnclosing(SourceFile.class).getSourcePath().toUri().toString();
|
||||
String uri = getCursor().firstEnclosing(SourceFile.class).getSourcePath().toUri().toASCIIString();
|
||||
FixAssistMarker marker = new FixAssistMarker(Tree.randomId(), getId())
|
||||
.withFixes(
|
||||
new FixDescriptor(RECIPE_ID, List.of(uri), RecipeCodeActionDescriptor.buildLabel(LABEL, RecipeScope.NODE))
|
||||
|
||||
@@ -70,7 +70,7 @@ public class UnnecessarySpringExtensionProblem implements RecipeCodeActionDescri
|
||||
})) {
|
||||
c = c.withLeadingAnnotations(ListUtils.map(c.getLeadingAnnotations(), a -> {
|
||||
if (SPRING_EXTENSION_ANNOTATIN_MATCHER.matches(a)) {
|
||||
String uri = getCursor().firstEnclosing(SourceFile.class).getSourcePath().toUri().toString();
|
||||
String uri = getCursor().firstEnclosing(SourceFile.class).getSourcePath().toUri().toASCIIString();
|
||||
FixAssistMarker fixMarker = new FixAssistMarker(Tree.randomId(), getId())
|
||||
.withFix(new FixDescriptor(ID, List.of(uri), RecipeCodeActionDescriptor.buildLabel(LABEL, RecipeScope.PROJECT)));
|
||||
return a.withMarkers(a.getMarkers().add(fixMarker));
|
||||
|
||||
@@ -184,7 +184,7 @@ public final class CompilationUnitCache implements DocumentContentProvider {
|
||||
* for later use. The JDT ASTs are not thread safe!
|
||||
*/
|
||||
public <T> T withCompilationUnit(IJavaProject project, URI uri, Function<CompilationUnit, T> requestor) {
|
||||
logger.info("CU Cache: work item submitted for doc {}", uri.toString());
|
||||
logger.info("CU Cache: work item submitted for doc {}", uri.toASCIIString());
|
||||
|
||||
if (project != null) {
|
||||
|
||||
@@ -196,11 +196,11 @@ public final class CompilationUnitCache implements DocumentContentProvider {
|
||||
|
||||
try {
|
||||
Tuple2<List<Classpath>, INameEnvironmentWithProgress> lookupEnvTuple = loadLookupEnvTuple(project);
|
||||
String utiStr = uri.toString();
|
||||
String utiStr = uri.toASCIIString();
|
||||
String unitName = utiStr.substring(utiStr.lastIndexOf("/"));
|
||||
CompilationUnit cUnit = parse2(fetchContent(uri).toCharArray(), utiStr, unitName, lookupEnvTuple.getT1(), lookupEnvTuple.getT2());
|
||||
|
||||
logger.debug("CU Cache: created new AST for {}", uri.toString());
|
||||
logger.debug("CU Cache: created new AST for {}", uri.toASCIIString());
|
||||
|
||||
return cUnit;
|
||||
} catch (Exception e) {
|
||||
@@ -331,7 +331,7 @@ public final class CompilationUnitCache implements DocumentContentProvider {
|
||||
@Override
|
||||
public String fetchContent(URI uri) throws Exception {
|
||||
if (documentService != null) {
|
||||
TextDocument document = documentService.getLatestSnapshot(uri.toString());
|
||||
TextDocument document = documentService.getLatestSnapshot(uri.toASCIIString());
|
||||
if (document != null) {
|
||||
return document.get();
|
||||
}
|
||||
|
||||
@@ -84,8 +84,11 @@ public class SpringFactoriesIndexer implements SpringIndexer {
|
||||
|
||||
@Override
|
||||
public boolean isInterestedIn(String docURI) {
|
||||
Path path = Paths.get(URI.create(docURI));
|
||||
return FILE_GLOB_PATTERN.matches(path);
|
||||
if (docURI.endsWith(".factories")) {
|
||||
Path path = Paths.get(URI.create(docURI));
|
||||
return FILE_GLOB_PATTERN.matches(path);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -197,8 +200,8 @@ public class SpringFactoriesIndexer implements SpringIndexer {
|
||||
String content = Files.readString(file);
|
||||
ImmutableList.Builder<CachedSymbol> builder = ImmutableList.builder();
|
||||
long lastModified = Files.getLastModifiedTime(file).toMillis();
|
||||
String docUri = file.toUri().toString();
|
||||
for (EnhancedSymbolInformation s : computeSymbols(file.toUri().toString(), content)) {
|
||||
String docUri = file.toUri().toASCIIString();
|
||||
for (EnhancedSymbolInformation s : computeSymbols(docUri, content)) {
|
||||
builder.add(new CachedSymbol(docUri, lastModified, s));
|
||||
}
|
||||
return builder.build();
|
||||
|
||||
@@ -287,7 +287,7 @@ public class SpringIndexerJava implements SpringIndexer {
|
||||
@Override
|
||||
public void acceptAST(String sourceFilePath, CompilationUnit cu) {
|
||||
File file = new File(sourceFilePath);
|
||||
String docURI = UriUtil.toUri(file).toString();
|
||||
String docURI = UriUtil.toUri(file).toASCIIString();
|
||||
|
||||
DocumentDescriptor updatedDoc = updatedDocs.get(docURI);
|
||||
long lastModified = updatedDoc.getLastModified();
|
||||
@@ -335,7 +335,7 @@ public class SpringIndexerJava implements SpringIndexer {
|
||||
|
||||
DocumentDescriptor[] docsToScan = filesToScan.stream().map(file -> {
|
||||
File realFile = new File(file);
|
||||
String docURI = UriUtil.toUri(realFile).toString();
|
||||
String docURI = UriUtil.toUri(realFile).toASCIIString();
|
||||
long lastModified = realFile.lastModified();
|
||||
return new DocumentDescriptor(docURI, lastModified);
|
||||
}).toArray(DocumentDescriptor[]::new);
|
||||
@@ -398,7 +398,7 @@ public class SpringIndexerJava implements SpringIndexer {
|
||||
@Override
|
||||
public void acceptAST(String sourceFilePath, CompilationUnit cu) {
|
||||
File file = new File(sourceFilePath);
|
||||
String docURI = UriUtil.toUri(file).toString();
|
||||
String docURI = UriUtil.toUri(file).toASCIIString();
|
||||
long lastModified = file.lastModified();
|
||||
AtomicReference<TextDocument> docRef = new AtomicReference<>();
|
||||
|
||||
@@ -640,7 +640,7 @@ public class SpringIndexerJava implements SpringIndexer {
|
||||
try {
|
||||
for (Path path : testJavaFiles) {
|
||||
URI docUri = UriUtil.toUri(path.toFile());
|
||||
symbolHandler.removeSymbols(project, docUri.toString());
|
||||
symbolHandler.removeSymbols(project, docUri.toASCIIString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("{}", e);
|
||||
@@ -666,7 +666,7 @@ public class SpringIndexerJava implements SpringIndexer {
|
||||
File file = path.toFile();
|
||||
URI docUri = UriUtil.toUri(file);
|
||||
String content = FileUtils.readFileToString(file);
|
||||
scanFile(project, new DocumentDescriptor(docUri.toString(), file.lastModified()), content);
|
||||
scanFile(project, new DocumentDescriptor(docUri.toASCIIString(), file.lastModified()), content);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("{}", e);
|
||||
|
||||
@@ -199,7 +199,7 @@ public class SpringIndexerXML implements SpringIndexer {
|
||||
File file = new File(fileName);
|
||||
long lastModified = file.lastModified();
|
||||
|
||||
String docURI = UriUtil.toUri(file).toString();
|
||||
String docURI = UriUtil.toUri(file).toASCIIString();
|
||||
String fileContent = FileUtils.readFileToString(file);
|
||||
|
||||
scanFile(project, fileContent, docURI, lastModified, generatedSymbols);
|
||||
@@ -288,7 +288,7 @@ public class SpringIndexerXML implements SpringIndexer {
|
||||
String[] docURIs = new String[files.length];
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
|
||||
String docURI = UriUtil.toUri(new File(files[i])).toString();
|
||||
String docURI = UriUtil.toUri(new File(files[i])).toASCIIString();
|
||||
symbolHandler.removeSymbols(project, docURI);
|
||||
docURIs[i] = docURI;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public class SymbolCacheOnDisc implements SymbolCache {
|
||||
public void removeFile(SymbolCacheKey cacheKey, String file) {
|
||||
CacheStore cacheStore = this.stores.get(cacheKey);
|
||||
if (cacheStore != null) {
|
||||
String docURI = UriUtil.toUri(new File(file)).toString();
|
||||
String docURI = UriUtil.toUri(new File(file)).toASCIIString();
|
||||
|
||||
SortedMap<String, Long> timestampedFiles = new TreeMap<>(cacheStore.getTimestampedFiles());
|
||||
timestampedFiles.remove(file);
|
||||
@@ -174,7 +174,7 @@ public class SymbolCacheOnDisc implements SymbolCache {
|
||||
CacheStore cacheStore = this.stores.get(cacheKey);
|
||||
|
||||
if (cacheStore != null) {
|
||||
String docURI = UriUtil.toUri(new File(file)).toString();
|
||||
String docURI = UriUtil.toUri(new File(file)).toASCIIString();
|
||||
|
||||
SortedMap<String, Long> timestampedFiles = new TreeMap<>(cacheStore.getTimestampedFiles());
|
||||
timestampedFiles.put(file, lastModified);
|
||||
@@ -212,7 +212,7 @@ public class SymbolCacheOnDisc implements SymbolCache {
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
|
||||
// update cache internal map of timestamps per file
|
||||
String docURI = UriUtil.toUri(new File(files[i])).toString();
|
||||
String docURI = UriUtil.toUri(new File(files[i])).toASCIIString();
|
||||
allDocURIs.add(docURI);
|
||||
|
||||
timestampedFiles.put(files[i], lastModified[i]);
|
||||
|
||||
@@ -171,7 +171,7 @@ public class ValuePropertyReferencesProvider implements ReferenceProvider {
|
||||
YamlASTProvider parser = new YamlParser();
|
||||
|
||||
URI docURI = Paths.get(filePath).toUri();
|
||||
TextDocument doc = new TextDocument(docURI.toString(), null);
|
||||
TextDocument doc = new TextDocument(docURI.toASCIIString(), null);
|
||||
doc.setText(fileContent);
|
||||
YamlFileAST ast = parser.getAST(doc);
|
||||
|
||||
@@ -193,7 +193,7 @@ public class ValuePropertyReferencesProvider implements ReferenceProvider {
|
||||
range.setStart(start);
|
||||
range.setEnd(end);
|
||||
|
||||
Location location = new Location(docURI.toString(), range);
|
||||
Location location = new Location(docURI.toASCIIString(), range);
|
||||
foundLocations.add(location);
|
||||
}
|
||||
}
|
||||
@@ -243,7 +243,7 @@ public class ValuePropertyReferencesProvider implements ReferenceProvider {
|
||||
parseResults.ast.getNodes(KeyValuePair.class).forEach(pair -> {
|
||||
if (pair.getKey() != null && pair.getKey().decode().equals(propertyKey)) {
|
||||
URI docURI = Paths.get(filePath).toUri();
|
||||
TextDocument doc = new TextDocument(docURI.toString(), null);
|
||||
TextDocument doc = new TextDocument(docURI.toASCIIString(), null);
|
||||
doc.setText(fileContent);
|
||||
|
||||
try {
|
||||
@@ -263,7 +263,7 @@ public class ValuePropertyReferencesProvider implements ReferenceProvider {
|
||||
range.setStart(start);
|
||||
range.setEnd(end);
|
||||
|
||||
Location location = new Location(docURI.toString(), range);
|
||||
Location location = new Location(docURI.toASCIIString(), range);
|
||||
foundLocations.add(location);
|
||||
|
||||
} catch (BadLocationException e) {
|
||||
|
||||
@@ -247,7 +247,7 @@ public class JdtLsProjectCache implements InitializableJavaProjectsService, Serv
|
||||
}
|
||||
|
||||
@Override
|
||||
public IJavadocProvider javadocProvider(String projectUri, CPE classpathEntry) {
|
||||
public IJavadocProvider javadocProvider(URI projectUri, CPE classpathEntry) {
|
||||
return new JdtLsJavadocProvider(server.getClient(), projectUri);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2019 Pivotal, Inc.
|
||||
* Copyright (c) 2019, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -109,7 +109,7 @@ public class CommonQuickfixes {
|
||||
Path metadataFilePath = sourceFolders.stream().map(f -> f.toPath()).map(path -> path.resolve(METADATA_PATH)).filter(path -> Files.exists(path)).findFirst().orElse(null);
|
||||
if (metadataFilePath == null) {
|
||||
metadataFilePath = preferredSourceFolder.toPath().resolve(METADATA_PATH);
|
||||
we.getDocumentChanges().add(Either.forRight(new CreateFile(metadataFilePath.toUri().toString())));
|
||||
we.getDocumentChanges().add(Either.forRight(new CreateFile(metadataFilePath.toUri().toASCIIString())));
|
||||
}
|
||||
if (metadataFilePath != null) {
|
||||
String content = Files.exists(metadataFilePath) ? IOUtil.toString(Files.newInputStream(metadataFilePath)) : "";
|
||||
@@ -120,10 +120,10 @@ public class CommonQuickfixes {
|
||||
} else {
|
||||
metadata.addDefaultInfo(params.getProperty());
|
||||
TextDocumentEdit edit = new TextDocumentEdit();
|
||||
edit.setTextDocument(new VersionedTextDocumentIdentifier(metadataFilePath.toUri().toString(), null));
|
||||
edit.setTextDocument(new VersionedTextDocumentIdentifier(metadataFilePath.toUri().toASCIIString(), null));
|
||||
TextEdit textEdit = new TextEdit();
|
||||
textEdit.setNewText(metadata.getTextContent());
|
||||
TextDocument doc = new TextDocument(metadataFilePath.toUri().toString(), null);
|
||||
TextDocument doc = new TextDocument(metadataFilePath.toUri().toASCIIString(), null);
|
||||
doc.setText(content);
|
||||
textEdit.setRange(doc.toRange(new Region(0, content.length())));
|
||||
edit.setEdits(ImmutableList.of(textEdit));
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ProjectVersionDiagnosticProvider {
|
||||
Version javaProjectVersion = SpringProjectUtil.getSpringBootVersion(javaProject);
|
||||
|
||||
if (javaProjectVersion == null) {
|
||||
log.warn("Unable to resolve version for project: " + javaProject.getLocationUri().toString());
|
||||
log.warn("Unable to resolve version for project: " + javaProject.getLocationUri().toASCIIString());
|
||||
return new DiagnosticResult(buildFileUri, Collections.emptyList());
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ public class VersionValidators {
|
||||
ca.setTitle("Upgrade to Spring Boot " + latest.toString() + " (Maven dependency version changes only)");
|
||||
String commandId = SpringBootUpgrade.CMD_UPGRADE_SPRING_BOOT;
|
||||
ca.setCommand(new Command("Upgrade to Version " + latest.toString(), commandId,
|
||||
ImmutableList.of(javaProject.getLocationUri().toString(), latest.toString())));
|
||||
ImmutableList.of(javaProject.getLocationUri().toASCIIString(), latest.toString())));
|
||||
|
||||
|
||||
return createDiagnostic(ca, problemType, message.toString());
|
||||
@@ -233,7 +233,7 @@ public class VersionValidators {
|
||||
ca.setTitle("Upgrade to Spring Boot " + latest.toString() + " (executes the full project conversion recipe from OpenRewrite)");
|
||||
String commandId = SpringBootUpgrade.CMD_UPGRADE_SPRING_BOOT;
|
||||
ca.setCommand(new Command("Upgrade to Version " + latest.toString(), commandId,
|
||||
ImmutableList.of(javaProject.getLocationUri().toString(), latest.toString())));
|
||||
ImmutableList.of(javaProject.getLocationUri().toASCIIString(), latest.toString())));
|
||||
|
||||
|
||||
return createDiagnostic(ca, problemType, message.toString());
|
||||
@@ -264,7 +264,7 @@ public class VersionValidators {
|
||||
ca.setTitle("Upgrade to Spring Boot " + latest.toString() + " (executes the full project conversion recipe from OpenRewrite)");
|
||||
String commandId = SpringBootUpgrade.CMD_UPGRADE_SPRING_BOOT;
|
||||
ca.setCommand(new Command("Upgrade to Version " + latest.toString(), commandId,
|
||||
ImmutableList.of(javaProject.getLocationUri().toString(), latest.toString())));
|
||||
ImmutableList.of(javaProject.getLocationUri().toASCIIString(), latest.toString())));
|
||||
|
||||
|
||||
return createDiagnostic(ca, problemType, message.toString());
|
||||
|
||||
@@ -85,7 +85,7 @@ public class TypeCompletionProposalProvider implements XMLCompletionProvider {
|
||||
|
||||
log.info("Prefix is '{}'", prefix);
|
||||
|
||||
JavaCodeCompleteParams params = new JavaCodeCompleteParams(project.getLocationUri().toString(), prefix, true, true);
|
||||
JavaCodeCompleteParams params = new JavaCodeCompleteParams(project.getLocationUri().toASCIIString(), prefix, true, true);
|
||||
CompletableFuture<List<JavaCodeCompleteData>> completions = server.getClient().javaCodeComplete(params);
|
||||
|
||||
final String finalPrefix = prefix;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class BeanRefHyperlinkProvider implements XMLHyperlinkProvider {
|
||||
Optional<IJavaProject> foundProject = this.projectFinder.find(doc.getId());
|
||||
if (foundProject.isPresent()) {
|
||||
final IJavaProject project = foundProject.get();
|
||||
String projectLocation = project.getLocationUri() != null ? project.getLocationUri().toString() : "";
|
||||
String projectLocation = project.getLocationUri() != null ? project.getLocationUri().toASCIIString() : "";
|
||||
|
||||
// make sure the project and the symbol location share the same prefix "file:///"
|
||||
// looks like project locations are containing a "file:/" only
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.bootiful;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -68,7 +69,7 @@ public class JavaTestConf {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IJavadocProvider javadocProvider(String projectUri, CPE cpe) {
|
||||
public IJavadocProvider javadocProvider(URI projectUri, CPE cpe) {
|
||||
return javadocService.javadocProvider(projectUri, cpe);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class AstParserTest {
|
||||
|
||||
char[] content = IOUtils.toString(uri).toCharArray();
|
||||
|
||||
CompilationUnit cu = CompilationUnitCache.parse2(content, uri.toString(), unitName, jp);
|
||||
CompilationUnit cu = CompilationUnitCache.parse2(content, uri.toASCIIString(), unitName, jp);
|
||||
|
||||
assertNotNull(cu);
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public class SpringIndexerTestSpecialCharacters {
|
||||
// TODO: the direct path to URI conversion changes the é into an %-encoded character, so maybe we should switch to that entirely
|
||||
|
||||
// String docUri = directory.toPath().resolve("src/main/java/org/test/ClassWithSpécialCharacter.java").toUri().toString();
|
||||
String docUri = UriUtil.toUri(directory.toPath().resolve("src/main/java/org/test/ClassWithSpécialCharacter.java").toFile()).toString();
|
||||
String docUri = UriUtil.toUri(directory.toPath().resolve("src/main/java/org/test/ClassWithSpécialCharacter.java").toFile()).toASCIIString();
|
||||
|
||||
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@Configurable", docUri, 4, 0, 4, 13));
|
||||
}
|
||||
|
||||
@@ -539,8 +539,8 @@ public class SymbolCacheOnDiscTest {
|
||||
FileTime timeFile2 = Files.getLastModifiedTime(file2);
|
||||
String[] files = {file1.toAbsolutePath().toString(), file2.toAbsolutePath().toString()};
|
||||
|
||||
String doc1URI = UriUtil.toUri(file1.toFile()).toString();
|
||||
String doc2URI = UriUtil.toUri(file2.toFile()).toString();
|
||||
String doc1URI = UriUtil.toUri(file1.toFile()).toASCIIString();
|
||||
String doc2URI = UriUtil.toUri(file2.toFile()).toASCIIString();
|
||||
|
||||
List<CachedSymbol> generatedSymbols = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ public class AdHocSpringPropertyIndexProviderTest {
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"initial-property" //not changed yet because didn't fire change events.
|
||||
);
|
||||
documents.fire(new TextDocumentSaveChange(new TextDocument(propsFile.toURI().toString(), LanguageId.BOOT_PROPERTIES)));
|
||||
documents.fire(new TextDocumentSaveChange(new TextDocument(propsFile.toURI().toASCIIString(), LanguageId.BOOT_PROPERTIES)));
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"from-properties"
|
||||
);
|
||||
@@ -157,7 +157,7 @@ public class AdHocSpringPropertyIndexProviderTest {
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"from-properties"
|
||||
);
|
||||
documents.fire(new TextDocumentSaveChange(new TextDocument(propsFile.toURI().toString(), LanguageId.BOOT_PROPERTIES_YAML)));
|
||||
documents.fire(new TextDocumentSaveChange(new TextDocument(propsFile.toURI().toASCIIString(), LanguageId.BOOT_PROPERTIES_YAML)));
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"from-properties",
|
||||
"from-yaml"
|
||||
|
||||
@@ -187,7 +187,7 @@ public class MockProjects {
|
||||
}
|
||||
|
||||
public String uri(String projectRelativePath) {
|
||||
return new File(root, projectRelativePath).toURI().toString();
|
||||
return new File(root, projectRelativePath).toURI().toASCIIString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -274,7 +274,7 @@ public class MockProjects {
|
||||
synchronized (listeners) {
|
||||
for (FileListener l : listeners.values()) {
|
||||
if (l.matcher.matches(path)) {
|
||||
l.handler.accept(new String[] {target.toURI().toString()});
|
||||
l.handler.accept(new String[] {target.toURI().toASCIIString()});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public class ValueSpelExpressionValidationTest {
|
||||
harness.intialize(null);
|
||||
|
||||
directory = new File(ProjectsHarness.class.getResource("/test-projects/test-annotations/").toURI());
|
||||
docUri = directory.toPath().resolve("src/main/java/org/test/TestValueCompletion.java").toUri().toString();
|
||||
docUri = directory.toPath().resolve("src/main/java/org/test/TestValueCompletion.java").toUri().toASCIIString();
|
||||
|
||||
problemCollector = new TestProblemCollector();
|
||||
reconcileEngine = new BootJavaReconcileEngine(projectFinder, new JavaReconciler[] {
|
||||
|
||||
@@ -94,7 +94,7 @@ public class XMLSpelExpressionValidationTest {
|
||||
harness.useProject(project);
|
||||
|
||||
directory = new File(ProjectsHarness.class.getResource("/test-projects/test-xml-validations/").toURI());
|
||||
docUri = directory.toPath().resolve("src/main/webapp/WEB-INF/spring/root-context.xml").toUri().toString();
|
||||
docUri = directory.toPath().resolve("src/main/webapp/WEB-INF/spring/root-context.xml").toUri().toASCIIString();
|
||||
|
||||
problemCollector = new TestProblemCollector();
|
||||
reconcileEngine = new SpringXMLReconcileEngine(projectFinder, config);
|
||||
|
||||
@@ -124,7 +124,7 @@ public class DefinitionLinkAsserts {
|
||||
if (sourceUrl.isPresent()) {
|
||||
|
||||
URI docUri = javaDocumentUriProvider.docUri(project, fqName);
|
||||
loc.setUri(docUri.toString());
|
||||
loc.setUri(docUri.toASCIIString());
|
||||
|
||||
String typeName = fqName.substring(fqName.lastIndexOf('.') + 1);
|
||||
URI sourceUri = sourceUrl.get().toURI();
|
||||
@@ -179,7 +179,7 @@ public class DefinitionLinkAsserts {
|
||||
if (sourceUrl.isPresent()) {
|
||||
|
||||
URI docUri = javaDocumentUriProvider.docUri(project, method.fqName);
|
||||
loc.setUri(docUri.toString());
|
||||
loc.setUri(docUri.toASCIIString());
|
||||
|
||||
URI sourceUri = sourceUrl.get().toURI();
|
||||
Range r = cuCache.withCompilationUnit(project, sourceUri, (cu) -> {
|
||||
@@ -240,7 +240,7 @@ public class DefinitionLinkAsserts {
|
||||
URI sourceUri = sourceUrl.get().toURI();
|
||||
|
||||
URI docUri = javaDocumentUriProvider.docUri(project, field.fqName);
|
||||
loc.setUri(docUri.toString());
|
||||
loc.setUri(docUri.toASCIIString());
|
||||
|
||||
Range r = cuCache.withCompilationUnit(project, sourceUri, (cu) -> {
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2022 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -58,7 +58,7 @@ public class SpringPropertiesIndexTest {
|
||||
|
||||
File javaFile = new File(directory, "/src/main/java/demo/Application.java");
|
||||
|
||||
TextDocument doc = new TextDocument(javaFile.toURI().toString(), LanguageId.JAVA);
|
||||
TextDocument doc = new TextDocument(javaFile.toURI().toASCIIString(), LanguageId.JAVA);
|
||||
|
||||
// Not cached yet, hence progress service invoked
|
||||
ProgressService progressService = mock(ProgressService.class);
|
||||
@@ -73,7 +73,7 @@ public class SpringPropertiesIndexTest {
|
||||
verify(progressService, never()).progressBegin(any(), any(), any());
|
||||
|
||||
// Change POM file for the project
|
||||
harness.changeFile(new File(directory, MavenCore.POM_XML).toURI().toString());
|
||||
harness.changeFile(new File(directory, MavenCore.POM_XML).toURI().toASCIIString());
|
||||
|
||||
// POM has changed, hence project needs to be reloaded, cached value is cleared
|
||||
progressService = mock(ProgressService.class);
|
||||
|
||||
@@ -4,4 +4,5 @@ import org.springframework.beans.factory.annotation.Configurable;
|
||||
|
||||
@Configurable
|
||||
public class ClassWithSpécialCharacter {
|
||||
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ public class ProjectClasspathUriResolverExtension implements URIResolverExtensio
|
||||
|
||||
private IJavaProjectData getBestMatchingProject(String file) {
|
||||
try {
|
||||
String fileUri = new URL(file).toURI().toString();
|
||||
String fileUri = new URL(file).toURI().toASCIIString();
|
||||
return javaProjectProvider.findProject(fileUri);
|
||||
} catch (MalformedURLException | URISyntaxException e) {
|
||||
throw new IllegalStateException(e);
|
||||
|
||||
@@ -184,7 +184,7 @@ public class FilteringURLResourceLoader extends ResourceLoader {
|
||||
if (attrs.isRegularFile()) {
|
||||
String name = rootDir.relativize(file).toString();
|
||||
if (interesttingResourceNames.test(name)) {
|
||||
resources.put(name, file.toUri().toString());
|
||||
resources.put(name, file.toUri().toASCIIString());
|
||||
}
|
||||
}
|
||||
return fvr;
|
||||
|
||||
@@ -105,7 +105,7 @@ public class ProjectResourceLoaderCache {
|
||||
private static void addFile(List<URL> paths, File file) throws MalformedURLException {
|
||||
if (file.exists()) {
|
||||
if (file.isDirectory()) {
|
||||
paths.add(new URL(file.toURI().toString() + File.separator));
|
||||
paths.add(new URL(file.toURI().toASCIIString() + File.separator));
|
||||
}
|
||||
else {
|
||||
paths.add(file.toURI().toURL());
|
||||
|
||||
Reference in New Issue
Block a user