Temp reformatting of read-only files?

I'm considering posting a feature request, but I want some idea of what
other people think first. (And if anyone knows of a duplicate or similar
request, let me know -- I couldn't find one.)

Basically, the JDK source (in src.jar) is horribly formatted in many
places. Braces don't line up, etc. I would like a way to view this
reformatted according to my IDEA preferences. Failing that if I could at
least get the indentation applied I'd settle for that.

Is there a way to do this in IDEA that I haven't found (short of
unpacking the src.jar)?

Note that the potential feature request I'm planning to file would
include not just the src.jar but other read-only code as well. Say
you're working on a project and someone checked in some badly formatted
code that you need to reference. On most projects I've been on it's
considered bad form to check out something just to reformat and
check-in.

Opinions, suggestions?


~Mike

7 comments
Comment actions Permalink

Mike Abney wrote:

> .. I would like a way to view this reformatted according
> to my IDEA preferences.

Look at the 3rd message in the request :
http://www.intellij.net/tracker/idea/viewSCR?publicId=7326

Feel free to comment and vote for it.

Alain

0
Comment actions Permalink

I'd use this feature in a shot.

That said I'd also like a slight modification of this where I'd like to
temporarily reformat the code, but without changing the line numbers.
I.e. fix up the spacing and indentation, but if the braces etc. are on
the wrong lines then just leave them alone. That way the code
readability is improved, but I can still follow a stack trace.

Guy

Mike Abney wrote:

I'm considering posting a feature request, but I want some idea of what
other people think first. (And if anyone knows of a duplicate or similar
request, let me know -- I couldn't find one.)

Basically, the JDK source (in src.jar) is horribly formatted in many
places. Braces don't line up, etc. I would like a way to view this
reformatted according to my IDEA preferences. Failing that if I could at
least get the indentation applied I'd settle for that.

Is there a way to do this in IDEA that I haven't found (short of
unpacking the src.jar)?

Note that the potential feature request I'm planning to file would
include not just the src.jar but other read-only code as well. Say
you're working on a project and someone checked in some badly formatted
code that you need to reference. On most projects I've been on it's
considered bad form to check out something just to reformat and
check-in.

Opinions, suggestions?


~Mike


0
Comment actions Permalink

Alain Ravet wrote:

> Look at the 3rd message in the request :
> http://www.intellij.net/tracker/idea/viewSCR?publicId=7326

As it was hidden in the thread, and not the main subject, I've just
extracted the interesting part, and made a separate from it :
"Auto-reformat read-only files according to user policy"
http://www.intellij.net/tracker/idea/viewSCR?publicId=13743

Feel free to vote for it.

Alain

0
Comment actions Permalink

why not have IDEA keep track of the mapping of line numbers for us so "following a stack trace" just involves clicking on a line, like it does now. if the stack trace says foo.java (line 500), and that happens to take us to line 475 in the reformatted file, then so be it.

i can see problems with line 500 now being more than one line, but that could be displayed, too. it could be done by showing old line numbers, by highlighting the line(s) that correspond to the jumped-to-line, or by other means.

this would need to be solved not just for stack traces, but also for debugging. this would be a GREAT feature, but only, IMO, if the line-number mapping were dealt with in some elegant way.

0
Comment actions Permalink

From what I've seen, the only reason the code in src.zip looks bad is that most of the JDK appears to be written in a text editor where a tab character is 8 spaces (and IDEA defaults to 4, no?). Changing my tab settings fixed that.

0
Comment actions Permalink

Ahhh... wow. Such a simple solution. Kind of a pain if you use tabs
(fortunately I don't), so I'll still vote for the feature request (SCR
13743), but thanks for the tip. It fixes up most of my problems as well.


~Mike


Keith Lea <keith@cs.oswego.edu> wrote in
news:2142155.1056745760699.JavaMail.itn@is.intellij.net:

From what I've seen, the only reason the code in src.zip looks bad is
that most of the JDK appears to be written in a text editor where a
tab character is 8 spaces (and IDEA defaults to 4, no?). Changing my
tab settings fixed that.


0
Comment actions Permalink

Votes applied. Thanks for pointing it out.


~Mike

Alain Ravet wrote:

As it was hidden in the thread, and not the main subject, I've just
extracted the interesting part, and made a separate from it :
"Auto-reformat read-only files according to user policy"
http://www.intellij.net/tracker/idea/viewSCR?publicId=13743

Feel free to vote for it.

Alain


0

Please sign in to leave a comment.