Search in sources :

Example 11 with IMethod

use of org.springframework.ide.vscode.commons.java.IMethod 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)

Example 12 with IMethod

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

the class JavaIndexTest method voidMethodNoParams.

@Test
public void voidMethodNoParams() throws Exception {
    MavenJavaProject project = mavenProjectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
    IType type = project.getClasspath().findType("java.util.ArrayList");
    assertNotNull(type);
    IMethod m = type.getMethod("clear", Stream.empty());
    assertEquals("clear", m.getElementName());
    assertEquals(IVoidType.DEFAULT, m.getReturnType());
    assertEquals(0, m.parameters().count());
}
Also used : MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) IMethod(org.springframework.ide.vscode.commons.java.IMethod) IType(org.springframework.ide.vscode.commons.java.IType) Test(org.junit.Test)

Aggregations

IMethod (org.springframework.ide.vscode.commons.java.IMethod)12 IType (org.springframework.ide.vscode.commons.java.IType)12 Test (org.junit.Test)10 MavenJavaProject (org.springframework.ide.vscode.commons.maven.java.MavenJavaProject)10 IJavadoc (org.springframework.ide.vscode.commons.javadoc.IJavadoc)7 IField (org.springframework.ide.vscode.commons.java.IField)5 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 InetAddress (java.net.InetAddress)1 Charset (java.nio.charset.Charset)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1