Java Code Examples for org.eclipse.jdt.core.dom.ClassInstanceCreation#setType()

The following examples show how to use org.eclipse.jdt.core.dom.ClassInstanceCreation#setType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConvertAnonymousToNestedRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private ASTNode createNewClassInstanceCreation(CompilationUnitRewrite rewrite, ITypeBinding[] parameters) {
	AST ast= fAnonymousInnerClassNode.getAST();
	ClassInstanceCreation newClassCreation= ast.newClassInstanceCreation();
	newClassCreation.setAnonymousClassDeclaration(null);
	Type type= null;
	SimpleName newNameNode= ast.newSimpleName(fClassName);
	if (parameters.length > 0) {
		final ParameterizedType parameterized= ast.newParameterizedType(ast.newSimpleType(newNameNode));
		for (int index= 0; index < parameters.length; index++)
			parameterized.typeArguments().add(ast.newSimpleType(ast.newSimpleName(parameters[index].getName())));
		type= parameterized;
	} else
		type= ast.newSimpleType(newNameNode);
	newClassCreation.setType(type);
	copyArguments(rewrite, newClassCreation);
	addArgumentsForLocalsUsedInInnerClass(newClassCreation);

	addLinkedPosition(KEY_TYPE_NAME, newNameNode, rewrite.getASTRewrite(), true);

	return newClassCreation;
}
 
Example 2
Source File: IntroduceFactoryRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Sets the type being instantiated in the given constructor call, including
    * specifying any necessary type arguments.
 * @param newCtorCall the constructor call to modify
 * @param ctorTypeName the simple name of the type being instantiated
 * @param ctorOwnerTypeParameters the formal type parameters of the type being
 * instantiated
 * @param ast utility object used to create AST nodes
 */
private void setCtorTypeArguments(ClassInstanceCreation newCtorCall, String ctorTypeName, ITypeBinding[] ctorOwnerTypeParameters, AST ast) {
       if (ctorOwnerTypeParameters.length == 0) // easy, just a simple type
           newCtorCall.setType(ASTNodeFactory.newType(ast, ctorTypeName));
       else {
           Type baseType= ast.newSimpleType(ast.newSimpleName(ctorTypeName));
           ParameterizedType newInstantiatedType= ast.newParameterizedType(baseType);
           List<Type> newInstTypeArgs= newInstantiatedType.typeArguments();

           for(int i= 0; i < ctorOwnerTypeParameters.length; i++) {
               Type typeArg= ASTNodeFactory.newType(ast, ctorOwnerTypeParameters[i].getName());

               newInstTypeArgs.add(typeArg);
           }
           newCtorCall.setType(newInstantiatedType);
       }
}
 
Example 3
Source File: StringFormatGenerator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Expression createMemberAccessExpression(Object member, boolean ignoreArraysCollections, boolean ignoreNulls) {
	ITypeBinding type= getMemberType(member);
	if (!getContext().is50orHigher() && type.isPrimitive()) {
		String nonPrimitiveType= null;
		String typeName= type.getName();
		if (typeName.equals("byte"))nonPrimitiveType= "java.lang.Byte"; //$NON-NLS-1$ //$NON-NLS-2$
		if (typeName.equals("short"))nonPrimitiveType= "java.lang.Short"; //$NON-NLS-1$ //$NON-NLS-2$
		if (typeName.equals("char"))nonPrimitiveType= "java.lang.Character"; //$NON-NLS-1$ //$NON-NLS-2$
		if (typeName.equals("int"))nonPrimitiveType= "java.lang.Integer"; //$NON-NLS-1$ //$NON-NLS-2$
		if (typeName.equals("long"))nonPrimitiveType= "java.lang.Long"; //$NON-NLS-1$ //$NON-NLS-2$
		if (typeName.equals("float"))nonPrimitiveType= "java.lang.Float"; //$NON-NLS-1$ //$NON-NLS-2$
		if (typeName.equals("double"))nonPrimitiveType= "java.lang.Double"; //$NON-NLS-1$ //$NON-NLS-2$
		if (typeName.equals("boolean"))nonPrimitiveType= "java.lang.Boolean"; //$NON-NLS-1$ //$NON-NLS-2$
		ClassInstanceCreation classInstance= fAst.newClassInstanceCreation();
		classInstance.setType(fAst.newSimpleType(addImport(nonPrimitiveType)));
		classInstance.arguments().add(super.createMemberAccessExpression(member, true, true));
		return classInstance;
	}
	return super.createMemberAccessExpression(member, ignoreArraysCollections, ignoreNulls);
}
 
Example 4
Source File: BuildMethodBodyCreatorFragment.java    From SparkBuilderGenerator with MIT License 5 votes vote down vote up
public Block createBody(AST ast, TypeDeclaration originalType) {
    ClassInstanceCreation newClassInstanceCreation = ast.newClassInstanceCreation();
    newClassInstanceCreation.setType(ast.newSimpleType(ast.newName(originalType.getName().toString())));
    newClassInstanceCreation.arguments().add(ast.newThisExpression());

    ReturnStatement statement = ast.newReturnStatement();
    statement.setExpression(newClassInstanceCreation);

    Block block = ast.newBlock();
    block.statements().add(statement);
    return block;
}
 
Example 5
Source File: EnsuresPredicateFix.java    From CogniCrypt with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * This method builds a {@link ClassInstanceCreation} object (i.e. "new Ensuerer(varName, predicate")
 * 
 * @param ast
 * @param varName
 * @param predicate
 * @return
 */
private ClassInstanceCreation createEnsurerClassInstance(final AST ast, String varName, String predicate) {
	final ClassInstanceCreation classInstance = ast.newClassInstanceCreation();
	classInstance.setType(createAstType(INJAR_CLASS_NAME, ast));
	final StringLiteral literalPredicate = ast.newStringLiteral();
	literalPredicate.setLiteralValue(predicate);
	classInstance.arguments().add(ast.newSimpleName(varName));
	classInstance.arguments().add(literalPredicate);

	return classInstance;
}
 
Example 6
Source File: NewBuilderAndWithMethodCallCreationFragment.java    From SparkBuilderGenerator with MIT License 5 votes vote down vote up
public Block createReturnBlock(AST ast, TypeDeclaration builderType, String withName, String parameterName) {
    Block builderMethodBlock = ast.newBlock();
    ReturnStatement returnStatement = ast.newReturnStatement();
    ClassInstanceCreation newClassInstanceCreation = ast.newClassInstanceCreation();
    newClassInstanceCreation.setType(ast.newSimpleType(ast.newName(builderType.getName().toString())));

    MethodInvocation withMethodInvocation = ast.newMethodInvocation();
    withMethodInvocation.setExpression(newClassInstanceCreation);
    withMethodInvocation.setName(ast.newSimpleName(withName));
    withMethodInvocation.arguments().add(ast.newSimpleName(parameterName));

    returnStatement.setExpression(withMethodInvocation);
    builderMethodBlock.statements().add(returnStatement);
    return builderMethodBlock;
}
 
Example 7
Source File: BlockWithNewBuilderCreationFragment.java    From SparkBuilderGenerator with MIT License 5 votes vote down vote up
public Block createReturnBlock(AST ast, TypeDeclaration builderType) {
    Block builderMethodBlock = ast.newBlock();
    ReturnStatement returnStatement = ast.newReturnStatement();
    ClassInstanceCreation newClassInstanceCreation = ast.newClassInstanceCreation();
    newClassInstanceCreation.setType(ast.newSimpleType(ast.newName(builderType.getName().toString())));
    returnStatement.setExpression(newClassInstanceCreation);
    builderMethodBlock.statements().add(returnStatement);
    return builderMethodBlock;
}
 
Example 8
Source File: LocalCorrectionsSubProcessor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private static ThrowStatement getThrowForUnsupportedCase(Expression switchExpr, AST ast, ASTRewrite astRewrite) {
	ThrowStatement newThrowStatement = ast.newThrowStatement();
	ClassInstanceCreation newCic = ast.newClassInstanceCreation();
	newCic.setType(ast.newSimpleType(ast.newSimpleName("UnsupportedOperationException"))); //$NON-NLS-1$
	InfixExpression newInfixExpr = ast.newInfixExpression();
	StringLiteral newStringLiteral = ast.newStringLiteral();
	newStringLiteral.setLiteralValue("Unimplemented case: "); //$NON-NLS-1$
	newInfixExpr.setLeftOperand(newStringLiteral);
	newInfixExpr.setOperator(InfixExpression.Operator.PLUS);
	newInfixExpr.setRightOperand((Expression) astRewrite.createCopyTarget(switchExpr));
	newCic.arguments().add(newInfixExpr);
	newThrowStatement.setExpression(newCic);
	return newThrowStatement;
}
 
Example 9
Source File: LocalCorrectionsSubProcessor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private static ThrowStatement getThrowForUnexpectedDefault(Expression switchExpression, AST ast, ASTRewrite astRewrite) {
	ThrowStatement newThrowStatement = ast.newThrowStatement();
	ClassInstanceCreation newCic = ast.newClassInstanceCreation();
	newCic.setType(ast.newSimpleType(ast.newSimpleName("IllegalArgumentException"))); //$NON-NLS-1$
	InfixExpression newInfixExpr = ast.newInfixExpression();
	StringLiteral newStringLiteral = ast.newStringLiteral();
	newStringLiteral.setLiteralValue("Unexpected value: "); //$NON-NLS-1$
	newInfixExpr.setLeftOperand(newStringLiteral);
	newInfixExpr.setOperator(InfixExpression.Operator.PLUS);
	newInfixExpr.setRightOperand((Expression) astRewrite.createCopyTarget(switchExpression));
	newCic.arguments().add(newInfixExpr);
	newThrowStatement.setExpression(newCic);
	return newThrowStatement;
}
 
Example 10
Source File: CreateDoPrivilegedBlockResolution.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
private ClassInstanceCreation createPrivilegedActionCreation(ASTRewrite rewrite, ClassInstanceCreation classLoaderCreation) {
    AST ast = rewrite.getAST();

    ClassInstanceCreation privilegedActionCreation = ast.newClassInstanceCreation();
    ParameterizedType privilegedActionType = createPrivilegedActionType(rewrite, classLoaderCreation);
    AnonymousClassDeclaration anonymousClassDeclaration = createAnonymousClassDeclaration(rewrite, classLoaderCreation);

    privilegedActionCreation.setType(privilegedActionType);
    privilegedActionCreation.setAnonymousClassDeclaration(anonymousClassDeclaration);

    return privilegedActionCreation;
}
 
Example 11
Source File: IntroduceParameterObjectProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public Expression createDefaultExpression(List<Expression> invocationArguments, ParameterInfo addedInfo, List<ParameterInfo> parameterInfos, MethodDeclaration enclosingMethod, boolean isRecursive, CompilationUnitRewrite cuRewrite) {
	final AST ast= cuRewrite.getAST();
	final ASTRewrite rewrite= cuRewrite.getASTRewrite();
	if (isRecursive && canReuseParameterObject(invocationArguments, addedInfo, parameterInfos, enclosingMethod)) {
		return ast.newSimpleName(addedInfo.getNewName());
	}
	ClassInstanceCreation classCreation= ast.newClassInstanceCreation();

	int startPosition= enclosingMethod != null ? enclosingMethod.getStartPosition() : cuRewrite.getRoot().getStartPosition();
	ContextSensitiveImportRewriteContext context= fParameterObjectFactory.createParameterClassAwareContext(fCreateAsTopLevel, cuRewrite, startPosition);
	classCreation.setType(fParameterObjectFactory.createType(fCreateAsTopLevel, cuRewrite, startPosition));
	List<Expression> constructorArguments= classCreation.arguments();
	for (Iterator<ParameterInfo> iter= parameterInfos.iterator(); iter.hasNext();) {
		ParameterInfo pi= iter.next();
		if (isValidField(pi)) {
			if (pi.isOldVarargs()) {
				boolean isLastParameter= !iter.hasNext();
				constructorArguments.addAll(computeVarargs(invocationArguments, pi, isLastParameter, cuRewrite, context));
			} else {
				Expression exp= invocationArguments.get(pi.getOldIndex());
				importNodeTypes(exp, cuRewrite, context);
				constructorArguments.add(moveNode(exp, rewrite));
			}
		}
	}
	return classCreation;
}
 
Example 12
Source File: IntroduceParameterRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void addParameterInfo(CompilationUnitRewrite cuRewrite) throws JavaModelException {
	ITypeBinding typeBinding= Bindings.normalizeForDeclarationUse(fSelectedExpression.resolveTypeBinding(), fSelectedExpression.getAST());
	String name= fParameterName != null ? fParameterName : guessedParameterName();
	Expression expression= fSelectedExpression instanceof ParenthesizedExpression ? ((ParenthesizedExpression)fSelectedExpression).getExpression() : fSelectedExpression;
	
	ImportRewrite importRewrite= cuRewrite.getImportRewrite();			
	ImportRewriteContext importRewriteContext= new ContextSensitiveImportRewriteContext(fSelectedExpression, importRewrite);
	String typeName= importRewrite.addImport(typeBinding, importRewriteContext);
	
	String defaultValue= null;
	if (expression instanceof ClassInstanceCreation && typeBinding.isParameterizedType()) {
		ClassInstanceCreation classInstanceCreation= (ClassInstanceCreation) expression;
		Type cicType= classInstanceCreation.getType();
		if (cicType instanceof ParameterizedType && ((ParameterizedType) cicType).typeArguments().size() == 0) {
			// expand the diamond:
			AST ast= cuRewrite.getAST();				
			Type type= importRewrite.addImport(typeBinding, ast, importRewriteContext);				
			classInstanceCreation.setType(type);    // Should not touch the original AST ...
			defaultValue= ASTNodes.asFormattedString(classInstanceCreation,  0, StubUtility.getLineDelimiterUsed(cuRewrite.getCu()), cuRewrite.getCu().getJavaProject().getOptions(true));
			classInstanceCreation.setType(cicType); // ... so let's restore it right away.
		}
	}
	
	if (defaultValue == null) {
		defaultValue= fSourceCU.getBuffer().getText(expression.getStartPosition(), expression.getLength());
	}
	fParameter= ParameterInfo.createInfoForAddedParameter(typeBinding, typeName, name, defaultValue);
	if (fArguments == null) {
		List<ParameterInfo> parameterInfos= fChangeSignatureProcessor.getParameterInfos();
		int parametersCount= parameterInfos.size();
		if (parametersCount > 0 && parameterInfos.get(parametersCount - 1).isOldVarargs())
			parameterInfos.add(parametersCount - 1, fParameter);
		else
			parameterInfos.add(fParameter);
	}
}
 
Example 13
Source File: StringBuilderGenerator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void initialize() {
	super.initialize();
	fBuilderVariableName= createNameSuggestion(getContext().is50orHigher() ? "builder" : "buffer", NamingConventions.VK_LOCAL); //$NON-NLS-1$ //$NON-NLS-2$
	fBuffer= new StringBuffer();
	VariableDeclarationFragment fragment= fAst.newVariableDeclarationFragment();
	fragment.setName(fAst.newSimpleName(fBuilderVariableName));
	ClassInstanceCreation classInstance= fAst.newClassInstanceCreation();
	Name typeName= addImport(getContext().is50orHigher() ? "java.lang.StringBuilder" : "java.lang.StringBuffer"); //$NON-NLS-1$ //$NON-NLS-2$
	classInstance.setType(fAst.newSimpleType(typeName));
	fragment.setInitializer(classInstance);
	VariableDeclarationStatement vStatement= fAst.newVariableDeclarationStatement(fragment);
	vStatement.setType(fAst.newSimpleType((Name)ASTNode.copySubtree(fAst, typeName)));
	toStringMethod.getBody().statements().add(vStatement);
}
 
Example 14
Source File: CustomBuilderGenerator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private MethodInvocation createAppendMethodForMember(Object member) {
	ITypeBinding memberType= getMemberType(member);
	String memberTypeName= memberType.getQualifiedName();

	Expression memberAccessExpression= null;

	AppendMethodInformation ami= appendMethodSpecificTypes.get(memberTypeName);
	if (ami == null && memberType.isPrimitive()) {
		memberTypeName= wrapperTypes[primitiveTypes.indexOf(memberTypeName)];
		memberType= fAst.resolveWellKnownType(memberTypeName);
		ami= appendMethodSpecificTypes.get(memberTypeName);
		if (!getContext().is50orHigher()) {
			ClassInstanceCreation classInstance= fAst.newClassInstanceCreation();
			classInstance.setType(fAst.newSimpleType(addImport(memberTypeName)));
			classInstance.arguments().add(createMemberAccessExpression(member, true, true));
			memberAccessExpression= classInstance;
		}
	}
	while (ami == null) {
		memberType= memberType.getSuperclass();
		if (memberType != null)
			memberTypeName= memberType.getQualifiedName();
		else
			memberTypeName= "java.lang.Object"; //$NON-NLS-1$
		ami= appendMethodSpecificTypes.get(memberTypeName);
	}

	if (memberAccessExpression == null) {
		memberAccessExpression= createMemberAccessExpression(member, false, getContext().isSkipNulls());
	}

	MethodInvocation appendInvocation= fAst.newMethodInvocation();
	appendInvocation.setName(fAst.newSimpleName(getContext().getCustomBuilderAppendMethod()));
	if (ami.methodType == 1 || ami.methodType == 2) {
		appendInvocation.arguments().add(memberAccessExpression);
	}
	if (ami.methodType == 2 || ami.methodType == 3) {
		StringLiteral literal= fAst.newStringLiteral();
		literal.setLiteralValue(getMemberName(member, ToStringTemplateParser.MEMBER_NAME_PARENTHESIS_VARIABLE));
		appendInvocation.arguments().add(literal);
	}
	if (ami.methodType == 3) {
		appendInvocation.arguments().add(memberAccessExpression);
	}

	canChainLastAppendCall= ami.returnsBuilder;

	return appendInvocation;
}
 
Example 15
Source File: CustomBuilderGenerator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public MethodDeclaration generateToStringMethod() throws CoreException {
	initialize();

	//ToStringBuilder builder= new ToStringBuilder(this);
	String builderVariableName= createNameSuggestion(getContext().getCustomBuilderVariableName(), NamingConventions.VK_LOCAL);
	VariableDeclarationFragment fragment= fAst.newVariableDeclarationFragment();
	fragment.setName(fAst.newSimpleName(builderVariableName));
	ClassInstanceCreation classInstance= fAst.newClassInstanceCreation();
	Name typeName= addImport(getContext().getCustomBuilderClass());
	classInstance.setType(fAst.newSimpleType(typeName));
	classInstance.arguments().add(fAst.newThisExpression());
	fragment.setInitializer(classInstance);
	VariableDeclarationStatement vStatement= fAst.newVariableDeclarationStatement(fragment);
	vStatement.setType(fAst.newSimpleType((Name)ASTNode.copySubtree(fAst, typeName)));
	toStringMethod.getBody().statements().add(vStatement);

	/* expression for accumulating chained calls */
	Expression expression= null;

	for (int i= 0; i < getContext().getSelectedMembers().length; i++) {
		//builder.append("member", member);
		MethodInvocation appendInvocation= createAppendMethodForMember(getContext().getSelectedMembers()[i]);
		if (getContext().isSkipNulls() && !getMemberType(getContext().getSelectedMembers()[i]).isPrimitive()) {
			if (expression != null) {
				toStringMethod.getBody().statements().add(fAst.newExpressionStatement(expression));
				expression= null;
			}
			appendInvocation.setExpression(fAst.newSimpleName(builderVariableName));
			IfStatement ifStatement= fAst.newIfStatement();
			ifStatement.setExpression(createInfixExpression(createMemberAccessExpression(getContext().getSelectedMembers()[i], true, true), Operator.NOT_EQUALS, fAst.newNullLiteral()));
			ifStatement.setThenStatement(createOneStatementBlock(appendInvocation));
			toStringMethod.getBody().statements().add(ifStatement);
		} else {
			if (expression != null) {
				appendInvocation.setExpression(expression);
			} else {
				appendInvocation.setExpression(fAst.newSimpleName(builderVariableName));
			}
			if (getContext().isCustomBuilderChainedCalls() && canChainLastAppendCall) {
				expression= appendInvocation;
			} else {
				expression= null;
				toStringMethod.getBody().statements().add(fAst.newExpressionStatement(appendInvocation));
			}
		}
	}

	if (expression != null) {
		toStringMethod.getBody().statements().add(fAst.newExpressionStatement(expression));
	}
	// return builder.toString();
	ReturnStatement rStatement= fAst.newReturnStatement();
	rStatement.setExpression(createMethodInvocation(builderVariableName, getContext().getCustomBuilderResultMethod(), null));
	toStringMethod.getBody().statements().add(rStatement);

	complete();

	return toStringMethod;
}
 
Example 16
Source File: ExtractClassRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private FieldDeclaration createParameterObjectField(ParameterObjectFactory pof, TypeDeclaration typeNode, int modifier) {
	AST ast= fBaseCURewrite.getAST();
	ClassInstanceCreation creation= ast.newClassInstanceCreation();
	creation.setType(pof.createType(fDescriptor.isCreateTopLevel(), fBaseCURewrite, typeNode.getStartPosition()));
	ListRewrite listRewrite= fBaseCURewrite.getASTRewrite().getListRewrite(creation, ClassInstanceCreation.ARGUMENTS_PROPERTY);
	for (Iterator<FieldInfo> iter= fVariables.values().iterator(); iter.hasNext();) {
		FieldInfo fi= iter.next();
		if (isCreateField(fi)) {
			Expression expression= fi.initializer;
			if (expression != null && !fi.hasFieldReference()) {
				importNodeTypes(expression, fBaseCURewrite);
				ASTNode createMoveTarget= fBaseCURewrite.getASTRewrite().createMoveTarget(expression);
				if (expression instanceof ArrayInitializer) {
					ArrayInitializer ai= (ArrayInitializer) expression;
					ITypeBinding type= ai.resolveTypeBinding();
					Type addImport= fBaseCURewrite.getImportRewrite().addImport(type, ast);
					fBaseCURewrite.getImportRemover().registerAddedImports(addImport);
					ArrayCreation arrayCreation= ast.newArrayCreation();
					arrayCreation.setType((ArrayType) addImport);
					arrayCreation.setInitializer((ArrayInitializer) createMoveTarget);
					listRewrite.insertLast(arrayCreation, null);
				} else {
					listRewrite.insertLast(createMoveTarget, null);
				}
			}
		}
	}

	VariableDeclarationFragment fragment= ast.newVariableDeclarationFragment();
	fragment.setName(ast.newSimpleName(fDescriptor.getFieldName()));
	fragment.setInitializer(creation);

	ModifierKeyword acc= null;
	if (Modifier.isPublic(modifier)) {
		acc= ModifierKeyword.PUBLIC_KEYWORD;
	} else if (Modifier.isProtected(modifier)) {
		acc= ModifierKeyword.PROTECTED_KEYWORD;
	} else if (Modifier.isPrivate(modifier)) {
		acc= ModifierKeyword.PRIVATE_KEYWORD;
	}

	FieldDeclaration fieldDeclaration= ast.newFieldDeclaration(fragment);
	fieldDeclaration.setType(pof.createType(fDescriptor.isCreateTopLevel(), fBaseCURewrite, typeNode.getStartPosition()));
	if (acc != null)
		fieldDeclaration.modifiers().add(ast.newModifier(acc));
	return fieldDeclaration;
}
 
Example 17
Source File: BlockWithNewCopyInstanceConstructorCreationFragment.java    From SparkBuilderGenerator with MIT License 4 votes vote down vote up
private ClassInstanceCreation createClassInstantiation(AST ast, TypeDeclaration builderType, String parameterName) {
    ClassInstanceCreation newClassInstanceCreation = ast.newClassInstanceCreation();
    newClassInstanceCreation.setType(ast.newSimpleType(ast.newName(builderType.getName().toString())));
    newClassInstanceCreation.arguments().add(createArgument(ast, parameterName));
    return newClassInstanceCreation;
}