use of org.springframework.ide.vscode.boot.properties.reconcile.PropertyNavigator in project sts4 by spring-projects.
the class PropertiesCompletionProposalsCalculator method getNavigationProposals.
private Collection<ICompletionProposal> getNavigationProposals() {
String navPrefix = navigationPrefixFinder.getPrefix(doc, offset);
try {
if (navPrefix != null) {
// offset of 'nav' operator char (i.e. '.' or ']').
int navOffset = offset - navPrefix.length() - 1;
navPrefix = fuzzySearchPrefix.getPrefix(doc, navOffset);
if (navPrefix != null && !navPrefix.isEmpty()) {
PropertyInfo prop = findLongestValidProperty(index, navPrefix);
if (prop != null) {
int regionStart = navOffset - navPrefix.length();
Collection<ICompletionProposal> hintProposals = getKeyHintProposals(prop, navOffset);
if (CollectionUtil.hasElements(hintProposals)) {
return hintProposals;
}
PropertyNavigator navigator = new PropertyNavigator(doc, null, typeUtil, new DocumentRegion(doc, regionStart, navOffset));
Type type = navigator.navigate(regionStart + prop.getId().length(), TypeParser.parse(prop.getType()));
if (type != null) {
return getNavigationProposals(type, navOffset);
}
}
}
}
} catch (Exception e) {
Log.log(e);
}
return Collections.emptyList();
}
use of org.springframework.ide.vscode.boot.properties.reconcile.PropertyNavigator in project sts4 by spring-projects.
the class CommonLanguageTools method getValueType.
/**
* Determine the value type for a give propertyName.
*/
public static Type getValueType(FuzzyMap<PropertyInfo> index, TypeUtil typeUtil, String propertyName) {
try {
PropertyInfo prop = index.get(propertyName);
if (prop != null) {
return TypeParser.parse(prop.getType());
} else {
prop = CommonLanguageTools.findLongestValidProperty(index, propertyName);
if (prop != null) {
TextDocument doc = new TextDocument(null, LanguageId.PLAINTEXT);
doc.setText(propertyName);
PropertyNavigator navigator = new PropertyNavigator(doc, null, typeUtil, new DocumentRegion(doc, 0, doc.getLength()));
return navigator.navigate(prop.getId().length(), TypeParser.parse(prop.getType()));
}
}
} catch (Exception e) {
Log.log(e);
}
return null;
}
Aggregations