Bug 297225

Summary: [formatter] Indentation may be still wrong in certain circumstances after formatting
Product: [Eclipse Project] JDT Reporter: Frederic Fusier <frederic_fusier>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann, satyam.kandula
Version: 3.6   
Target Milestone: 3.6 M4   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description Frederic Fusier CLA 2009-12-08 11:06:18 EST
Build I20091208-0100.

The indentation computed while formatting may be still wrong even after the fix for bug 293300 which solves most of invalid cases.

For instance, the following test case:
public class X {
   	
   	/**
   	 * The foo method
   	 */
	void foo() {}
}

is wrongly formatted as follow when all comments formatting is disabled:
public class X06 {

	/**
	* The foo method
	*/
	void foo() {
	}
}

This is due to an invalid guess of the indentation value when there's a mix of tab and spaces in the current comment indentation... This was partially fixed while fixing bug 293300, but apparently, there is still some problematic cases.
Comment 1 Frederic Fusier CLA 2009-12-08 11:28:11 EST
Created attachment 154025 [details]
Proposed patch

Verify all places where similar algorithm is used. Rename methods and variables as it's safer to compute the indentation and add 1 when the column is needed...
Comment 2 Frederic Fusier CLA 2009-12-08 17:16:35 EST
All JDT (Core/UI/Text) tests pass with the proposed patch and massive formatter tests only show improvements, hence I have released it for 3.6M4...
Comment 3 Olivier Thomann CLA 2009-12-08 20:44:27 EST
+1 for 3.6M4. We want the code formatter to be as stable as possible as soon as possible.
Comment 4 Satyam Kandula CLA 2009-12-09 08:24:19 EST
Verified for 3.6M4 using Build id:  I20091209-0100
Comment 5 Olivier Thomann CLA 2009-12-09 10:36:15 EST
Verified.