@Override public boolean visit(MarkerAnnotation node) { ASTNode parent = node.getParent(); if (isTestAnnotation(node.getTypeName().toString())) { if (parent instanceof MethodDeclaration) { addTestMethod((MethodDeclaration) parent, JDK15_ANNOTATION); } else if (parent instanceof TypeDeclaration) { // TESTNG-24 m_typeIsTest = true; m_annotationType = JDK15_ANNOTATION; } } else if (isFactoryAnnotation(node.getTypeName().toString())) { if (parent instanceof MethodDeclaration) { m_annotationType = JDK15_ANNOTATION; addFactoryMethod((MethodDeclaration) parent, JDK15_ANNOTATION); } } return false; }
/* * @see ASTVisitor#visit(MarkerAnnotation) * @since 3.0 */ public boolean visit(MarkerAnnotation node) { this.fBuffer.append("@"); // $NON-NLS-1$ node.getTypeName().accept(this); return false; }
/* (non-Javadoc) * @see org.eclipse.jdt.internal.corext.dom.GenericVisitor#visit(org.eclipse.jdt.core.dom.MarkerAnnotation) */ @Override public boolean visit(MarkerAnnotation node) { typeRefFound(node.getTypeName()); return false; }
public static void addFinalAndValAnnotationToModifierList( Object converter, List<IExtendedModifier> modifiers, AST ast, LocalDeclaration in) { // First check that 'in' has the final flag on, and a @val / @lombok.val annotation. if ((in.modifiers & ClassFileConstants.AccFinal) == 0) return; if (in.annotations == null) return; boolean found = false; Annotation valAnnotation = null; for (Annotation ann : in.annotations) { if (PatchVal.couldBeVal(ann.type)) { found = true; valAnnotation = ann; break; } } if (!found) return; // Now check that 'out' is missing either of these. if (modifiers == null) return; // This is null only if the project is 1.4 or less. Lombok doesn't work in that. boolean finalIsPresent = false; boolean valIsPresent = false; for (Object present : modifiers) { if (present instanceof Modifier) { ModifierKeyword keyword = ((Modifier) present).getKeyword(); if (keyword == null) continue; if (keyword.toFlagValue() == Modifier.FINAL) finalIsPresent = true; } if (present instanceof org.eclipse.jdt.core.dom.Annotation) { Name typeName = ((org.eclipse.jdt.core.dom.Annotation) present).getTypeName(); if (typeName != null) { String fullyQualifiedName = typeName.getFullyQualifiedName(); if ("val".equals(fullyQualifiedName) || "lombok.val".equals(fullyQualifiedName)) { valIsPresent = true; } } } } if (!finalIsPresent) { modifiers.add( createModifier( ast, ModifierKeyword.FINAL_KEYWORD, valAnnotation.sourceStart, valAnnotation.sourceEnd)); } if (!valIsPresent) { MarkerAnnotation newAnnotation = createValAnnotation( ast, valAnnotation, valAnnotation.sourceStart, valAnnotation.sourceEnd); try { Reflection.astConverterRecordNodes.invoke(converter, newAnnotation, valAnnotation); Reflection.astConverterRecordNodes.invoke( converter, newAnnotation.getTypeName(), valAnnotation.type); } catch (IllegalAccessException e) { throw Lombok.sneakyThrow(e); } catch (InvocationTargetException e) { throw Lombok.sneakyThrow(e.getCause()); } modifiers.add(newAnnotation); } }