X

Geertjan's Blog

  • May 27, 2012

Analyzer Skeleton for NetBeans IDE

Geertjan Wielenga
Product Manager

Simple starting point for creating a new analyzer, similar to FindBugs, but this time for something else, e.g., HTML Tidy:

Doesn't do anything yet, but here's the code:

import java.util.Collections;
import javax.swing.JComponent;
import org.netbeans.modules.analysis.spi.Analyzer;
import org.netbeans.spi.editor.hints.ErrorDescription;
import org.openide.util.lookup.ServiceProvider;
public class MyAnalyzer implements Analyzer {
    @Override
    public Iterable<? extends ErrorDescription> analyze() {
        return Collections.emptyList();
    }
    @Override
    public boolean cancel() {
        return true;
    }
    @ServiceProvider(service=AnalyzerFactory.class)
    public static final class MyAnalyzerFactory extends AnalyzerFactory {
        public MyAnalyzerFactory() {
            super("htmltidy", "HTML Tidy", (String) null);
        }
        @Override
        public Iterable<? extends WarningDescription> getWarnings() {
            return Collections.emptyList();
        }
        @Override
        public <D, C extends JComponent> CustomizerProvider<D, C> getCustomizerProvider() {
            return null;
        }
        @Override
        public Analyzer createAnalyzer(Context cntxt) {
            return new MyAnalyzer();
        }
    }
}

The point of the above code, and this entire blog entry, is to highlight the fact that you can integrate your own analyzers, as one or more plugins into NetBeans IDE... because the NetBeans IDE analyzer feature is pluggable.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.