Switch to URI#toASCIIString()

This commit is contained in:
aboyko
2023-01-12 16:31:50 -05:00
parent c1accd1016
commit 8db31656a9
72 changed files with 166 additions and 158 deletions

View File

@@ -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);
};
}

View File

@@ -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) {

View File

@@ -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)

View File

@@ -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());

View File

@@ -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);
}

View File

@@ -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) {