My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 16890: Xml formatting with attributes sorting
1 person starred this issue and may be notified of changes. Back to list
 
Reported by vov...@gmail.com, May 16, 2011
Can you please add xml formatting to Eclipse ADT.

1. So all attributes can be sorted in alphabetic order. And ability to specify order and what attributes should follow first, like:
android:id
android:layout_width
android:layout_height
all other in alphabetic order

2. Add smart attributes wrap, like it works in Intellij IDEA.
Jul 11, 2011
#1 ralf%and...@gtempaccount.com
If we ever do that, it should be an option.

I personally like a different order:
- id,
- layout_width/height,
- all other layout_* attrs,
- all widget specific attrs.
Status: Unassigned
Owner: tnor...@google.com
Labels: Subcomponent-Tools-adt-editors
Jul 11, 2011
#2 vov...@gmail.com
Yes, I agree with you. I use that order all the time.
It's allows easier and faster to navigate through the xml code.
Jul 15, 2011
Project Member #3 tnor...@google.com
Romain argued that the "style" attribute should also go in there, between id and layout_width.

I've added some preliminary support for XML attribute sorting here:
https://review.source.android.com/#/c/24613/

Note that this applies to edits made by the Layout Editor, it does not affect the XML formatter itself, which we also need to do (so the above CL only partially fixes this issue.)
Jul 15, 2011
#4 vov...@gmail.com
I checked AOSP sources, and somewhere style is between id and layout_width and somewhere it at the end of the list. 

I personally like it at the end of the list :)
So maybe more developers can vote where to put it?

Another question, where id should be? On same line as tag, or new line, because eclipse format it only on newline. So letting to put it on the same line will be good too.

Thanks for working on this feature.
Jul 15, 2011
Project Member #5 tnor...@google.com
The Eclipse defaults for XML formatting are unfortunate (from an Android developer's perspective) since it's quite different from the preferred Android convention (where we generally place one attribute per line, indent with 4 spaces instead of one tab, and so on).

We're thinking of adding a new setting to the Android editor settings to the effect of

    [x] Use Android code style for XML formatting

which when chosen (which will probably be the default) will cause the XML formatter to use a set of preconfigured options that more resemble the Android style, such that out of the box, an ADT user will by default get XML files that look similar to all the tutorials and examples. And somebody who want a really particular XML formatting on their own can uncheck that option and go tweak all the settings in the XML editor preference page.

One thing that remains to be seen is whether we need replace or augment the formatter; last time I played with it I wasn't able to set up everything I wanted; the behavior of closing tags wasn't quite right, and I think we also want to default to separating each element with a single newline.

Jul 27, 2011
Project Member #6 tnor...@google.com
The attribute sorting (performed by the layout editor manipualtions) is now in ADT 13. Leaving this issue open to track the ability to reorder on editor reformat as well.
Status: Assigned
Aug 1, 2011
Project Member #7 tnor...@google.com
Pending fix for attribute sorting as part of formatting: https://review.source.android.com//#/c/24955/
Aug 4, 2011
Project Member #8 tnor...@google.com
Integrated; fixed for ADT 13.
Status: FutureRelease
Labels: Target-r13
Oct 19, 2011
Project Member #9 x...@android.com
(No comment was entered for this change.)
Status: Released
Sign in to add a comment

Powered by Google Project Hosting