Bug 59575 - invalid formatting
Summary: invalid formatting
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-21 23:28 EDT by Jeff McAffer CLA
Modified: 2004-05-18 11:10 EDT (History)
0 users

See Also:


Attachments
test case for the formatter (32.09 KB, application/octet-stream)
2004-04-22 14:03 EDT, Olivier Thomann CLA
no flags Details
wrong result after applying the edits on the document (15.59 KB, application/octet-stream)
2004-04-22 14:13 EDT, Olivier Thomann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff McAffer CLA 2004-04-21 23:28:22 EDT
in i0420

- load org.eclipse.platform from CVS and check out revision 1.56 of Main
- set the code formatter preferences to the core settings found at 
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-core-
home/documents/core_formatting.xml
- Set the "Compiler->Advanced->Usage of non-externalized strings" to Error
- format Main 
- notice that many methods (e..g, getInstallLocation) formatted incorrectly 
(the method headers are not indented and directly follow the preceding method)
- if you change the Compiler setting to ignore, the class formats correctly.
Comment 1 Olivier Thomann CLA 2004-04-22 14:03:41 EDT
Created attachment 9869 [details]
test case for the formatter

I don't know what is going on in the editor. The formatter itself has no
problem to format that code. But inside the editor the code is all mixed up
after the formatting.
Comment 2 Olivier Thomann CLA 2004-04-22 14:06:13 EDT
Move to JDT/Text.
What happens when the code contains errors (like non NLS string literals). The
code formatter doesn't care about these errors. I attached a test case before
formatting (Main_in.java) and after formatting (Main_out.java). You can check
that the formatting inside the editor is different from what I get from the code
formatter. I use the same edits. I will also attach the code after formatting in
the java editor.
Comment 3 Olivier Thomann CLA 2004-04-22 14:13:37 EDT
Created attachment 9870 [details]
wrong result after applying the edits on the document

I wonder if this is not a bug relative to the positionning of markers in the
compilation unit. Jeff says that if no errors are returned (ignore non-nls
string literal) then it works fine. From a code formatter point of view, the
text to format is identical, but I think it is different for you to apply the
edits on the document.
Comment 4 Olivier Thomann CLA 2004-04-22 14:42:02 EDT
I raise the severity, because this seems to be a severe problem with applying
edits on a document that contains marker. Let me know if I can help.
Comment 5 Olivier Thomann CLA 2004-04-22 15:30:47 EDT
I take it back on my side for now. It seems that the number of edits is
different if the file contains errors or not. I don't see why, but this is the case.
I am investigating.
Comment 6 Olivier Thomann CLA 2004-04-22 16:02:27 EDT
In fact, the bug comes from the code formatter. The problem is that compile
errors can change the file ignoreFurtherInvestigation on the method declaration
and constructor declarations. In this case the code formatter jumps above them
and this leads to inconsistent edits that are therefore impropertly applied to
the document.
So the document is not responsible. I am investigating what can be done in the
code formatter to fix this issue.
Comment 7 Olivier Thomann CLA 2004-04-22 16:13:08 EDT
I think the fix is to use the default compiler options in the code formatter
when building the compilation unit declaration used by the visitor. The code
formatter only cares about syntax problems, but it doesn't care about errors in
the code like non-nls strings.
I am working on a fix.
Comment 8 Olivier Thomann CLA 2004-04-22 17:05:29 EDT
Fixed and released in HEAD.
Regression test added.
Comment 9 David Audel CLA 2004-05-18 11:10:28 EDT
Verified for 3.0M9