Search in sources :

Example 1 with IJavaElement

use of org.springframework.ide.vscode.commons.java.IJavaElement in project sts4 by spring-projects.

the class ApplicationYamlAssistContext method getAllJavaElements.

private static List<IJavaElement> getAllJavaElements(TypeUtil typeUtil, Type parentType, String propName) {
    if (propName != null) {
        Type beanType = parentType;
        if (TypeUtil.isMap(beanType)) {
            Type keyType = typeUtil.getKeyType(beanType);
            if (keyType != null && typeUtil.isEnum(keyType)) {
                IField field = typeUtil.getEnumConstant(keyType, propName);
                if (field != null) {
                    return ImmutableList.of(field);
                }
            }
        } else {
            ArrayList<IJavaElement> elements = new ArrayList<IJavaElement>(3);
            maybeAdd(elements, typeUtil.getField(beanType, propName));
            maybeAdd(elements, typeUtil.getSetter(beanType, propName).get());
            maybeAdd(elements, typeUtil.getGetter(beanType, propName));
            if (!elements.isEmpty()) {
                return elements;
            }
        }
    }
    return ImmutableList.of();
}
Also used : IJavaElement(org.springframework.ide.vscode.commons.java.IJavaElement) Type(org.springframework.ide.vscode.boot.metadata.types.Type) YamlPathSegmentType(org.springframework.ide.vscode.commons.yaml.path.YamlPathSegment.YamlPathSegmentType) ArrayList(java.util.ArrayList) IField(org.springframework.ide.vscode.commons.java.IField)

Aggregations

ArrayList (java.util.ArrayList)1 Type (org.springframework.ide.vscode.boot.metadata.types.Type)1 IField (org.springframework.ide.vscode.commons.java.IField)1 IJavaElement (org.springframework.ide.vscode.commons.java.IJavaElement)1 YamlPathSegmentType (org.springframework.ide.vscode.commons.yaml.path.YamlPathSegment.YamlPathSegmentType)1