Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define defaults for Java editorconfig properties #8

Open
ppalaga opened this issue Feb 3, 2019 · 6 comments
Open

Define defaults for Java editorconfig properties #8

ppalaga opened this issue Feb 3, 2019 · 6 comments

Comments

@ppalaga
Copy link
Contributor

ppalaga commented Feb 3, 2019

Background

Not sure how it works in IntelliJ, but in Eclipse, most of the properties cannot be "unset", in sense to make the IDE not to perform the associated check (and correction).

An example: Eclipse's equivalent of indent_style can be either space or tab. It is not possible to configure the formatter in such a way that it leaves the indentation as it is.

In editorconfig the situation is different: all common properties are unset by default, basically meaning that the editor should not perform any related action.

The proposal

To make both worlds to work together, I propose to define a default for each property. E.g. indent_style would have default space which would be effective for the formatter in case indent_style is not set in .editorconfig. Actually indent_style is not a good example because it is not from the Java domain that we define here. But I hope you get the idea.

Technical

Some ideas how to implement the defaults:

  • Clearly a Java class with constants would do the job for us, but would not be usable at all for non-Java implementations of this standard.
  • So we need to take some structured file format, e.g. properties, .editorconfig itself, or even this editorconfig defaults json: https://github.com/editorconfig/editorconfig-defaults

WDYT @dyadix ?

@ppalaga ppalaga changed the title Define defaults for the editorconfig properties Define defaults for Java editorconfig properties Feb 3, 2019
@ppalaga
Copy link
Contributor Author

ppalaga commented Feb 3, 2019

Having looked through https://github.com/editorconfig/editorconfig-defaults and editorconfig/editorconfig#298 properly, I'd say that we should first incubate our settings here and then mirror them there once they get acceptable for us. I mean the master file containing our defaults should definitely live here under editorconfig-java-domain project.

Let me try to implement this with an .editorconfig file.

ppalaga added a commit to ppalaga/editorconfig-java-domain that referenced this issue Feb 3, 2019
@ppalaga
Copy link
Contributor Author

ppalaga commented Feb 3, 2019

I think the new test in #9 proves sufficiently that IntelliJ, much like JDT, uses space as a default for indent_style. Hence, this proposal probably makes sense equally for both IDEs.

@dyadix
Copy link

dyadix commented Feb 28, 2019

Well, if indent_size is not set at all, IntelliJ uses the same indent size as a user has specified in project settings. The same applies to all other options. So basically .editorconfig options are an additional layer on top of project settings, not something replacing them completely. So unset would work as follows: if there is a previously set indent_size somewhere in a parent directory, unset will drop it and force the indent set in project settings.

@ppalaga
Copy link
Contributor Author

ppalaga commented Feb 28, 2019

.editorconfig options are an additional layer on top of project settings

Good to know.

I think I would not like it like this neither as an owner of some .editorconfig file nor as a contributor to a project having .editorconfig defined. The possibility, that properties not set in .editorconfig are taken from user's local setup (which can be whatever) harm the portability of the formatting rules quite substantially.

Clearly, users need ways to disable/enhance/... .editorconfig, and also an option to delegate to local settings may be useful for some users, but I do not think it should be enabled by default.

If you keep it like that, the only option for the people to get formatting reproducible across desktops will be to explicitly define every single editorconfig property. I think I would not be keen on doing that. For Java we are going to have tens of them.

@dyadix
Copy link

dyadix commented Mar 1, 2019

There are actually different use cases. I agree that for testing purposes it's good to have well established defaults but in real life if you don't define anything, it means you don't care and you don't want to restrict developers on the style they are using for whatever reason. Right now IntelliJ users can share the project style via version control and just add something on top of it. If they want to have a complete definition in .editorconfig, that's also not a problem: we'll offer an export functionality which will simply export all the setting to .editorconfig automatically. But if we always assume that undefined settings are some defaults, this will force users with already existing projects to redefine everything in .editorconfig and I'm not sure they will be happy.

@dyadix
Copy link

dyadix commented Mar 1, 2019

An idea which has just come to my mind: what if we add java_defaults=true/false property which would explicitly force some commonly agreed default settings? It could be a certain compromise. Or even better perhaps: java_base_style=default. We could add then other predefined styles later. That would eliminate the need to specify every formatting option. Of course more specific settings can be provided as well (on top of base style).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants