Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package net.sf.alchim.codeplus.spoonchecker;
 
 
public abstract class AbstractAnalyzer<E extends CtElementextends AbstractProcessor<E> {
    @Property
    public Severity severity = .;
    @SuppressWarnings("unchecked")
    public AbstractAnalyzer() {
        super();
        clearProcessedElementType();
        boolean isEmpty = true;
        for (Method m : getClass().getMethods()) {
            if (m.getName().equals("analyze")
                    && (m.getParameterTypes().length == 1)) {
                Class c = m.getParameterTypes()[0];
                if (CtElement.class != c) {
                    addProcessedElementType(c);
                    isEmpty = false;
                }
            }
        }
        if (isEmpty) {
            addProcessedElementType(CtElement.class);
        }
    }
    final public void process(E element) {
        if ((.compareTo(.) > 0) || !existsSuppressWarning(element)) {
            analyze(element);
        }
    }
    abstract public void analyze(E element);
    protected boolean existsSuppressWarning(CtElement element) {
        boolean back = false;
        if (element != null) {
            SuppressWarnings sw = element.getAnnotation(SuppressWarnings.class);
            if (sw != null) {
                for(String value :sw.value()) {
                    back = value.equals(this.getClass().getName());
                    back = back || value.equals(this.getClass().getSimpleName());
                    back = back || value.equals(getCategory());
                    if (back) {
                        break;
                    }
                }
            }
            if (!back) {
                back = existsSuppressWarning(element.getParent());
            }
        }
        return back;
    }
    protected String getCategory() {
        return "none";
    }
    @SuppressWarnings("unchecked")
    protected void report(CtElement elementString msgProblemFixer<CtElement>... fixers) {
        ProblemFixer<CtElement>[] nfixers = new ProblemFixer[fixers.length+1];
        nfixers[nfixers.length-1] = new SuppressWarningFixer(this.getClass());
        getEnvironment().report(thiselementmsgnfixers);
    }
New to GrepCode? Check out our FAQ X