Java 类org.eclipse.jdt.core.dom.CatchClause 实例源码

项目:o3smeasures-tool    文件:WeightMethodsPerClassVisitor.java   
/**
 * Method that check statement type.
 * @author Mariana Azevedo
 * @since 13/07/2014
 * @param itStatement
 */
private void getStatementType(Object itStatement) {
    if (itStatement instanceof CatchClause){
        this.visitor.visit((CatchClause)itStatement);
    }else if (itStatement instanceof ForStatement){
        this.visitor.visit((ForStatement)itStatement);
    }else if (itStatement instanceof IfStatement){
        this.visitor.visit((IfStatement)itStatement);
    }else if (itStatement instanceof WhileStatement){
        this.visitor.visit((WhileStatement)itStatement);
    }else if (itStatement instanceof TryStatement){
        this.visitor.visit((TryStatement)itStatement);
    }else if (itStatement instanceof ConditionalExpression){
        this.visitor.visit((ConditionalExpression)itStatement);
    }else if (itStatement instanceof SwitchCase){
        this.visitor.visit((SwitchCase)itStatement);
    }else if (itStatement instanceof DoStatement){
        this.visitor.visit((DoStatement)itStatement);
    }else if (itStatement instanceof ExpressionStatement){
        this.visitor.visit((ExpressionStatement)itStatement);
    }
}
项目:eclipse.jdt.ls    文件:FlowContext.java   
boolean isExceptionCaught(ITypeBinding excpetionType) {
    for (Iterator<List<CatchClause>> exceptions= fExceptionStack.iterator(); exceptions.hasNext(); ) {
        for (Iterator<CatchClause> catchClauses= exceptions.next().iterator(); catchClauses.hasNext(); ) {
            SingleVariableDeclaration caughtException= catchClauses.next().getException();
            IVariableBinding binding= caughtException.resolveBinding();
            if (binding == null) {
                continue;
            }
            ITypeBinding caughtype= binding.getType();
            while (caughtype != null) {
                if (caughtype == excpetionType) {
                    return true;
                }
                caughtype= caughtype.getSuperclass();
            }
        }
    }
    return false;
}
项目:eclipse.jdt.ls    文件:FlowAnalyzer.java   
@Override
public boolean visit(TryStatement node) {
    if (traverseNode(node)) {
        fFlowContext.pushExcptions(node);
        for (Iterator<VariableDeclarationExpression> iterator = node.resources().iterator(); iterator.hasNext();) {
            iterator.next().accept(this);
        }
        node.getBody().accept(this);
        fFlowContext.popExceptions();
        List<CatchClause> catchClauses = node.catchClauses();
        for (Iterator<CatchClause> iter = catchClauses.iterator(); iter.hasNext();) {
            iter.next().accept(this);
        }
        Block finallyBlock = node.getFinally();
        if (finallyBlock != null) {
            finallyBlock.accept(this);
        }
    }
    return false;
}
项目:eclipse.jdt.ls    文件:FlowAnalyzer.java   
@Override
public void endVisit(TryStatement node) {
    if (skipNode(node)) {
        return;
    }
    TryFlowInfo info = createTry();
    setFlowInfo(node, info);
    for (Iterator<VariableDeclarationExpression> iterator = node.resources().iterator(); iterator.hasNext();) {
        info.mergeResources(getFlowInfo(iterator.next()), fFlowContext);
    }
    info.mergeTry(getFlowInfo(node.getBody()), fFlowContext);
    for (Iterator<CatchClause> iter = node.catchClauses().iterator(); iter.hasNext();) {
        CatchClause element = iter.next();
        info.mergeCatch(getFlowInfo(element), fFlowContext);
    }
    info.mergeFinally(getFlowInfo(node.getFinally()), fFlowContext);
}
项目:eclipse.jdt.ls    文件:StatementAnalyzer.java   
@Override
public void endVisit(TryStatement node) {
    ASTNode firstSelectedNode = getFirstSelectedNode();
    if (getSelection().getEndVisitSelectionMode(node) == Selection.AFTER) {
        if (firstSelectedNode == node.getBody() || firstSelectedNode == node.getFinally()) {
            invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
        } else {
            List<CatchClause> catchClauses = node.catchClauses();
            for (Iterator<CatchClause> iterator = catchClauses.iterator(); iterator.hasNext();) {
                CatchClause element = iterator.next();
                if (element == firstSelectedNode || element.getBody() == firstSelectedNode) {
                    invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
                } else if (element.getException() == firstSelectedNode) {
                    invalidSelection(RefactoringCoreMessages.StatementAnalyzer_catch_argument);
                }
            }
        }
    }
    super.endVisit(node);
}
项目:che    文件:FlowContext.java   
boolean isExceptionCaught(ITypeBinding excpetionType) {
  for (Iterator<List<CatchClause>> exceptions = fExceptionStack.iterator();
      exceptions.hasNext(); ) {
    for (Iterator<CatchClause> catchClauses = exceptions.next().iterator();
        catchClauses.hasNext(); ) {
      SingleVariableDeclaration caughtException = catchClauses.next().getException();
      IVariableBinding binding = caughtException.resolveBinding();
      if (binding == null) continue;
      ITypeBinding caughtype = binding.getType();
      while (caughtype != null) {
        if (caughtype == excpetionType) return true;
        caughtype = caughtype.getSuperclass();
      }
    }
  }
  return false;
}
项目:che    文件:FullConstraintCreator.java   
@Override
public ITypeConstraint[] create(CatchClause node) {
  SingleVariableDeclaration exception = node.getException();
  ConstraintVariable nameVariable =
      fConstraintVariableFactory.makeExpressionOrTypeVariable(exception.getName(), getContext());

  ITypeConstraint[] defines =
      fTypeConstraintFactory.createDefinesConstraint(
          nameVariable, fConstraintVariableFactory.makeTypeVariable(exception.getType()));

  ITypeBinding throwable =
      node.getAST().resolveWellKnownType("java.lang.Throwable"); // $NON-NLS-1$
  ITypeConstraint[] catchBound =
      fTypeConstraintFactory.createSubtypeConstraint(
          nameVariable, fConstraintVariableFactory.makeRawBindingVariable(throwable));

  ArrayList<ITypeConstraint> result = new ArrayList<ITypeConstraint>();
  result.addAll(Arrays.asList(defines));
  result.addAll(Arrays.asList(catchBound));
  return result.toArray(new ITypeConstraint[result.size()]);
}
项目:che    文件:StatementAnalyzer.java   
@Override
public void endVisit(TryStatement node) {
  ASTNode firstSelectedNode = getFirstSelectedNode();
  if (getSelection().getEndVisitSelectionMode(node) == Selection.AFTER) {
    if (firstSelectedNode == node.getBody() || firstSelectedNode == node.getFinally()) {
      invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
    } else {
      List<CatchClause> catchClauses = node.catchClauses();
      for (Iterator<CatchClause> iterator = catchClauses.iterator(); iterator.hasNext(); ) {
        CatchClause element = iterator.next();
        if (element == firstSelectedNode || element.getBody() == firstSelectedNode) {
          invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
        } else if (element.getException() == firstSelectedNode) {
          invalidSelection(RefactoringCoreMessages.StatementAnalyzer_catch_argument);
        }
      }
    }
  }
  super.endVisit(node);
}
项目:Eclipse-Postfix-Code-Completion    文件:InlineTempRefactoring.java   
private RefactoringStatus checkSelection(VariableDeclaration decl) {
    ASTNode parent= decl.getParent();
    if (parent instanceof MethodDeclaration) {
        return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InlineTempRefactoring_method_parameter);
    }

    if (parent instanceof CatchClause) {
        return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InlineTempRefactoring_exceptions_declared);
    }

    if (parent instanceof VariableDeclarationExpression && parent.getLocationInParent() == ForStatement.INITIALIZERS_PROPERTY) {
        return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InlineTempRefactoring_for_initializers);
    }

    if (parent instanceof VariableDeclarationExpression && parent.getLocationInParent() == TryStatement.RESOURCES_PROPERTY) {
        return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InlineTempRefactoring_resource_in_try_with_resources);
    }

    if (decl.getInitializer() == null) {
        String message= Messages.format(RefactoringCoreMessages.InlineTempRefactoring_not_initialized, BasicElementLabels.getJavaElementName(decl.getName().getIdentifier()));
        return RefactoringStatus.createFatalErrorStatus(message);
    }

    return checkAssignments(decl);
}
项目:Eclipse-Postfix-Code-Completion    文件:FlowContext.java   
boolean isExceptionCaught(ITypeBinding excpetionType) {
    for (Iterator<List<CatchClause>> exceptions= fExceptionStack.iterator(); exceptions.hasNext(); ) {
        for (Iterator<CatchClause> catchClauses= exceptions.next().iterator(); catchClauses.hasNext(); ) {
            SingleVariableDeclaration caughtException= catchClauses.next().getException();
            IVariableBinding binding= caughtException.resolveBinding();
            if (binding == null)
                continue;
            ITypeBinding caughtype= binding.getType();
            while (caughtype != null) {
                if (caughtype == excpetionType)
                    return true;
                caughtype= caughtype.getSuperclass();
            }
        }
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:FlowAnalyzer.java   
@Override
public boolean visit(TryStatement node) {
    if (traverseNode(node)) {
        fFlowContext.pushExcptions(node);
        node.getBody().accept(this);
        fFlowContext.popExceptions();
        List<CatchClause> catchClauses= node.catchClauses();
        for (Iterator<CatchClause> iter= catchClauses.iterator(); iter.hasNext();) {
            iter.next().accept(this);
        }
        Block finallyBlock= node.getFinally();
        if (finallyBlock != null) {
            finallyBlock.accept(this);
        }
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:FullConstraintCreator.java   
@Override
public ITypeConstraint[] create(CatchClause node) {
    SingleVariableDeclaration exception= node.getException();
    ConstraintVariable nameVariable= fConstraintVariableFactory.makeExpressionOrTypeVariable(exception.getName(), getContext());

    ITypeConstraint[] defines= fTypeConstraintFactory.createDefinesConstraint(
            nameVariable,
            fConstraintVariableFactory.makeTypeVariable(exception.getType()));

    ITypeBinding throwable= node.getAST().resolveWellKnownType("java.lang.Throwable"); //$NON-NLS-1$
    ITypeConstraint[] catchBound= fTypeConstraintFactory.createSubtypeConstraint(
            nameVariable,
            fConstraintVariableFactory.makeRawBindingVariable(throwable));

    ArrayList<ITypeConstraint> result= new ArrayList<ITypeConstraint>();
    result.addAll(Arrays.asList(defines));
    result.addAll(Arrays.asList(catchBound));
    return result.toArray(new ITypeConstraint[result.size()]);
}
项目:Eclipse-Postfix-Code-Completion    文件:StatementAnalyzer.java   
@Override
public void endVisit(TryStatement node) {
    ASTNode firstSelectedNode= getFirstSelectedNode();
    if (getSelection().getEndVisitSelectionMode(node) == Selection.AFTER) {
        if (firstSelectedNode == node.getBody() || firstSelectedNode == node.getFinally()) {
            invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
        } else {
            List<CatchClause> catchClauses= node.catchClauses();
            for (Iterator<CatchClause> iterator= catchClauses.iterator(); iterator.hasNext();) {
                CatchClause element= iterator.next();
                if (element == firstSelectedNode || element.getBody() == firstSelectedNode) {
                    invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
                } else if (element.getException() == firstSelectedNode) {
                    invalidSelection(RefactoringCoreMessages.StatementAnalyzer_catch_argument);
                }
            }
        }
    }
    super.endVisit(node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:InlineTempRefactoring.java   
private RefactoringStatus checkSelection(VariableDeclaration decl) {
    ASTNode parent= decl.getParent();
    if (parent instanceof MethodDeclaration) {
        return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InlineTempRefactoring_method_parameter);
    }

    if (parent instanceof CatchClause) {
        return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InlineTempRefactoring_exceptions_declared);
    }

    if (parent instanceof VariableDeclarationExpression && parent.getLocationInParent() == ForStatement.INITIALIZERS_PROPERTY) {
        return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InlineTempRefactoring_for_initializers);
    }

    if (parent instanceof VariableDeclarationExpression && parent.getLocationInParent() == TryStatement.RESOURCES_PROPERTY) {
        return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InlineTempRefactoring_resource_in_try_with_resources);
    }

    if (decl.getInitializer() == null) {
        String message= Messages.format(RefactoringCoreMessages.InlineTempRefactoring_not_initialized, BasicElementLabels.getJavaElementName(decl.getName().getIdentifier()));
        return RefactoringStatus.createFatalErrorStatus(message);
    }

    return checkAssignments(decl);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:FlowContext.java   
boolean isExceptionCaught(ITypeBinding excpetionType) {
    for (Iterator<List<CatchClause>> exceptions= fExceptionStack.iterator(); exceptions.hasNext(); ) {
        for (Iterator<CatchClause> catchClauses= exceptions.next().iterator(); catchClauses.hasNext(); ) {
            SingleVariableDeclaration caughtException= catchClauses.next().getException();
            IVariableBinding binding= caughtException.resolveBinding();
            if (binding == null)
                continue;
            ITypeBinding caughtype= binding.getType();
            while (caughtype != null) {
                if (caughtype == excpetionType)
                    return true;
                caughtype= caughtype.getSuperclass();
            }
        }
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:FlowAnalyzer.java   
@Override
public boolean visit(TryStatement node) {
    if (traverseNode(node)) {
        fFlowContext.pushExcptions(node);
        node.getBody().accept(this);
        fFlowContext.popExceptions();
        List<CatchClause> catchClauses= node.catchClauses();
        for (Iterator<CatchClause> iter= catchClauses.iterator(); iter.hasNext();) {
            iter.next().accept(this);
        }
        Block finallyBlock= node.getFinally();
        if (finallyBlock != null) {
            finallyBlock.accept(this);
        }
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:FullConstraintCreator.java   
@Override
public ITypeConstraint[] create(CatchClause node) {
    SingleVariableDeclaration exception= node.getException();
    ConstraintVariable nameVariable= fConstraintVariableFactory.makeExpressionOrTypeVariable(exception.getName(), getContext());

    ITypeConstraint[] defines= fTypeConstraintFactory.createDefinesConstraint(
            nameVariable,
            fConstraintVariableFactory.makeTypeVariable(exception.getType()));

    ITypeBinding throwable= node.getAST().resolveWellKnownType("java.lang.Throwable"); //$NON-NLS-1$
    ITypeConstraint[] catchBound= fTypeConstraintFactory.createSubtypeConstraint(
            nameVariable,
            fConstraintVariableFactory.makeRawBindingVariable(throwable));

    ArrayList<ITypeConstraint> result= new ArrayList<ITypeConstraint>();
    result.addAll(Arrays.asList(defines));
    result.addAll(Arrays.asList(catchBound));
    return result.toArray(new ITypeConstraint[result.size()]);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:StatementAnalyzer.java   
@Override
public void endVisit(TryStatement node) {
    ASTNode firstSelectedNode= getFirstSelectedNode();
    if (getSelection().getEndVisitSelectionMode(node) == Selection.AFTER) {
        if (firstSelectedNode == node.getBody() || firstSelectedNode == node.getFinally()) {
            invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
        } else {
            List<CatchClause> catchClauses= node.catchClauses();
            for (Iterator<CatchClause> iterator= catchClauses.iterator(); iterator.hasNext();) {
                CatchClause element= iterator.next();
                if (element == firstSelectedNode || element.getBody() == firstSelectedNode) {
                    invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
                } else if (element.getException() == firstSelectedNode) {
                    invalidSelection(RefactoringCoreMessages.StatementAnalyzer_catch_argument);
                }
            }
        }
    }
    super.endVisit(node);
}
项目:jive    文件:StatementVisitor.java   
/**
 * 'catch(' exception ')' '{' body '}'
 */
@Override
public boolean visit(final CatchClause node)
{
  final int lineNo = lineStart(node);
  // new dependence
  final IResolvedLine rd = createDependence(LK_CATCH, lineNo, mdg.parent());
  // control node parent
  final ASTNode controlNode = ASTTools.enclosingControlScope(node);
  // last line of the control scope
  final int lineEnd = lineEnd(controlNode);
  // the catch dependence must be propagated to all lines in the method's body
  jumpDependences.put(lineEnd, rd);
  // new variable use
  final IResolvedData rv = factory.resolveExpression(node.getException().getName(), node, null,
      false, true);
  // map this definition
  rd.definitions().add(rv);
  // append the control dependence
  rd.uses().add(rv);
  // recursively append dependences
  appendRecursive(lineNo, rd, node.getBody());
  // do not visit children
  return false;
}
项目:bayou    文件:DOMTryStatement.java   
@Override
public DSubTree handle() {
    DSubTree tree = new DSubTree();

    // restriction: considering only the first catch clause
    DSubTree Ttry = new DOMBlock(statement.getBody()).handle();
    DSubTree Tcatch;
    if (! statement.catchClauses().isEmpty())
        Tcatch = new DOMCatchClause((CatchClause) statement.catchClauses().get(0)).handle();
    else
        Tcatch = new DSubTree();
    DSubTree Tfinally = new DOMBlock(statement.getFinally()).handle();

    boolean except = Ttry.isValid() && Tcatch.isValid();

    if (except)
        tree.addNode(new DExcept(Ttry.getNodes(), Tcatch.getNodes()));
    else {
        // only one of these will add nodes
        tree.addNodes(Ttry.getNodes());
        tree.addNodes(Tcatch.getNodes());
    }

    tree.addNodes(Tfinally.getNodes());

    return tree;
}
项目:junit2spock    文件:TryStatementWrapper.java   
TryStatementWrapper(TryStatement statement, int indentationLevel, Applicable applicable) {
    super(indentationLevel, applicable);
    body.addAll(statement.resources());
    ofNullable(statement.getBody()).ifPresent(block -> body.addAll(block.statements()));
    this.catchClauses = (LinkedList<CatchClauseWrapper>) statement.catchClauses().stream()
            .map(catchClause -> new CatchClauseWrapper((CatchClause) catchClause, indentationLevel, applicable))
            .collect(toCollection(LinkedList::new));
    finallyBody = ofNullable(statement.getFinally())
            .map(Block::statements);

    applicable.applyFeaturesToStatements(body);
    finallyBody.ifPresent(applicable::applyFeaturesToStatements);
}
项目:RefDiff    文件:ASTVisitorAtomicChange.java   
public boolean visit(TryStatement node) {
    if (mtbStack.isEmpty()) // not part of a method
        return true;

    String bodyStr = node.getBody() != null ? node.getBody().toString()
            : "";
    bodyStr = edit_str(bodyStr);
    StringBuilder catchClauses = new StringBuilder();
    for (Object o : node.catchClauses()) {
        if (catchClauses.length() > 0)
            catchClauses.append(",");
        CatchClause c = (CatchClause) o;
        catchClauses.append(getQualifiedName(c.getException().getType()
                .resolveBinding()));
        catchClauses.append(":");
        if (c.getBody() != null)
            catchClauses.append(edit_str(c.getBody().toString()));
    }
    String finallyStr = node.getFinally() != null ? node.getFinally()
            .toString() : "";
    finallyStr = edit_str(finallyStr);

    IMethodBinding mtb = mtbStack.peek();
    String methodStr = getQualifiedName(mtb);

    facts.add(Fact.makeTryCatchFact(bodyStr, catchClauses.toString(),
            finallyStr, methodStr));

    return true;
}
项目:o3smeasures-tool    文件:CyclomaticComplexityVisitor.java   
/**
 * @see ASTVisitor#visit(CatchClause)
 */
@Override
public boolean visit(CatchClause node) {
    cyclomaticComplexityIndex++;
    sumCyclomaticComplexity++;
    return true;
}
项目:eclipse.jdt.ls    文件:CodeScopeBuilder.java   
@Override
public boolean visit(CatchClause node) {
    // open a new scope for the exception declaration.
    fScopes.add(fScope);
    fScope = new Scope(fScope, node.getStartPosition(), node.getLength());
    return true;
}
项目:eclipse.jdt.ls    文件:FlowContext.java   
void pushExcptions(TryStatement node) {
    List<CatchClause> catchClauses= node.catchClauses();
    if (catchClauses == null) {
        catchClauses= EMPTY_CATCH_CLAUSE;
    }
    fExceptionStack.add(catchClauses);
}
项目:eclipse.jdt.ls    文件:FlowAnalyzer.java   
@Override
public void endVisit(CatchClause node) {
    if (skipNode(node)) {
        return;
    }
    processSequential(node, node.getException(), node.getBody());
}
项目:eclipse.jdt.ls    文件:AbstractExceptionAnalyzer.java   
@Override
public boolean visit(TryStatement node) {
    fCurrentExceptions = new ArrayList<>(1);
    fTryStack.push(fCurrentExceptions);

    // visit try block
    node.getBody().accept(this);

    List<VariableDeclarationExpression> resources = node.resources();
    for (Iterator<VariableDeclarationExpression> iterator = resources.iterator(); iterator.hasNext();) {
        iterator.next().accept(this);
    }

    // Remove those exceptions that get catch by following catch blocks
    List<CatchClause> catchClauses = node.catchClauses();
    if (!catchClauses.isEmpty()) {
        handleCatchArguments(catchClauses);
    }
    List<ITypeBinding> current = fTryStack.pop();
    fCurrentExceptions = fTryStack.peek();
    for (Iterator<ITypeBinding> iter = current.iterator(); iter.hasNext();) {
        addException(iter.next(), node.getAST());
    }

    // visit catch and finally
    for (Iterator<CatchClause> iter = catchClauses.iterator(); iter.hasNext();) {
        iter.next().accept(this);
    }
    if (node.getFinally() != null) {
        node.getFinally().accept(this);
    }

    // return false. We have visited the body by ourselves.
    return false;
}
项目:eclipse.jdt.ls    文件:AbstractExceptionAnalyzer.java   
private void handleCatchArguments(List<CatchClause> catchClauses) {
    for (Iterator<CatchClause> iter = catchClauses.iterator(); iter.hasNext();) {
        Type type = iter.next().getException().getType();
        if (type instanceof UnionType) {
            List<Type> types = ((UnionType) type).types();
            for (Iterator<Type> iterator = types.iterator(); iterator.hasNext();) {
                removeCaughtExceptions(iterator.next().resolveBinding());
            }
        } else {
            removeCaughtExceptions(type.resolveBinding());
        }
    }
}
项目:code    文件:DefaultingVisitor.java   
@Override
public boolean visit(CatchClause node) {
    SingleVariableDeclaration param = node.getException();

    ITypeBinding type = param.resolveBinding().getType();
    if (!hasAnnotation(param.modifiers())) {
        if (!type.isPrimitive()) {
            if (type.getName().compareTo("String") != 0) {
                setParameterAnnotation(rewrite, param, "lent");
            }
        }
    }

    return super.visit(node);
}
项目:code    文件:RemoveAnnotationsVisitor.java   
@Override
public boolean visit(CatchClause node) {

    SingleVariableDeclaration param = node.getException();

    ITypeBinding type = param.resolveBinding().getType();
    SingleMemberAnnotation annot = hasAnnotation(param.modifiers());
    if (annot != null) {
        ListRewrite paramRewrite = rewrite.getListRewrite(param, SingleVariableDeclaration.MODIFIERS2_PROPERTY);
        paramRewrite.remove(annot, null);
    }


    return super.visit(node);
}
项目:code    文件:DefaultingVisitor.java   
@Override
public boolean visit(CatchClause node) {
    SingleVariableDeclaration param = node.getException();

    ITypeBinding type = param.resolveBinding().getType();
    if (!hasAnnotation(param.modifiers())) {
        if (!type.isPrimitive()) {
            if (type.getName().compareTo("String") != 0) {
                setParameterAnnotation(rewrite, param, "lent");
            }
        }
    }

    return super.visit(node);
}
项目:code    文件:RemoveAnnotationsVisitor.java   
@Override
public boolean visit(CatchClause node) {

    SingleVariableDeclaration param = node.getException();

    ITypeBinding type = param.resolveBinding().getType();
    SingleMemberAnnotation annot = hasAnnotation(param.modifiers());
    if (annot != null) {
        ListRewrite paramRewrite = rewrite.getListRewrite(param, SingleVariableDeclaration.MODIFIERS2_PROPERTY);
        paramRewrite.remove(annot, null);
    }


    return super.visit(node);
}
项目:Ref-Finder    文件:ASTVisitorAtomicChange.java   
public boolean visit(TryStatement node)
{
  if (this.mtbStack.isEmpty()) {
    return true;
  }
  String bodyStr = node.getBody() != null ? node.getBody().toString() : 
    "";
  bodyStr = edit_str(bodyStr);
  StringBuilder catchClauses = new StringBuilder();
  for (Object o : node.catchClauses())
  {
    if (catchClauses.length() > 0) {
      catchClauses.append(",");
    }
    CatchClause c = (CatchClause)o;
    catchClauses.append(getQualifiedName(c.getException().getType()
      .resolveBinding()));
    catchClauses.append(":");
    if (c.getBody() != null) {
      catchClauses.append(edit_str(c.getBody().toString()));
    }
  }
  String finallyStr = node.getFinally() != null ? node.getFinally()
    .toString() : "";
  finallyStr = edit_str(finallyStr);

  IMethodBinding mtb = (IMethodBinding)this.mtbStack.peek();
  String methodStr = getQualifiedName(mtb);

  this.facts.add(Fact.makeTryCatchFact(bodyStr, catchClauses.toString(), 
    finallyStr, methodStr));

  return true;
}
项目:Ref-Finder    文件:ASTVisitorAtomicChange.java   
public boolean visit(TryStatement node) {
    if (mtbStack.isEmpty()) // not part of a method
        return true;

    String bodyStr = node.getBody() != null ? node.getBody().toString()
            : "";
    bodyStr = edit_str(bodyStr);
    StringBuilder catchClauses = new StringBuilder();
    for (Object o : node.catchClauses()) {
        if (catchClauses.length() > 0)
            catchClauses.append(",");
        CatchClause c = (CatchClause) o;
        catchClauses.append(getQualifiedName(c.getException().getType()
                .resolveBinding()));
        catchClauses.append(":");
        if (c.getBody() != null)
            catchClauses.append(edit_str(c.getBody().toString()));
    }
    String finallyStr = node.getFinally() != null ? node.getFinally()
            .toString() : "";
    finallyStr = edit_str(finallyStr);

    IMethodBinding mtb = mtbStack.peek();
    String methodStr = getQualifiedName(mtb);

    facts.add(Fact.makeTryCatchFact(bodyStr, catchClauses.toString(),
            finallyStr, methodStr));

    return true;
}
项目:Ref-Finder    文件:ASTVisitorAtomicChange.java   
public boolean visit(TryStatement node)
{
  if (this.mtbStack.isEmpty()) {
    return true;
  }
  String bodyStr = node.getBody() != null ? node.getBody().toString() : 
    "";
  bodyStr = edit_str(bodyStr);
  StringBuilder catchClauses = new StringBuilder();
  for (Object o : node.catchClauses())
  {
    if (catchClauses.length() > 0) {
      catchClauses.append(",");
    }
    CatchClause c = (CatchClause)o;
    catchClauses.append(getQualifiedName(c.getException().getType()
      .resolveBinding()));
    catchClauses.append(":");
    if (c.getBody() != null) {
      catchClauses.append(edit_str(c.getBody().toString()));
    }
  }
  String finallyStr = node.getFinally() != null ? node.getFinally()
    .toString() : "";
  finallyStr = edit_str(finallyStr);

  IMethodBinding mtb = (IMethodBinding)this.mtbStack.peek();
  String methodStr = getQualifiedName(mtb);

  this.facts.add(Fact.makeTryCatchFact(bodyStr, catchClauses.toString(), 
    finallyStr, methodStr));

  return true;
}
项目:che    文件:ScopeAnalyzer.java   
@Override
public boolean visit(CatchClause node) {
  if (isInside(node)) {
    node.getBody().accept(this);
    node.getException().accept(this);
  }
  return false;
}
项目:che    文件:CodeScopeBuilder.java   
@Override
public boolean visit(CatchClause node) {
  // open a new scope for the exception declaration.
  fScopes.add(fScope);
  fScope = new Scope(fScope, node.getStartPosition(), node.getLength());
  return true;
}
项目:che    文件:InferTypeArgumentsConstraintCreator.java   
@Override
public boolean visit(CatchClause node) {
  SingleVariableDeclaration exception = node.getException();
  IVariableBinding variableBinding = exception.resolveBinding();
  VariableVariable2 cv = fTCModel.makeDeclaredVariableVariable(variableBinding, fCU);
  setConstraintVariable(exception, cv);
  return true;
}
项目:che    文件:InlineTempRefactoring.java   
private RefactoringStatus checkSelection(VariableDeclaration decl) {
  ASTNode parent = decl.getParent();
  if (parent instanceof MethodDeclaration) {
    return RefactoringStatus.createFatalErrorStatus(
        RefactoringCoreMessages.InlineTempRefactoring_method_parameter);
  }

  if (parent instanceof CatchClause) {
    return RefactoringStatus.createFatalErrorStatus(
        RefactoringCoreMessages.InlineTempRefactoring_exceptions_declared);
  }

  if (parent instanceof VariableDeclarationExpression
      && parent.getLocationInParent() == ForStatement.INITIALIZERS_PROPERTY) {
    return RefactoringStatus.createFatalErrorStatus(
        RefactoringCoreMessages.InlineTempRefactoring_for_initializers);
  }

  if (parent instanceof VariableDeclarationExpression
      && parent.getLocationInParent() == TryStatement.RESOURCES_PROPERTY) {
    return RefactoringStatus.createFatalErrorStatus(
        RefactoringCoreMessages.InlineTempRefactoring_resource_in_try_with_resources);
  }

  if (decl.getInitializer() == null) {
    String message =
        Messages.format(
            RefactoringCoreMessages.InlineTempRefactoring_not_initialized,
            BasicElementLabels.getJavaElementName(decl.getName().getIdentifier()));
    return RefactoringStatus.createFatalErrorStatus(message);
  }

  return checkAssignments(decl);
}
项目:che    文件:AbstractExceptionAnalyzer.java   
@Override
public boolean visit(TryStatement node) {
  fCurrentExceptions = new ArrayList<ITypeBinding>(1);
  fTryStack.push(fCurrentExceptions);

  // visit try block
  node.getBody().accept(this);

  List<VariableDeclarationExpression> resources = node.resources();
  for (Iterator<VariableDeclarationExpression> iterator = resources.iterator();
      iterator.hasNext(); ) {
    iterator.next().accept(this);
  }

  // Remove those exceptions that get catch by following catch blocks
  List<CatchClause> catchClauses = node.catchClauses();
  if (!catchClauses.isEmpty()) handleCatchArguments(catchClauses);
  List<ITypeBinding> current = fTryStack.pop();
  fCurrentExceptions = fTryStack.peek();
  for (Iterator<ITypeBinding> iter = current.iterator(); iter.hasNext(); ) {
    addException(iter.next(), node.getAST());
  }

  // visit catch and finally
  for (Iterator<CatchClause> iter = catchClauses.iterator(); iter.hasNext(); ) {
    iter.next().accept(this);
  }
  if (node.getFinally() != null) node.getFinally().accept(this);

  // return false. We have visited the body by ourselves.
  return false;
}