@Override public boolean visit(VariableDeclarationStatement node) { handleVariableDeclarations(node.fragments()); return true; }
@Override public boolean visit(VariableDeclarationStatement node) { handleToken((ASTNode) node.fragments().get(0), TokenNameIdentifier, true, false); handleCommas(node.fragments(), this.options.insert_space_before_comma_in_multiple_local_declarations, this.options.insert_space_after_comma_in_multiple_local_declarations); return true; }
@Override public boolean visit(VariableDeclarationStatement node) { handleToken((ASTNode) node.fragments().get(0), TokenNameIdentifier, true, false); handleCommas(node.fragments(), this.options.insert_space_before_comma_in_multiple_local_declarations, this.options.insert_space_after_comma_in_multiple_local_declarations); return true; }
@Override public boolean visit(VariableDeclarationStatement node) { handleToken((ASTNode) node.fragments().get(0), TokenNameIdentifier, true, false); handleCommas(node.fragments(), this.options.insert_space_before_comma_in_multiple_local_declarations, this.options.insert_space_after_comma_in_multiple_local_declarations); return true; }
private ArrayList<CAstNode> visit(VariableDeclarationStatement n, WalkContext context) { ArrayList<CAstNode> result = new ArrayList<>(); for (VariableDeclarationFragment o : (Iterable<VariableDeclarationFragment>) n.fragments()) result.add(visit(o, context)); return result; }
@Override public boolean visit(VariableDeclarationStatement node) { handleVariableDeclarations(node.fragments()); return true; }
private void alignDeclarations(List<Statement> statements) { List<List<VariableDeclarationStatement>> variableGroups = toAlignGroups(statements, n -> optionalCast(n, VariableDeclarationStatement.class)); this.alignGroups.addAll(variableGroups); AlignIndexFinder<VariableDeclarationStatement> nameFinder = vd -> findName( (VariableDeclarationFragment) vd.fragments().get(0)); variableGroups.forEach(vg -> alignNodes(vg, nameFinder)); AlignIndexFinder<VariableDeclarationStatement> assignFinder = vd -> findAssign( (VariableDeclarationFragment) vd.fragments().get(0)); variableGroups.forEach(vg -> alignNodes(vg, assignFinder)); }
@Override final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == MODIFIERS2_PROPERTY) { return modifiers(); } if (property == FRAGMENTS_PROPERTY) { return fragments(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }
final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == MODIFIERS2_PROPERTY) { return modifiers(); } if (property == FRAGMENTS_PROPERTY) { return fragments(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }
@Override public void endVisit(VariableDeclarationStatement node) { // TODO: in principle, no need to tie the VariableDeclarationFragments together. // The VariableDeclarationExpression can be split up when fragments get different types. // Warning: still need to connect fragments with type! endVisitFieldVariableDeclaration(node.getType(), node.fragments()); }
private void addLocalDeclarationRemoval(ASTRewrite rewrite) { VariableDeclarationStatement tempDeclarationStatement= getTempDeclarationStatement(); List fragments= tempDeclarationStatement.fragments(); int fragmentIndex= fragments.indexOf(fTempDeclarationNode); Assert.isTrue(fragmentIndex != -1); VariableDeclarationFragment fragment= (VariableDeclarationFragment)fragments.get(fragmentIndex); rewrite.remove(fragment, null); if (fragments.size() == 1) rewrite.remove(tempDeclarationStatement, null); }
private void addLocalDeclarationRemoval(ASTRewrite rewrite) { VariableDeclarationStatement tempDeclarationStatement= getTempDeclarationStatement(); List<VariableDeclarationFragment> fragments= tempDeclarationStatement.fragments(); int fragmentIndex= fragments.indexOf(fTempDeclarationNode); Assert.isTrue(fragmentIndex != -1); VariableDeclarationFragment fragment= fragments.get(fragmentIndex); rewrite.remove(fragment, null); if (fragments.size() == 1) rewrite.remove(tempDeclarationStatement, null); }
private static boolean isMultiDeclarationFragment(ASTNode node) { int nodeType= node.getNodeType(); if (nodeType == ASTNode.VARIABLE_DECLARATION_FRAGMENT) { node= node.getParent(); if (node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT) { VariableDeclarationStatement vs= (VariableDeclarationStatement)node; return vs.fragments().size() > 1; } } return false; }
private static boolean isMultiDeclarationFragment(ASTNode node) { int nodeType= node.getNodeType(); if (nodeType == ASTNode.VARIABLE_DECLARATION_FRAGMENT) { node= node.getParent(); if (node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT) { VariableDeclarationStatement vs= (VariableDeclarationStatement)node; return vs.fragments().size() > 1; } } return false; }
private VariableDeclarationStatement createLocalDeclaration(ITypeBinding type, String name, Expression initializer) { String typeName= fImportRewrite.addImport(type); VariableDeclarationStatement decl= (VariableDeclarationStatement)ASTNodeFactory.newStatement( fInvocation.getAST(), typeName + " " + name + ";"); //$NON-NLS-1$ //$NON-NLS-2$ ((VariableDeclarationFragment)decl.fragments().get(0)).setInitializer(initializer); return decl; }
/** * Makes the given statement final. * * @param statement the statment * @param rewrite the AST rewrite */ protected static void makeFinal(VariableDeclarationStatement statement, ASTRewrite rewrite) { VariableDeclaration fragment= (VariableDeclaration)statement.fragments().get(0); if (ASTNodes.findModifierNode(Modifier.FINAL, ASTNodes.getModifiers(fragment)) == null) { ModifierRewrite.create(rewrite, statement).setModifiers(Modifier.FINAL, Modifier.NONE, null); } }
/** * Make statement final * @param statement * @param rewrite */ protected static void makeFinal(VariableDeclarationStatement statement, ASTRewrite rewrite) { VariableDeclaration fragment= (VariableDeclaration)statement.fragments().get(0); if (ASTNodes.findModifierNode(Modifier.FINAL, ASTNodes.getModifiers(fragment)) == null) { ModifierRewrite.create(rewrite, statement).setModifiers(Modifier.FINAL, Modifier.NONE, null); } }
private VariableDeclarationStatement createLocalDeclaration(ITypeBinding type, String name, Expression initializer) { ImportRewriteContext context= new ContextSensitiveImportRewriteContext(fTargetNode, fImportRewrite); String typeName= fImportRewrite.addImport(type, context); VariableDeclarationStatement decl= (VariableDeclarationStatement)ASTNodeFactory.newStatement( fInvocation.getAST(), typeName + " " + name + ";"); //$NON-NLS-1$ //$NON-NLS-2$ ((VariableDeclarationFragment)decl.fragments().get(0)).setInitializer(initializer); return decl; }
@Override public void endVisit(VariableDeclarationStatement node) { if (skipNode(node)) { return; } GenericSequentialFlowInfo info = processSequential(node, node.getType()); process(info, node.fragments()); }
@Override public void endVisit(VariableDeclarationStatement node) { if (skipNode(node)) return; GenericSequentialFlowInfo info= processSequential(node, node.getType()); process(info, node.fragments()); }