List of usage examples for org.eclipse.jdt.core.dom ClassInstanceCreation arguments
ASTNode.NodeList arguments
To view the source code for org.eclipse.jdt.core.dom ClassInstanceCreation arguments.
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$ }// w w w . ja v a2s .c om 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. j a v 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:ca.mcgill.cs.swevo.ppa.inference.ConstructorInferenceStrategy.java
License:Open Source License
@Override public List<PPAIndex> getSecondaryIndexes(ASTNode node) { List<PPAIndex> indexes = super.getSecondaryIndexes(node); ClassInstanceCreation cic = (ClassInstanceCreation) node; // TODO (and to propagate to other parts of PPA // use of constructors for internal classes... // ASTNode container = PPAASTUtil.getContainer(mi); // if (indexer.isIndexable(container)) { // indexes.add(indexer.getMainIndex(container)); // }/*from ww w.j ava2s .c o m*/ for (Object arg : cic.arguments()) { ASTNode argNode = (ASTNode) arg; if (indexer.isIndexable(argNode)) { indexes.add(indexer.getMainIndex(argNode)); } } return indexes; }
From source file:ca.mcgill.cs.swevo.ppa.PPAASTUtil.java
License:Open Source License
public static boolean isIndicationOfField(Name node) { boolean isField = false; ASTNode parent = node.getParent();// ww w. j av a2 s .c o m // The thing here is that if the parent is a qualified name, go one // level up. // If the parent is still a qualified name, then, it means we were in // the middle, so this is // not necessarily a field. if (parent instanceof QualifiedName) { QualifiedName qName = (QualifiedName) parent; if (qName.getName().equals(node)) { node = (Name) parent; parent = parent.getParent(); } } if (parent instanceof ArrayAccess) { isField = true; // } else if (parent instanceof ArrayCreation) { // isField = true; } else if (parent instanceof ArrayInitializer) { isField = true; } else if (parent instanceof Assignment) { isField = true; } else if (parent instanceof CastExpression) { CastExpression cExpression = (CastExpression) parent; isField = cExpression.getExpression().equals(node); } else if (parent instanceof ConditionalExpression) { isField = true; } else if (parent instanceof InfixExpression) { isField = true; } else if (parent instanceof WhileStatement) { isField = true; } else if (parent instanceof DoStatement) { isField = true; } else if (parent instanceof ForStatement) { ForStatement forStatement = (ForStatement) parent; isField = forStatement.getExpression().equals(node); } else if (parent instanceof PrefixExpression) { isField = true; } else if (parent instanceof PostfixExpression) { isField = true; } else if (parent instanceof ReturnStatement) { isField = true; } else if (parent instanceof InstanceofExpression) { InstanceofExpression ioe = (InstanceofExpression) parent; isField = ioe.getLeftOperand().equals(node); } else if (parent instanceof FieldAccess) { isField = true; } else if (parent instanceof SuperFieldAccess) { isField = true; } else if (parent instanceof MethodInvocation) { MethodInvocation mi = (MethodInvocation) parent; for (Object object : mi.arguments()) { if (node == object) { isField = true; break; } } } else if (parent instanceof ClassInstanceCreation) { ClassInstanceCreation cic = (ClassInstanceCreation) parent; for (Object object : cic.arguments()) { if (node == object) { isField = true; break; } } } else if (parent instanceof VariableDeclarationFragment) { isField = true; } return isField; }
From source file:ch.acanda.eclipse.pmd.java.resolution.migration.ByteInstantiationAutoboxingQuickFix.java
License:Open Source License
/** * Replaces the Byte instantiation with its argument, e.g. {@code new Byte(123 + x)} with {@code 123 + x}. *//*from w ww . j a v a2 s . com*/ @Override protected boolean apply(final ClassInstanceCreation node) { final Expression argument = (Expression) node.arguments().get(0); replace(node, copy(argument)); return true; }
From source file:ch.acanda.eclipse.pmd.java.resolution.migration.ByteInstantiationValueOfQuickFix.java
License:Open Source License
/** * Replaces the Byte instantiation with its argument, e.g. {@code new Byte(123 + x)} with * {@code Byte.valueOf(123 + x)}.//from w w w. jav a 2s .c o m */ @Override @SuppressWarnings("unchecked") protected boolean apply(final ClassInstanceCreation node) { final AST ast = node.getAST(); final MethodInvocation invocation = ast.newMethodInvocation(); invocation.setExpression(ast.newSimpleName("Byte")); invocation.setName(ast.newSimpleName("valueOf")); invocation.arguments().add(copy((Expression) node.arguments().get(0))); replace(node, invocation); return true; }
From source file:ch.acanda.eclipse.pmd.java.resolution.migration.IntegerInstantiationValueOfQuickFix.java
License:Open Source License
/** * Replaces the Integer instantiation with its argument, e.g. {@code new Integer(123 + x)} with * {@code Integer.valueOf(123 + x)}.//from w w w . j ava2s . co m */ @Override @SuppressWarnings("unchecked") protected boolean apply(final ClassInstanceCreation node) { final AST ast = node.getAST(); final MethodInvocation invocation = ast.newMethodInvocation(); invocation.setExpression(ast.newSimpleName("Integer")); invocation.setName(ast.newSimpleName("valueOf")); invocation.arguments().add(copy((Expression) node.arguments().get(0))); replace(node, invocation); return true; }
From source file:ch.acanda.eclipse.pmd.java.resolution.migration.LongInstantiationValueOfQuickFix.java
License:Open Source License
/** * Replaces the Long instantiation with its argument, e.g. {@code new Long(123 + x)} with * {@code Long.valueOf(123 + x)}./*w ww . j a v a 2s . c o m*/ */ @Override @SuppressWarnings("unchecked") protected boolean apply(final ClassInstanceCreation node) { final AST ast = node.getAST(); final MethodInvocation invocation = ast.newMethodInvocation(); invocation.setExpression(ast.newSimpleName("Long")); invocation.setName(ast.newSimpleName("valueOf")); invocation.arguments().add(copy((Expression) node.arguments().get(0))); replace(node, invocation); return true; }
From source file:ch.acanda.eclipse.pmd.java.resolution.migration.ShortInstantiationValueOfQuickFix.java
License:Open Source License
/** * Replaces the Short instantiation with its argument, e.g. {@code new Short(123 + x)} with * {@code Short.valueOf(123 + x)}./* w w w .j a v a 2s .c o m*/ */ @Override @SuppressWarnings("unchecked") protected boolean apply(final ClassInstanceCreation node) { final AST ast = node.getAST(); final MethodInvocation invocation = ast.newMethodInvocation(); invocation.setExpression(ast.newSimpleName("Short")); invocation.setName(ast.newSimpleName("valueOf")); invocation.arguments().add(copy((Expression) node.arguments().get(0))); replace(node, invocation); return true; }
From source file:cn.ieclipse.adt.ext.jdt.SourceGenerator.java
License:Apache License
private static void rewriteOnCreate(CompilationUnit unit, String dbName, List<String> tableCreators) { AST ast = unit.getAST();/*from w w w.j av a 2s .c o m*/ TypeDeclaration type = (TypeDeclaration) unit.types().get(0); MethodDeclaration onCreate = getMethod(type, ("onCreate"), null); if (onCreate != null) { Block methodBlock = ast.newBlock(); // mOpenHelper = new // InlineOpenHelper(this.getContext(),"person.db",null,1); Assignment a = ast.newAssignment(); a.setOperator(Assignment.Operator.ASSIGN); a.setLeftHandSide(ast.newSimpleName("mOpenHelper")); ClassInstanceCreation cc = ast.newClassInstanceCreation(); cc.setType(ast.newSimpleType(ast.newSimpleName("SQLiteOpenHelper"))); ThisExpression thisExp = ast.newThisExpression(); MethodInvocation mi = ast.newMethodInvocation(); mi.setName(ast.newSimpleName("getContext")); mi.setExpression(thisExp); cc.arguments().add(mi); StringLiteral sl = ast.newStringLiteral(); sl.setLiteralValue(dbName); cc.arguments().add(sl); cc.arguments().add(ast.newNullLiteral()); cc.arguments().add(ast.newNumberLiteral("1")); a.setRightHandSide(cc); methodBlock.statements().add(ast.newExpressionStatement(a)); AnonymousClassDeclaration acd = ast.newAnonymousClassDeclaration(); cc.setAnonymousClassDeclaration(acd); genInnerSQLiteOpenHelper(acd, ast, tableCreators); a = ast.newAssignment(); a.setOperator(Assignment.Operator.ASSIGN); a.setLeftHandSide(ast.newSimpleName("session")); ClassInstanceCreation cic = ast.newClassInstanceCreation(); cic.setType(ast.newSimpleType(ast.newSimpleName("Session"))); // SingleVariableDeclaration svd = // ast.newSingleVariableDeclaration(); // svd.setName(ast.newSimpleName("mOpenHelper")); cic.arguments().add(ast.newSimpleName("mOpenHelper")); // vdf.setInitializer(cic); a.setRightHandSide(cic); // methodBlock.statements().add(vde); methodBlock.statements().add(ast.newExpressionStatement(a)); ReturnStatement returnStmt = ast.newReturnStatement(); returnStmt.setExpression(ast.newBooleanLiteral(true)); methodBlock.statements().add(returnStmt); onCreate.setBody(methodBlock); } }