use of org.springframework.ide.vscode.commons.java.IField in project sts4 by spring-projects.
the class HtmlJavadocTest method html_testFieldAndMethodJavadocForJar.
@Test
public void html_testFieldAndMethodJavadocForJar() throws Exception {
MavenJavaProject project = projectSupplier.get();
IType type = project.getClasspath().findType("org.springframework.boot.SpringApplication");
assertNotNull(type);
IField field = type.getField("BANNER_LOCATION_PROPERTY_VALUE");
assertNotNull(field);
String expected = String.join("\n", "<h4>BANNER_LOCATION_PROPERTY_VALUE</h4>", "<pre>public static final <a href=\"http://docs.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true\" title=\"class or interface in java.lang\">String</a> BANNER_LOCATION_PROPERTY_VALUE</pre>", "<div class=\"block\">Default banner location.</div>", "<dl>", "<dt><span class=\"seeLabel\">See Also:</span></dt>", "<dd><a href=\"../../../constant-values.html#org.springframework.boot.SpringApplication.BANNER_LOCATION_PROPERTY_VALUE\">Constant Field Values</a></dd>", "</dl>");
IJavadoc javaDoc = field.getJavaDoc();
assertNotNull(javaDoc);
assertEquals(expected, javaDoc.getRenderable().toHtml());
IMethod method = type.getMethod("getListeners", Stream.empty());
assertNotNull(method);
expected = String.join("\n", "<h4>getListeners</h4>", "<pre>public <a href=\"http://docs.oracle.com/javase/6/docs/api/java/util/Set.html?is-external=true\" title=\"class or interface in java.util\">Set</a><org.springframework.context.ApplicationListener<?>> getListeners()</pre>", "<div class=\"block\">Returns read-only ordered Set of the <code>ApplicationListener</code>s that will be", " applied to the SpringApplication and registered with the <code>ApplicationContext</code>", " .</div>", "<dl>", "<dt><span class=\"returnLabel\">Returns:</span></dt>", "<dd>the listeners</dd>", "</dl>");
javaDoc = method.getJavaDoc();
assertNotNull(javaDoc);
assertEquals(expected, javaDoc.getRenderable().toHtml());
}
use of org.springframework.ide.vscode.commons.java.IField in project sts4 by spring-projects.
the class HtmlJavadocTest method html_testJavadocOutputFolder.
@Test
public void html_testJavadocOutputFolder() throws Exception {
MavenJavaProject project = projectSupplier.get();
IType type = project.getClasspath().findType("hello.Greeting");
assertNotNull(type);
String expected = "<div class=\"block\">Comment for Greeting class</div>";
IJavadoc javaDoc = type.getJavaDoc();
assertNotNull(javaDoc);
assertEquals(expected, javaDoc.getRenderable().toHtml());
IField field = type.getField("id");
assertNotNull(field);
expected = String.join("\n", "<h4>id</h4>", "<pre>protected final long id</pre>", "<div class=\"block\">Comment for id field</div>");
javaDoc = field.getJavaDoc();
assertNotNull(javaDoc);
assertEquals(expected, javaDoc.getRenderable().toHtml());
IMethod method = type.getMethod("getId", Stream.empty());
assertNotNull(method);
expected = String.join("\n", "<h4>getId</h4>", "<pre>public long getId()</pre>", "<div class=\"block\">Comment for getId()</div>");
javaDoc = method.getJavaDoc();
assertNotNull(javaDoc);
assertEquals(expected, javaDoc.getRenderable().toHtml());
}
use of org.springframework.ide.vscode.commons.java.IField in project sts4 by spring-projects.
the class TypeUtil method getEnumConstant.
public IField getEnumConstant(Type enumType, String propName) {
IType type = findType(enumType);
// 1: if propname is already spelled exactly...
IField f = getExactField(type, propName);
if (f != null)
return f;
// 2: most likely enum constant is upper-case form of propname
String fieldName = StringUtil.hyphensToUpperCase(propName);
return getExactField(type, fieldName);
}
use of org.springframework.ide.vscode.commons.java.IField in project sts4 by spring-projects.
the class ApplicationYamlAssistContext method getAllJavaElements.
private static List<IJavaElement> getAllJavaElements(TypeUtil typeUtil, Type parentType, String propName) {
if (propName != null) {
Type beanType = parentType;
if (TypeUtil.isMap(beanType)) {
Type keyType = typeUtil.getKeyType(beanType);
if (keyType != null && typeUtil.isEnum(keyType)) {
IField field = typeUtil.getEnumConstant(keyType, propName);
if (field != null) {
return ImmutableList.of(field);
}
}
} else {
ArrayList<IJavaElement> elements = new ArrayList<IJavaElement>(3);
maybeAdd(elements, typeUtil.getField(beanType, propName));
maybeAdd(elements, typeUtil.getSetter(beanType, propName).get());
maybeAdd(elements, typeUtil.getGetter(beanType, propName));
if (!elements.isEmpty()) {
return elements;
}
}
}
return ImmutableList.of();
}
use of org.springframework.ide.vscode.commons.java.IField 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());
}
Aggregations