use of org.springframework.ide.vscode.boot.metadata.IndexNavigator 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