use of org.springframework.ide.vscode.commons.java.IMethod in project sts4 by spring-projects.
the class JavaIndexTest method constructorMethodWithParams.
@Test
public void constructorMethodWithParams() 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("<init>", Stream.of(IPrimitiveType.INT));
assertEquals(m.getDeclaringType().getElementName(), m.getElementName());
assertEquals(IVoidType.DEFAULT, m.getReturnType());
assertEquals(Collections.singletonList(IPrimitiveType.INT), m.parameters().collect(Collectors.toList()));
}
use of org.springframework.ide.vscode.commons.java.IMethod in project sts4 by spring-projects.
the class TypeUtil method getSetter.
public Optional<IMethod> getSetter(Type beanType, String propName) {
try {
String setterName = "set" + StringUtil.hyphensToCamelCase(propName, true);
IType type = findType(beanType);
return type.getMethods().filter(m -> setterName.equals(m.getElementName())).findFirst();
} catch (Exception e) {
Log.log(e);
}
return Optional.empty();
}
use of org.springframework.ide.vscode.commons.java.IMethod in project sts4 by spring-projects.
the class TypeUtil method getGetter.
public IJavaElement getGetter(Type beanType, String propName) {
String getterName = "get" + StringUtil.hyphensToCamelCase(propName, true);
IType type = findType(beanType);
IMethod m = type.getMethod(getterName, Stream.empty());
if (m.exists()) {
return m;
}
return null;
}
use of org.springframework.ide.vscode.commons.java.IMethod in project sts4 by spring-projects.
the class HtmlJavadocTest method html_testInnerClassLevel2_JavadocForOutputFolder.
@Test
public void html_testInnerClassLevel2_JavadocForOutputFolder() throws Exception {
MavenJavaProject project = projectSupplier.get();
IType type = project.getClasspath().findType("hello.Greeting$TestInnerClass$TestInnerClassLevel2");
assertNotNull(type);
IJavadoc javaDoc = type.getJavaDoc();
assertNotNull(javaDoc);
assertEquals("<div class=\"block\">Comment for level 2 nested class</div>", javaDoc.getRenderable().toHtml());
IField field = type.getField("innerLevel2Field");
assertNotNull(field);
String expected = String.join("\n", "<h4>innerLevel2Field</h4>", "<pre>protected int innerLevel2Field</pre>", "<div class=\"block\">Comment for level 2 inner field</div>");
javaDoc = field.getJavaDoc();
assertNotNull(javaDoc);
assertEquals(expected, javaDoc.getRenderable().toHtml());
IMethod method = type.getMethod("getInnerLevel2Field", Stream.empty());
assertNotNull(method);
expected = String.join("\n", "<h4>getInnerLevel2Field</h4>", "<pre>public int getInnerLevel2Field()</pre>", "<div class=\"block\">Comment for method inside level 2 nested class</div>");
javaDoc = method.getJavaDoc();
assertNotNull(javaDoc);
assertEquals(expected, javaDoc.getRenderable().toHtml());
}
use of org.springframework.ide.vscode.commons.java.IMethod in project sts4 by spring-projects.
the class HtmlJavadocTest method html_testMethodJavadoc.
@Test
public void html_testMethodJavadoc() throws Exception {
Assume.assumeTrue(javaVersionHigherThan(6));
MavenJavaProject project = projectSupplier.get();
IType type = project.getClasspath().findType("java.util.ArrayList");
assertNotNull(type);
IMethod method = type.getMethod("size", Stream.empty());
assertNotNull(method);
String expected = String.join("\n", "<h4>size</h4>", "<pre>public int size()</pre>", "<div class=\"block\">Returns the number of elements in this list.</div>");
IJavadoc javaDoc = method.getJavaDoc();
assertNotNull(javaDoc);
assertEquals(expected, javaDoc.getRenderable().toHtml().substring(0, expected.length()));
}
Aggregations