当前位置: 首页>>代码示例>>Java>>正文


Java VariableDeclarationStatement.setType方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.VariableDeclarationStatement.setType方法的典型用法代码示例。如果您正苦于以下问题:Java VariableDeclarationStatement.setType方法的具体用法?Java VariableDeclarationStatement.setType怎么用?Java VariableDeclarationStatement.setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.dom.VariableDeclarationStatement的用法示例。


在下文中一共展示了VariableDeclarationStatement.setType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDeclaration

import org.eclipse.jdt.core.dom.VariableDeclarationStatement; //导入方法依赖的package包/类
private VariableDeclarationStatement createDeclaration(
    IVariableBinding binding, Expression intilizer) {
  VariableDeclaration original =
      ASTNodes.findVariableDeclaration(binding, fAnalyzer.getEnclosingBodyDeclaration());
  VariableDeclarationFragment fragment = fAST.newVariableDeclarationFragment();
  fragment.setName((SimpleName) ASTNode.copySubtree(fAST, original.getName()));
  fragment.setInitializer(intilizer);
  VariableDeclarationStatement result = fAST.newVariableDeclarationStatement(fragment);
  result.modifiers().addAll(ASTNode.copySubtrees(fAST, ASTNodes.getModifiers(original)));
  result.setType(
      ASTNodeFactory.newType(
          fAST,
          original,
          fImportRewriter,
          new ContextSensitiveImportRewriteContext(original, fImportRewriter)));
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:ExtractMethodRefactoring.java

示例2: createUnobservedInitStmt

import org.eclipse.jdt.core.dom.VariableDeclarationStatement; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
	@Override
	public void createUnobservedInitStmt(CaptureLog log, int logRecNo) 
	{
		PostProcessor.notifyRecentlyProcessedLogRecNo(logRecNo);
		
		// NOTE: PLAIN INIT: has always one non-null param
		// TODO: use primitives
		final int    oid     = log.objectIds.get(logRecNo);
//		final String type    = log.oidClassNames.get(log.oidRecMapping.get(oid));
		final Object value   = log.params.get(logRecNo)[0];
		this.isXStreamNeeded = true;
		
		final VariableDeclarationFragment vd = ast.newVariableDeclarationFragment();
		// handling because there must always be a new instantiation statement for pseudo inits
		this.oidToVarMapping.remove(oid);
		vd.setName(ast.newSimpleName(this.createNewVarName(oid, log.oidClassNames.get(log.oidRecMapping.get(oid)), true)));
		
		final MethodInvocation methodInvocation = ast.newMethodInvocation();
		final Name name = ast.newSimpleName("XSTREAM");
		methodInvocation.setExpression(name);
		methodInvocation.setName(ast.newSimpleName("fromXML")); 
		
		final StringLiteral xmlParam = ast.newStringLiteral();
		xmlParam.setLiteralValue((String) value);
		methodInvocation.arguments().add(xmlParam);
		
//		final CastExpression castExpr = ast.newCastExpression();
//		castExpr.setType(this.createAstType(type, ast));
//		castExpr.setExpression(methodInvocation);
		
//		vd.setInitializer(castExpr);
		vd.setInitializer(methodInvocation);
		
		final VariableDeclarationStatement vs = ast.newVariableDeclarationStatement(vd);
		vs.setType(this.createAstType("Object", ast));
				
		methodBlock.statements().add(vs);
	}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:40,代码来源:JUnitCodeGenerator.java

示例3: createUnobservedInitStmt

import org.eclipse.jdt.core.dom.VariableDeclarationStatement; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void createUnobservedInitStmt(final int logRecNo, final Block methodBlock, final AST ast)
{
	// NOTE: PLAIN INIT: has always one non-null param
	// TODO: use primitives
	final int    oid     = this.log.objectIds.get(logRecNo);
	final String type    = this.log.oidClassNames.get(this.log.oidRecMapping.get(oid));
	final Object value   = this.log.params.get(logRecNo)[0];
	this.isXStreamNeeded = true;
	
	final VariableDeclarationFragment vd = ast.newVariableDeclarationFragment();
	// handling because there must always be a new instantiation statement for pseudo inits
	this.oidToVarMapping.remove(oid);
	vd.setName(ast.newSimpleName(this.createNewVarName(oid, type)));
	
	final MethodInvocation methodInvocation = ast.newMethodInvocation();
	final Name name = ast.newSimpleName("XSTREAM");
	methodInvocation.setExpression(name);
	methodInvocation.setName(ast.newSimpleName("fromXML")); 
	
	final StringLiteral xmlParam = ast.newStringLiteral();
	xmlParam.setLiteralValue((String) value);
	methodInvocation.arguments().add(xmlParam);
	
	final CastExpression castExpr = ast.newCastExpression();
	castExpr.setType(this.createAstType(type, ast));
	castExpr.setExpression(methodInvocation);
	
	vd.setInitializer(castExpr);
	
	final VariableDeclarationStatement vs = ast.newVariableDeclarationStatement(vd);
	vs.setType(this.createAstType(type, ast));
			
	methodBlock.statements().add(vs);
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:36,代码来源:CodeGenerator.java

示例4: variableDeclarationStatement

import org.eclipse.jdt.core.dom.VariableDeclarationStatement; //导入方法依赖的package包/类
public VariableDeclarationStatement variableDeclarationStatement(String name, Type type, Expression initializer) {
    VariableDeclarationFragment variableDeclarationFragment = variableDeclarationFragment(name);
    variableDeclarationFragment.setInitializer(initializer);
    VariableDeclarationStatement statement = ast.get().newVariableDeclarationStatement(variableDeclarationFragment);
    statement.setType(type);
    return statement;
}
 
开发者ID:opaluchlukasz,项目名称:junit2spock,代码行数:8,代码来源:ASTNodeFactory.java

示例5: createDeclaration

import org.eclipse.jdt.core.dom.VariableDeclarationStatement; //导入方法依赖的package包/类
private VariableDeclarationStatement createDeclaration(IVariableBinding binding, Expression intilizer) {
	VariableDeclaration original = ASTNodes.findVariableDeclaration(binding, fAnalyzer.getEnclosingBodyDeclaration());
	VariableDeclarationFragment fragment = fAST.newVariableDeclarationFragment();
	fragment.setName((SimpleName) ASTNode.copySubtree(fAST, original.getName()));
	fragment.setInitializer(intilizer);
	VariableDeclarationStatement result = fAST.newVariableDeclarationStatement(fragment);
	result.modifiers().addAll(ASTNode.copySubtrees(fAST, ASTNodes.getModifiers(original)));
	result.setType(ASTNodeFactory.newType(fAST, original, fImportRewriter, new ContextSensitiveImportRewriteContext(original, fImportRewriter)));
	return result;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:11,代码来源:ExtractMethodRefactoring.java

示例6: createTempDeclaration

import org.eclipse.jdt.core.dom.VariableDeclarationStatement; //导入方法依赖的package包/类
private VariableDeclarationStatement createTempDeclaration(Expression initializer)
    throws CoreException {
  AST ast = fCURewrite.getAST();

  VariableDeclarationFragment vdf = ast.newVariableDeclarationFragment();
  vdf.setName(ast.newSimpleName(fTempName));
  vdf.setInitializer(initializer);

  VariableDeclarationStatement vds = ast.newVariableDeclarationStatement(vdf);
  if (fDeclareFinal) {
    vds.modifiers().add(ast.newModifier(ModifierKeyword.FINAL_KEYWORD));
  }
  vds.setType(createTempType());

  if (fLinkedProposalModel != null) {
    ASTRewrite rewrite = fCURewrite.getASTRewrite();
    LinkedProposalPositionGroup nameGroup = fLinkedProposalModel.getPositionGroup(KEY_NAME, true);
    nameGroup.addPosition(rewrite.track(vdf.getName()), true);

    String[] nameSuggestions = guessTempNames();
    if (nameSuggestions.length > 0 && !nameSuggestions[0].equals(fTempName)) {
      nameGroup.addProposal(fTempName, null, nameSuggestions.length + 1);
    }
    for (int i = 0; i < nameSuggestions.length; i++) {
      nameGroup.addProposal(nameSuggestions[i], null, nameSuggestions.length - i);
    }
  }
  return vds;
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:ExtractTempRefactoring.java

示例7: createCollectionInitStmt

import org.eclipse.jdt.core.dom.VariableDeclarationStatement; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void createCollectionInitStmt(final CaptureLog log, final int logRecNo) 
{
	final int      oid          = log.objectIds.get(logRecNo);
	final Object[] params       = log.params.get(logRecNo);
	String         collTypeName = log.oidClassNames.get(log.oidRecMapping.get(oid));
	final Class<?> collType     = getClassForName(collTypeName);

	final String varName;
	
	// -- determine if an alternative collection must be used for code generation
	final boolean isPrivate = java.lang.reflect.Modifier.isPrivate(collType.getModifiers());
	if(isPrivate || ! hasDefaultConstructor(collType))
	{
		if(Set.class.isAssignableFrom(collType))
		{
			collTypeName = HashSet.class.getName();
		}
		else if (List.class.isAssignableFrom(collType))
		{
			collTypeName = ArrayList.class.getName();
		}
		else if(Queue.class.isAssignableFrom(collType))
		{
			collTypeName = ArrayDeque.class.getName();
		}
		else
		{
			throw new RuntimeException("Collection " + collType + " is not supported");
		}
	}

	// -- create code for instantiating collection
	varName = this.createNewVarName(oid, collTypeName);
	
	final VariableDeclarationFragment vd = ast.newVariableDeclarationFragment();
	final SimpleName varNameExpr = ast.newSimpleName(varName); 
	vd.setName(varNameExpr);	
	
	final ClassInstanceCreation ci = ast.newClassInstanceCreation();
	    ci.setType(this.createAstType(collTypeName, ast));
	    vd.setInitializer(ci);
	
	final VariableDeclarationStatement stmt = ast.newVariableDeclarationStatement(vd);
	stmt.setType(this.createAstType(collTypeName, ast));
	
	methodBlock.statements().add(stmt);	

	// --- create code for filling the collection
	Integer paramOID;
	MethodInvocation mi;
	for(int i = 0; i < params.length; i++)
	{
		mi = ast.newMethodInvocation();
		mi.setName(ast.newSimpleName("add"));
		
		paramOID = (Integer) params[i];
		if(paramOID == null)
		{
			mi.arguments().add(ast.newNullLiteral());
		}
		else
		{
			mi.arguments().add(ast.newSimpleName(this.oidToVarMapping.get(paramOID)));
		}
		
		methodBlock.statements().add(mi);	
	}
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:71,代码来源:JUnitCodeGenerator.java

示例8: createMapInitStmt

import org.eclipse.jdt.core.dom.VariableDeclarationStatement; //导入方法依赖的package包/类
@Override
public void createMapInitStmt(final CaptureLog log, final int logRecNo) {
	final int      oid          = log.objectIds.get(logRecNo);
	final Object[] params       = log.params.get(logRecNo);
	String         collTypeName = log.oidClassNames.get(log.oidRecMapping.get(oid));
	final Class<?> collType     = getClassForName(collTypeName);


	final String varName;
	
	// -- determine if an alternative collection must be used for code generation
	final boolean isPrivate = java.lang.reflect.Modifier.isPrivate(collType.getModifiers());
	if(isPrivate || ! hasDefaultConstructor(collType))
	{
		collTypeName = HashMap.class.getName();
	}

	// -- create code for instantiating collection
	varName = this.createNewVarName(oid, collTypeName);
	
	final VariableDeclarationFragment vd = ast.newVariableDeclarationFragment();
	final SimpleName varNameExpr = ast.newSimpleName(varName); 
	vd.setName(varNameExpr);	
	
	final ClassInstanceCreation ci = ast.newClassInstanceCreation();
	    ci.setType(this.createAstType(collTypeName, ast));
	    vd.setInitializer(ci);
	
	final VariableDeclarationStatement stmt = ast.newVariableDeclarationStatement(vd);
	stmt.setType(this.createAstType(collTypeName, ast));
	
	methodBlock.statements().add(stmt);	

	// --- create code for filling the collection
	Integer valueOID;
	Integer keyOID;
	
	MethodInvocation mi;
	for(int i = 0; i + 1< params.length; i+=2)
	{
		mi = ast.newMethodInvocation();
		mi.setName(ast.newSimpleName("put"));
		
		keyOID = (Integer) params[i];
	    mi.arguments().add(ast.newSimpleName(this.oidToVarMapping.get(keyOID)));
		
		valueOID = (Integer) params[i + 1];
		if(valueOID == null)
		{
			mi.arguments().add(ast.newNullLiteral());
		}
		else
		{
			mi.arguments().add(ast.newSimpleName(this.oidToVarMapping.get(valueOID)));
		}
		
		methodBlock.statements().add(mi);	
	}
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:60,代码来源:JUnitCodeGenerator.java

示例9: splitUpDeclarations

import org.eclipse.jdt.core.dom.VariableDeclarationStatement; //导入方法依赖的package包/类
private void splitUpDeclarations(ASTRewrite rewrite, TextEditGroup group, VariableDeclarationFragment frag, VariableDeclarationStatement originalStatement, List<Expression> sideEffects) {
	if (sideEffects.size() > 0) {
		ListRewrite statementRewrite= rewrite.getListRewrite(originalStatement.getParent(), (ChildListPropertyDescriptor) originalStatement.getLocationInParent());

		Statement previousStatement= originalStatement;
		for (int i= 0; i < sideEffects.size(); i++) {
			Expression sideEffect= sideEffects.get(i);
			Expression movedInit= (Expression) rewrite.createMoveTarget(sideEffect);
			ExpressionStatement wrapped= rewrite.getAST().newExpressionStatement(movedInit);
			statementRewrite.insertAfter(wrapped, previousStatement, group);
			previousStatement= wrapped;
		}

		VariableDeclarationStatement newDeclaration= null;
		List<VariableDeclarationFragment> fragments= originalStatement.fragments();
		int fragIndex= fragments.indexOf(frag);
		ListIterator<VariableDeclarationFragment> fragmentIterator= fragments.listIterator(fragIndex+1);
		while (fragmentIterator.hasNext()) {
			VariableDeclarationFragment currentFragment= fragmentIterator.next();
			VariableDeclarationFragment movedFragment= (VariableDeclarationFragment) rewrite.createMoveTarget(currentFragment);
			if (newDeclaration == null) {
				newDeclaration= rewrite.getAST().newVariableDeclarationStatement(movedFragment);
				Type copiedType= (Type) rewrite.createCopyTarget(originalStatement.getType());
				newDeclaration.setType(copiedType);
			} else {
				newDeclaration.fragments().add(movedFragment);
			}
		}
		if (newDeclaration != null){
			statementRewrite.insertAfter(newDeclaration, previousStatement, group);
			if (originalStatement.fragments().size() == newDeclaration.fragments().size() + 1){
				rewrite.remove(originalStatement, group);
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:37,代码来源:UnusedCodeFix.java

示例10: doAddLocal

import org.eclipse.jdt.core.dom.VariableDeclarationStatement; //导入方法依赖的package包/类
private ASTRewrite doAddLocal() {
  Expression expression = ((ExpressionStatement) fNodeToAssign).getExpression();
  AST ast = fNodeToAssign.getAST();

  ASTRewrite rewrite = ASTRewrite.create(ast);

  createImportRewrite((CompilationUnit) fNodeToAssign.getRoot());

  String[] varNames = suggestLocalVariableNames(fTypeBinding, expression);
  for (int i = 0; i < varNames.length; i++) {
    addLinkedPositionProposal(KEY_NAME, varNames[i], null);
  }

  VariableDeclarationFragment newDeclFrag = ast.newVariableDeclarationFragment();
  newDeclFrag.setName(ast.newSimpleName(varNames[0]));
  newDeclFrag.setInitializer((Expression) rewrite.createCopyTarget(expression));

  Type type = evaluateType(ast);

  if (ASTNodes.isControlStatementBody(fNodeToAssign.getLocationInParent())) {
    Block block = ast.newBlock();
    block.statements().add(rewrite.createMoveTarget(fNodeToAssign));
    rewrite.replace(fNodeToAssign, block, null);
  }

  if (needsSemicolon(expression)) {
    VariableDeclarationStatement varStatement = ast.newVariableDeclarationStatement(newDeclFrag);
    varStatement.setType(type);
    rewrite.replace(expression, varStatement, null);
  } else {
    // trick for bug 43248: use an VariableDeclarationExpression and keep the ExpressionStatement
    VariableDeclarationExpression varExpression =
        ast.newVariableDeclarationExpression(newDeclFrag);
    varExpression.setType(type);
    rewrite.replace(expression, varExpression, null);
  }

  addLinkedPosition(rewrite.track(newDeclFrag.getName()), true, KEY_NAME);
  addLinkedPosition(rewrite.track(type), false, KEY_TYPE);
  setEndPosition(rewrite.track(fNodeToAssign)); // set cursor after expression statement

  return rewrite;
}
 
开发者ID:eclipse,项目名称:che,代码行数:44,代码来源:AssignToVariableAssistProposal.java

示例11: createArrayInitStmt

import org.eclipse.jdt.core.dom.VariableDeclarationStatement; //导入方法依赖的package包/类
@Override
public void createArrayInitStmt(final CaptureLog log, final int logRecNo) {
	final int  oid  = log.objectIds.get(logRecNo);
	
	final Object[] params      = log.params.get(logRecNo);
	final String   arrTypeName = log.oidClassNames.get(log.oidRecMapping.get(oid));
	final Class<?> arrType     = getClassForName(arrTypeName);
	
	// --- create array instance creation e.g. int[] var = new int[10];
	
	final ArrayType     arrAstType      = (ArrayType) createAstArrayType(arrTypeName, ast);
	final ArrayCreation arrCreationExpr = ast.newArrayCreation();
	arrCreationExpr.setType(arrAstType);
	arrCreationExpr.dimensions().add(ast.newNumberLiteral(String.valueOf(params.length)));
		
	final String 					  arrVarName = this.createNewVarName(oid, arrTypeName);
	final VariableDeclarationFragment vd         = ast.newVariableDeclarationFragment();
	final SimpleName arrVarNameExpr = ast.newSimpleName(arrVarName); 
	vd.setName(arrVarNameExpr);	
	vd.setInitializer(arrCreationExpr);
	
	final VariableDeclarationStatement varDeclStmt = ast.newVariableDeclarationStatement(vd);
	varDeclStmt.setType(this.createAstType(arrTypeName, ast));
	
	methodBlock.statements().add(varDeclStmt);	
	
	// create array access statements var[0] = var1;
	Integer paramOID;
	Assignment assign;
	ArrayAccess arrAccessExpr;
	
	for(int i = 0; i < params.length; i++)
	{
		assign       = ast.newAssignment();
		arrAccessExpr = ast.newArrayAccess();
		arrAccessExpr.setIndex(ast.newNumberLiteral(String.valueOf(i)));
		arrAccessExpr.setArray(arrVarNameExpr);
		
		assign.setLeftHandSide(arrAccessExpr);
		
		paramOID = (Integer) params[i];
		if(paramOID == null)
		{
		   assign.setRightHandSide(ast.newNullLiteral());
		}
		else
		{
			assign.setRightHandSide(ast.newSimpleName(this.oidToVarMapping.get(paramOID)));
		}
		
		methodBlock.statements().add(assign);	
	}
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:54,代码来源:JUnitCodeGenerator.java

示例12: createTempDeclaration

import org.eclipse.jdt.core.dom.VariableDeclarationStatement; //导入方法依赖的package包/类
private VariableDeclarationStatement createTempDeclaration(Expression initializer) throws CoreException {
	AST ast= fCURewrite.getAST();

	VariableDeclarationFragment vdf= ast.newVariableDeclarationFragment();
	vdf.setName(ast.newSimpleName(fTempName));
	vdf.setInitializer(initializer);

	VariableDeclarationStatement vds= ast.newVariableDeclarationStatement(vdf);
	if (fDeclareFinal) {
		vds.modifiers().add(ast.newModifier(ModifierKeyword.FINAL_KEYWORD));
	}
	vds.setType(createTempType());

	if (fLinkedProposalModel != null) {
		ASTRewrite rewrite= fCURewrite.getASTRewrite();
		LinkedProposalPositionGroup nameGroup= fLinkedProposalModel.getPositionGroup(KEY_NAME, true);
		nameGroup.addPosition(rewrite.track(vdf.getName()), true);

		String[] nameSuggestions= guessTempNames();
		if (nameSuggestions.length > 0 && !nameSuggestions[0].equals(fTempName)) {
			nameGroup.addProposal(fTempName, null, nameSuggestions.length + 1);
		}
		for (int i= 0; i < nameSuggestions.length; i++) {
			nameGroup.addProposal(nameSuggestions[i], null, nameSuggestions.length - i);
		}
	}
	return vds;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:ExtractTempRefactoring.java

示例13: createDeclaration

import org.eclipse.jdt.core.dom.VariableDeclarationStatement; //导入方法依赖的package包/类
private VariableDeclarationStatement createDeclaration(IVariableBinding binding, Expression intilizer) {
	VariableDeclaration original= ASTNodes.findVariableDeclaration(binding, fAnalyzer.getEnclosingBodyDeclaration());
	VariableDeclarationFragment fragment= fAST.newVariableDeclarationFragment();
	fragment.setName((SimpleName)ASTNode.copySubtree(fAST, original.getName()));
	fragment.setInitializer(intilizer);
	VariableDeclarationStatement result= fAST.newVariableDeclarationStatement(fragment);
	result.modifiers().addAll(ASTNode.copySubtrees(fAST, ASTNodes.getModifiers(original)));
	result.setType(ASTNodeFactory.newType(fAST, original, fImportRewriter, new ContextSensitiveImportRewriteContext(original, fImportRewriter)));
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:ExtractMethodRefactoring.java

示例14: initialize

import org.eclipse.jdt.core.dom.VariableDeclarationStatement; //导入方法依赖的package包/类
@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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:StringBuilderGenerator.java

示例15: createMaxLenDeclaration

import org.eclipse.jdt.core.dom.VariableDeclarationStatement; //导入方法依赖的package包/类
/**
 * @return a statement in form of <code>final int maxLen = 10;</code>
 */
protected VariableDeclarationStatement createMaxLenDeclaration() {
	VariableDeclarationFragment fragment= fAst.newVariableDeclarationFragment();
	fragment.setName(fAst.newSimpleName(fMaxLenVariableName));
	fragment.setInitializer(fAst.newNumberLiteral(String.valueOf(fContext.getLimitItemsValue())));
	VariableDeclarationStatement declExpression= fAst.newVariableDeclarationStatement(fragment);
	declExpression.setType(fAst.newPrimitiveType(PrimitiveType.INT));
	declExpression.modifiers().add(fAst.newModifier(ModifierKeyword.FINAL_KEYWORD));
	return declExpression;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:AbstractToStringGenerator.java


注:本文中的org.eclipse.jdt.core.dom.VariableDeclarationStatement.setType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。