Search in sources :

Example 11 with MethodReference

use of org.eclipse.jdt.core.dom.MethodReference in project eclipse.jdt.ls by eclipse.

the class SurroundWithTryCatchAnalyzer method endVisit.

@Override
public void endVisit(CompilationUnit node) {
    ASTNode enclosingNode = null;
    if (!getStatus().hasFatalError() && hasSelectedNodes()) {
        enclosingNode = getEnclosingNode(getFirstSelectedNode());
    }
    super.endVisit(node);
    if (enclosingNode != null && !getStatus().hasFatalError()) {
        fExceptions = ExceptionAnalyzer.perform(enclosingNode, getSelection());
        if (fExceptions == null || fExceptions.length == 0) {
            if (enclosingNode instanceof MethodReference) {
                invalidSelection(RefactoringCoreMessages.SurroundWithTryCatchAnalyzer_doesNotContain);
            } else {
                // $NON-NLS-1$
                fExceptions = new ITypeBinding[] { node.getAST().resolveWellKnownType("java.lang.Exception") };
            }
        }
    }
}
Also used : ASTNode(org.eclipse.jdt.core.dom.ASTNode) MethodReference(org.eclipse.jdt.core.dom.MethodReference)

Aggregations

MethodReference (org.eclipse.jdt.core.dom.MethodReference)11 ASTNode (org.eclipse.jdt.core.dom.ASTNode)9 IMethodBinding (org.eclipse.jdt.core.dom.IMethodBinding)6 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)6 SingleVariableDeclaration (org.eclipse.jdt.core.dom.SingleVariableDeclaration)6 Type (org.eclipse.jdt.core.dom.Type)6 LambdaExpression (org.eclipse.jdt.core.dom.LambdaExpression)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)4 AST (org.eclipse.jdt.core.dom.AST)4 Block (org.eclipse.jdt.core.dom.Block)4 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)4 Expression (org.eclipse.jdt.core.dom.Expression)4 ExpressionStatement (org.eclipse.jdt.core.dom.ExpressionStatement)4 MethodDeclaration (org.eclipse.jdt.core.dom.MethodDeclaration)4 Statement (org.eclipse.jdt.core.dom.Statement)4 UnionType (org.eclipse.jdt.core.dom.UnionType)4 VariableDeclarationExpression (org.eclipse.jdt.core.dom.VariableDeclarationExpression)4 ASTRewrite (org.eclipse.jdt.core.dom.rewrite.ASTRewrite)4