Monday Mar 10, 2014

EditorConfig and NetBeans IDE (Part 1)

I made the first steps into EditorConfig support for NetBeans IDE.

Put a file named ".editorconfig" somewhere, e.g., the root folder, open a file, click the EditorConfig button (the mouse is the logo of EditorConfig) in the toolbar, which you can see below next to the Cut button, and then the Output window shows the parsed EditorConfig file, applied based on which type of file is currently selected.

However, I had assumed that the properties in the EditorConfig file would automatically be applied to the current file by EditorConfig. But that doesn't appear to be the case. So, for each property in EditorConfig (of which there are not many), I need to figure out how to map them to functionality in NetBeans IDE. In some cases, I guess there will not be APIs and I'll need to figure out on a case by case basis how to implement the property for the file in question.

The sources are here:

The related issue:

And here's all the code.

        category = "Tools",
        id = ""
        iconBase = "org/netbeans/ec/editorconfig.png",
        displayName = "#CTL_RunEditorconfigAction"
    @ActionReference(path = "Menu/Source", position = 200),
    @ActionReference(path = "Toolbars/Clipboard", position = 0)
@Messages("CTL_RunEditorconfigAction=Run EditorConfig")
public final class RunEditorconfigAction implements ActionListener {
    private final DataObject dobj;
    public RunEditorconfigAction(DataObject dobj) {
        this.dobj = dobj;
    public void actionPerformed(ActionEvent e) {
        InputOutput io = IOProvider.getDefault().getIO("EditorConfig", true);;
        OutputWriter writer = io.getOut();
        EditorConfig ec;
        try {
            ec = new EditorConfig();
            List<EditorConfig.OutPair> l = null;
            l = ec.getProperties(dobj.getPrimaryFile().getPath());
            for (int i = 0; i < l.size(); ++i) {
                writer.println(l.get(i).getKey() + "=" + l.get(i).getVal());
        } catch (PythonException ex) {
        } catch (EditorConfigException ex) {


Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« March 2014 »