Community
Participate
Working Groups
Most of JavaScript project uses today an .editorconfig file http://editorconfig.org/ and most of IDE like Visual Studio, JetBrains is able to use this .editorconfig file for their code styles. IMHO, I think JSDT should be able to use .editorconfig for code style. But perhaps it should be very good that it works too for Java and other Language editor, in other words Eclipse IDE should : * provide an .editorconfig editor. * give a common preferences based on .editorconfig. After that each language could use this configuration for their code styles.
I think this bug can be closed since there exists this bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=389139
No, it can't. That bug #389139 is already closed (as won't fix). So, if you have a contribution ready to be incubated by eclipse then you could re-open that bug and propose your contribution if you would. If you haven't, then this bug could be a source of new 'helpwanted' issue. So that such a contribution is still welcomed. IMHO, such a configuration could be useful for any Eclipse's editor, but we can start at least with implementing it for JavaScript editor and, if suceeded, to propose it for the whole community.
> No, it can't. Ok Victor I understand. I have no time today to develop this kind plugin since I have the intention to contribute to WTP with WTP JSON Editor https://github.com/angelozerr/eclipse-wtp-json (it's out of the topic, but completion based on JSON Schema starts working, now I'm working on bower dependencies completion).
See https://github.com/ncjones/editorconfig-eclipse
The .editorconfig specification http://editorconfig.org/#file-location says : "When opening a file, EditorConfig plugins look for a file named .editorconfig in the directory of the opened file and in every parent directory. A search for .editorconfig files will stop if the root filepath is reached or an EditorConfig file with root=true is found." It means that preferences of the editor must be setted according the file location. Today JSDT Editor doesn't provides this feature. It should be cool if JSDT could provide an extension point to customize preferences formatter for a given editor. This extension point could be called here http://git.eclipse.org/c/jsdt/webtools.jsdt.core.git/tree/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/javaeditor/CompilationUnitEditor.java#n215 to retrieve the options from the extension point.
The way the editorconfig-eclipse plugin is implemented requires me adding explicit support for every type of editor, for example: ``` setPreference("org.eclipse.jdt.core", "org.eclipse.jdt.core.formatter.tabulation.char", "space"); setPreference("org.eclipse.wst.xml.core", "indentationChar", "space"); ``` Currently only Text, Java and Xml editors are supported. I want to expand this support but it's clearly not a scalable solution and it's also quite a clunky hack since it modifies global settings whenever a file is opened. Ideally each editor should natively support editorconfig by applying editorconfig settings in preference over project and workspace settings. This would require making the editorconfig plugin a dependency of all editors. This requires some pretty significant changes in the IDE. What are your thoughts?
A possibility would be to have be able to plug editor config processors via Eclipse extension. So for example, JSDT would add a process that would take as input the editor config and apply the settings specific to JavaScript preferences and/or editors.
I think this needs to go into org.eclipse.ui.texteditor.AbstractTextEditor. I feel that imitating the behavior via changing preferences is error prone as well. Has anyone looked if AbstractTextEditor is a good place to build this into?
> I think this needs to go into org.eclipse.ui.texteditor.AbstractTextEditor. I feel that imitating the behavior via changing preferences is error prone as well. I have found a clean solution to customize editor instance (and not the whole editor of the project) with IEclipsePreferences. The basic idea is that the editor must returns her instance of IEclipsePreferences with getAdapter --------------------------------- editorPreferences = new EclipsePreferences(); editorPreferences.addPreferenceChangeListener( new org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener() { @Override public void preferenceChange(PreferenceChangeEvent event) { handlePreferenceStoreChanged(new PropertyChangeEvent(event.getSource(), event.getKey(), event.getOldValue(), event.getNewValue())); } }); } /* * @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent) */ protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { ... } @Override public Object getAdapter(@SuppressWarnings("rawtypes") Class key) { if (key.equals(IEclipsePreferences.class)) { // support for .editorconfig return editorPreferences; } return super.getAdapter(key); } --------------------------------- And after an external action can update the editor preferences like this: --------------------------------- IEditorPart editor = ... IEclipsePreferences p = (IEclipsePreferences) editor.getAdapter(IEclipsePreferences.class); if (p != null) { p.put("spacesForTabs", "true") } --------------------------------- Please read my comment at https://github.com/ncjones/editorconfig-eclipse/issues/9#issuecomment-221233859 > Has anyone looked if AbstractTextEditor is a good place to build this into? I think the code with getAdapter could be hosted inside AbstractTextEditor, it should really cool! What do you think about this idea?
@Angelo: I have the impression that this gets really into the right direction, thanks for sharing those thought? So you'd just like to be able to access editor preferences from a given AbstractTextEditor? If so, can you please another bugzilla for that, again Platform/Text to work on this specific change. I believe such a request can easily be honored, maybe even from Neon.1.
> @Angelo: I have the impression that this gets really into the right direction, thanks for sharing those thought? Glad this idea please you:) I have tested with my TypeScript Editor and it works like a charm. > So you'd just like to be able to access editor preferences from a given AbstractTextEditor? Exactly, instead of each editor implements the same code woth getAdapter, AbstractTextEditor could do that. > If so, can you please another bugzilla for that, again Platform/Text to work on this specific change. > I believe such a request can easily be honored, maybe even from Neon.1. Cool! For your information, I'm improving .editorconfig support for Eclipse (like with my idea of getAdapter, but too I have implemented a EditorConfig editor with syntax coloration https://github.com/ncjones/editorconfig-eclipse/issues/7#issuecomment-221390476 I'm waiting for answer (is https://github.com/ncjones/editorconfig-eclipse is in live?), otherwise I will create my own project.
> If so, can you please another bugzilla for that, again Platform/Text to work on this specific change. done at https://bugs.eclipse.org/bugs/show_bug.cgi?id=457046#c5