Bug 14429

Summary: Smoke 20020423: replace from local history wrong indentation
Product: [Eclipse Project] JDT Reporter: Dirk Baeumer <dirk_baeumer>
Component: UIAssignee: Dirk Baeumer <dirk_baeumer>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: andre_weinand
Version: 2.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Dirk Baeumer CLA 2002-04-23 12:38:43 EDT
- load TestCase.java
- edit method runTest
- save
- replace method with latest from local histroy
observe: the method is wrong indented

IMO the culprit is a change DB did at MemberEdit.
Comment 1 Dirk Baeumer CLA 2002-04-23 13:55:33 EDT
The problem has nothing to do with the change in MemberEdit. It is as follows:

the method runTest contains lines with no indentation. As a result the method 
removeIndentation doesn't remove any indentation. Thus we end up having two 
indentations.

To fix the problem the method that computes the indent of a code block must 
deal with empty lines and lines that only contain a new line.
Comment 2 Dirk Baeumer CLA 2002-04-23 14:12:12 EDT
The suggested fix is problematic since the member edit and the code formatter 
util don't know anything about line delimiters. The member edit API takes an 
array of lines and the initial assumption was that the lines don't contain line 
delimiters (but it isn't doced). There are helper methods on Strings and 
TextBuffer to convert a string or a range into an array of lines.

IMO we should fix as follows:

- MemberEdit assumes that the passed array of lines don't contain line
  delimiters. We doc that in the constructor
- CodeFormatterUtil treats empty lines correctly.

Andre what do you think ? Can you pass an array of line which don't contain 
line delimiters
Comment 3 Dirk Baeumer CLA 2002-04-24 06:46:29 EDT
Fixed in build > I20020423