diff --git a/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/MavenCore.java b/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/MavenCore.java index 5c264ce18..2b7e290c1 100644 --- a/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/MavenCore.java +++ b/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/MavenCore.java @@ -26,12 +26,14 @@ import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashSet; +import java.util.List; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.model.DependencyManagement; import org.apache.maven.project.MavenProject; @@ -245,7 +247,7 @@ public class MavenCore { return artifacts.parallelStream().map(artifact -> { if (!artifact.isResolved()) { try { - artifact = maven.resolve(artifact, null, request); + artifact = maven.resolve(artifact, project.getRemoteArtifactRepositories(), request); } catch (MavenException e) { Log.log(e); // Maven 2.x quirk: an artifact always points at the local repo, @@ -269,20 +271,20 @@ public class MavenCore { return lrm.getRepository().getBasedir(); } - public Artifact getSources(Artifact artifact) throws MavenException { - return maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), CLASSIFIER_SOURCES, null, maven.createExecutionRequest()); + public Artifact getSources(Artifact artifact, List repositories) throws MavenException { + return maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), CLASSIFIER_SOURCES, repositories, maven.createExecutionRequest()); } - public Artifact getJavadoc(Artifact artifact) throws MavenException { - return maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), CLASSIFIER_JAVADOC, null, maven.createExecutionRequest()); + public Artifact getJavadoc(Artifact artifact, List repositories) throws MavenException { + return maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), CLASSIFIER_JAVADOC, repositories, maven.createExecutionRequest()); } - public Artifact getTests(Artifact artifact) throws MavenException { - return maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), CLASSIFIER_TESTS, null, maven.createExecutionRequest()); + public Artifact getTests(Artifact artifact, List repositories) throws MavenException { + return maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), CLASSIFIER_TESTS, repositories, maven.createExecutionRequest()); } - public Artifact getTestSources(Artifact artifact) throws MavenException { - return maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), CLASSIFIER_TESTSOURCES, null, maven.createExecutionRequest()); + public Artifact getTestSources(Artifact artifact, List repositories) throws MavenException { + return maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), CLASSIFIER_TESTSOURCES, repositories, maven.createExecutionRequest()); } public Stream getJreLibs() throws MavenException { diff --git a/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/MavenProjectClasspath.java b/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/MavenProjectClasspath.java index b07d61ca1..54bbffc42 100644 --- a/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/MavenProjectClasspath.java +++ b/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/MavenProjectClasspath.java @@ -192,7 +192,7 @@ public class MavenProjectClasspath implements IClasspath { return new ParserJavadocProvider(type -> { try { Artifact artifact = getArtifactFromJarFile(classpathResource).get(); - URL sourceContainer = maven.getSources(artifact).getFile().toURI().toURL(); + URL sourceContainer = maven.getSources(artifact, project.getRemoteArtifactRepositories()).getFile().toURI().toURL(); return SourceUrlProviderFromSourceContainer.JAR_SOURCE_URL_PROVIDER.sourceUrl(sourceContainer, type); } catch (MavenException e) { @@ -225,7 +225,7 @@ public class MavenProjectClasspath implements IClasspath { return new HtmlJavadocProvider(type -> { try { Artifact artifact = getArtifactFromJarFile(classpathResource).get(); - URL sourceContainer = maven.getJavadoc(artifact).getFile().toURI().toURL(); + URL sourceContainer = maven.getJavadoc(artifact, project.getRemoteArtifactRepositories()).getFile().toURI().toURL(); return SourceUrlProviderFromSourceContainer.JAR_JAVADOC_URL_PROVIDER.sourceUrl(sourceContainer, type); } catch (MavenException e) { diff --git a/vscode-extensions/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/Editor.java b/vscode-extensions/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/Editor.java index cb7c69b0f..ccbbadb7f 100644 --- a/vscode-extensions/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/Editor.java +++ b/vscode-extensions/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/Editor.java @@ -343,6 +343,20 @@ public class Editor { assertContains(expectSnippet, hover.getContents().toString()); } + /** + * Verifies an expected text is the hover text that is computed when + * hovering mouse at position at the end of first occurrence of a given + * string in the editor. + */ + public void assertHoverExactText(String afterString, String expectedHover) throws Exception { + int pos = getRawText().indexOf(afterString); + if (pos>=0) { + pos += afterString.length(); + } + Hover hover = harness.getHover(document, document.toPosition(pos)); + assertEquals(expectedHover, hover.getContents().toString()); + } + public void assertCompletionDetails(String expectLabel, String expectDetail, String expectDocSnippet) throws Exception { CompletionItem it = harness.resolveCompletionItem(assertCompletionWithLabel(expectLabel)); if (expectDetail!=null) { diff --git a/vscode-extensions/vscode-boot-properties/src/main/java/org/springframework/ide/vscode/boot/common/InformationTemplates.java b/vscode-extensions/vscode-boot-properties/src/main/java/org/springframework/ide/vscode/boot/common/InformationTemplates.java index f84c193fd..4ae8484bd 100644 --- a/vscode-extensions/vscode-boot-properties/src/main/java/org/springframework/ide/vscode/boot/common/InformationTemplates.java +++ b/vscode-extensions/vscode-boot-properties/src/main/java/org/springframework/ide/vscode/boot/common/InformationTemplates.java @@ -24,12 +24,14 @@ public class InformationTemplates { public static Renderable createHover(PropertyInfo info) { Deprecation deprecation = createDeprecation(info); - return InformationTemplates.createHover(info.getId(), info.getType(), info.getDefaultValue(), text(info.getDescription()), deprecation); + Renderable description = info.getDescription() == null ? null : text(info.getDescription()); + return InformationTemplates.createHover(info.getId(), info.getType(), info.getDefaultValue(), description, deprecation); } public static Renderable createCompletionDocumentation(PropertyInfo info) { Deprecation deprecation = createDeprecation(info); - return InformationTemplates.createCompletionDocumentation(text(info.getDescription()), info.getDefaultValue(), deprecation); + Renderable description = info.getDescription() == null ? null : text(info.getDescription()); + return InformationTemplates.createCompletionDocumentation(description, info.getDefaultValue(), deprecation); } public static Renderable createHover(String id, String type, Object defaultValue, Renderable description, Deprecation deprecation) { diff --git a/vscode-extensions/vscode-boot-properties/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java b/vscode-extensions/vscode-boot-properties/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java index 7ce70df72..025fa51b8 100644 --- a/vscode-extensions/vscode-boot-properties/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java +++ b/vscode-extensions/vscode-boot-properties/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java @@ -1577,6 +1577,14 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest { editor.assertNoHover("ggggg.kkkk"); } + @Test public void testEmptyDescriptionHover() throws Exception { + data("debug", "java.lang.String", null, null); + Editor editor = newEditor( + "debug=something\n" + ); + editor.assertHoverExactText("debug", "[**debug** \n[java.lang.String](null)]"); + } + @Override protected SimpleLanguageServer newLanguageServer() { BootPropertiesLanguageServer server = new BootPropertiesLanguageServer(md.getIndexProvider(), typeUtilProvider, javaProjectFinder);