Bug 49908 - Renaming of DefaultCodeFormatterConstants.java
Summary: Renaming of DefaultCodeFormatterConstants.java
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.0 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 49571 49953
  Show dependency tree
 
Reported: 2004-01-13 10:07 EST by Silvio Böhler CLA
Modified: 2004-02-11 13:27 EST (History)
1 user (show)

See Also:


Attachments
Options prior to renaming. (35.59 KB, text/plain)
2004-01-13 10:21 EST, Olivier Thomann CLA
no flags Details
New version after renaming (53.73 KB, text/plain)
2004-01-13 17:51 EST, Olivier Thomann CLA
no flags Details
My changes, grep for TODO (53.06 KB, application/octet-stream)
2004-01-14 05:37 EST, Silvio Böhler CLA
no flags Details
Last version. (52.29 KB, application/octet-stream)
2004-01-14 09:48 EST, Olivier Thomann CLA
no flags Details
New version (52.63 KB, text/plain)
2004-01-14 11:29 EST, Silvio Böhler CLA
no flags Details
Last version (54.29 KB, application/octet-stream)
2004-01-14 17:40 EST, Olivier Thomann CLA
no flags Details
Here we go. The last one with all your last changes (52.93 KB, application/octet-stream)
2004-01-15 09:01 EST, Olivier Thomann CLA
no flags Details
Fixed. Here is the latest version (53.17 KB, application/octet-stream)
2004-01-15 11:07 EST, Olivier Thomann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Silvio Böhler CLA 2004-01-13 10:07:31 EST
This PR is for keeping track of and comment the renaming of the code formatter
options. Intermediate versions of the file can be attached here for revision by
anyone interested.
Comment 1 Silvio Böhler CLA 2004-01-13 10:09:30 EST
Proposition: By making the difference between 'arguments' (calls) and
'parameters' (declarations), we can omit INVOCATION and DECLARATION for the
respective options.

Example: 

FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS

becomes

FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_ARGUMENTS
Comment 2 Olivier Thomann CLA 2004-01-13 10:21:38 EST
Created attachment 7409 [details]
Options prior to renaming.

The options have been reorganize by topics. It makes it simpler to find a
option in the list. Then we can discuss the common pattern names.
Comment 3 Silvio Böhler CLA 2004-01-13 10:30:14 EST
The 'INSERT_SPACE' bunch of constants could be better grouped, but that's easier
once the options are named in a more consistent manner. I'd like to do the
grouping as soon as the names are changed, if you want. I've already grouped
these options once in a (hopefully) semantic consistent way on my pref page, so
I can bring in the thoughts I made there. 

The deprecated options should be put together somewhere at the end of the file,
its rather confusing having them mixed with the other options.
Comment 4 Olivier Thomann CLA 2004-01-13 10:39:19 EST
Ok, I will move all deprecated at the end of the file.
Now let's see the renaming.
1) Changing all INSERT_SPACE to match this pattern
INSERT_SPACE_{BEFORE/AFTER}_{SYNTACTICAL ELEMENT}_IN_{JAVA LANGUAGE ELEMENT}
2) Changing all BRACE_POSITION to match this pattern:
FORMATTER_BRACE_POSITION_FOR_{JAVA LANGUAGE ELEMENT}
3) Changing all ALIGNMENT for
FORMATTER_ALIGNMENT_FOR_{SYNTACTICAL ELEMENT}_IN_{JAVA LANGUAGE ELEMENT}

What do you think?
Comment 5 Silvio Böhler CLA 2004-01-13 10:50:58 EST
Ok, that's fine. 

We also need: 

INSERT_SPACE_BETWEEN_EMTPY_{PAREN/BRACES/BRACKETS}_IN_{JAVA ELEMENT}
INSERT_SPACE_AROUND_{SWITCH_CONDITION/IF_CONDITION/...}
Comment 6 Olivier Thomann CLA 2004-01-13 15:50:46 EST
Applying comment 1, we end up in a collision case.
The constant would not be used for the same option anymore.
FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_ARGUMENTS =>
FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_PARAMETERS

FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MESSAGESEND_ARGUMENTS =>
FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_ARGUMENTS

Can this be handled in the conversion layout?
Comment 7 Olivier Thomann CLA 2004-01-13 17:51:29 EST
Created attachment 7429 [details]
New version after renaming

Silvio, could you please review the constants after renaming?
If this is fine for you, I will update all references to the old constants in
JDT/Core code.
I left some TODO tasks to remember that I have to add three new options. Let me
know if you think I forgot something.
All deprecated constants are left at the end of the file with its new
corresponding option(s).
Comment 8 Olivier Thomann CLA 2004-01-13 19:00:40 EST
Regarding comment 1, I removed the DECLARATION, but I left INVOCATION to prevent
duplicate constants. Let me know if this is fine for you.
Comment 9 Silvio Böhler CLA 2004-01-14 05:37:54 EST
Created attachment 7433 [details]
My changes, grep for TODO

Hmm, looks good! 

I like that you got rid of the INSERT_SPACE_IN_FOR_PARENS etc by providing
options to configure space after opening and before closing paren seperately!
This greatly facilitates my new ordering scheme which focusses on syntactical
elements [](){},; etc.

Regarding my comment 1, I haven't considered the fact that for example 
BEFORE_OPENING_PAREN_IN_METHOD doesn't include either the word ARGUMENT or
PARAMETER. So I think for consistency reasons, we should add _DECLARATION
whenever the corresponding option for declarations contains _INVOCATION. 
As a general rule, the effect of an option should be unambiguously described by
its name.

The duplicate constant is not so much of a problem, I can handle this in my
compatibility code. But would it be possible to assign a new value to the
re-used constant? By appending some number to the string for example? Else its
difficult.

I made some comments in the file, look out for the TODO tags.

I also removed several of the deprecated alignment options, which have never
been used in my code and consequently don't need to be preserved.

What about type_member_alignment? I doesn't seem to fit into the ALIGNMENT
options as actually it's more kind of a boolean option: multicolumns or not.
Therefore, I propose to take it out of the ALIGNMENT options (by renaming it)
and make it boolean. 

And I discovered an alignment options which is already present in the old
constants but which I've never used so far: MULTIPLE_FIELDS_ALIGNMENT. What
does it do? Is it a standard line wrapping option?

There's also a new one, FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR. I
don't currently have a good overview about what's new compared to the version
we've used in this weeks integration build. Can you give me some summary?

Further, given the constaint of using string values and not having available
native enumerations, the value ranges and types for each option (or at least
the uncommon ones) should be specified in javadoc. Especially the alignment
options are quite confusing, as the API is really low level. Internally for the
formatter page, I use a wrapper class which is used to set the alignment
options and convert them to value string, maybe we can move this to core?
Bit-shifting and masking should be hidden behind an API... ;-) 

But that's another issue, I think I'll make a new PR to discuss this. Would be
a good opportunity now to change this together with the renaming, as all
ALIGNMENT option names change anyway.
Comment 10 Olivier Thomann CLA 2004-01-14 08:57:14 EST
Let's try to answer all your questions:

I will add again _DECLARATION to be consistent. Then we should not have any
conflicts or duplicates in the naming.

The suggestion for type_member_alignment is good. Let's make it a boolean.
The new name could be:
FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS value TRUE/FALSE

The MULTIPLE_FIELDS_ALIGNMENT is a way to wrap multi field alignments. There is
no equivalent for multiple local declarations because it would be too costly.
This will be added once we are using DOM/AST nodes.

FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR is the same than the ones for
the methods. The constructor alignment was reusing the method alignment. This
was not consistent with other options for constructors and methods.

Hopefully I answered all your questions. I will use your version and implements
all the TODOs. I will attach it again once it is done and let me know if this is
fine. I'd like to do all other changes today and then we could release the code
tomorrow for Friday's nightly build.

What do you think?
Comment 11 Silvio Böhler CLA 2004-01-14 09:19:33 EST
I only meant to add _DECLARATION where the name would be ambiguous, for example 
in FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD (decl or invocation?).

But for the duplicate you mentioned 
(FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_ARGUMENTS), nothing changes and 
we still have the name clash.

Would it be ok to assign another string value to this constant? This would 
solve everything (for example, appending '2' or so).

Sorry for the long comment 9, I was just hacking and writing at the same time.
Comment 12 Olivier Thomann CLA 2004-01-14 09:48:37 EST
Created attachment 7437 [details]
Last version.

Please review it. I'd like to make a patch with this version.
Comment 13 Silvio Böhler CLA 2004-01-14 11:29:08 EST
Created attachment 7440 [details]
New version

Ok, here's another revision. I've grouped some things and added some TODOs.
Comment 14 Silvio Böhler CLA 2004-01-14 11:43:06 EST
FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK is missing and should be 
added.
Comment 15 Silvio Böhler CLA 2004-01-14 11:49:03 EST
FORMATTER_INSERT_SPACE_BEFORE_FIRST_PARAMETER_IN_CONSTRUCTOR
FORMATTER_INSERT_SPACE_BEFORE_FIRST_PARAMETER_IN_METHOD

should rather be named

FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION
FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION
Comment 16 Silvio Böhler CLA 2004-01-14 11:50:27 EST
FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR

-> FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR_DECLARATION
Comment 17 Silvio Böhler CLA 2004-01-14 12:21:49 EST
Another name clash:

ORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_ARGUMENTS
FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_ARGUMENTS

used to affect method declarations, now they are used for invocations...

Hmmm, let's add _invocation and _declaration everywhere. Ok?
Comment 18 Silvio Böhler CLA 2004-01-14 12:27:03 EST
FORMATTER_INSERT_SPACE_BEFORE_FIRST_EXPRESSION_IN_ARRAY_INITIALIZER
->
FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER
Comment 19 Silvio Böhler CLA 2004-01-14 12:42:25 EST
I've just finished double-checking all the insert_space options, and I'm quite
happy about the naming! Sorry for the mass of comments though...at least they're
small... ;-)
Comment 20 Olivier Thomann CLA 2004-01-14 13:44:25 EST
Would you have a final version around?
Comment 21 Olivier Thomann CLA 2004-01-14 17:40:43 EST
Created attachment 7448 [details]
Last version

Hopefully this is it.

I am about to update the code formatter with this version. Is it ok for you?
I think I update it with all your last changes.
This constant is now a boolean FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS.
I didn't get your point about the BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY.

let me know before I arrive tomorrow morning if this is ok. If yes, I will work
on a patch for you.
Comment 22 Silvio Böhler CLA 2004-01-15 05:59:03 EST
* We should unify on either using CONSTRUCTOR or CONSTRUCTOR_DECLARATION
thoroughly. The former requires less options to change, the latter is more
consistent with METHOD_DECLARATION.

* Using reference search, I checked all the deprecated constants on whether they
appear in jdt.ui code or not. Here's a list of constants which have never been
used, either because I forgot to add them or because you've added them only
recently after last I-build. These could be removed safely without deprecating
them first from my point of view:

FORMATTER_MULTIPLE_FIELDS_ALIGNMENT
FORMATTER_INSERT_SPACE_BEFORE_CONSTRUCTOR_DECLARATION_FIRST_ARGUMENT
FORMATTER_INSERT_SPACE_BETWEEN_CONSTRUCTOR_DECLARATION_EMPTY_ARGUMENTS
FORMATTER_INSERT_SPACE_BEFORE_CONSTRUCTOR_DECLARATION_CLOSING_PAREN
FORMATTER_INSERT_SPACE_BEFORE_CONSTRUCTOR_DECLARATION_FIRST_PARAMETER
FORMATTER_INSERT_SPACE_BEFORE_CONSTRUCTOR_DECLARATION_OPEN_BRACE
FORMATTER_INSERT_SPACE_BEFORE_CONSTRUCTOR_DECLARATION_OPEN_BRACE
FORMATTER_INSERT_SPACE_BEFORE_METHOD_INVOCATION
FORMATTER_INSERT_SPACE_BEFORE_METHOD_DECLARATION_CLOSING_PAREN
FORMATTER_INSERT_SPACE_BEFORE_METHOD_DECLARATION_FIRST_PARAMETER
FORMATTER_NUMBER_OF_BLANK_LINES_TO_INSERT_AT_BEGINNING_OF_METHOD_BODY
FORMATTER_ALIGNMENT_FOR_TYPE_MEMBERS
FORMATTER_NUMBER_OF_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY

* Why did you rename 
FORMATTER_INSERT_SPACE_BEFORE/AFTER_COMMA_IN_METHOD_THROWS
into
FORMATTER_INSERT_SPACE_BEFORE/AFTER_COMMA_IN_THROWS_CLAUSE

We have throws clauses also for constructors
(FORMATTER_INSERT_SPACE_BEFORE/AFTER_COMMA_IN_CONSTRUCTOR_THROWS), so it's not
consistent anymore. I'd leave it as they are or to call them 

FORMATTER_INSERT_SPACE_BEFORE/AFTER_COMMA_IN_METHOD_DECLARATION_THROWS
FORMATTER_INSERT_SPACE_BEFORE/AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS.
What do you think?


Comment 23 Silvio Böhler CLA 2004-01-15 06:02:00 EST
My last point in comment 22 depends of course on whether we agree on CONSTRUCTOR
or CONSTRUCTOR_DECLARATION. I'd prefer the latter, so constructors and methods
are treated everywhere in the same way.

Hoping that these we're the last changes...
Comment 24 Olivier Thomann CLA 2004-01-15 08:11:45 EST
Ok, I will make the last changes. I send you the file again for review and then
I update the code formatter.
Comment 25 Olivier Thomann CLA 2004-01-15 09:01:42 EST
Created attachment 7456 [details]
Here we go. The last one with all your last changes

Please, have a look. I think this is fine now.
I removed unused constants and change CONSTRUCTOR for CONSTRUCTOR_DECLARATION
everywhere. I also fixed the THROWS constants.
Let me know what you think. If you are ok with this one, I update the code
formatter and hopefully I can provide you a patch later today.
Comment 26 Olivier Thomann CLA 2004-01-15 10:16:24 EST
I also added:
FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION
FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION
Comment 27 Silvio Böhler CLA 2004-01-15 10:35:26 EST
Just two issues:

* You took out FORMATTER_ALIGNMENT_FOR_TYPE_MEMBERS instead of
FORMATTER_TYPE_MEMBER_ALIGNMENT.

* FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD misses the
_DECLARATION suffix.

I think everything else is fine, I'm looking forward to your patch.
Comment 28 Olivier Thomann CLA 2004-01-15 11:07:52 EST
Created attachment 7461 [details]
Fixed. Here is the latest version

I should be able to issue a patch later today.
Comment 29 Olivier Thomann CLA 2004-01-15 12:53:14 EST
I also added:
FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION
Comment 30 Olivier Thomann CLA 2004-01-15 13:06:35 EST
FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_TYPE_REFERENCE is not
deprecated anymore, because for an array type reference the brackets are always
empty. So there is no need to add EMPTY in the name. This is redundant and not
consistent with other settings that make the distinction between empty and not
empty.
Comment 31 Olivier Thomann CLA 2004-01-15 16:44:20 EST
Please, check that you are using all constants in the code formatter preference
page. I checked on my side that the formatter is using each constant.
All tests are passing with the new version.
Comment 32 Olivier Thomann CLA 2004-01-15 17:56:05 EST
Set milestone
Comment 33 Olivier Thomann CLA 2004-01-16 12:05:07 EST
Fixed and released in HEAD.
Comment 34 Frederic Fusier CLA 2004-02-11 13:27:50 EST
Verified for 3.0-M7 with build I200402102000.