| Summary: | [formatter] formatter:off/on tags does not work correctly | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Vimil Saju <vimilsaju> | ||||||
| Component: | Core | Assignee: | Frederic Fusier <frederic_fusier> | ||||||
| Status: | VERIFIED FIXED | QA Contact: | |||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | daniel_megert, Olivier_Thomann, remy.suen, satyam.kandula, srikanth_sankaran, vimilsaju, zornitsa.kostadinova.bg | ||||||
| Version: | 3.6 | Flags: | daniel_megert:
pmc_approved+
srikanth_sankaran: review+ Olivier_Thomann: review+ |
||||||
| Target Milestone: | 3.6.1 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows XP | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
Bugs with the Java tooling goes to JDT. Code formatting works as expected for the below code snippet though.
Here the formatter:on tag is placed just below the class declaration.
//@formatter:off
public class TestClass
{
//@formatter:on
public static void main(String[] args)
{
int a;int b;
System.out.println(a);
}
}
I have some class level annotations which i don't want to be formatted. which is where the code formatting tags do not work
like the below example
//@formatter:off
@TestAnnotation (
testAttribute = {"test1", "test2", "test3"}
)
//@formatter:on
public class TestClass
{
public static void main(String[] args)
{
int a;int b;
System.out.println(a);
}
}
Even the following one works:
//@formatter:off
//@formatter:on
public class X04
{
public static void main(String[] args)
{
int a=0;int b;
System.out.println(a);
}
}
I'll investigate...
Created attachment 176439 [details]
Proposed patch
There were in fact two problems addressed by this patch:
1) When enabling/disabling tags were in two consecutive line comments, the second was not taken into account
2) enabling/disabling tags were not taken into account when formatting modifiers
Released in HEAD for 3.7M2 Srikanth, I think it could be a good candidate for 3.6.1. Do you agree? Frederic,
Did you check if the patch fixes the issue where the formatter:on/off tags enclose
class level annotations. Here's an example.
//@formatter:off
@TestAnnotation (
testAttribute = {"test1", "test2", "test3"}
)
//@formatter:on
public class TestClass
{
public static void main(String[] args)
{
int a;int b;
System.out.println(a);
}
}
In the above example the formatter:on tag does not turn formatting back on.
Neither does the below example where I have put an extra line before the formatter:on tag
//@formatter:off
@TestAnnotation (
testAttribute = {"test1", "test2", "test3"}
)
//@formatter:on
public class TestClass
{
public static void main(String[] args)
{
int a;int b;
System.out.println(a);
}
}
(In reply to comment #7) > Frederic, > > Did you check if the patch fixes the issue where the formatter:on/off tags > enclose > class level annotations. Here's an example. > Yep :-) As this sample was already described in comment 2, I added it to the regression tests (see test testBug320754_02 in FormatterBugTests test suite) > > In the above example the formatter:on tag does not turn formatting back on. > > Neither does the below example where I have put an extra line before the > formatter:on tag > > //@formatter:off > @TestAnnotation ( > testAttribute = {"test1", "test2", "test3"} > ) > > //@formatter:on > public class TestClass > { > public static void main(String[] args) > { > int a;int b; > > System.out.println(a); > > } > } I didn't have this peculiar one, but I have now added it to the regression tests... So, there won't be any problem with your test cases if you use HEAD or the next integration build. HTH OK for 3.6.1. Patch looks good. The block comment above the tests looks incorrect (copy + paste problem) Dani, Unfortunately, I missed to backport the fix for this bug in R3_6_maintenance. Do you think it still feasible to put it in 3.6.1 RC3? Olivier, We now need an additional committer review to have a chance to put this fix into 3.6.1 RC3, could you please do it? TIA +1. This should be part of 3.6.1 as this is a new feature introduced with 3.6 and it has to work properly. Created attachment 177749 [details]
Proposed patch for R3_6_maintenance branch
+1 for 3.6.1 RC3. (In reply to comment #14) > +1 for 3.6.1 RC3. Released for 3.6.1 in R3_6_maintenance stream. Verified for 3.6.1 using build M20100901-1310. Verified for 3.7M2 using build I20100909-1700 This is not fixed; Eclipse SDK Version: 3.7.1 + android plugins Does not work for me on Ubuntu 10.04.3 LTS (In reply to comment #18) > This is not fixed; > > Eclipse SDK > Version: 3.7.1 > + android plugins > > Does not work for me on Ubuntu 10.04.3 LTS Please open a new bug report with steps to reproduce the problem you see. |
Build Identifier: 20100617-1415 trying to disable code formatting for specific pieces of code using the formatter:of/on tags does not work Reproducible: Always Steps to Reproduce: //@formatter:off //@formatter:on public class TestClass { public static void main(String[] args) { int a;int b; System.out.println(a); } } --- The above code does not get formatted to put the declaration statements on a new line when the formatter:off and formatter:on tags are present. When the formatter:off and formatter:on tags are remove the above code gets formatted correctly and the declaration statements are put on a new line.