Search in sources :

Example 6 with IField

use of org.springframework.ide.vscode.commons.java.IField in project sts4 by spring-projects.

the class HtmlJavadocTest method html_testNoJavadocField.

@Test
public void html_testNoJavadocField() throws Exception {
    MavenJavaProject project = projectSupplier.get();
    IType type = project.getClasspath().findType("hello.GreetingController");
    assertNotNull(type);
    IField field = type.getField("template");
    assertNotNull(field);
    String expected = String.join("\n", "<h4>template</h4>", "<pre>public static final&nbsp;<a href=\"http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true\" title=\"class or interface in java.lang\">String</a> template</pre>", "<dl>", "<dt><span class=\"seeLabel\">See Also:</span></dt>", "<dd><a href=\"../constant-values.html#hello.GreetingController.template\">Constant Field Values</a></dd>", "</dl>");
    IJavadoc javaDoc = field.getJavaDoc();
    assertNotNull(javaDoc);
    assertEquals(expected, javaDoc.getRenderable().toHtml());
}
Also used : MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) IJavadoc(org.springframework.ide.vscode.commons.javadoc.IJavadoc) IField(org.springframework.ide.vscode.commons.java.IField) IType(org.springframework.ide.vscode.commons.java.IType) Test(org.junit.Test)

Example 7 with IField

use of org.springframework.ide.vscode.commons.java.IField in project sts4 by spring-projects.

the class HtmlJavadocTest method html_testInnerClassJavadocForOutputFolder.

@Test
public void html_testInnerClassJavadocForOutputFolder() throws Exception {
    MavenJavaProject project = projectSupplier.get();
    IType type = project.getClasspath().findType("hello.Greeting$TestInnerClass");
    assertNotNull(type);
    IJavadoc javaDoc = type.getJavaDoc();
    assertNotNull(javaDoc);
    assertEquals("<div class=\"block\">Comment for inner class</div>", javaDoc.getRenderable().toHtml());
    IField field = type.getField("innerField");
    assertNotNull(field);
    String expected = String.join("\n", "<h4>innerField</h4>", "<pre>protected&nbsp;int innerField</pre>", "<div class=\"block\">Comment for inner field</div>");
    javaDoc = field.getJavaDoc();
    assertNotNull(javaDoc);
    assertEquals(expected, javaDoc.getRenderable().toHtml());
    IMethod method = type.getMethod("getInnerField", Stream.empty());
    assertNotNull(method);
    expected = String.join("\n", "<h4>getInnerField</h4>", "<pre>public&nbsp;int&nbsp;getInnerField()</pre>", "<div class=\"block\">Comment for method inside nested class</div>");
    javaDoc = method.getJavaDoc();
    assertNotNull(javaDoc);
    assertEquals(expected, javaDoc.getRenderable().toHtml());
}
Also used : MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) IJavadoc(org.springframework.ide.vscode.commons.javadoc.IJavadoc) IMethod(org.springframework.ide.vscode.commons.java.IMethod) IField(org.springframework.ide.vscode.commons.java.IField) IType(org.springframework.ide.vscode.commons.java.IType) Test(org.junit.Test)

Aggregations

IField (org.springframework.ide.vscode.commons.java.IField)7 IType (org.springframework.ide.vscode.commons.java.IType)6 Test (org.junit.Test)5 IJavadoc (org.springframework.ide.vscode.commons.javadoc.IJavadoc)5 MavenJavaProject (org.springframework.ide.vscode.commons.maven.java.MavenJavaProject)5 IMethod (org.springframework.ide.vscode.commons.java.IMethod)4 ArrayList (java.util.ArrayList)1 Type (org.springframework.ide.vscode.boot.metadata.types.Type)1 IJavaElement (org.springframework.ide.vscode.commons.java.IJavaElement)1 YamlPathSegmentType (org.springframework.ide.vscode.commons.yaml.path.YamlPathSegment.YamlPathSegmentType)1