PT #164318678: Support for Jar sources processing by Boot LS
This commit is contained in:
@@ -23,6 +23,7 @@ public class LanguageId {
|
||||
public static final LanguageId CONCOURSE_PIPELINE = of("concourse-pipeline-yaml");
|
||||
public static final LanguageId CF_MANIFEST = of("manifest-yaml");
|
||||
public static final LanguageId JAVA = of("java");
|
||||
public static final LanguageId CLASS = of("class");
|
||||
public static final LanguageId YAML = of("yaml");
|
||||
public static final LanguageId XML = of("xml");
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
// Do not add more components here. You should instead just make your new
|
||||
// components into separate beans.
|
||||
|
||||
public static final Set<LanguageId> LANGUAGES = ImmutableSet.of(LanguageId.JAVA);
|
||||
public static final Set<LanguageId> LANGUAGES = ImmutableSet.of(LanguageId.JAVA, LanguageId.CLASS);
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(BootJavaLanguageServerComponents.class);
|
||||
|
||||
|
||||
@@ -11,9 +11,11 @@
|
||||
package org.springframework.ide.vscode.boot.jdt.ls;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -43,6 +45,8 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
public class JdtLsProjectCache implements InitializableJavaProjectsService {
|
||||
|
||||
private static final Object JDT_SCHEME = "jdt";
|
||||
|
||||
private final boolean IS_JANDEX_INDEX;
|
||||
|
||||
private SimpleLanguageServer server;
|
||||
@@ -151,6 +155,11 @@ public class JdtLsProjectCache implements InitializableJavaProjectsService {
|
||||
|
||||
@Override
|
||||
public Optional<IJavaProject> find(TextDocumentIdentifier doc) {
|
||||
// JDT URI has project
|
||||
URI docUri = URI.create(doc.getUri());
|
||||
if (JDT_SCHEME.equals(docUri.getScheme()) && "contents".equals(docUri.getAuthority())) {
|
||||
return findProjectForJDtUri(docUri);
|
||||
}
|
||||
String uri = UriUtil.normalize(doc.getUri());
|
||||
log.debug("find {} ", uri);
|
||||
synchronized (table) {
|
||||
@@ -177,6 +186,27 @@ public class JdtLsProjectCache implements InitializableJavaProjectsService {
|
||||
}
|
||||
}
|
||||
|
||||
private Optional<IJavaProject> findProjectForJDtUri(URI uri) {
|
||||
String query = uri.getQuery();
|
||||
try {
|
||||
String decodedQuery = URLDecoder.decode(query, "UTF-8");
|
||||
int lastIdx = decodedQuery.indexOf("/\\/");
|
||||
if (lastIdx > 0) {
|
||||
String projectName = decodedQuery.substring(1, lastIdx);
|
||||
synchronized (table) {
|
||||
for (IJavaProject project : table.values()) {
|
||||
if (project.getElementName().equals(projectName)) {
|
||||
return Optional.of(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
log.error("{}", e);
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IJavadocProvider javadocProvider(String projectUri, CPE classpathEntry) {
|
||||
return new JdtLsJavadocProvider(server.getClient(), projectUri);
|
||||
|
||||
@@ -44,6 +44,10 @@ export function activate(context: VSCode.ExtensionContext): Thenable<LanguageCli
|
||||
language: JAVA_LANGUAGE_ID,
|
||||
scheme: 'file'
|
||||
},
|
||||
{
|
||||
language: JAVA_LANGUAGE_ID,
|
||||
scheme: 'jdt'
|
||||
},
|
||||
{
|
||||
language: XML_LANGUAGE_ID,
|
||||
scheme: 'file'
|
||||
|
||||
Reference in New Issue
Block a user