use of org.springframework.ide.vscode.boot.metadata.types.Type 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.boot.metadata.types.Type in project sts4 by spring-projects.
the class TypeParserTest method testMultipleParams.
@Test
public void testMultipleParams() throws Exception {
Type type = TypeParser.parse("Map<Foo,Bar>");
assertEquals("Map", type.getErasure());
assertTrue(type.isGeneric());
Type[] params = type.getParams();
assertEquals(2, params.length);
type = params[0];
assertEquals("Foo", type.getErasure());
assertFalse(type.isGeneric());
type = params[1];
assertEquals("Bar", type.getErasure());
assertFalse(type.isGeneric());
}
use of org.springframework.ide.vscode.boot.metadata.types.Type in project sts4 by spring-projects.
the class TypeParserTest method testTypeEquality.
@Test
public void testTypeEquality() throws Exception {
Type type1 = TypeParser.parse("Map<Foo,List<Bar>>");
Type type2 = TypeParser.parse("Map<Foo,List<Bar>>");
Type type3 = TypeParser.parse("Map<Bar,List<Bar>>");
assertEquals(type1, type2);
assertNotEquals(type1, type3);
}
use of org.springframework.ide.vscode.boot.metadata.types.Type in project sts4 by spring-projects.
the class TypeParserTest method testSimpleGeneric.
@Test
public void testSimpleGeneric() throws Exception {
Type type = TypeParser.parse("List<Foo>");
assertEquals("List", type.getErasure());
assertTrue(type.isGeneric());
Type[] params = type.getParams();
assertEquals(1, params.length);
type = params[0];
assertEquals("Foo", type.getErasure());
assertFalse(type.isGeneric());
}
use of org.springframework.ide.vscode.boot.metadata.types.Type in project sts4 by spring-projects.
the class TypeParserTest method testNestedGenerics.
@Test
public void testNestedGenerics() throws Exception {
Type type = TypeParser.parse("Map<Foo,List<Bar>>");
assertEquals("Map", type.getErasure());
assertTrue(type.isGeneric());
assertEquals("Map<Foo,List<Bar>>", type.toString());
}
Aggregations