private static boolean locationNeedsParentheses(StructuralPropertyDescriptor locationInParent) { if (locationInParent instanceof ChildListPropertyDescriptor && locationInParent != InfixExpression.EXTENDED_OPERANDS_PROPERTY) { // e.g. argument lists of MethodInvocation, ClassInstanceCreation, dimensions of ArrayCreation ... return false; } if (locationInParent == VariableDeclarationFragment.INITIALIZER_PROPERTY || locationInParent == SingleVariableDeclaration.INITIALIZER_PROPERTY || locationInParent == ReturnStatement.EXPRESSION_PROPERTY || locationInParent == EnhancedForStatement.EXPRESSION_PROPERTY || locationInParent == ForStatement.EXPRESSION_PROPERTY || locationInParent == WhileStatement.EXPRESSION_PROPERTY || locationInParent == DoStatement.EXPRESSION_PROPERTY || locationInParent == AssertStatement.EXPRESSION_PROPERTY || locationInParent == AssertStatement.MESSAGE_PROPERTY || locationInParent == IfStatement.EXPRESSION_PROPERTY || locationInParent == SwitchStatement.EXPRESSION_PROPERTY || locationInParent == SwitchCase.EXPRESSION_PROPERTY || locationInParent == ArrayAccess.INDEX_PROPERTY || locationInParent == ThrowStatement.EXPRESSION_PROPERTY || locationInParent == SynchronizedStatement.EXPRESSION_PROPERTY || locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) { return false; } return true; }
private static boolean locationNeedsParentheses(StructuralPropertyDescriptor locationInParent) { if (locationInParent instanceof ChildListPropertyDescriptor && locationInParent != InfixExpression.EXTENDED_OPERANDS_PROPERTY) { // e.g. argument lists of MethodInvocation, ClassInstanceCreation, dimensions of ArrayCreation // ... return false; } if (locationInParent == VariableDeclarationFragment.INITIALIZER_PROPERTY || locationInParent == SingleVariableDeclaration.INITIALIZER_PROPERTY || locationInParent == ReturnStatement.EXPRESSION_PROPERTY || locationInParent == EnhancedForStatement.EXPRESSION_PROPERTY || locationInParent == ForStatement.EXPRESSION_PROPERTY || locationInParent == WhileStatement.EXPRESSION_PROPERTY || locationInParent == DoStatement.EXPRESSION_PROPERTY || locationInParent == AssertStatement.EXPRESSION_PROPERTY || locationInParent == AssertStatement.MESSAGE_PROPERTY || locationInParent == IfStatement.EXPRESSION_PROPERTY || locationInParent == SwitchStatement.EXPRESSION_PROPERTY || locationInParent == SwitchCase.EXPRESSION_PROPERTY || locationInParent == ArrayAccess.INDEX_PROPERTY || locationInParent == ThrowStatement.EXPRESSION_PROPERTY || locationInParent == SynchronizedStatement.EXPRESSION_PROPERTY || locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) { return false; } return true; }
@Override public void endVisit(AssertStatement node) { if (skipNode(node)) { return; } IfFlowInfo info = new IfFlowInfo(); setFlowInfo(node, info); info.mergeCondition(getFlowInfo(node.getExpression()), fFlowContext); info.merge(getFlowInfo(node.getMessage()), null, fFlowContext); }
@Override public void endVisit(AssertStatement node) { if (skipNode(node)) return; IfFlowInfo info= new IfFlowInfo(); setFlowInfo(node, info); info.mergeCondition(getFlowInfo(node.getExpression()), fFlowContext); info.merge(getFlowInfo(node.getMessage()), null, fFlowContext); }
private static Expression getBooleanExpression(ASTNode node) { if (!(node instanceof Expression)) { return null; } // check if the node is a location where it can be negated StructuralPropertyDescriptor locationInParent= node.getLocationInParent(); if (locationInParent == QualifiedName.NAME_PROPERTY) { node= node.getParent(); locationInParent= node.getLocationInParent(); } while (locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) { node= node.getParent(); locationInParent= node.getLocationInParent(); } Expression expression= (Expression) node; if (!isBoolean(expression)) { return null; } if (expression.getParent() instanceof InfixExpression) { return expression; } if (locationInParent == Assignment.RIGHT_HAND_SIDE_PROPERTY || locationInParent == IfStatement.EXPRESSION_PROPERTY || locationInParent == WhileStatement.EXPRESSION_PROPERTY || locationInParent == DoStatement.EXPRESSION_PROPERTY || locationInParent == ReturnStatement.EXPRESSION_PROPERTY || locationInParent == ForStatement.EXPRESSION_PROPERTY || locationInParent == AssertStatement.EXPRESSION_PROPERTY || locationInParent == MethodInvocation.ARGUMENTS_PROPERTY || locationInParent == ConstructorInvocation.ARGUMENTS_PROPERTY || locationInParent == SuperMethodInvocation.ARGUMENTS_PROPERTY || locationInParent == EnumConstantDeclaration.ARGUMENTS_PROPERTY || locationInParent == SuperConstructorInvocation.ARGUMENTS_PROPERTY || locationInParent == ClassInstanceCreation.ARGUMENTS_PROPERTY || locationInParent == ConditionalExpression.EXPRESSION_PROPERTY || locationInParent == PrefixExpression.OPERAND_PROPERTY) { return expression; } return null; }
@Override public boolean visit(AssertStatement node) { this.fBuffer.append("assert ");//$NON-NLS-1$ node.getExpression().accept(this); if (node.getMessage() != null) { this.fBuffer.append(" : ");//$NON-NLS-1$ node.getMessage().accept(this); } this.fBuffer.append(";");//$NON-NLS-1$ return false; }
public boolean visit(AssertStatement node) { printIndent(); this.buffer.append("assert ");//$NON-NLS-1$ node.getExpression().accept(this); if (node.getMessage() != null) { this.buffer.append(" : ");//$NON-NLS-1$ node.getMessage().accept(this); } this.buffer.append(";\n");//$NON-NLS-1$ return false; }
/** * We do not support assert. * * 'assert' Expression [ ':' Expression ] ';' */ @Override public boolean visit(final AssertStatement node) { // do not visit children return false; }
@Override public boolean visit(AssertStatement node) { //System.out.println("Found: " + node.getClass()); print("assert("); node.getExpression().accept(this); if (node.getMessage() != null) { print(", "); node.getMessage().accept(this); } println(");"); return false; }
@Override public boolean visit(AssertStatement node) { asserts.add(node); return super.visit(node); }
/** {@inheritDoc} */ @Override public void endVisit(AssertStatement node) { logger.warn("Method endVisitAssertStatement for " + node + " for " + node + " not implemented!"); super.endVisit(node); }
/** {@inheritDoc} */ @Override public boolean visit(AssertStatement node) { logger.warn("Method visitAssertStatement for " + node + " for " + node + " not implemented!"); return super.visit(node); }
@Override public boolean visit(final AssertStatement node) { return false; }
@Override public boolean visit(final AssertStatement node) { return this.visitInstrumentable(node); }
@Override public boolean visit(AssertStatement node) { if (node.subtreeMatch(fMatcher, fNodeToMatch)) return matches(node); return super.visit(node); }
@Override public boolean visit(AssertStatement node) { add(fCreator.create(node)); return true; }
@Override public void endVisit(AssertStatement node) { endVisitNode(node); }
@Override public boolean visit(AssertStatement node) { return visitNode(node); }
@Override public boolean visit(AssertStatement node) { return visit((Statement)node); }
@Override public void endVisit(AssertStatement node) { endVisit((Statement)node); }
@Override public boolean visit(final AssertStatement node) { return this.internalVisit(node); }
/** * This method allows to get all the Blocks for the Class on which it is; * * @return a List of all Blocks; */ public Collection<AssertStatement> getAsserts() { return asserts; }
/** * @param node the AST node * @return array of type constraints, may be empty * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.AssertStatement) */ public ITypeConstraint[] create(AssertStatement node) { return EMPTY_ARRAY; }
public boolean visit(AssertStatement node){return this.visitStatement(node);}