Search in sources :

Example 1 with PsiReferenceList

use of com.intellij.psi.PsiReferenceList in project intellij-community by JetBrains.

the class ObscureThrownExceptionsPredicate method satisfiedBy.

@Override
public boolean satisfiedBy(PsiElement element) {
    if (!(element instanceof PsiReferenceList)) {
        return false;
    }
    final PsiReferenceList throwsList = (PsiReferenceList) element;
    if (throwsList.getReferenceElements().length < 2) {
        return false;
    }
    final PsiElement parent = element.getParent();
    if (!(parent instanceof PsiMethod)) {
        return false;
    }
    final PsiMethod method = (PsiMethod) parent;
    return method.getThrowsList().equals(element);
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) PsiReferenceList(com.intellij.psi.PsiReferenceList) PsiElement(com.intellij.psi.PsiElement)

Example 2 with PsiReferenceList

use of com.intellij.psi.PsiReferenceList in project intellij-community by JetBrains.

the class InlineSuperClassRefactoringHandler method inlineElement.

public void inlineElement(final Project project, final Editor editor, final PsiElement element) {
    PsiClass superClass = (PsiClass) element;
    if (!superClass.getManager().isInProject(superClass)) {
        CommonRefactoringUtil.showErrorHint(project, editor, "Cannot inline non-project class", REFACTORING_NAME, null);
        return;
    }
    PsiClass chosen = null;
    PsiReference reference = editor != null ? TargetElementUtil.findReference(editor, editor.getCaretModel().getOffset()) : null;
    if (reference != null) {
        final PsiElement resolve = reference.resolve();
        if (resolve == superClass) {
            final PsiElement referenceElement = reference.getElement();
            if (referenceElement != null) {
                final PsiElement parent = referenceElement.getParent();
                if (parent instanceof PsiReferenceList) {
                    final PsiElement gParent = parent.getParent();
                    if (gParent instanceof PsiClass) {
                        chosen = (PsiClass) gParent;
                    }
                }
            }
        }
    }
    new InlineSuperClassRefactoringDialog(project, superClass, chosen).show();
}
Also used : PsiReferenceList(com.intellij.psi.PsiReferenceList) PsiClass(com.intellij.psi.PsiClass) PsiReference(com.intellij.psi.PsiReference) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiElement (com.intellij.psi.PsiElement)2 PsiReferenceList (com.intellij.psi.PsiReferenceList)2 PsiClass (com.intellij.psi.PsiClass)1 PsiMethod (com.intellij.psi.PsiMethod)1 PsiReference (com.intellij.psi.PsiReference)1