Adopt Renderables in Javadoc. Refactoring for building mvn projects
This commit is contained in:
@@ -9,15 +9,11 @@ import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.java.IType;
|
||||
import org.springframework.ide.vscode.commons.javadoc.IJavadoc;
|
||||
import org.springframework.ide.vscode.commons.util.Assert;
|
||||
import org.springframework.ide.vscode.commons.util.HtmlBuffer;
|
||||
import org.springframework.ide.vscode.commons.util.Log;
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
import org.springframework.ide.vscode.commons.util.Renderables;
|
||||
import org.springframework.ide.vscode.commons.util.StringUtil;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
|
||||
/**
|
||||
* Sts version of {@link ValueHint} contains similar data, but accomoates
|
||||
* a html snippet to be computed lazyly for the description.
|
||||
@@ -114,26 +110,14 @@ public class StsValueHint {
|
||||
}
|
||||
|
||||
private static Renderable javaDocSnippet(IJavaElement je) {
|
||||
try {
|
||||
Supplier<IJavadoc> jdoc = Suppliers.memoize(() -> je.getJavaDoc());
|
||||
return Renderables.lazy(() -> {
|
||||
IJavadoc jdoc = je.getJavaDoc();
|
||||
if (jdoc != null) {
|
||||
return new Renderable() {
|
||||
|
||||
@Override
|
||||
public void renderAsMarkdown(StringBuilder buffer) {
|
||||
buffer.append(jdoc.get().markdown());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderAsHtml(HtmlBuffer buffer) {
|
||||
buffer.raw(jdoc.get().html());
|
||||
}
|
||||
};
|
||||
return jdoc.getRenderable();
|
||||
} else {
|
||||
return Renderables.NO_DESCRIPTION;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.log(e);
|
||||
}
|
||||
return Renderables.NO_DESCRIPTION;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.springframework.ide.vscode.commons.java.roaster;
|
||||
|
||||
import org.jboss.forge.roaster.model.JavaDoc;
|
||||
import org.springframework.ide.vscode.commons.javadoc.IJavadoc;
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
|
||||
public class RoasterJavadoc implements IJavadoc {
|
||||
|
||||
@@ -13,22 +14,13 @@ public class RoasterJavadoc implements IJavadoc {
|
||||
|
||||
@Override
|
||||
public String raw() {
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String plainText() {
|
||||
return javadoc.getFullText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String html() {
|
||||
public Renderable getRenderable() {
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String markdown() {
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package org.springframework.ide.vscode.commons.javadoc;
|
||||
|
||||
import com.overzealous.remark.Remark;
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
import org.springframework.ide.vscode.commons.util.Renderables;
|
||||
|
||||
public class HtmlJavadoc implements IJavadoc {
|
||||
|
||||
private String html;
|
||||
private Remark remark;
|
||||
|
||||
public HtmlJavadoc(String html) {
|
||||
this.html = html;
|
||||
this.remark = new Remark();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -18,18 +17,9 @@ public class HtmlJavadoc implements IJavadoc {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String plainText() {
|
||||
throw new UnsupportedOperationException("Not yet implemnted");
|
||||
public Renderable getRenderable() {
|
||||
return Renderables.htmlBlob(html);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String html() {
|
||||
return html;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String markdown() {
|
||||
return remark.convertFragment(html);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package org.springframework.ide.vscode.commons.javadoc;
|
||||
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
|
||||
public interface IJavadoc {
|
||||
|
||||
String raw();
|
||||
|
||||
String plainText();
|
||||
Renderable getRenderable();
|
||||
|
||||
String html();
|
||||
|
||||
String markdown();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.springframework.ide.vscode.commons.javadoc;
|
||||
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
|
||||
public class RawJavadoc implements IJavadoc {
|
||||
|
||||
private String rawContent;
|
||||
@@ -14,18 +16,8 @@ public class RawJavadoc implements IJavadoc {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String plainText() {
|
||||
throw new UnsupportedOperationException("Not yet implemnted");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String html() {
|
||||
throw new UnsupportedOperationException("Not yet implemnted");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String markdown() {
|
||||
throw new UnsupportedOperationException("Not yet implemnted");
|
||||
public Renderable getRenderable() {
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package org.springframework.ide.vscode.commons.maven;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.ide.vscode.commons.util.ExternalCommand;
|
||||
import org.springframework.ide.vscode.commons.util.ExternalProcess;
|
||||
|
||||
public class MavenBuilder {
|
||||
|
||||
|
||||
private Path projectPath;
|
||||
|
||||
private List<String> targets;
|
||||
|
||||
private List<String> properties;
|
||||
|
||||
public void execute() throws IOException, InterruptedException {
|
||||
Path mvnwPath = System.getProperty("os.name").toLowerCase().startsWith("win") ? projectPath.resolve("mvnw.cmd")
|
||||
: projectPath.resolve("mvnw");
|
||||
mvnwPath.toFile().setExecutable(true);
|
||||
List<String> all = new ArrayList<>(1 + targets.size() + properties.size());
|
||||
all.add(mvnwPath.toAbsolutePath().toString());
|
||||
all.addAll(targets);
|
||||
all.addAll(properties);
|
||||
ExternalProcess process = new ExternalProcess(projectPath.toFile(),
|
||||
new ExternalCommand(all.toArray(new String[all.size()])), true);
|
||||
if (process.getExitValue() != 0) {
|
||||
throw new RuntimeException("Failed to build test project");
|
||||
}
|
||||
}
|
||||
|
||||
public static MavenBuilder newBuilder(Path projectPath) {
|
||||
return new MavenBuilder(projectPath);
|
||||
}
|
||||
|
||||
public MavenBuilder clean() {
|
||||
targets.add("clean");
|
||||
return this;
|
||||
}
|
||||
|
||||
public MavenBuilder pack() {
|
||||
targets.add("package");
|
||||
return this;
|
||||
}
|
||||
|
||||
public MavenBuilder skipTests() {
|
||||
properties.add("-DskipTests");
|
||||
return this;
|
||||
}
|
||||
|
||||
public MavenBuilder javadoc() {
|
||||
properties.add("javadoc:javadoc");
|
||||
return this;
|
||||
}
|
||||
|
||||
private MavenBuilder(Path projectPath) {
|
||||
this.projectPath = projectPath;
|
||||
this.targets = new ArrayList<>();
|
||||
this.properties = new ArrayList<>();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,8 +53,6 @@ import org.eclipse.aether.util.graph.visitor.FilteringDependencyVisitor;
|
||||
import org.springframework.ide.vscode.commons.jandex.JandexIndex;
|
||||
import org.springframework.ide.vscode.commons.javadoc.HtmlJavadocProvider;
|
||||
import org.springframework.ide.vscode.commons.javadoc.SourceUrlProviderFromSourceContainer;
|
||||
import org.springframework.ide.vscode.commons.util.ExternalCommand;
|
||||
import org.springframework.ide.vscode.commons.util.ExternalProcess;
|
||||
import org.springframework.ide.vscode.commons.util.Log;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
@@ -128,40 +126,6 @@ public class MavenCore {
|
||||
return Arrays.stream(text.split(File.pathSeparator)).map(dir::resolve);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds maven project
|
||||
*
|
||||
* @param Path of the project
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void buildMavenProject(Path projectPath) throws Exception {
|
||||
Path mvnwPath = System.getProperty("os.name").toLowerCase().startsWith("win")
|
||||
? projectPath.resolve("mvnw.cmd") : projectPath.resolve("mvnw");
|
||||
mvnwPath.toFile().setExecutable(true);
|
||||
ExternalProcess process = new ExternalProcess(projectPath.toFile(),
|
||||
new ExternalCommand(mvnwPath.toAbsolutePath().toString(), "clean", "package", "-DskipTests"), true);
|
||||
if (process.getExitValue() != 0) {
|
||||
throw new RuntimeException("Failed to build test project");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate javadoc jar for maven project
|
||||
*
|
||||
* @param Path of the project
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void generateJavadocFolderForMavenProject(Path projectPath) throws Exception {
|
||||
Path mvnwPath = System.getProperty("os.name").toLowerCase().startsWith("win")
|
||||
? projectPath.resolve("mvnw.cmd") : projectPath.resolve("mvnw");
|
||||
mvnwPath.toFile().setExecutable(true);
|
||||
ExternalProcess process = new ExternalProcess(projectPath.toFile(),
|
||||
new ExternalCommand(mvnwPath.toAbsolutePath().toString(), "javadoc:javadoc"), true);
|
||||
if (process.getExitValue() != 0) {
|
||||
throw new RuntimeException("Failed to build test project");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates Maven Project descriptor based on the pom file.
|
||||
*
|
||||
|
||||
@@ -30,7 +30,7 @@ public class DependencyTreeTest {
|
||||
|
||||
private void testMavenClasspath(String projectName) throws Exception {
|
||||
Path testProjectPath = Paths.get(DependencyTreeTest.class.getResource("/" + projectName).toURI());
|
||||
MavenCore.buildMavenProject(testProjectPath);
|
||||
MavenBuilder.newBuilder(testProjectPath).clean().pack().skipTests().execute();
|
||||
|
||||
MavenProject project = MavenCore.getInstance().readProject(testProjectPath.resolve(MavenCore.POM_XML).toFile());
|
||||
Set<Path> calculatedClassPath = MavenCore.getInstance().resolveDependencies(project, null).stream().map(artifact -> {
|
||||
|
||||
@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collections;
|
||||
@@ -31,7 +32,7 @@ public class JavaIndexTest {
|
||||
@Override
|
||||
public Path load(String projectName) throws Exception {
|
||||
Path testProjectPath = Paths.get(DependencyTreeTest.class.getResource("/" + projectName).toURI());
|
||||
MavenCore.buildMavenProject(testProjectPath);
|
||||
MavenBuilder.newBuilder(testProjectPath).clean().pack().javadoc().skipTests().execute();
|
||||
return testProjectPath;
|
||||
}
|
||||
|
||||
@@ -42,7 +43,6 @@ public class JavaIndexTest {
|
||||
@Override
|
||||
public MavenJavaProject load(String projectName) throws Exception {
|
||||
Path testProjectPath = Paths.get(DependencyTreeTest.class.getResource("/" + projectName).toURI());
|
||||
MavenCore.buildMavenProject(testProjectPath);
|
||||
return createMavenProject(testProjectPath);
|
||||
}
|
||||
|
||||
@@ -212,15 +212,15 @@ public class JavaIndexTest {
|
||||
IType type = project.findType("hello.Greeting");
|
||||
|
||||
assertNotNull(type);
|
||||
assertEquals("Comment for Greeting class", type.getJavaDoc().plainText());
|
||||
assertEquals("Comment for Greeting class", type.getJavaDoc().raw());
|
||||
|
||||
IField field = type.getField("id");
|
||||
assertNotNull(field);
|
||||
assertEquals("Comment for id field", field.getJavaDoc().plainText());
|
||||
assertEquals("Comment for id field", field.getJavaDoc().raw());
|
||||
|
||||
IMethod method = type.getMethod("getId", Stream.empty());
|
||||
assertNotNull(method);
|
||||
assertEquals("Comment for getId()", method.getJavaDoc().plainText());
|
||||
assertEquals("Comment for getId()", method.getJavaDoc().raw());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -229,15 +229,15 @@ public class JavaIndexTest {
|
||||
MavenJavaProject project = createMavenProject(projectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file"));
|
||||
IType type = project.findType("hello.Greeting$TestInnerClass");
|
||||
assertNotNull(type);
|
||||
assertEquals("Comment for inner class", type.getJavaDoc().plainText());
|
||||
assertEquals("Comment for inner class", type.getJavaDoc().raw());
|
||||
|
||||
IField field = type.getField("innerField");
|
||||
assertNotNull(field);
|
||||
assertEquals("Comment for inner field", field.getJavaDoc().plainText());
|
||||
assertEquals("Comment for inner field", field.getJavaDoc().raw());
|
||||
|
||||
IMethod method = type.getMethod("getInnerField", Stream.empty());
|
||||
assertNotNull(method);
|
||||
assertEquals("Comment for method inside nested class", method.getJavaDoc().plainText());
|
||||
assertEquals("Comment for method inside nested class", method.getJavaDoc().raw());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -249,11 +249,11 @@ public class JavaIndexTest {
|
||||
IType type = project.findType("org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener");
|
||||
assertNotNull(type);
|
||||
String expected = "{@link ApplicationListener} that replaces the liquibase {@link ServiceLocator} with a";
|
||||
assertEquals(expected, type.getJavaDoc().plainText().substring(0, expected.length()));
|
||||
assertEquals(expected, type.getJavaDoc().raw().substring(0, expected.length()));
|
||||
|
||||
type = project.findType("org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener$LiquibasePresent");
|
||||
assertNotNull(type);
|
||||
assertEquals("Inner class to prevent class not found issues.", type.getJavaDoc().plainText());
|
||||
assertEquals("Inner class to prevent class not found issues.", type.getJavaDoc().raw());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -267,12 +267,12 @@ public class JavaIndexTest {
|
||||
|
||||
IField field = type.getField("BANNER_LOCATION_PROPERTY_VALUE");
|
||||
assertNotNull(field);
|
||||
assertEquals("Default banner location.", field.getJavaDoc().plainText());
|
||||
assertEquals("Default banner location.", field.getJavaDoc().raw());
|
||||
|
||||
IMethod method = type.getMethod("getListeners", Stream.empty());
|
||||
assertNotNull(method);
|
||||
String expected = "Returns read-only ordered Set of the {@link ApplicationListener} s that will be";
|
||||
assertEquals(expected, method.getJavaDoc().plainText().substring(0, expected.length()));
|
||||
assertEquals(expected, method.getJavaDoc().raw().substring(0, expected.length()));
|
||||
}
|
||||
|
||||
|
||||
@@ -288,7 +288,7 @@ public class JavaIndexTest {
|
||||
"<div class=\"block\">An object that maps keys to values. A map cannot contain duplicate keys;",
|
||||
" each key can map to at most one value."
|
||||
);
|
||||
assertEquals(expected, type.getJavaDoc().html().substring(0, expected.length()));
|
||||
assertEquals(expected, type.getJavaDoc().getRenderable().toHtml().substring(0, expected.length()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -302,7 +302,7 @@ public class JavaIndexTest {
|
||||
String expected = String.join("\n",
|
||||
"<div class=\"block\">A map entry (key-value pair). The <tt>Map.entrySet</tt> method returns",
|
||||
" a collection-view of the map, whose elements are of this class. The");
|
||||
assertEquals(expected, type.getJavaDoc().html().substring(0, expected.length()));
|
||||
assertEquals(expected, type.getJavaDoc().getRenderable().toHtml().substring(0, expected.length()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -321,7 +321,7 @@ public class JavaIndexTest {
|
||||
"<pre>public int size()</pre>",
|
||||
"<div class=\"block\">Returns the number of elements in this list.</div>"
|
||||
);
|
||||
assertEquals(expected, method.getJavaDoc().html().substring(0, expected.length()));
|
||||
assertEquals(expected, method.getJavaDoc().getRenderable().toHtml().substring(0, expected.length()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -338,7 +338,7 @@ public class JavaIndexTest {
|
||||
String expected = String.join("\n",
|
||||
"<h4>ArrayList</h4>"
|
||||
);
|
||||
assertEquals(expected, method.getJavaDoc().html().substring(0, expected.length()));
|
||||
assertEquals(expected, method.getJavaDoc().getRenderable().toHtml().substring(0, expected.length()));
|
||||
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ public class JavaIndexTest {
|
||||
"<dd><a href=\"../../../constant-values.html#org.springframework.boot.SpringApplication.BANNER_LOCATION_PROPERTY_VALUE\">Constant Field Values</a></dd>",
|
||||
"</dl>"
|
||||
);
|
||||
assertEquals(expected, field.getJavaDoc().html());
|
||||
assertEquals(expected, field.getJavaDoc().getRenderable().toHtml());
|
||||
|
||||
IMethod method = type.getMethod("getListeners", Stream.empty());
|
||||
assertNotNull(method);
|
||||
@@ -377,20 +377,19 @@ public class JavaIndexTest {
|
||||
"<dd>the listeners</dd>",
|
||||
"</dl>"
|
||||
);
|
||||
assertEquals(expected, method.getJavaDoc().html());
|
||||
assertEquals(expected, method.getJavaDoc().getRenderable().toHtml());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void html_testJavadocOutputFolder() throws Exception {
|
||||
MavenProjectClasspath.providerType = JavadocProviderTypes.HTML;
|
||||
Path projectPath = projectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
|
||||
MavenCore.generateJavadocFolderForMavenProject(projectPath);
|
||||
MavenJavaProject project = createMavenProject(projectPath);
|
||||
IType type = project.findType("hello.Greeting");
|
||||
|
||||
assertNotNull(type);
|
||||
String expected = "<div class=\"block\">Comment for Greeting class</div>";
|
||||
assertEquals(expected, type.getJavaDoc().html());
|
||||
assertEquals(expected, type.getJavaDoc().getRenderable().toHtml());
|
||||
|
||||
IField field = type.getField("id");
|
||||
assertNotNull(field);
|
||||
@@ -399,7 +398,7 @@ public class JavaIndexTest {
|
||||
"<pre>protected final long id</pre>",
|
||||
"<div class=\"block\">Comment for id field</div>"
|
||||
);
|
||||
assertEquals(expected, field.getJavaDoc().html());
|
||||
assertEquals(expected, field.getJavaDoc().getRenderable().toHtml());
|
||||
|
||||
IMethod method = type.getMethod("getId", Stream.empty());
|
||||
assertNotNull(method);
|
||||
@@ -408,19 +407,18 @@ public class JavaIndexTest {
|
||||
"<pre>public long getId()</pre>",
|
||||
"<div class=\"block\">Comment for getId()</div>"
|
||||
);
|
||||
assertEquals(expected, method.getJavaDoc().html());
|
||||
assertEquals(expected, method.getJavaDoc().getRenderable().toHtml());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void html_testInnerClassJavadocForOutputFolder() throws Exception {
|
||||
MavenProjectClasspath.providerType = JavadocProviderTypes.HTML;
|
||||
Path projectPath = projectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
|
||||
MavenCore.generateJavadocFolderForMavenProject(projectPath);
|
||||
MavenJavaProject project = createMavenProject(projectPath);
|
||||
|
||||
IType type = project.findType("hello.Greeting$TestInnerClass");
|
||||
assertNotNull(type);
|
||||
assertEquals("<div class=\"block\">Comment for inner class</div>", type.getJavaDoc().html());
|
||||
assertEquals("<div class=\"block\">Comment for inner class</div>", type.getJavaDoc().getRenderable().toHtml());
|
||||
|
||||
IField field = type.getField("innerField");
|
||||
assertNotNull(field);
|
||||
@@ -429,7 +427,7 @@ public class JavaIndexTest {
|
||||
"<pre>protected int innerField</pre>",
|
||||
"<div class=\"block\">Comment for inner field</div>"
|
||||
);
|
||||
assertEquals(expected, field.getJavaDoc().html());
|
||||
assertEquals(expected, field.getJavaDoc().getRenderable().toHtml());
|
||||
|
||||
IMethod method = type.getMethod("getInnerField", Stream.empty());
|
||||
assertNotNull(method);
|
||||
@@ -438,19 +436,18 @@ public class JavaIndexTest {
|
||||
"<pre>public int getInnerField()</pre>",
|
||||
"<div class=\"block\">Comment for method inside nested class</div>"
|
||||
);
|
||||
assertEquals(expected, method.getJavaDoc().html());
|
||||
assertEquals(expected, method.getJavaDoc().getRenderable().toHtml());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void html_testInnerClassLevel2_JavadocForOutputFolder() throws Exception {
|
||||
MavenProjectClasspath.providerType = JavadocProviderTypes.HTML;
|
||||
Path projectPath = projectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
|
||||
MavenCore.generateJavadocFolderForMavenProject(projectPath);
|
||||
MavenJavaProject project = createMavenProject(projectPath);
|
||||
|
||||
IType type = project.findType("hello.Greeting$TestInnerClass$TestInnerClassLevel2");
|
||||
assertNotNull(type);
|
||||
assertEquals("<div class=\"block\">Comment for level 2 nested class</div>", type.getJavaDoc().html());
|
||||
assertEquals("<div class=\"block\">Comment for level 2 nested class</div>", type.getJavaDoc().getRenderable().toHtml());
|
||||
|
||||
IField field = type.getField("innerLevel2Field");
|
||||
assertNotNull(field);
|
||||
@@ -459,7 +456,7 @@ public class JavaIndexTest {
|
||||
"<pre>protected int innerLevel2Field</pre>",
|
||||
"<div class=\"block\">Comment for level 2 inner field</div>"
|
||||
);
|
||||
assertEquals(expected, field.getJavaDoc().html());
|
||||
assertEquals(expected, field.getJavaDoc().getRenderable().toHtml());
|
||||
|
||||
IMethod method = type.getMethod("getInnerLevel2Field", Stream.empty());
|
||||
assertNotNull(method);
|
||||
@@ -468,14 +465,13 @@ public class JavaIndexTest {
|
||||
"<pre>public int getInnerLevel2Field()</pre>",
|
||||
"<div class=\"block\">Comment for method inside level 2 nested class</div>"
|
||||
);
|
||||
assertEquals(expected, method.getJavaDoc().html());
|
||||
assertEquals(expected, method.getJavaDoc().getRenderable().toHtml());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void html_testNoJavadocClass() throws Exception {
|
||||
MavenProjectClasspath.providerType = JavadocProviderTypes.HTML;
|
||||
Path projectPath = projectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
|
||||
MavenCore.generateJavadocFolderForMavenProject(projectPath);
|
||||
MavenJavaProject project = createMavenProject(projectPath);
|
||||
|
||||
IType type = project.findType("hello.GreetingController");
|
||||
@@ -487,7 +483,6 @@ public class JavaIndexTest {
|
||||
public void html_testEmptyJavadocClass() throws Exception {
|
||||
MavenProjectClasspath.providerType = JavadocProviderTypes.HTML;
|
||||
Path projectPath = projectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
|
||||
MavenCore.generateJavadocFolderForMavenProject(projectPath);
|
||||
MavenJavaProject project = createMavenProject(projectPath);
|
||||
|
||||
IType type = project.findType("hello.Application");
|
||||
@@ -499,7 +494,6 @@ public class JavaIndexTest {
|
||||
public void html_testNoJavadocMethod() throws Exception {
|
||||
MavenProjectClasspath.providerType = JavadocProviderTypes.HTML;
|
||||
Path projectPath = projectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
|
||||
MavenCore.generateJavadocFolderForMavenProject(projectPath);
|
||||
MavenJavaProject project = createMavenProject(projectPath);
|
||||
|
||||
IType type = project.findType("hello.Application");
|
||||
@@ -511,15 +505,15 @@ public class JavaIndexTest {
|
||||
"<pre>@Bean",
|
||||
"public org.springframework.web.servlet.config.annotation.WebMvcConfigurer corsConfigurer()</pre>"
|
||||
);
|
||||
assertEquals(expected, method.getJavaDoc().html());
|
||||
assertEquals(expected, method.getJavaDoc().getRenderable().toHtml());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void html_testNoJavadocField() throws Exception {
|
||||
MavenProjectClasspath.providerType = JavadocProviderTypes.HTML;
|
||||
Path projectPath = projectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
|
||||
MavenCore.generateJavadocFolderForMavenProject(projectPath);
|
||||
MavenJavaProject project = createMavenProject(projectPath);
|
||||
Files.list(project.getOutputFolder().getParent().resolve("site")).forEach(System.out::println);
|
||||
|
||||
IType type = project.findType("hello.GreetingController");
|
||||
assertNotNull(type);
|
||||
@@ -533,6 +527,6 @@ public class JavaIndexTest {
|
||||
"<dd><a href=\"../constant-values.html#hello.GreetingController.template\">Constant Field Values</a></dd>",
|
||||
"</dl>"
|
||||
);
|
||||
assertEquals(expected, field.getJavaDoc().html());
|
||||
assertEquals(expected, field.getJavaDoc().getRenderable().toHtml());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.overzealous.remark.Remark;
|
||||
|
||||
@@ -161,6 +162,21 @@ public class Renderables {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Renderable lazy(Supplier<Renderable> supplier) {
|
||||
return new Renderable() {
|
||||
|
||||
@Override
|
||||
public void renderAsMarkdown(StringBuilder buffer) {
|
||||
supplier.get().renderAsMarkdown(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderAsHtml(HtmlBuffer buffer) {
|
||||
supplier.get().renderAsHtml(buffer);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Renderable fromClasspath(final Class<?> klass, final String resourcePath) {
|
||||
return new Renderable() {
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.maven.MavenBuilder;
|
||||
import org.springframework.ide.vscode.commons.maven.MavenCore;
|
||||
import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject;
|
||||
import org.springframework.ide.vscode.commons.maven.java.classpathfile.JavaProjectWithClasspathFile;
|
||||
@@ -59,11 +60,10 @@ public class ProjectsHarness {
|
||||
Path testProjectPath = getProjectPath(name);
|
||||
switch (type) {
|
||||
case MAVEN:
|
||||
MavenCore.buildMavenProject(testProjectPath);
|
||||
// MavenCore.generateJavadocFolderForMavenProject(testProjectPath);
|
||||
MavenBuilder.newBuilder(testProjectPath).clean().pack()./*javadoc().*/skipTests().execute();
|
||||
return new MavenJavaProject(testProjectPath.resolve(MavenCore.POM_XML).toFile());
|
||||
case CLASSPATH_TXT:
|
||||
MavenCore.buildMavenProject(testProjectPath);
|
||||
MavenBuilder.newBuilder(testProjectPath).clean().pack().skipTests().execute();
|
||||
return new JavaProjectWithClasspathFile(testProjectPath.resolve(MavenCore.CLASSPATH_TXT).toFile());
|
||||
default:
|
||||
throw new IllegalStateException("Bug!!! Missing case");
|
||||
|
||||
Reference in New Issue
Block a user