Search in sources :

Example 1 with GrDisjunctionTypeElement

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

the class GrRemoveExceptionFix method findTypeElementInDisjunction.

@Nullable
private static GrTypeElement findTypeElementInDisjunction(Editor editor, PsiFile file) {
    final int offset = editor.getCaretModel().getOffset();
    final PsiElement at = file.findElementAt(offset);
    final GrDisjunctionTypeElement disjunction = PsiTreeUtil.getParentOfType(at, GrDisjunctionTypeElement.class);
    if (disjunction == null)
        return null;
    for (GrTypeElement element : disjunction.getTypeElements()) {
        if (element.getTextRange().contains(offset)) {
            return element;
        }
    }
    return null;
}
Also used : GrTypeElement(org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement) GrDisjunctionTypeElement(org.jetbrains.plugins.groovy.lang.psi.api.types.GrDisjunctionTypeElement) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 Nullable (org.jetbrains.annotations.Nullable)1 GrDisjunctionTypeElement (org.jetbrains.plugins.groovy.lang.psi.api.types.GrDisjunctionTypeElement)1 GrTypeElement (org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement)1