本文整理汇总了Java中org.eclipse.jdt.core.dom.SingleMemberAnnotation.setTypeName方法的典型用法代码示例。如果您正苦于以下问题:Java SingleMemberAnnotation.setTypeName方法的具体用法?Java SingleMemberAnnotation.setTypeName怎么用?Java SingleMemberAnnotation.setTypeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.SingleMemberAnnotation
的用法示例。
在下文中一共展示了SingleMemberAnnotation.setTypeName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setFieldAnnotation
import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
private void setFieldAnnotation(ASTRewrite rewrite, FieldDeclaration fieldDeclaration, String annotation) {
SingleMemberAnnotation newFieldAnnotation = fieldDeclaration.getAST().newSingleMemberAnnotation();
newFieldAnnotation.setTypeName(rewrite.getAST().newSimpleName("Domain"));
StringLiteral newStringLiteral = rewrite.getAST().newStringLiteral();
newStringLiteral.setLiteralValue(annotation);
newFieldAnnotation.setValue(newStringLiteral);
ASTNode modifier = getModifier(fieldDeclaration.modifiers());
if (modifier != null) {
ListRewrite paramRewrite = rewrite.getListRewrite(fieldDeclaration, FieldDeclaration.MODIFIERS2_PROPERTY);
paramRewrite.insertAfter(newFieldAnnotation, modifier, null);
}
else {
ListRewrite fieldRewrite = rewrite.getListRewrite(fieldDeclaration, FieldDeclaration.MODIFIERS2_PROPERTY);
fieldRewrite.insertFirst(newFieldAnnotation, null);
}
}
示例2: getTypeAnnotationDomainAssumes
import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
private SingleMemberAnnotation getTypeAnnotationDomainAssumes(ASTRewrite rewrite, TypeDeclaration typeDeclaration, String annotation, String domainName) {
ArrayInitializer initializer = rewrite.getAST().newArrayInitializer();
if (domainName != null) {
ListRewrite listRewrite = rewrite.getListRewrite(initializer, ArrayInitializer.EXPRESSIONS_PROPERTY);
StringLiteral newStringLiteral = rewrite.getAST().newStringLiteral();
newStringLiteral.setLiteralValue(domainName);
listRewrite.insertFirst(newStringLiteral, null);
declareOtherDomains(rewrite, listRewrite, typeDeclaration);
}
SingleMemberAnnotation newParamAnnotation = typeDeclaration.getAST().newSingleMemberAnnotation();
newParamAnnotation.setTypeName(rewrite.getAST().newSimpleName(annotation));
newParamAnnotation.setValue(initializer);
return newParamAnnotation;
}
示例3: getTypeAnnotationParams
import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
private SingleMemberAnnotation getTypeAnnotationParams(ASTRewrite rewrite, TypeDeclaration typeDeclaration,
String annotation) {
ArrayInitializer initializer = rewrite.getAST().newArrayInitializer();
if (!typeDeclaration.resolveBinding().getQualifiedName().equals(Config.MAINCLASS)) {
StringLiteral newStringLiteral = rewrite.getAST().newStringLiteral();
newStringLiteral.setLiteralValue("p");
ListRewrite listRewrite = rewrite.getListRewrite(initializer, ArrayInitializer.EXPRESSIONS_PROPERTY);
listRewrite.insertFirst(newStringLiteral, null);
}
SingleMemberAnnotation newParamAnnotation = typeDeclaration.getAST().newSingleMemberAnnotation();
newParamAnnotation.setTypeName(rewrite.getAST().newSimpleName(annotation));
newParamAnnotation.setValue(initializer);
return newParamAnnotation;
}
示例4: createGeneratedAnnotation
import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
private SingleMemberAnnotation createGeneratedAnnotation(AST ast) {
SingleMemberAnnotation generatedAnnotation = ast.newSingleMemberAnnotation();
generatedAnnotation.setTypeName(ast.newSimpleName("Generated"));
StringLiteral annotationValue = ast.newStringLiteral();
annotationValue.setLiteralValue(StaticPreferences.PLUGIN_GENERATED_ANNOTATION_NAME);
generatedAnnotation.setValue(annotationValue);
return generatedAnnotation;
}
示例5: setParameterAnnotation
import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
private void setParameterAnnotation(ASTRewrite rewrite, SingleVariableDeclaration param, String annotation) {
SingleMemberAnnotation newParamAnnotation = param.getAST().newSingleMemberAnnotation();
newParamAnnotation.setTypeName(rewrite.getAST().newSimpleName("Domain"));
StringLiteral newStringLiteral = rewrite.getAST().newStringLiteral();
newStringLiteral.setLiteralValue(annotation);
newParamAnnotation.setValue(newStringLiteral);
ListRewrite paramRewrite = rewrite.getListRewrite(param, SingleVariableDeclaration.MODIFIERS2_PROPERTY);
paramRewrite.insertFirst(newParamAnnotation, null);
}
示例6: getParameterAnnotation
import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
private SingleMemberAnnotation getParameterAnnotation(ASTRewrite rewrite, SingleVariableDeclaration param,
String annotation) {
SingleMemberAnnotation newParamAnnotation = param.getAST().newSingleMemberAnnotation();
newParamAnnotation.setTypeName(rewrite.getAST().newSimpleName("Domain"));
StringLiteral newStringLiteral = rewrite.getAST().newStringLiteral();
newStringLiteral.setLiteralValue(annotation);
newParamAnnotation.setValue(newStringLiteral);
return newParamAnnotation;
}
示例7: getReturnTypeAnnotation
import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
private SingleMemberAnnotation getReturnTypeAnnotation(ASTRewrite rewrite, MethodDeclaration methodDeclaration,
String annotation) {
SingleMemberAnnotation newReturnAnnotation = methodDeclaration.getAST().newSingleMemberAnnotation();
newReturnAnnotation.setTypeName(rewrite.getAST().newSimpleName("Domain"));
StringLiteral newStringLiteral = rewrite.getAST().newStringLiteral();
newStringLiteral.setLiteralValue(annotation);
newReturnAnnotation.setValue(newStringLiteral);
return newReturnAnnotation;
}
示例8: getTypeAnnotationDomain
import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
private SingleMemberAnnotation getTypeAnnotationDomain(ASTRewrite rewrite, TypeDeclaration typeDeclaration,
String annotation, String domainName) {
ArrayInitializer initializer = rewrite.getAST().newArrayInitializer();
if (domainName != null) {
ListRewrite listRewrite = rewrite.getListRewrite(initializer, ArrayInitializer.EXPRESSIONS_PROPERTY);
StringLiteral newStringLiteral = rewrite.getAST().newStringLiteral();
newStringLiteral.setLiteralValue(domainName);
listRewrite.insertFirst(newStringLiteral, null);
// XXX. HACK: Add hard-coded public domain, PD
StringLiteral newStringLiteralPD = rewrite.getAST().newStringLiteral();
newStringLiteralPD.setLiteralValue("PD");
listRewrite.insertLast(newStringLiteralPD, null);
// Add other domains that are created using other refinements
declareOtherDomains(rewrite, listRewrite, typeDeclaration);
// XXX. HACK: Add another hard-coded domain, PARAM. NO.
// StringLiteral newStringLiteralPARAM = rewrite.getAST().newStringLiteral();
// newStringLiteralPARAM.setLiteralValue("PARAM");
// listRewrite.insertLast(newStringLiteralPARAM, null);
}
SingleMemberAnnotation newParamAnnotation = typeDeclaration.getAST().newSingleMemberAnnotation();
newParamAnnotation.setTypeName(rewrite.getAST().newSimpleName(annotation));
newParamAnnotation.setValue(initializer);
return newParamAnnotation;
}
示例9: getTypeAnnotationInherits
import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
private SingleMemberAnnotation getTypeAnnotationInherits(ASTRewrite rewrite, TypeDeclaration typeDeclaration,
String annotation, String domainName) {
boolean display = false;
ArrayInitializer initializer = rewrite.getAST().newArrayInitializer();
ListRewrite listRewrite = rewrite.getListRewrite(initializer, ArrayInitializer.EXPRESSIONS_PROPERTY);
List localSuperClasses = getAllSuperTypes(typeDeclaration);
if (!localSuperClasses.isEmpty()) {
int i = 0;
for (Iterator iterSuperClass = localSuperClasses.iterator(); iterSuperClass.hasNext();) {
Type tt = (Type) iterSuperClass.next();
if (tt != null) {
StringBuilder builder = new StringBuilder();
// Use simple name rather than fully qualified type name. Typechecker does not expect qualified name.
builder.append(Signature.getSimpleName(tt.toString()));
builder.append("<");
builder.append(domainName);
builder.append(">");
StringLiteral newStringLiteral = rewrite.getAST().newStringLiteral();
newStringLiteral.setLiteralValue(builder.toString());
listRewrite.insertAt(newStringLiteral, i, null);
i++;
display = true;
}
}
}
SingleMemberAnnotation newParamAnnotation = typeDeclaration.getAST().newSingleMemberAnnotation();
newParamAnnotation.setTypeName(rewrite.getAST().newSimpleName(annotation));
newParamAnnotation.setValue(initializer);
if (display) {
return newParamAnnotation;
}
return null;
}
示例10: getVariableAnnotation
import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
private SingleMemberAnnotation getVariableAnnotation(ASTNode varDecl, String annotation) {
SingleMemberAnnotation newParamAnnotation = varDecl.getAST().newSingleMemberAnnotation();
newParamAnnotation.setTypeName(rewrite.getAST().newSimpleName("Domain"));
StringLiteral newStringLiteral = rewrite.getAST().newStringLiteral();
newStringLiteral.setLiteralValue(annotation);
newParamAnnotation.setValue(newStringLiteral);
return newParamAnnotation;
}
示例11: createMethodDeclaration
import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
public MethodDeclaration createMethodDeclaration(IType clientBundle, ASTRewrite astRewrite,
ImportRewrite importRewrite, boolean addComments) throws CoreException {
AST ast = astRewrite.getAST();
MethodDeclaration methodDecl = ast.newMethodDeclaration();
// Method is named after the resource it accesses
methodDecl.setName(ast.newSimpleName(getMethodName()));
// Method return type is a ResourcePrototype subtype
ITypeBinding resourceTypeBinding = JavaASTUtils.resolveType(clientBundle.getJavaProject(), getReturnTypeName());
Type resourceType = importRewrite.addImport(resourceTypeBinding, ast);
methodDecl.setReturnType2(resourceType);
// Add @Source annotation if necessary
String sourceAnnotationValue = getSourceAnnotationValue(clientBundle);
if (sourceAnnotationValue != null) {
// Build the annotation
SingleMemberAnnotation sourceAnnotation = ast.newSingleMemberAnnotation();
sourceAnnotation.setTypeName(ast.newName("Source"));
StringLiteral annotationValue = ast.newStringLiteral();
annotationValue.setLiteralValue(sourceAnnotationValue);
sourceAnnotation.setValue(annotationValue);
// Add the annotation to the method
ChildListPropertyDescriptor modifiers = methodDecl.getModifiersProperty();
ListRewrite modifiersRewriter = astRewrite.getListRewrite(methodDecl, modifiers);
modifiersRewriter.insertFirst(sourceAnnotation, null);
}
return methodDecl;
}