Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package net.sf.alchim.codeplus.spoonprocessor;
 
 import java.util.Set;
 
public class ProcessorHelper {
    public static CtAnnotation<?> findAnnotation(CtElement eltClass<? extends Annotationtype) {
        CtAnnotation<?> annotation = null;
        for (CtAnnotation<?> a : elt.getAnnotations()) {
            if (type.equals(a.getActualAnnotation().annotationType())) {
                annotation = a;
                break;
            }
        }
        return annotation;
    }
    public static void removeAnnotation(CtElement eltClass<? extends Annotationtype) {
        Set<CtAnnotation<?>> annotations = elt.getAnnotations();
        for(CtAnnotation<?> cta : annotations) {
            try {
                if (cta.getActualAnnotation().annotationType().equals(type)) {
                    annotations.remove(cta);
                }
            } catch(NullPointerException exc) {
            }
        }
        elt.setAnnotations(annotations);
    }
    public static void forcePositionOfEveryStmt(CtStatement stmtSourcePosition position) {
        Collection<CtAbstractInvocation<?>> is = Query.getElements(stmtnew Filter<CtAbstractInvocation<?>>() {
            @SuppressWarnings("unchecked")
            public Class getType() {
                return CtAbstractInvocation.class;
            }
            public boolean matches(CtAbstractInvocation<?> element) {
                return true;
            }
        });
        for (CtAbstractInvocation<?> i : is) {
            i.setPosition(position);
        }
    }
New to GrepCode? Check out our FAQ X