List of usage examples for org.eclipse.jdt.core.dom VariableDeclarationExpression getType
public Type getType()
From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
@Override public boolean visit(VariableDeclarationExpression node) { if (node.getAST().apiLevel() >= JLS3) { printModifiers(node.modifiers()); }/*w ww .ja v a 2 s .co m*/ node.getType().accept(this); this.fBuffer.append(" ");//$NON-NLS-1$ for (Iterator<VariableDeclarationFragment> it = node.fragments().iterator(); it.hasNext();) { VariableDeclarationFragment f = it.next(); f.accept(this); if (it.hasNext()) { this.fBuffer.append(", ");//$NON-NLS-1$ } } return false; }
From source file:boa.datagen.util.Java7Visitor.java
License:Apache License
@Override public boolean visit(VariableDeclarationExpression node) { boa.types.Ast.Expression.Builder eb = boa.types.Ast.Expression.newBuilder(); // eb.setPosition(pos.build()); eb.setKind(boa.types.Ast.Expression.ExpressionKind.VARDECL); for (Object o : node.fragments()) { VariableDeclarationFragment f = (VariableDeclarationFragment) o; Variable.Builder b = Variable.newBuilder(); // b.setPosition(pos.build());//FIXME b.setName(f.getName().getFullyQualifiedName()); for (Object m : node.modifiers()) { if (((IExtendedModifier) m).isAnnotation()) ((Annotation) m).accept(this); else/*from w w w. ja va 2s . c o m*/ ((org.eclipse.jdt.core.dom.Modifier) m).accept(this); b.addModifiers(modifiers.pop()); } boa.types.Ast.Type.Builder tb = boa.types.Ast.Type.newBuilder(); String name = typeName(node.getType()); for (int i = 0; i < f.getExtraDimensions(); i++) name += "[]"; tb.setName(getIndex(name)); tb.setKind(boa.types.Ast.TypeKind.OTHER); b.setVariableType(tb.build()); if (f.getInitializer() != null) { f.getInitializer().accept(this); b.setInitializer(expressions.pop()); } eb.addVariableDecls(b.build()); } expressions.push(eb.build()); return false; }
From source file:chibi.gumtreediff.gen.jdt.cd.CdJdtVisitor.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from ww w .j ava 2 s .co m public boolean visit(VariableDeclarationExpression node) { pushNode(node, ""); visitListAsNode(EntityType.MODIFIERS, node.modifiers()); node.getType().accept(this); visitListAsNode(EntityType.FRAGMENTS, node.fragments()); return false; }
From source file:coloredide.utils.CopiedNaiveASTFlattener.java
License:Open Source License
public boolean visit(VariableDeclarationExpression node) { if (node.getAST().apiLevel() >= AST.JLS3) { printModifiers(node.modifiers()); }/*from w ww . j av a 2s .co m*/ node.getType().accept(this); this.buffer.append(" ");//$NON-NLS-1$ for (Iterator it = node.fragments().iterator(); it.hasNext();) { VariableDeclarationFragment f = (VariableDeclarationFragment) it.next(); f.accept(this); if (it.hasNext()) { this.buffer.append(", ");//$NON-NLS-1$ } } return false; }
From source file:com.bsiag.eclipse.jdt.java.formatter.SpacePreparator.java
License:Open Source License
@Override public boolean visit(VariableDeclarationExpression node) { ASTNode parent = node.getParent();/*from w ww. j a va 2s . co m*/ if (parent instanceof ForStatement) { handleCommas(node.fragments(), this.options.insert_space_before_comma_in_for_inits, this.options.insert_space_after_comma_in_for_inits); } else if (parent instanceof ExpressionStatement) { handleCommas(node.fragments(), this.options.insert_space_before_comma_in_multiple_local_declarations, this.options.insert_space_after_comma_in_multiple_local_declarations); } this.tm.firstTokenAfter(node.getType(), -1).spaceBefore(); return true; }
From source file:com.google.dart.java2dart.SyntaxTranslator.java
License:Open Source License
@Override public boolean visit(org.eclipse.jdt.core.dom.ForStatement node) { Expression condition = translateExpression(node.getExpression()); List<Expression> updaters = translateExpressionList(node.updaters()); Statement body = (Statement) translate(node.getBody()); Object javaInitializer = !node.initializers().isEmpty() ? node.initializers().get(0) : null; if (javaInitializer instanceof org.eclipse.jdt.core.dom.VariableDeclarationExpression) { org.eclipse.jdt.core.dom.VariableDeclarationExpression javaVDE = (org.eclipse.jdt.core.dom.VariableDeclarationExpression) javaInitializer; List<VariableDeclaration> variables = Lists.newArrayList(); for (Iterator<?> I = javaVDE.fragments().iterator(); I.hasNext();) { org.eclipse.jdt.core.dom.VariableDeclarationFragment fragment = (org.eclipse.jdt.core.dom.VariableDeclarationFragment) I .next();/*ww w . j ava 2s . co m*/ variables.add((VariableDeclaration) translate(fragment)); } VariableDeclarationList variableList = variableDeclarationList(null, (TypeName) translate(javaVDE.getType()), variables); return done(forStatement(variableList, condition, updaters, body)); } else { Expression initializer = translate((org.eclipse.jdt.core.dom.ASTNode) javaInitializer); return done(forStatement(initializer, condition, updaters, body)); } }
From source file:com.google.devtools.j2cpp.gen.CppStatementGenerator.java
License:Open Source License
@Override public boolean visit(VariableDeclarationExpression node) { buffer.append(NameTable.javaRefToCpp(node.getType())); buffer.append(" "); for (Iterator<?> it = node.fragments().iterator(); it.hasNext();) { VariableDeclarationFragment f = (VariableDeclarationFragment) it.next(); f.accept(this); if (it.hasNext()) { buffer.append(", "); }// w w w .j a va2 s . co m } return false; }
From source file:com.google.devtools.j2cpp.types.ImplementationImportCollector.java
License:Open Source License
@Override public boolean visit(VariableDeclarationExpression node) { Type type = node.getType(); addReference(type);// ww w .j av a2 s . c o m return super.visit(node); }
From source file:com.google.devtools.j2objc.ast.DebugASTPrinter.java
License:Apache License
@Override public boolean visit(VariableDeclarationExpression node) { printModifiers(node.getTypeBinding().getModifiers()); node.getType().accept(this); sb.print(' '); for (Iterator<VariableDeclarationFragment> it = node.getFragments().iterator(); it.hasNext();) { it.next().accept(this); if (it.hasNext()) { sb.print(", "); }//from ww w.ja v a 2 s . c o m } return false; }
From source file:com.google.googlejavaformat.java.JavaInputAstVisitor.java
License:Apache License
/** Visitor method for {@link VariableDeclarationExpression}s. */ @Override/*from www .j av a 2s .c o m*/ public boolean visit(VariableDeclarationExpression node) { sync(node); builder.open(plusFour); // TODO(jdd): Why no use common method? for (IExtendedModifier modifier : (List<IExtendedModifier>) node.modifiers()) { ((ASTNode) modifier).accept(this); builder.breakToFill(" "); } node.getType().accept(this); if (node.fragments().size() == 1) { builder.breakToFill(" "); visit((VariableDeclarationFragment) node.fragments().get(0)); } else { // TODO(jdd): Are the indentations consistent here? builder.breakToFill(" "); builder.open(plusFour); boolean first = true; for (VariableDeclarationFragment fragment : (List<VariableDeclarationFragment>) node.fragments()) { if (!first) { token(","); builder.breakToFill(" "); } visit(fragment); first = false; } builder.close(); } builder.close(); return false; }