use of org.springframework.ide.vscode.boot.metadata.types.TypedProperty in project sts4 by spring-projects.
the class HintProviders method forMap.
public static HintProvider forMap(HintProvider _keyProvider, HintProvider _valueProvider, final Type valueType, final boolean dimensionAware) {
final HintProvider keyProvider = notNull(_keyProvider);
final HintProvider valueProvider = notNull(_valueProvider);
if (isNull(keyProvider) && isNull(valueProvider)) {
return NULL;
}
return new HintProvider() {
@Override
public HintProvider traverse(YamlPathSegment s) throws Exception {
switch(s.getType()) {
case VAL_AT_INDEX:
case VAL_AT_KEY:
if (dimensionAware) {
return forHere(valueProvider);
} else {
return forAllValueContexts(valueProvider);
}
default:
return NULL;
}
}
@Override
public List<StsValueHint> getValueHints(String query) {
if (dimensionAware) {
// pickier, completions only suggested in the domain of map, but not for map itself.
return ImmutableList.of();
} else {
return valueProvider.getValueHints(query);
}
}
@Override
public List<TypedProperty> getPropertyHints(String query) {
List<StsValueHint> keyHints = keyProvider.getValueHints(query);
if (CollectionUtil.hasElements(keyHints)) {
List<TypedProperty> props = new ArrayList<>(keyHints.size());
for (StsValueHint keyHint : keyHints) {
Object key = keyHint.getValue();
if (key instanceof String) {
props.add(new TypedProperty((String) key, valueType, null));
}
}
return props;
}
return ImmutableList.of();
}
};
}
Aggregations