本文整理汇总了Java中org.eclipse.jdt.core.dom.AST.newSingleVariableDeclaration方法的典型用法代码示例。如果您正苦于以下问题:Java AST.newSingleVariableDeclaration方法的具体用法?Java AST.newSingleVariableDeclaration怎么用?Java AST.newSingleVariableDeclaration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.AST
的用法示例。
在下文中一共展示了AST.newSingleVariableDeclaration方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPrivateConstructorDefinition
import org.eclipse.jdt.core.dom.AST; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public MethodDeclaration createPrivateConstructorDefinition(AST ast, TypeDeclaration originalType, TypeDeclaration builderType,
List<BuilderField> builderFields) {
MethodDeclaration method = ast.newMethodDeclaration();
method.setConstructor(true);
method.setName(ast.newSimpleName(originalType.getName().toString()));
if (preferencesManager.getPreferenceValue(ADD_GENERATED_ANNOTATION)) {
generatedAnnotationPopulator.addGeneratedAnnotation(ast, method);
}
method.modifiers().add(ast.newModifier(ModifierKeyword.PRIVATE_KEYWORD));
SingleVariableDeclaration methodParameterDeclaration = ast.newSingleVariableDeclaration();
methodParameterDeclaration.setType(ast.newSimpleType(ast.newName(builderType.getName().toString())));
methodParameterDeclaration.setName(ast.newSimpleName(camelCaseConverter.toLowerCamelCase(builderType.getName().toString())));
method.parameters().add(methodParameterDeclaration);
return method;
}
开发者ID:helospark,项目名称:SparkBuilderGenerator,代码行数:20,代码来源:PrivateConstructorMethodDefinitionCreationFragment.java
示例2: addNewParameters
import org.eclipse.jdt.core.dom.AST; //导入方法依赖的package包/类
@Override
protected void addNewParameters(ASTRewrite rewrite, List<String> takenNames, List<SingleVariableDeclaration> params, ImportRewriteContext context) throws CoreException {
AST ast= rewrite.getAST();
List<Expression> arguments= fArguments;
for (int i= 0; i < arguments.size(); i++) {
Expression elem= arguments.get(i);
SingleVariableDeclaration param= ast.newSingleVariableDeclaration();
// argument type
String argTypeKey= "arg_type_" + i; //$NON-NLS-1$
Type type= evaluateParameterType(ast, elem, argTypeKey, context);
param.setType(type);
// argument name
String argNameKey= "arg_name_" + i; //$NON-NLS-1$
String name= evaluateParameterName(takenNames, elem, type, argNameKey);
param.setName(ast.newSimpleName(name));
params.add(param);
}
}
示例3: createWithMethodParameter
import org.eclipse.jdt.core.dom.AST; //导入方法依赖的package包/类
public SingleVariableDeclaration createWithMethodParameter(AST ast, Type type, String fieldName) {
SingleVariableDeclaration methodParameterDeclaration = ast.newSingleVariableDeclaration();
methodParameterDeclaration.setType((Type) ASTNode.copySubtree(ast, type));
methodParameterDeclaration.setName(ast.newSimpleName(fieldName));
if (preferencesManager.getPreferenceValue(PluginPreferenceList.ADD_NONNULL_ON_PARAMETERS)) {
markerAnnotationAttacher.attachNonNull(ast, methodParameterDeclaration);
}
return methodParameterDeclaration;
}
示例4: addNewParameters
import org.eclipse.jdt.core.dom.AST; //导入方法依赖的package包/类
private void addNewParameters(ASTRewrite rewrite, List<SingleVariableDeclaration> params, ImportRewriteContext context) throws CoreException {
if (!isGetter) {
AST ast = rewrite.getAST();
SingleVariableDeclaration param = ast.newSingleVariableDeclaration();
Type type = getImportRewrite().addImport(fVariableBinding.getType(), ast, context, TypeLocation.PARAMETER);
param.setType(type);
param.setName(ast.newSimpleName(getArgumentName()));
params.add(param);
}
}
示例5: doAddParam
import org.eclipse.jdt.core.dom.AST; //导入方法依赖的package包/类
private ASTRewrite doAddParam(CompilationUnit cu) {
AST ast= cu.getAST();
SimpleName node= fOriginalNode;
BodyDeclaration decl= ASTResolving.findParentBodyDeclaration(node);
if (decl instanceof MethodDeclaration) {
MethodDeclaration methodDeclaration= (MethodDeclaration) decl;
ASTRewrite rewrite= ASTRewrite.create(ast);
ImportRewrite imports= createImportRewrite((CompilationUnit) decl.getRoot());
ImportRewriteContext importRewriteContext= new ContextSensitiveImportRewriteContext(decl, imports);
SingleVariableDeclaration newDecl= ast.newSingleVariableDeclaration();
newDecl.setType(evaluateVariableType(ast, imports, importRewriteContext, methodDeclaration.resolveBinding(), TypeLocation.PARAMETER));
newDecl.setName(ast.newSimpleName(node.getIdentifier()));
ListRewrite listRewriter= rewrite.getListRewrite(decl, MethodDeclaration.PARAMETERS_PROPERTY);
listRewriter.insertLast(newDecl, null);
// add javadoc tag
Javadoc javadoc= methodDeclaration.getJavadoc();
if (javadoc != null) {
HashSet<String> leadingNames= new HashSet<>();
for (Iterator<SingleVariableDeclaration> iter= methodDeclaration.parameters().iterator(); iter.hasNext();) {
SingleVariableDeclaration curr= iter.next();
leadingNames.add(curr.getName().getIdentifier());
}
SimpleName newTagRef= ast.newSimpleName(node.getIdentifier());
TagElement newTagElement= ast.newTagElement();
newTagElement.setTagName(TagElement.TAG_PARAM);
newTagElement.fragments().add(newTagRef);
TextElement commentStart= ast.newTextElement();
newTagElement.fragments().add(commentStart);
ListRewrite tagsRewriter= rewrite.getListRewrite(javadoc, Javadoc.TAGS_PROPERTY);
JavadocTagsSubProcessor.insertTag(tagsRewriter, newTagElement, leadingNames);
}
return rewrite;
}
return null;
}