List of usage examples for org.eclipse.jdt.core.dom ClassInstanceCreation typeArguments
ASTNode.NodeList typeArguments
To view the source code for org.eclipse.jdt.core.dom ClassInstanceCreation typeArguments.
Click Source Link
From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
@Override public boolean visit(ClassInstanceCreation node) { if (node.getExpression() != null) { node.getExpression().accept(this); this.fBuffer.append(".");//$NON-NLS-1$ }/*from w ww .ja va2 s. c o m*/ this.fBuffer.append("new ");//$NON-NLS-1$ if (node.getAST().apiLevel() >= JLS3) { if (!node.typeArguments().isEmpty()) { this.fBuffer.append("<");//$NON-NLS-1$ for (Iterator<Type> it = node.typeArguments().iterator(); it.hasNext();) { Type t = it.next(); t.accept(this); if (it.hasNext()) { this.fBuffer.append(",");//$NON-NLS-1$ } } this.fBuffer.append(">");//$NON-NLS-1$ } node.getType().accept(this); } this.fBuffer.append("(");//$NON-NLS-1$ for (Iterator<Expression> it = node.arguments().iterator(); it.hasNext();) { Expression e = it.next(); e.accept(this); if (it.hasNext()) { this.fBuffer.append(",");//$NON-NLS-1$ } } this.fBuffer.append(")");//$NON-NLS-1$ if (node.getAnonymousClassDeclaration() != null) { node.getAnonymousClassDeclaration().accept(this); } return false; }
From source file:boa.datagen.util.Java7Visitor.java
License:Apache License
@Override public boolean visit(ClassInstanceCreation node) { boa.types.Ast.Expression.Builder b = boa.types.Ast.Expression.newBuilder(); // b.setPosition(pos.build()); b.setKind(boa.types.Ast.Expression.ExpressionKind.NEW); boa.types.Ast.Type.Builder tb = boa.types.Ast.Type.newBuilder(); tb.setName(getIndex(typeName(node.getType()))); tb.setKind(boa.types.Ast.TypeKind.CLASS); b.setNewType(tb.build());/* w w w .jav a 2 s .c o m*/ for (Object t : node.typeArguments()) { boa.types.Ast.Type.Builder gtb = boa.types.Ast.Type.newBuilder(); gtb.setName(getIndex(typeName((org.eclipse.jdt.core.dom.Type) t))); gtb.setKind(boa.types.Ast.TypeKind.GENERIC); b.addGenericParameters(gtb.build()); } if (node.getExpression() != null) { node.getExpression().accept(this); b.addExpressions(expressions.pop()); } for (Object a : node.arguments()) { ((org.eclipse.jdt.core.dom.Expression) a).accept(this); b.addExpressions(expressions.pop()); } if (node.getAnonymousClassDeclaration() != null) { declarations.push(new ArrayList<boa.types.Ast.Declaration>()); node.getAnonymousClassDeclaration().accept(this); for (boa.types.Ast.Declaration d : declarations.pop()) b.setAnonDeclaration(d); } expressions.push(b.build()); return false; }
From source file:coloredide.utils.CopiedNaiveASTFlattener.java
License:Open Source License
public boolean visit(ClassInstanceCreation node) { if (node.getExpression() != null) { node.getExpression().accept(this); this.buffer.append(".");//$NON-NLS-1$ }/*from w w w . j a va2 s . c o m*/ this.buffer.append("new ");//$NON-NLS-1$ if (node.getAST().apiLevel() >= AST.JLS3) { if (!node.typeArguments().isEmpty()) { this.buffer.append("<");//$NON-NLS-1$ for (Iterator it = node.typeArguments().iterator(); it.hasNext();) { Type t = (Type) it.next(); t.accept(this); if (it.hasNext()) { this.buffer.append(",");//$NON-NLS-1$ } } this.buffer.append(">");//$NON-NLS-1$ } node.getType().accept(this); } this.buffer.append("(");//$NON-NLS-1$ for (Iterator it = node.arguments().iterator(); it.hasNext();) { Expression e = (Expression) it.next(); e.accept(this); if (it.hasNext()) { this.buffer.append(",");//$NON-NLS-1$ } } this.buffer.append(")");//$NON-NLS-1$ if (node.getAnonymousClassDeclaration() != null) { node.getAnonymousClassDeclaration().accept(this); } return false; }
From source file:com.bsiag.eclipse.jdt.java.formatter.SpacePreparator.java
License:Open Source License
@Override public boolean visit(ClassInstanceCreation node) { List<Type> typeArguments = node.typeArguments(); handleTypeArguments(typeArguments);/* w w w . ja v a 2 s . c o m*/ handleInvocation(node, node.getType(), node.getAnonymousClassDeclaration()); if (!typeArguments.isEmpty()) { handleTokenBefore(typeArguments.get(0), TokenNamenew, false, true); // fix for: new<Integer>A<String>() } handleCommas(node.arguments(), this.options.insert_space_before_comma_in_allocation_expression, this.options.insert_space_after_comma_in_allocation_expression); return true; }
From source file:com.google.googlejavaformat.java.JavaInputAstVisitor.java
License:Apache License
/** Visitor method for {@link ClassInstanceCreation}s. */ @Override// ww w . ja v a 2s.c o m public boolean visit(ClassInstanceCreation node) { sync(node); builder.open(ZERO); if (node.getExpression() != null) { node.getExpression().accept(this); builder.breakOp(); token("."); } token("new"); builder.space(); addTypeArguments(node.typeArguments(), plusFour); node.getType().accept(this); addArguments(node.arguments(), plusFour); builder.close(); if (node.getAnonymousClassDeclaration() != null) { visit(node.getAnonymousClassDeclaration()); } return false; }
From source file:lang.java.jdt.internal.JdtAstToRascalAstConverter.java
License:Open Source License
public boolean visit(ClassInstanceCreation node) { IValue expression = node.getExpression() == null ? null : visitChild(node.getExpression()); IValue type = null;//from www. j a va 2 s . c o m IValueList genericTypes = new IValueList(values); if (node.getAST().apiLevel() == AST.JLS2) { type = visitChild(node.getName()); } else { type = visitChild(node.getType()); if (!node.typeArguments().isEmpty()) { for (Iterator it = node.typeArguments().iterator(); it.hasNext();) { Type t = (Type) it.next(); genericTypes.add(visitChild(t)); } } } IValueList arguments = new IValueList(values); for (Iterator it = node.arguments().iterator(); it.hasNext();) { Expression e = (Expression) it.next(); arguments.add(visitChild(e)); } IValue anonymousClassDeclaration = node.getAnonymousClassDeclaration() == null ? null : visitChild(node.getAnonymousClassDeclaration()); ownValue = constructRascalNode(node, optional(expression), type, genericTypes.asList(), arguments.asList(), optional(anonymousClassDeclaration)); return false; }
From source file:org.codemucker.jmutate.ast.JAstFlattener.java
License:Open Source License
public boolean visit(ClassInstanceCreation node) { if (node.getExpression() != null) { node.getExpression().accept(this); this.buffer.append(".");//$NON-NLS-1$ }// w w w . j a v a 2 s. c o m this.buffer.append("new ");//$NON-NLS-1$ if (node.getAST().apiLevel() == JLS2) { getName(node).accept(this); } if (node.getAST().apiLevel() >= JLS3) { if (!node.typeArguments().isEmpty()) { this.buffer.append("<");//$NON-NLS-1$ for (Iterator it = node.typeArguments().iterator(); it.hasNext();) { Type t = (Type) it.next(); t.accept(this); if (it.hasNext()) { this.buffer.append(",");//$NON-NLS-1$ } } this.buffer.append(">");//$NON-NLS-1$ } node.getType().accept(this); } this.buffer.append("(");//$NON-NLS-1$ for (Iterator it = node.arguments().iterator(); it.hasNext();) { Expression e = (Expression) it.next(); e.accept(this); if (it.hasNext()) { this.buffer.append(",");//$NON-NLS-1$ } } this.buffer.append(")");//$NON-NLS-1$ if (node.getAnonymousClassDeclaration() != null) { node.getAnonymousClassDeclaration().accept(this); } return false; }
From source file:org.eclipse.emf.texo.generator.ImportReferenceCollector.java
License:Open Source License
@Override public boolean visit(final ClassInstanceCreation node) { doVisitChildren(node.typeArguments()); doVisitNode(node.getType());//from ww w . ja v a 2s. c o m evalQualifyingExpression(node.getExpression(), null); if (node.getAnonymousClassDeclaration() != null) { node.getAnonymousClassDeclaration().accept(this); } doVisitChildren(node.arguments()); return false; }
From source file:org.eclipse.jdt.core.dom.ASTConverter.java
License:Open Source License
public ClassInstanceCreation convert(org.eclipse.jdt.internal.compiler.ast.AllocationExpression expression) { ClassInstanceCreation classInstanceCreation = new ClassInstanceCreation(this.ast); if (this.resolveBindings) { recordNodes(classInstanceCreation, expression); }//from w w w .j a v a 2 s . c o m if (expression.typeArguments != null) { switch (this.ast.apiLevel) { case AST.JLS2_INTERNAL: classInstanceCreation.setFlags(classInstanceCreation.getFlags() | ASTNode.MALFORMED); break; default: for (int i = 0, max = expression.typeArguments.length; i < max; i++) { classInstanceCreation.typeArguments().add(convertType(expression.typeArguments[i])); } } } switch (this.ast.apiLevel) { case AST.JLS2_INTERNAL: classInstanceCreation.internalSetName(convert(expression.type)); break; default: classInstanceCreation.setType(convertType(expression.type)); } classInstanceCreation.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1); org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = expression.arguments; if (arguments != null) { int length = arguments.length; for (int i = 0; i < length; i++) { classInstanceCreation.arguments().add(convert(arguments[i])); } } removeTrailingCommentFromExpressionEndingWithAParen(classInstanceCreation); return classInstanceCreation; }
From source file:org.eclipse.jdt.core.dom.ASTConverter.java
License:Open Source License
public Expression convert(org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression allocation) { final ClassInstanceCreation classInstanceCreation = new ClassInstanceCreation(this.ast); if (allocation.enclosingInstance != null) { classInstanceCreation.setExpression(convert(allocation.enclosingInstance)); }// w w w. j a va 2 s .c o m switch (this.ast.apiLevel) { case AST.JLS2_INTERNAL: classInstanceCreation.internalSetName(convert(allocation.type)); break; default: classInstanceCreation.setType(convertType(allocation.type)); } org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = allocation.arguments; if (arguments != null) { int length = arguments.length; for (int i = 0; i < length; i++) { Expression argument = convert(arguments[i]); if (this.resolveBindings) { recordNodes(argument, arguments[i]); } classInstanceCreation.arguments().add(argument); } } if (allocation.typeArguments != null) { switch (this.ast.apiLevel) { case AST.JLS2_INTERNAL: classInstanceCreation.setFlags(classInstanceCreation.getFlags() | ASTNode.MALFORMED); break; default: for (int i = 0, max = allocation.typeArguments.length; i < max; i++) { classInstanceCreation.typeArguments().add(convertType(allocation.typeArguments[i])); } } } if (allocation.anonymousType != null) { int declarationSourceStart = allocation.sourceStart; classInstanceCreation.setSourceRange(declarationSourceStart, allocation.anonymousType.bodyEnd - declarationSourceStart + 1); final AnonymousClassDeclaration anonymousClassDeclaration = new AnonymousClassDeclaration(this.ast); int start = retrieveStartBlockPosition(allocation.anonymousType.sourceEnd, allocation.anonymousType.bodyEnd); anonymousClassDeclaration.setSourceRange(start, allocation.anonymousType.bodyEnd - start + 1); classInstanceCreation.setAnonymousClassDeclaration(anonymousClassDeclaration); buildBodyDeclarations(allocation.anonymousType, anonymousClassDeclaration); if (this.resolveBindings) { recordNodes(classInstanceCreation, allocation.anonymousType); recordNodes(anonymousClassDeclaration, allocation.anonymousType); anonymousClassDeclaration.resolveBinding(); } return classInstanceCreation; } else { final int start = allocation.sourceStart; classInstanceCreation.setSourceRange(start, allocation.sourceEnd - start + 1); if (this.resolveBindings) { recordNodes(classInstanceCreation, allocation); } removeTrailingCommentFromExpressionEndingWithAParen(classInstanceCreation); return classInstanceCreation; } }