本文整理汇总了Java中org.eclipse.jdt.core.dom.AST.newMarkerAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java AST.newMarkerAnnotation方法的具体用法?Java AST.newMarkerAnnotation怎么用?Java AST.newMarkerAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.AST
的用法示例。
在下文中一共展示了AST.newMarkerAnnotation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createOverrideAnnotation
import org.eclipse.jdt.core.dom.AST; //导入方法依赖的package包/类
public static void createOverrideAnnotation(ASTRewrite rewrite, ImportRewrite imports, MethodDeclaration decl, TextEditGroup group) {
if (findAnnotation("java.lang.Override", decl.modifiers()) != null) { //$NON-NLS-1$
return; // No need to add duplicate annotation
}
AST ast= rewrite.getAST();
ASTNode root= decl.getRoot();
ImportRewriteContext context= null;
if (root instanceof CompilationUnit) {
context= new ContextSensitiveImportRewriteContext((CompilationUnit) root, decl.getStartPosition(), imports);
}
Annotation marker= ast.newMarkerAnnotation();
marker.setTypeName(ast.newName(imports.addImport("java.lang.Override", context))); //$NON-NLS-1$
rewrite.getListRewrite(decl, MethodDeclaration.MODIFIERS2_PROPERTY).insertFirst(marker, group);
}
示例2: addAnnotation
import org.eclipse.jdt.core.dom.AST; //导入方法依赖的package包/类
private static void addAnnotation(final AST ast, final ASTRewrite rewriter, String annotationName,
Collection<TypeDeclaration> nodes) {
for (final TypeDeclaration node : nodes) {
final ListRewrite listRewrite = rewriter.getListRewrite(node, TypeDeclaration.MODIFIERS2_PROPERTY);
final MarkerAnnotation markerAnnotation = ast.newMarkerAnnotation();
markerAnnotation.setTypeName(ast.newName(annotationName));
listRewrite.insertFirst(markerAnnotation, null);
}
}
示例3: createMarkerAnnotation
import org.eclipse.jdt.core.dom.AST; //导入方法依赖的package包/类
private MarkerAnnotation createMarkerAnnotation(AST ast, String annotation) {
MarkerAnnotation markerAnnotation = ast.newMarkerAnnotation();
markerAnnotation.setTypeName(ast.newSimpleName(annotation));
return markerAnnotation;
}