Search in sources :

Example 1 with HintProvider

use of org.springframework.ide.vscode.boot.metadata.hints.HintProvider in project sts4 by spring-projects.

the class CommonLanguageTools method getValueHints.

public static Collection<StsValueHint> getValueHints(FuzzyMap<PropertyInfo> index, TypeUtil typeUtil, String query, String propertyName, EnumCaseMode caseMode) {
    Type type = getValueType(index, typeUtil, propertyName);
    if (TypeUtil.isSequencable(type)) {
        // It is useful to provide content assist for the values in the list when entering a list
        type = TypeUtil.getDomainType(type);
    }
    List<StsValueHint> allHints = new ArrayList<>();
    {
        Collection<StsValueHint> hints = typeUtil.getHintValues(type, query, caseMode);
        if (CollectionUtil.hasElements(hints)) {
            allHints.addAll(hints);
        }
    }
    {
        PropertyInfo prop = index.findLongestCommonPrefixEntry(propertyName);
        if (prop != null) {
            HintProvider hintProvider = prop.getHints(typeUtil, false);
            if (!HintProviders.isNull(hintProvider)) {
                allHints.addAll(hintProvider.getValueHints(query));
            }
        }
    }
    return allHints;
}
Also used : Type(org.springframework.ide.vscode.boot.metadata.types.Type) StsValueHint(org.springframework.ide.vscode.boot.metadata.hints.StsValueHint) ArrayList(java.util.ArrayList) Collection(java.util.Collection) HintProvider(org.springframework.ide.vscode.boot.metadata.hints.HintProvider) PropertyInfo(org.springframework.ide.vscode.boot.metadata.PropertyInfo)

Example 2 with HintProvider

use of org.springframework.ide.vscode.boot.metadata.hints.HintProvider in project sts4 by spring-projects.

the class PropertiesCompletionProposalsCalculator method getKeyHintProposals.

private Collection<ICompletionProposal> getKeyHintProposals(PropertyInfo prop, int navOffset) {
    HintProvider hintProvider = prop.getHints(typeUtil, false);
    if (!HintProviders.isNull(hintProvider)) {
        String query = textBetween(doc, navOffset + 1, offset);
        List<TypedProperty> hintProperties = hintProvider.getPropertyHints(query);
        if (CollectionUtil.hasElements(hintProperties)) {
            return createPropertyProposals(TypeParser.parse(prop.getType()), navOffset, query, hintProperties);
        }
    }
    return ImmutableList.of();
}
Also used : HintProvider(org.springframework.ide.vscode.boot.metadata.hints.HintProvider) TypedProperty(org.springframework.ide.vscode.boot.metadata.types.TypedProperty)

Aggregations

HintProvider (org.springframework.ide.vscode.boot.metadata.hints.HintProvider)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 PropertyInfo (org.springframework.ide.vscode.boot.metadata.PropertyInfo)1 StsValueHint (org.springframework.ide.vscode.boot.metadata.hints.StsValueHint)1 Type (org.springframework.ide.vscode.boot.metadata.types.Type)1 TypedProperty (org.springframework.ide.vscode.boot.metadata.types.TypedProperty)1