Search in sources :

Example 1 with PsiTypeParameterListOwner

use of com.intellij.psi.PsiTypeParameterListOwner 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

PsiElement (com.intellij.psi.PsiElement)1 PsiTypeParameter (com.intellij.psi.PsiTypeParameter)1 PsiTypeParameterListOwner (com.intellij.psi.PsiTypeParameterListOwner)1 Nullable (org.jetbrains.annotations.Nullable)1 GrCodeReferenceElement (org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement)1 GrTypeArgumentList (org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList)1