Bug 145544

Summary: Comment indentation wrong when using sun conventions
Product: [Eclipse Project] JDT Reporter: Tom Hofmann <eclipse>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Peter.Portante
Version: 3.2   
Target Milestone: 3.3 M1   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
org.eclipse.jdt.core.diff
none
org.eclipse.jdt.core.diff none

Description Tom Hofmann CLA 2006-06-06 10:41:40 EDT
3.2 RC7

- use Sun's coding conventions
- have the CU below (. == space, --> == tab)

------------ Format.java --------
package a;

class Format {
..../**
.... * Type comment
.... */
....class Inner {
------->/**
-------> * Member comment
-------> */
------->int field;
....}
}
-----------------------------------

- format it

> expected: type comment indented with 4 spaces, member comment with 1 tab (unchanged from above).

< actual: 

------------ Format.java --------
package a;

class Format {
..../**
........ * Type comment
........ */
....class Inner {
------->/**
........ * Member comment
........ */
------->int field;
....}
}
-----------------------------------


Part of the problem is in JDT-text land, but org.eclipse.jdt.internal.formatter.comment.CommentRegion also needs an update. I will attach a patch.
Comment 1 Tom Hofmann CLA 2006-06-06 10:46:50 EDT
Created attachment 43592 [details]
org.eclipse.jdt.core.diff

Corrects computeIndentation. The ctor change takes into account that the visual tab size is stored in the INDENTATION_SIZE preference when the indent char is SPACE. 

I also removed an unused parameter and removed some duplicate code - feel free to ignore.
Comment 2 Tom Hofmann CLA 2006-06-09 04:41:56 EDT
Created attachment 43963 [details]
org.eclipse.jdt.core.diff

Correction of the previous patch - when indenting with spaces, the created indent must of course not use tabs...
Comment 3 Olivier Thomann CLA 2006-06-21 14:43:58 EDT
Fixed and released in HEAD.
Regression test added in org.eclipse.jdt.core.tests.formatter.comment.MultiLineTestCase.testMultiLineCommentFor145544
Comment 4 Frederic Fusier CLA 2006-08-03 08:46:18 EDT
Released for 3.3 M1
Comment 5 Frederic Fusier CLA 2006-08-08 04:00:33 EDT
Verified for 3.3 M1 using build I20060807-2000.
Comment 6 Olivier Thomann CLA 2006-11-23 13:17:37 EST
*** Bug 165337 has been marked as a duplicate of this bug. ***