use of org.springframework.ide.vscode.boot.metadata.types.Type in project sts4 by spring-projects.
the class TypeUtilTest method testGetProperties.
@Test
public void testGetProperties() throws Exception {
useProject("enums-boot-1.3.2-app");
assertNotNull(project.getClasspath().findType("demo.Color"));
assertNotNull(project.getClasspath().findType("demo.ColorData"));
Type data = TypeParser.parse("demo.ColorData");
assertType("java.lang.Double", getPropertyType(data, "wavelen"));
assertType("java.lang.String", getPropertyType(data, "name"));
assertType("demo.Color", getPropertyType(data, "next"));
assertType("demo.ColorData", getPropertyType(data, "nested"));
assertType("java.util.List<java.lang.String>", getPropertyType(data, "tags"));
assertType("java.util.Map<java.lang.String,demo.ColorData>", getPropertyType(data, "mapped-children"));
assertType("java.util.Map<demo.Color,demo.ColorData>", getPropertyType(data, "color-children"));
// Also gets aliased as camelCased names?
assertType("java.util.Map<demo.Color,demo.ColorData>", getPropertyType(data, "colorChildren"));
assertType("java.util.Map<java.lang.String,demo.ColorData>", getPropertyType(data, "mappedChildren"));
// Gets aliased names only if asked for it?
assertType("java.util.Map<java.lang.String,demo.ColorData>", getPropertyType(data, "mappedChildren", EnumCaseMode.ORIGNAL, BeanPropertyNameMode.CAMEL_CASE));
assertType(null, getPropertyType(data, "mappedChildren", EnumCaseMode.ORIGNAL, BeanPropertyNameMode.HYPHENATED));
assertType(null, getPropertyType(data, "mapped-children", EnumCaseMode.ORIGNAL, BeanPropertyNameMode.CAMEL_CASE));
assertType("java.util.Map<java.lang.String,demo.ColorData>", getPropertyType(data, "mapped-children", EnumCaseMode.ORIGNAL, BeanPropertyNameMode.HYPHENATED));
}
use of org.springframework.ide.vscode.boot.metadata.types.Type in project sts4 by spring-projects.
the class ApplicationYamlASTReconciler method reconcile.
private void reconcile(YamlFileAST root, NodeTuple entry, IndexNavigator nav) {
Node keyNode = entry.getKeyNode();
String key = asScalar(keyNode);
if (key == null) {
expectScalar(keyNode);
} else {
IndexNavigator subNav = nav.selectSubProperty(key);
PropertyInfo match = subNav.getExactMatch();
PropertyInfo extension = subNav.getExtensionCandidate();
if (match == null && extension == null) {
// nothing found for this key. Maybe user is using camelCase variation of the key?
String keyAlias = StringUtil.camelCaseToHyphens(key);
IndexNavigator subNavAlias = nav.selectSubProperty(keyAlias);
match = subNavAlias.getExactMatch();
extension = subNavAlias.getExtensionCandidate();
if (match != null || extension != null) {
// Got something for the alias, so use that instead.
// Note: do not swap for alias unless we actually found something.
// This gives more logical errors (in terms of user's key, not its canonical alias)
subNav = subNavAlias;
}
}
if (match != null && extension != null) {
// This ambiguity is hard to deal with and we choose not to do so for now
return;
} else if (match != null) {
Type type = TypeParser.parse(match.getType());
if (match.isDeprecated()) {
deprecatedProperty(match, keyNode);
}
reconcile(root, entry.getValueNode(), type);
} else if (extension != null) {
// We don't really care about the extension only about the fact that it
// exists and so it is meaningful to continue checking...
Node valueNode = entry.getValueNode();
reconcile(root, valueNode, subNav);
} else {
// both are null, this means there's no valid property with the current prefix
// whether exact or extending it with further navigation
unkownProperty(keyNode, subNav.getPrefix(), entry);
}
}
}
Aggregations