Bug 88252 - Deleting a MemberValuePair with a NormalAnnotation child does not work
Summary: Deleting a MemberValuePair with a NormalAnnotation child does not work
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-16 16:37 EST by Tom Stamm CLA
Modified: 2005-03-30 23:29 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Stamm CLA 2005-03-16 16:37:56 EST
When deleting a MemberValuePair ASTNode, which has a NormalAnnotation as its
value Expression, part of the annotation gets left behind in the source. When
stepping through this in the debugger, it looks like the MemberValuePair's
getLength() method is not returning the correct length; it is ignoring anything
after and including the first open paren of the NormalAnnotation.

I am removing the MemberValuePair by navigating to it through the AST, and then
calling the delete() method.

For example I created the following code (through AST calls):

 @Jpf.Action(
      validatableProperties={@Jpf.ValidatableProperty(propertyName="fooField",
        localeRules={@Jpf.ValidationLocaleRules(
            validateMinLength=@Jpf.ValidateMinLength(chars="12")
        )}
      )}
    )
    public Forward actionForValidationRuleTest()    {
        return null;
    }


The problem occurs when trying to delete the MemberValuePair:
validateMinLength=@Jpf.ValidateMinLength(chars="12")

it leaves behind the "(chars="12")", so the resulting code is:

 @Jpf.Action(
      validatableProperties={@Jpf.ValidatableProperty(propertyName="fooField",
        localeRules={@Jpf.ValidationLocaleRules(
            (chars="12")
        )}
      )}
    )
    public Forward actionForValidationRuleTest()    {
        return null;
    }

Tracing through in th debugger, it looks like the MemberValuePair is returning
an incorrect length when the value is a NormalAnnotation. Even though it's
toString value is:
validateMinLength=@Jpf.ValidateMinLength(chars="12")

which is 52 chars long, it is returning 40 chars as its length, which
corresponds to the part that actually got removed:
validateMinLength=@Jpf.ValidateMinLength

I also tried this with a NormalAnnotation with no children, and the same thing
happened, it left behind an empty "()".

I can try to put together a simple set of sample code to reproduce this if it
will help; I don't currently have a small isolated repro case that I can upload.

(these annotations are defined in the apache beehive project's pageflow
annotations, but the definitions aren't necessary to repro this)
Comment 1 Olivier Thomann CLA 2005-03-16 23:02:13 EST
The bug seems to be in the ASTConverter.
I am investigating.
Comment 2 Olivier Thomann CLA 2005-03-17 00:16:03 EST
I fixed the positions bug.
Fixed and released in HEAD.
Regression test added in ASTConverter15Test.test0149
Comment 3 Olivier Thomann CLA 2005-03-30 23:29:30 EST
Verified in 20050330-0500