Search in sources :

Example 71 with GrCodeReferenceElement

use of org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement in project intellij-community by JetBrains.

the class GroovyTypeParameterInfoHandler method findElementForParameterInfo.

@Nullable
@Override
public GrTypeArgumentList findElementForParameterInfo(@NotNull CreateParameterInfoContext context) {
    final GrTypeArgumentList parameterList = ParameterInfoUtils.findParentOfType(context.getFile(), context.getOffset(), GrTypeArgumentList.class);
    if (parameterList != null) {
        if (!(parameterList.getParent() instanceof GrCodeReferenceElement))
            return null;
        final GrCodeReferenceElement ref = ((GrCodeReferenceElement) parameterList.getParent());
        final PsiElement resolved = ref.resolve();
        if (!(resolved instanceof PsiTypeParameterListOwner))
            return null;
        final PsiTypeParameter[] typeParams = ((PsiTypeParameterListOwner) resolved).getTypeParameters();
        if (typeParams.length == 0)
            return null;
        context.setItemsToShow(typeParams);
        return parameterList;
    }
    return null;
}
Also used : PsiTypeParameterListOwner(com.intellij.psi.PsiTypeParameterListOwner) GrCodeReferenceElement(org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement) PsiTypeParameter(com.intellij.psi.PsiTypeParameter) GrTypeArgumentList(org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

GrCodeReferenceElement (org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement)71 NotNull (org.jetbrains.annotations.NotNull)14 GroovyPsiElement (org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement)13 PsiElement (com.intellij.psi.PsiElement)12 Nullable (org.jetbrains.annotations.Nullable)12 GroovyResolveResult (org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult)11 GrReferenceExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression)10 GrNewExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression)8 GroovyPsiElementFactory (org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory)7 GrImportStatement (org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement)7 GrArgumentList (org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList)6 GroovyFile (org.jetbrains.plugins.groovy.lang.psi.GroovyFile)5 GrAnonymousClassDefinition (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition)5 PsiClass (com.intellij.psi.PsiClass)4 GrReferenceElement (org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement)4 GrTypeArgumentList (org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList)4 Editor (com.intellij.openapi.editor.Editor)3 IncorrectOperationException (com.intellij.util.IncorrectOperationException)3 GrAnnotation (org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation)3 GrExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression)3