org.eclipse.jdt.core.dom.CatchClause Java Examples

The following examples show how to use org.eclipse.jdt.core.dom.CatchClause. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InlineTempRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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);
}
 
Example #2
Source File: ExtractMethodFragmentRefactoring.java    From JDeodorant with MIT License 6 votes vote down vote up
protected TryStatement copyTryStatement(ASTRewrite sourceRewriter, AST ast, TryStatement tryStatementParent) {
	TryStatement newTryStatement = ast.newTryStatement();
	ListRewrite resourceRewrite = sourceRewriter.getListRewrite(newTryStatement, TryStatement.RESOURCES_PROPERTY);
	List<VariableDeclarationExpression> resources = tryStatementParent.resources();
	for(VariableDeclarationExpression expression : resources) {
		resourceRewrite.insertLast(expression, null);
	}
	ListRewrite catchClauseRewrite = sourceRewriter.getListRewrite(newTryStatement, TryStatement.CATCH_CLAUSES_PROPERTY);
	List<CatchClause> catchClauses = tryStatementParent.catchClauses();
	for(CatchClause catchClause : catchClauses) {
		catchClauseRewrite.insertLast(catchClause, null);
	}
	if(tryStatementParent.getFinally() != null) {
		sourceRewriter.set(newTryStatement, TryStatement.FINALLY_PROPERTY, tryStatementParent.getFinally(), null);
	}
	return newTryStatement;
}
 
Example #3
Source File: FlowContext.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #4
Source File: FlowAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@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;
}
 
Example #5
Source File: FlowContext.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
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;
}
 
Example #6
Source File: AstVisitor.java    From jdt2famix with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean visit(CatchClause node) {
	if (importer.topFromContainerStack(Method.class) != null) {
		importer.topFromContainerStack(Method.class).incCyclomaticComplexity();
	}

	CaughtException caughtException = new CaughtException();
	ITypeBinding binding = node.getException().getType().resolveBinding();
	if (binding != null) {
		Type caughtType = importer.ensureTypeFromTypeBinding(binding);
		caughtException.setExceptionClass((com.feenk.jdt2famix.model.famix.Class) caughtType);
		caughtException.setDefiningMethod((Method) importer.topOfContainerStack());
		importer.repository().add(caughtException);
	}
	return true;
}
 
Example #7
Source File: FlowAnalyzer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
@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;
}
 
Example #8
Source File: FullConstraintCreator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@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()]);
}
 
Example #9
Source File: FlowAnalyzer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
@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);
}
 
Example #10
Source File: StatementAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@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);
}
 
Example #11
Source File: ExceptionOccurrencesFinder.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(TryStatement node) {
	int currentSize= fCaughtExceptions.size();
	List<CatchClause> catchClauses= node.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();) {
				addCaughtException(iterator.next());
			}
		} else {
			addCaughtException(type);
		}
	}

	node.getBody().accept(this);

	handleResourceDeclarations(node);

	int toRemove= fCaughtExceptions.size() - currentSize;
	for (int i= toRemove; i > 0; i--) {
		fCaughtExceptions.remove(currentSize);
	}

	// 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;
}
 
Example #12
Source File: FlowAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void endVisit(TryStatement node) {
	if (skipNode(node))
		return;
	TryFlowInfo info= createTry();
	setFlowInfo(node, info);
	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);
}
 
Example #13
Source File: AbstractExceptionAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@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;
}
 
Example #14
Source File: AbstractExceptionAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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());
		}
	}
}
 
Example #15
Source File: ScopeAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(CatchClause node) {
	if (isInside(node)) {
		node.getBody().accept(this);
		node.getException().accept(this);
	}
	return false;
}
 
Example #16
Source File: CodeScopeBuilder.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@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;
}
 
Example #17
Source File: ImplementationSmellDetector.java    From DesigniteJava with Apache License 2.0 5 votes vote down vote up
public List<ImplementationCodeSmell> detectEmptyCatchBlock() {
	MethodControlFlowVisitor visitor = new MethodControlFlowVisitor();
	methodMetrics.getMethod().getMethodDeclaration().accept(visitor);
	for (TryStatement tryStatement : visitor.getTryStatements()) {
		for (Object catchClause : tryStatement.catchClauses()) {
			if (!hasBody((CatchClause) catchClause)) {
				addToSmells(initializeCodeSmell(EMPTY_CATCH_CLAUSE));
			}
		}
	}
	return smells;
}
 
Example #18
Source File: QuickAssistProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static void setCatchClauseBody(CatchClause newCatchClause, ASTRewrite rewrite, CatchClause catchClause) {
		// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=350285
		
//		newCatchClause.setBody((Block) rewrite.createCopyTarget(catchClause.getBody()));
		
		//newCatchClause#setBody() destroys the formatting, hence copy statement by statement.
		List<Statement> statements= catchClause.getBody().statements();
		for (Iterator<Statement> iterator2= statements.iterator(); iterator2.hasNext();) {
			newCatchClause.getBody().statements().add(rewrite.createCopyTarget(iterator2.next()));
		}
	}
 
Example #19
Source File: NewCUUsingWizardProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private ITypeBinding getPossibleSuperTypeBinding(ASTNode node) {
	if (fTypeKind == K_ANNOTATION) {
		return null;
	}

	AST ast= node.getAST();
	node= ASTNodes.getNormalizedNode(node);
	ASTNode parent= node.getParent();
	switch (parent.getNodeType()) {
		case ASTNode.METHOD_DECLARATION:
			if (node.getLocationInParent() == MethodDeclaration.THROWN_EXCEPTION_TYPES_PROPERTY) {
				return ast.resolveWellKnownType("java.lang.Exception"); //$NON-NLS-1$
			}
			break;
		case ASTNode.THROW_STATEMENT :
			return ast.resolveWellKnownType("java.lang.Exception"); //$NON-NLS-1$
		case ASTNode.SINGLE_VARIABLE_DECLARATION:
			if (parent.getLocationInParent() == CatchClause.EXCEPTION_PROPERTY) {
				return ast.resolveWellKnownType("java.lang.Exception"); //$NON-NLS-1$
			}
			break;
		case ASTNode.VARIABLE_DECLARATION_STATEMENT:
		case ASTNode.FIELD_DECLARATION:
			return null; // no guessing for LHS types, cannot be a supertype of a known type
		case ASTNode.PARAMETERIZED_TYPE:
			return null; // Inheritance doesn't help: A<X> z= new A<String>(); ->
	}
	ITypeBinding binding= ASTResolving.guessBindingForTypeReference(node);
	if (binding != null && !binding.isRecovered()) {
		return binding;
	}
	return null;
}
 
Example #20
Source File: CloneInstanceMapper.java    From JDeodorant with MIT License 5 votes vote down vote up
private ASTNode getParent(ASTNode controlNode) {
	if(!(controlNode.getParent() instanceof Block))
		return controlNode.getParent();
	while(controlNode.getParent() instanceof Block) {
		controlNode = controlNode.getParent();
	}
	if(controlNode.getParent() instanceof CatchClause) {
		CatchClause catchClause = (CatchClause)controlNode.getParent();
		return catchClause.getParent();
	}
	return controlNode.getParent();
}
 
Example #21
Source File: CloneInstanceMapper.java    From JDeodorant with MIT License 5 votes vote down vote up
private boolean isNestedUnderAnonymousClassDeclarationOrCatchClauseOrFinallyBlock(ASTNode node) {
	ASTNode parent = node.getParent();
	while(parent != null) {
		if(parent instanceof AnonymousClassDeclaration || parent instanceof CatchClause ||
				isFinallyBlockOfTryStatement(parent)) {
			return true;
		}
		parent = parent.getParent();
	}
	return false;
}
 
Example #22
Source File: ASTNodeMatcher.java    From JDeodorant with MIT License 5 votes vote down vote up
public boolean match(CatchClause node, Object other) {
	if (!(other instanceof CatchClause)) {
		return false;
	}
	CatchClause o = (CatchClause) other;
	return (
		safeSubtreeMatch(node.getException(), o.getException())
			&& safeSubtreeListMatch(node.getBody().statements(), o.getBody().statements()));
}
 
Example #23
Source File: ASTNodeMatcher.java    From JDeodorant with MIT License 5 votes vote down vote up
private boolean isNestedUnderAnonymousClassDeclaration(ASTNode node) {
	ASTNode parent = node.getParent();
	while(parent != null) {
		if(parent instanceof AnonymousClassDeclaration || parent instanceof CatchClause ||
				isFinallyBlockOfTryStatement(parent)) {
			return true;
		}
		parent = parent.getParent();
	}
	return false;
}
 
Example #24
Source File: TryStatementWriter.java    From juniversal with MIT License 5 votes vote down vote up
@Override
public void write(TryStatement tryStatement) {
    if (tryStatement.resources().size() > 0)
        writeTryWithResources(tryStatement);
    else {
        matchAndWrite("try");

        copySpaceAndComments();
        writeNode(tryStatement.getBody());

        forEach(tryStatement.catchClauses(), (CatchClause catchClause) -> {
            copySpaceAndComments();
            matchAndWrite("catch");

            copySpaceAndComments();
            matchAndWrite("(");

            copySpaceAndComments();
            writeNode(catchClause.getException());

            copySpaceAndComments();
            matchAndWrite(")");

            copySpaceAndComments();
            writeNode(catchClause.getBody());
        });

        @Nullable Block finallyBlock = tryStatement.getFinally();
        if (finallyBlock != null) {
            copySpaceAndComments();
            matchAndWrite("finally");

            copySpaceAndComments();
            writeNode(finallyBlock);
        }
    }
}
 
Example #25
Source File: FlowContext.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
void pushExcptions(TryStatement node) {
	List<CatchClause> catchClauses= node.catchClauses();
	if (catchClauses == null) {
		catchClauses= EMPTY_CATCH_CLAUSE;
	}
	fExceptionStack.add(catchClauses);
}
 
Example #26
Source File: AbstractExceptionAnalyzer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@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;
}
 
Example #27
Source File: AbstractExceptionAnalyzer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
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());
		}
	}
}
 
Example #28
Source File: JavaASTFlattener.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean visit(final SingleVariableDeclaration it) {
  if ((((it.getParent() instanceof MethodDeclaration) || (it.getParent() instanceof CatchClause)) || 
    (it.getParent() instanceof EnhancedForStatement))) {
    final Function1<IExtendedModifier, Boolean> _function = (IExtendedModifier it_1) -> {
      return Boolean.valueOf(it_1.isAnnotation());
    };
    this.appendModifiers(it, IterableExtensions.<IExtendedModifier>filter(Iterables.<IExtendedModifier>filter(it.modifiers(), IExtendedModifier.class), _function));
  } else {
    this.appendModifiers(it, it.modifiers());
  }
  it.getType().accept(this);
  this.appendExtraDimensions(it.getExtraDimensions());
  boolean _isVarargs = it.isVarargs();
  if (_isVarargs) {
    this.appendToBuffer("...");
  }
  this.appendSpaceToBuffer();
  it.getName().accept(this);
  Expression _initializer = it.getInitializer();
  boolean _tripleNotEquals = (_initializer != null);
  if (_tripleNotEquals) {
    this.appendToBuffer("=");
    it.getInitializer().accept(this);
  }
  return false;
}
 
Example #29
Source File: JavaASTFlattener.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean visit(final CatchClause node) {
  int _nodeType = node.getException().getType().getNodeType();
  boolean _tripleEquals = (_nodeType == 84);
  if (_tripleEquals) {
    this.appendToBuffer(" catch (");
    final List<ASTNode> types = this._aSTFlattenerUtils.genericChildListProperty(node.getException().getType(), "types");
    if (types!=null) {
      final Procedure2<ASTNode, Integer> _function = (ASTNode child, Integer index) -> {
        child.accept(this);
        int _size = types.size();
        int _minus = (_size - 1);
        boolean _lessThan = ((index).intValue() < _minus);
        if (_lessThan) {
          this.appendSpaceToBuffer();
          this.appendToBuffer("|");
          this.appendSpaceToBuffer();
        }
      };
      IterableExtensions.<ASTNode>forEach(types, _function);
    }
    this.appendSpaceToBuffer();
    this.appendToBuffer(this._aSTFlattenerUtils.toSimpleName(node.getException().getName()));
    this.appendToBuffer(") ");
    node.getBody().accept(this);
  } else {
    this.appendToBuffer(" catch (");
    node.getException().accept(this);
    this.appendToBuffer(") ");
    node.getBody().accept(this);
  }
  return false;
}
 
Example #30
Source File: FlowAnalyzer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void endVisit(CatchClause node) {
	if (skipNode(node)) {
		return;
	}
	processSequential(node, node.getException(), node.getBody());
}