From d17359ab1129f5dcd98ad6217c4e8284d9604b47 Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Mon, 12 Dec 2016 15:24:06 -0500 Subject: [PATCH 1/3] Include repositories specified in the pom for artifact resolution --- .../ide/vscode/commons/maven/MavenCore.java | 20 ++++++++++--------- .../maven/java/MavenProjectClasspath.java | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) 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) { From 672cc6874fe3734d8e8a9113cc1693e72f47f61a Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Mon, 12 Dec 2016 18:16:05 -0500 Subject: [PATCH 2/3] Ensure hovers don't have string null in the description part --- .../vscode/languageserver/testharness/Editor.java | 14 ++++++++++++++ .../vscode/boot/common/InformationTemplates.java | 6 ++++-- .../boot/test/ApplicationPropertiesEditorTest.java | 8 ++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) 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..7061a150a 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 textSnippet is contained in 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 expectSnippet) throws Exception { + int pos = getRawText().indexOf(afterString); + if (pos>=0) { + pos += afterString.length(); + } + Hover hover = harness.getHover(document, document.toPosition(pos)); + assertEquals(expectSnippet, 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); From 0397eb058ec4f0ba56b1cd539eecc297f665dab4 Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Mon, 12 Dec 2016 18:18:00 -0500 Subject: [PATCH 3/3] Fixed comment for the new test harness method --- .../ide/vscode/languageserver/testharness/Editor.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 7061a150a..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 @@ -344,17 +344,17 @@ public class Editor { } /** - * Verifies an expected textSnippet is contained in the hover text that is - * computed when hovering mouse at position at the end of first occurrence of - * a given string in the editor. + * 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 expectSnippet) throws Exception { + 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(expectSnippet, hover.getContents().toString()); + assertEquals(expectedHover, hover.getContents().toString()); } public void assertCompletionDetails(String expectLabel, String expectDetail, String expectDocSnippet) throws Exception {