本文整理汇总了Java中com.github.javaparser.ast.body.AnnotationDeclaration类的典型用法代码示例。如果您正苦于以下问题:Java AnnotationDeclaration类的具体用法?Java AnnotationDeclaration怎么用?Java AnnotationDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AnnotationDeclaration类属于com.github.javaparser.ast.body包,在下文中一共展示了AnnotationDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import com.github.javaparser.ast.body.AnnotationDeclaration; //导入依赖的package包/类
@Override
public void visit(final AnnotationDeclaration n, final Object arg) {
printer.printLn("AnnotationDeclaration");
printJavaComment(n.getComment(), arg);
printJavadoc(n.getJavaDoc(), arg);
printMemberAnnotations(n.getAnnotations(), arg);
printModifiers(n.getModifiers());
printer.print("@interface ");
printer.print(n.getName());
printer.printLn(" {");
printer.indent();
if (n.getMembers() != null) {
printMembers(n.getMembers(), arg);
}
printer.unindent();
printer.print("}");
}
示例2: visit
import com.github.javaparser.ast.body.AnnotationDeclaration; //导入依赖的package包/类
@Override
public JCTree visit(final AnnotationDeclaration n, final Object arg) {
/* TODO - Annotations are not currently supported
if (n.getJavaDoc() != null) {
JCTree result = n.getJavaDoc().accept(this, arg);
}
if (n.getAnnotations() != null) {
for (final AnnotationExpr a : n.getAnnotations()) {
JCTree result = a.accept(this, arg);
}
}
if (n.getMembers() != null) {
for (final BodyDeclaration member : n.getMembers()) {
JCTree result = member.accept(this, arg);
}
}
return new AJCAnnotationDeclaration( make.AnnotationDeclaration( ), ( (n.getComment()!=null)?n.getComment().getContent():null ) );
*/
System.err.println("Assigning null at:" + Thread.currentThread().getStackTrace()[1].getLineNumber());
return null;
}
示例3: visit
import com.github.javaparser.ast.body.AnnotationDeclaration; //导入依赖的package包/类
@Override public Boolean visit(final AnnotationDeclaration n1, final Node arg) {
final AnnotationDeclaration n2 = (AnnotationDeclaration) arg;
// javadoc are checked at CompilationUnit
if (n1.getModifiers() != n2.getModifiers()) {
return Boolean.FALSE;
}
if (!objEquals(n1.getName(), n2.getName())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getMembers(), n2.getMembers())) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
示例4: visit
import com.github.javaparser.ast.body.AnnotationDeclaration; //导入依赖的package包/类
@Override public void visit(final AnnotationDeclaration n, final Object arg) {
printJavaComment(n.getComment(), arg);
printJavadoc(n.getJavaDoc(), arg);
printMemberAnnotations(n.getAnnotations(), arg);
printModifiers(n.getModifiers());
printer.print("@interface ");
printer.print(n.getName());
printer.printLn(" {");
printer.indent();
if (n.getMembers() != null) {
printMembers(n.getMembers(), arg);
}
printer.unindent();
printer.print("}");
}
示例5: visit
import com.github.javaparser.ast.body.AnnotationDeclaration; //导入依赖的package包/类
@Override public void visit(final AnnotationDeclaration n, final A arg) {
visitComment(n.getComment(), arg);
if (n.getJavaDoc() != null) {
n.getJavaDoc().accept(this, arg);
}
if (n.getAnnotations() != null) {
for (final AnnotationExpr a : n.getAnnotations()) {
a.accept(this, arg);
}
}
if (n.getMembers() != null) {
for (final BodyDeclaration member : n.getMembers()) {
member.accept(this, arg);
}
}
}
示例6: visit
import com.github.javaparser.ast.body.AnnotationDeclaration; //导入依赖的package包/类
@Override public void visit(final AnnotationDeclaration n, final A arg) {
jw.write(n);
visitComment(n.getComment(), arg);
if (n.getJavaDoc() != null) {
n.getJavaDoc().accept(this, arg);
}
if (n.getAnnotations() != null) {
for (final AnnotationExpr a : n.getAnnotations()) {
a.accept(this, arg);
}
}
if (n.getMembers() != null) {
for (final BodyDeclaration member : n.getMembers()) {
member.accept(this, arg);
}
}
}
示例7: visit
import com.github.javaparser.ast.body.AnnotationDeclaration; //导入依赖的package包/类
@Override public Node visit(final AnnotationDeclaration n, final A arg) {
if (n.getJavaDoc() != null) {
n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg));
}
final List<AnnotationExpr> annotations = n.getAnnotations();
if (annotations != null) {
for (int i = 0; i < annotations.size(); i++) {
annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg));
}
removeNulls(annotations);
}
final List<BodyDeclaration> members = n.getMembers();
if (members != null) {
for (int i = 0; i < members.size(); i++) {
members.set(i, (BodyDeclaration) members.get(i).accept(this, arg));
}
removeNulls(members);
}
return n;
}
示例8: visit
import com.github.javaparser.ast.body.AnnotationDeclaration; //导入依赖的package包/类
@Override public Boolean visit(final AnnotationDeclaration n1, final Node arg) {
final AnnotationDeclaration n2 = (AnnotationDeclaration) arg;
// javadoc are checked at CompilationUnit
if (!n1.getModifiers().equals(n2.getModifiers())) {
return false;
}
if (!objEquals(n1.getName(), n2.getName())) {
return false;
}
if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) {
return false;
}
if (!nodesEquals(n1.getMembers(), n2.getMembers())) {
return false;
}
return true;
}
示例9: visit
import com.github.javaparser.ast.body.AnnotationDeclaration; //导入依赖的package包/类
@Override public void visit(final AnnotationDeclaration n, final Object arg) {
printJavaComment(n.getComment(), arg);
printJavadoc(n.getJavaDoc(), arg);
printMemberAnnotations(n.getAnnotations(), arg);
printModifiers(n.getModifiers());
printer.print("@interface ");
printer.print(n.getName());
printer.printLn(" {");
printer.indent();
if (n.getMembers() != null) {
printMembers(n.getMembers(), arg);
}
printer.unindent();
printer.print("}");
}
示例10: calculateRelations
import com.github.javaparser.ast.body.AnnotationDeclaration; //导入依赖的package包/类
public void calculateRelations(Collection<File> files) {
System.out.println();
int totalFiles = files.size();
int fileIndex = 1;
for (File file : files) {
try {
CompilationUnit cu = parse(file);
NodeList<TypeDeclaration<?>> types = cu.getTypes();
for (TypeDeclaration<?> type : types) {
boolean isInterface = type instanceof ClassOrInterfaceDeclaration && ((ClassOrInterfaceDeclaration) type).isInterface();
boolean isAnnotation = type instanceof AnnotationDeclaration;
boolean isEnumeration = type instanceof EnumDeclaration;
boolean isClass = !isAnnotation && !isEnumeration && !isInterface;
if (isInterface) {
// check if this interface extends another interface and persist relation in EXTENDS table
ClassOrInterfaceDeclaration interfaceDeclaration = (ClassOrInterfaceDeclaration) type;
extendsRelationCalculator.calculate(interfaceDeclaration, cu);
}
if (isClass) {
ClassOrInterfaceDeclaration classDeclaration = (ClassOrInterfaceDeclaration) type;
// check if this class implements an interface and persist relation in IMPLEMENTS table
implementsRelationCalculator.calculate(classDeclaration, cu);
// check if this class extends another class and persist relation in EXTENDS table
extendsRelationCalculator.calculate(classDeclaration, cu);
}
if (isClass || isInterface) {
annotatedWithCalculator.calculate((ClassOrInterfaceDeclaration) type, cu);
}
}
} catch (ParseProblemException | IOException e) {
System.err.println("Error while parsing " + file.getAbsolutePath());
}
System.out.print("\rCalculating relations: " + getPercent(fileIndex, totalFiles) + "% " + ("(" + fileIndex + "/" + totalFiles + ")"));
fileIndex++;
}
System.out.println();
}
示例11: doMerge
import com.github.javaparser.ast.body.AnnotationDeclaration; //导入依赖的package包/类
@Override
public AnnotationDeclaration doMerge(AnnotationDeclaration first, AnnotationDeclaration second) {
AnnotationDeclaration ad = new AnnotationDeclaration();
ad.setJavaDoc(mergeSingle(first.getJavaDoc(), second.getJavaDoc()));
ad.setMembers(mergeCollections(first.getMembers(), second.getMembers()));
ad.setAnnotations(mergeCollections(first.getAnnotations(), second.getAnnotations()));
ad.setModifiers(mergeModifiers(first.getModifiers(), second.getModifiers()));
return ad;
}
示例12: visit
import com.github.javaparser.ast.body.AnnotationDeclaration; //导入依赖的package包/类
@Override
public Node visit(AnnotationDeclaration _n, Object _arg) {
JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
List<BodyDeclaration> members = visit(_n.getMembers(), _arg);
Comment comment = cloneNodes(_n.getComment(), _arg);
AnnotationDeclaration r = new AnnotationDeclaration(
_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(),
_n.getModifiers(), annotations, _n.getName(), members
);
r.setComment(comment);
return r;
}
示例13: doCompile
import com.github.javaparser.ast.body.AnnotationDeclaration; //导入依赖的package包/类
@Override
protected UnitCache<EmulTypeElement> doCompile(TypeDeclaration unit) {
String unitName = unit.getName();
String qualifiedName = TypeUtil.determineQualifiedName(
getCompileUnit(), unit.getNameExpr());
TypeMirror type = new EmulType(new StringName(qualifiedName), TypeKind.DECLARED);
Name name = new StringName(unitName);
ElementKind kind = ElementKind.OTHER;
List<Element> members = new ArrayList<>();
Set<Modifier> modifierSet = ModifierUtil.asSet(unit.getModifiers());
if(unit instanceof AnnotationDeclaration) {
kind = ElementKind.ANNOTATION_TYPE;
} else if(unit instanceof EnumDeclaration) {
kind = ElementKind.ENUM;
} else if(unit instanceof ClassOrInterfaceDeclaration) {
if(((ClassOrInterfaceDeclaration) unit).isInterface()) {
kind = ElementKind.INTERFACE;
} else {
kind = ElementKind.CLASS;
}
}
EmulTypeElement element = new EmulTypeElement(type, kind, parent, members,
modifierSet, name, name, NestingKind.TOP_LEVEL);
// Children
NodeToElementCompiler compiler = new NodeToElementCompiler(getCompileUnit(), element);
for(BodyDeclaration member : unit.getMembers()) {
Element childElem = compiler.compile(member);
if(childElem != null) {
members.add(childElem);
}
}
return new UnitCache<>(element);
}
示例14: visit
import com.github.javaparser.ast.body.AnnotationDeclaration; //导入依赖的package包/类
@Override
public void visit(AnnotationDeclaration node, Object arg) {
if (node == null) {
return;
}
ensurePackageName(node);
Log.d(TAG, "visit AnnotationDeclaration, name: %s", node.getName());
classVisitor.inspectTypeDeclaration(sourceInfo, node, null, false);
}
示例15: visit
import com.github.javaparser.ast.body.AnnotationDeclaration; //导入依赖的package包/类
@Override
public Node visit(AnnotationDeclaration _n, Object _arg) {
List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
List<BodyDeclaration<?>> members = visit(_n.getMembers(), _arg);
Comment comment = cloneNodes(_n.getComment(), _arg);
AnnotationDeclaration r = new AnnotationDeclaration(
_n.getRange(),
_n.getModifiers(), annotations, _n.getName(), members
);
r.setComment(comment);
return r;
}