Search in sources :

Example 1 with Deprecation

use of org.springframework.ide.vscode.boot.configurationmetadata.Deprecation in project sts4 by spring-projects.

the class InformationTemplates method createHover.

public static Renderable createHover(PropertyInfo info) {
    Deprecation deprecation = createDeprecation(info);
    Renderable description = info.getDescription() == null ? null : text(info.getDescription());
    return InformationTemplates.createHover(info.getId(), info.getType(), info.getDefaultValue(), description, deprecation);
}
Also used : Renderable(org.springframework.ide.vscode.commons.util.Renderable) Deprecation(org.springframework.ide.vscode.boot.configurationmetadata.Deprecation)

Example 2 with Deprecation

use of org.springframework.ide.vscode.boot.configurationmetadata.Deprecation in project sts4 by spring-projects.

the class InformationTemplates method createCompletionDocumentation.

public static Renderable createCompletionDocumentation(PropertyInfo info) {
    Deprecation deprecation = createDeprecation(info);
    Renderable description = info.getDescription() == null ? null : text(info.getDescription());
    return InformationTemplates.createCompletionDocumentation(description, info.getDefaultValue(), deprecation);
}
Also used : Renderable(org.springframework.ide.vscode.commons.util.Renderable) Deprecation(org.springframework.ide.vscode.boot.configurationmetadata.Deprecation)

Example 3 with Deprecation

use of org.springframework.ide.vscode.boot.configurationmetadata.Deprecation in project sts4 by spring-projects.

the class PropertyIndexHarness method deprecate.

public synchronized void deprecate(String key, String replacedBy, String reason) {
    index = null;
    ConfigurationMetadataProperty info = datas.get(key);
    Deprecation d = new Deprecation();
    d.setReplacement(replacedBy);
    d.setReason(reason);
    info.setDeprecation(d);
}
Also used : ConfigurationMetadataProperty(org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMetadataProperty) Deprecation(org.springframework.ide.vscode.boot.configurationmetadata.Deprecation)

Example 4 with Deprecation

use of org.springframework.ide.vscode.boot.configurationmetadata.Deprecation in project sts4 by spring-projects.

the class PropertyIndexHarness method deprecate.

public synchronized void deprecate(String key, String replacedBy, String reason) {
    index = null;
    ConfigurationMetadataProperty info = datas.get(key);
    Deprecation d = new Deprecation();
    d.setReplacement(replacedBy);
    d.setReason(reason);
    info.setDeprecation(d);
}
Also used : ConfigurationMetadataProperty(org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMetadataProperty) Deprecation(org.springframework.ide.vscode.boot.configurationmetadata.Deprecation)

Example 5 with Deprecation

use of org.springframework.ide.vscode.boot.configurationmetadata.Deprecation in project sts4 by spring-projects.

the class TypeUtil method getProperties.

/**
 * Determine properties that are setable on object of given type.
 * <p>
 * Note that this may return both null or an empty list, but they mean
 * different things. Null means that the properties on the object are not known,
 * and therefore reconciling should not check property validity. On the other hand
 * returning an empty list means that there are no properties. In this case,
 * accessing properties is invalid and reconciler should show an error message
 * for any property access.
 *
 * @return A list of known properties or null if the list of properties is unknown.
 */
public List<TypedProperty> getProperties(Type type, EnumCaseMode enumMode, BeanPropertyNameMode beanMode) {
    if (type == null) {
        return null;
    }
    if (!isDotable(type)) {
        // If dot navigation is not valid then really this is just like saying the type has no properties.
        return Collections.emptyList();
    }
    if (isMap(type)) {
        Type keyType = getKeyType(type);
        if (keyType != null) {
            Collection<StsValueHint> keyHints = getAllowedValues(keyType, enumMode);
            if (CollectionUtil.hasElements(keyHints)) {
                Type valueType = getDomainType(type);
                ArrayList<TypedProperty> properties = new ArrayList<>(keyHints.size());
                for (StsValueHint hint : keyHints) {
                    String propName = hint.getValue();
                    properties.add(new TypedProperty(propName, valueType, hint.getDescription(), hint.getDeprecation()));
                }
                return properties;
            }
        }
    } else {
        String typename = type.getErasure();
        IType typeFromIndex = findType(typename);
        // TODO: handle type parameters.
        if (typeFromIndex != null) {
            ArrayList<TypedProperty> properties = new ArrayList<>();
            getGetterMethods(typeFromIndex).forEach(m -> {
                Deprecation deprecation = DeprecationUtil.extract(m);
                Type propType = null;
                try {
                    propType = Type.fromJavaType(m.getReturnType());
                } catch (Exception e) {
                    Log.log(e);
                }
                if (beanMode.includesHyphenated()) {
                    properties.add(new TypedProperty(getterOrSetterNameToProperty(m.getElementName()), propType, deprecation));
                }
                if (beanMode.includesCamelCase()) {
                    properties.add(new TypedProperty(getterOrSetterNameToCamelName(m.getElementName()), propType, deprecation));
                }
            });
            return properties;
        }
    }
    return null;
}
Also used : IType(org.springframework.ide.vscode.commons.java.IType) StsValueHint(org.springframework.ide.vscode.boot.metadata.hints.StsValueHint) Deprecation(org.springframework.ide.vscode.boot.configurationmetadata.Deprecation) ArrayList(java.util.ArrayList) IType(org.springframework.ide.vscode.commons.java.IType)

Aggregations

Deprecation (org.springframework.ide.vscode.boot.configurationmetadata.Deprecation)6 ConfigurationMetadataProperty (org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMetadataProperty)2 Renderable (org.springframework.ide.vscode.commons.util.Renderable)2 ArrayList (java.util.ArrayList)1 StsValueHint (org.springframework.ide.vscode.boot.metadata.hints.StsValueHint)1 IType (org.springframework.ide.vscode.commons.java.IType)1