Search in sources :

Example 1 with PsiTryStatement

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

the class FinallyBlockSelectioner method select.

@Override
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
    List<TextRange> result = new ArrayList<>();
    final PsiElement parent = e.getParent();
    if (parent instanceof PsiTryStatement) {
        final PsiTryStatement tryStatement = (PsiTryStatement) parent;
        final PsiCodeBlock finallyBlock = tryStatement.getFinallyBlock();
        if (finallyBlock != null) {
            result.add(new TextRange(e.getTextRange().getStartOffset(), finallyBlock.getTextRange().getEndOffset()));
        }
    }
    return result;
}
Also used : PsiCodeBlock(com.intellij.psi.PsiCodeBlock) ArrayList(java.util.ArrayList) PsiTryStatement(com.intellij.psi.PsiTryStatement) TextRange(com.intellij.openapi.util.TextRange) PsiElement(com.intellij.psi.PsiElement)

Example 2 with PsiTryStatement

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

the class MoveCatchUpFix method invoke.

@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) {
    PsiTryStatement statement = myCatchSection.getTryStatement();
    statement.addBefore(myCatchSection, myMoveBeforeSection);
    myCatchSection.delete();
}
Also used : PsiTryStatement(com.intellij.psi.PsiTryStatement)

Aggregations

PsiTryStatement (com.intellij.psi.PsiTryStatement)2 TextRange (com.intellij.openapi.util.TextRange)1 PsiCodeBlock (com.intellij.psi.PsiCodeBlock)1 PsiElement (com.intellij.psi.PsiElement)1 ArrayList (java.util.ArrayList)1