use of org.eclipse.jdt.core.dom.Annotation in project generator by mybatis.
the class JavaFileMerger method addExistsAnnotations.
@SuppressWarnings("unchecked")
private void addExistsAnnotations(BodyDeclaration node, List<Annotation> oldAnnotations) {
Set<String> newAnnotationTypes = new HashSet<String>();
int lastAnnotationIndex = 0;
int idx = 0;
for (Object modifier : node.modifiers()) {
if (modifier instanceof Annotation) {
Annotation newAnnotation = (Annotation) modifier;
newAnnotationTypes.add(newAnnotation.getTypeName().getFullyQualifiedName());
lastAnnotationIndex = idx;
}
idx++;
}
if (oldAnnotations != null) {
for (Annotation oldAnnotation : oldAnnotations) {
if (newAnnotationTypes.contains(oldAnnotation.getTypeName().getFullyQualifiedName()))
continue;
AST nodeAst = node.getAST();
node.modifiers().add(lastAnnotationIndex++, ASTNode.copySubtree(nodeAst, oldAnnotation));
}
}
}
use of org.eclipse.jdt.core.dom.Annotation in project che by eclipse.
the class ExtractConstantRefactoring method getReplacementScope.
/*
* Elements returned by next() are BodyDeclaration or Annotation instances.
*/
private Iterator<ASTNode> getReplacementScope() throws JavaModelException {
boolean declPredecessorReached = false;
Collection<ASTNode> scope = new ArrayList<ASTNode>();
AbstractTypeDeclaration containingType = getContainingTypeDeclarationNode();
if (containingType instanceof EnumDeclaration) {
// replace in all enum constants bodies
EnumDeclaration enumDeclaration = (EnumDeclaration) containingType;
scope.addAll(enumDeclaration.enumConstants());
}
for (Iterator<IExtendedModifier> iter = containingType.modifiers().iterator(); iter.hasNext(); ) {
IExtendedModifier modifier = iter.next();
if (modifier instanceof Annotation) {
scope.add((ASTNode) modifier);
}
}
for (Iterator<BodyDeclaration> bodyDeclarations = containingType.bodyDeclarations().iterator(); bodyDeclarations.hasNext(); ) {
BodyDeclaration bodyDeclaration = bodyDeclarations.next();
if (bodyDeclaration == getNodeToInsertConstantDeclarationAfter())
declPredecessorReached = true;
if (insertFirst() || declPredecessorReached || !isStaticFieldOrStaticInitializer(bodyDeclaration))
scope.add(bodyDeclaration);
}
return scope.iterator();
}
use of org.eclipse.jdt.core.dom.Annotation in project Main by SpartanRefactoring.
the class ZZZ___Fixture_ModelClass method a32.
@Test
@method
public void a32() {
for (final Annotation a : annotations()) {
final SingleMemberAnnotation ¢ = az.singleMemberAnnotation(a);
if (¢ == null)
continue;
final List<SimpleName> ns = annotees.of(¢);
assert ns != null;
final SimpleName n = the.firstOf(ns);
assert n != null;
if (!"annotation".equals(n + ""))
continue;
final List<? extends ASTNode> s = scope.of(n);
assert s != null : //
fault.dump() + "\n\t scope = " + //
s + "\n\t ¢ = " + //
¢ + "\n\t n = " + //
n + "\n\t ns = " + //
ns + fault.done();
}
}
use of org.eclipse.jdt.core.dom.Annotation in project Main by SpartanRefactoring.
the class ZZZ___Fixture_ModelClass method a33.
@Test
@method
public void a33() {
for (final Annotation a : annotations()) {
final SingleMemberAnnotation x = az.singleMemberAnnotation(a);
if (x != null && (x.getTypeName() + "").equals(ScopeSize.class.getSimpleName() + "")) {
final SimpleName n = the.firstOf(annotees.of(x));
if (!"fenum".equals(n + ""))
continue;
azzert.that(x + ": " + n + "/" + definition.kind(n), scope.of(n).size(), is(value(x)));
}
}
}
use of org.eclipse.jdt.core.dom.Annotation in project Main by SpartanRefactoring.
the class ZZZ___Fixture_ModelClass method a38.
@Test
@method
public void a38() {
for (final Annotation a : annotations()) {
final SingleMemberAnnotation x = az.singleMemberAnnotation(a);
if (x != null && (x.getTypeName() + "").equals(ScopeSize.class.getSimpleName() + "")) {
final SimpleName n = the.firstOf(annotees.of(x));
if (!DummyClass.class.getSimpleName().equals(n + ""))
continue;
azzert.that(x + ": " + n + "/" + definition.kind(n), scope.of(n).size(), is(value(x)));
}
}
}
Aggregations