Java Code Examples for org.eclipse.lsp4j.SymbolKind#Field

The following examples show how to use org.eclipse.lsp4j.SymbolKind#Field . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroovyLanguageServerUtils.java    From groovy-language-server with Apache License 2.0 6 votes vote down vote up
public static SymbolKind astNodeToSymbolKind(ASTNode node) {
	if (node instanceof ClassNode) {
		ClassNode classNode = (ClassNode) node;
		if (classNode.isInterface()) {
			return SymbolKind.Interface;
		} else if (classNode.isEnum()) {
			return SymbolKind.Enum;
		}
		return SymbolKind.Class;
	} else if (node instanceof MethodNode) {
		return SymbolKind.Method;
	} else if (node instanceof Variable) {
		if (node instanceof FieldNode || node instanceof PropertyNode) {
			return SymbolKind.Field;
		}
		return SymbolKind.Variable;
	}
	return SymbolKind.Property;
}
 
Example 2
Source File: XMLSymbolsProvider.java    From lemminx with Eclipse Public License 2.0 6 votes vote down vote up
private static SymbolKind getSymbolKind(DOMNode node) {
	if (node.isProcessingInstruction() || node.isProlog()) {
		return SymbolKind.Property;
	} else if (node.isDoctype()) {
		return SymbolKind.Struct;
	} else if (node.isDTDElementDecl()) {
		return SymbolKind.Property;
	} else if (node.isDTDEntityDecl()) {
		return SymbolKind.Namespace;
	} else if (node.isDTDAttListDecl()) {
		return SymbolKind.Key;
	} else if (node.isDTDNotationDecl()) {
		return SymbolKind.Variable;
	}
	return SymbolKind.Field;
}
 
Example 3
Source File: JSONDocumentSymbolKindProvider.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected SymbolKind getSymbolKind(EClass clazz) {
	if (clazz.getEPackage() == JSONPackage.eINSTANCE) {
		switch (clazz.getClassifierID()) {
		case JSONPackage.JSON_DOCUMENT: {
			return SymbolKind.File;
		}
		case JSONPackage.JSON_OBJECT: {
			return SymbolKind.Object;
		}
		case JSONPackage.JSON_ARRAY: {
			return SymbolKind.Array;
		}
		case JSONPackage.NAME_VALUE_PAIR: {
			return SymbolKind.Field;
		}
		case JSONPackage.JSON_STRING_LITERAL: {
			// The outline does not look like something super exciting with this symbol
			// kind, but its likely the best choice here
			return SymbolKind.String;
		}
		case JSONPackage.JSON_NUMERIC_LITERAL: {
			return SymbolKind.Number;
		}
		case JSONPackage.JSON_BOOLEAN_LITERAL: {
			return SymbolKind.Boolean;
		}
		case JSONPackage.JSON_NULL_LITERAL: {
			return SymbolKind.Null;
		}
		}
	}
	throw new UnsupportedOperationException("Not supported for " + clazz.getName());
}
 
Example 4
Source File: TextDocumentServiceImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static SymbolKind elementKind2SymbolKind(ElementKind kind) {
    switch (kind) {
        case PACKAGE:
            return SymbolKind.Package;
        case ENUM:
            return SymbolKind.Enum;
        case CLASS:
            return SymbolKind.Class;
        case ANNOTATION_TYPE:
            return SymbolKind.Interface;
        case INTERFACE:
            return SymbolKind.Interface;
        case ENUM_CONSTANT:
            return SymbolKind.EnumMember;
        case FIELD:
            return SymbolKind.Field; //TODO: constant
        case PARAMETER:
            return SymbolKind.Variable;
        case LOCAL_VARIABLE:
            return SymbolKind.Variable;
        case EXCEPTION_PARAMETER:
            return SymbolKind.Variable;
        case METHOD:
            return SymbolKind.Method;
        case CONSTRUCTOR:
            return SymbolKind.Constructor;
        case TYPE_PARAMETER:
            return SymbolKind.TypeParameter;
        case RESOURCE_VARIABLE:
            return SymbolKind.Variable;
        case MODULE:
            return SymbolKind.Module;
        case STATIC_INIT:
        case INSTANCE_INIT:
        case OTHER:
        default:
            return SymbolKind.File; //XXX: what here?
    }
}
 
Example 5
Source File: SymbolKindCalculationHelper.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/** */
public SymbolKind getSymbolKind(Object obj) {
	if (obj == null) {
		return null;
	}
	if (obj instanceof ParameterizedTypeRef) {
		return null;
	}
	if (obj instanceof Script) {
		return SymbolKind.Module;
	}
	if (obj instanceof ImportDeclaration) {
		return SymbolKind.Namespace;
	}
	if (obj instanceof NamedImportSpecifier) {
		return SymbolKind.Namespace;
	}
	if (obj instanceof N4ClassifierDeclaration) {
		return SymbolKind.Class;
	}
	if (obj instanceof N4GetterDeclaration) {
		return SymbolKind.Property;
	}
	if (obj instanceof N4SetterDeclaration) {
		return SymbolKind.Property;
	}
	if (obj instanceof ExportedVariableStatement) {
		return SymbolKind.Variable;
	}
	if (obj instanceof NamedElement) {
		return SymbolKind.Property;
	}
	if (obj instanceof TModule) {
		return SymbolKind.Module;
	}
	if (obj instanceof TClass) {
		return SymbolKind.Class;
	}
	if (obj instanceof TInterface) {
		return SymbolKind.Interface;
	}
	if (obj instanceof TEnum) {
		return SymbolKind.Enum;
	}
	if (obj instanceof TEnumLiteral) {
		return SymbolKind.EnumMember;
	}
	if (obj instanceof NullLiteral) {
		return SymbolKind.Null;
	}
	if (obj instanceof NumericLiteral) {
		return SymbolKind.Number;
	}
	if (obj instanceof BooleanLiteral) {
		return SymbolKind.Boolean;
	}
	if (obj instanceof StringLiteral) {
		return SymbolKind.String;
	}
	if (obj instanceof ObjectLiteral) {
		return SymbolKind.Object;
	}
	if (obj instanceof TGetter) {
		return SymbolKind.Property;
	}
	if (obj instanceof TSetter) {
		return SymbolKind.Property;
	}
	if (obj instanceof FunctionTypeExpression) {
		return SymbolKind.Operator;
	}
	if (obj instanceof TMethod) {
		return SymbolKind.Method;
	}
	if (obj instanceof TFunction) {
		return SymbolKind.Function;
	}
	if (obj instanceof TFormalParameter) {
		return null;
	}
	if (obj instanceof TField) {
		return SymbolKind.Field;
	}
	if (obj instanceof TypeVariable) {
		return SymbolKind.TypeParameter;
	}
	if (obj instanceof IdentifiableElement) {
		return SymbolKind.Property;
	}
	if (obj instanceof IEObjectDescription) {
		return SymbolKind.Property;
	}
	return null;
}
 
Example 6
Source File: LanguageServerCompilerUtils.java    From vscode-as3mxml with Apache License 2.0 4 votes vote down vote up
public static SymbolKind getSymbolKindFromDefinition(IDefinition definition)
{
    if (definition instanceof IPackageDefinition)
    {
        return SymbolKind.Package;
    }
    else if (definition instanceof IClassDefinition)
    {
        return SymbolKind.Class;
    }
    else if (definition instanceof IInterfaceDefinition)
    {
        return SymbolKind.Interface;
    }
    else if (definition instanceof IAccessorDefinition)
    {
        return SymbolKind.Property;
    }
    else if (definition instanceof IFunctionDefinition)
    {
        IFunctionDefinition functionDefinition = (IFunctionDefinition) definition;
        if (functionDefinition.isConstructor())
        {
            return SymbolKind.Constructor;
        }
        IDefinition parentDefinition = functionDefinition.getParent();
        if (parentDefinition != null && parentDefinition instanceof ITypeDefinition)
        {
            return SymbolKind.Method;
        }
        return SymbolKind.Function;
    }
    else if (definition instanceof IConstantDefinition)
    {
        return SymbolKind.Constant;
    }
    else if (definition instanceof IVariableDefinition)
    {
        IVariableDefinition variableDefinition = (IVariableDefinition) definition;
        VariableClassification variableClassification = variableDefinition.getVariableClassification();
        if (variableClassification != null)
        {
            switch(variableClassification)
            {
                case INTERFACE_MEMBER:
                case CLASS_MEMBER:
                {
                    return SymbolKind.Field;
                }
                default:
                {
                    return SymbolKind.Variable;
                }
            }
        }
    }
    else if (definition instanceof IEventDefinition)
    {
        return SymbolKind.Event;
    }
    else if (definition instanceof IStyleDefinition)
    {
        return SymbolKind.Field;
    }
    return SymbolKind.Object;
}