Summary: | [ast rewrite] Inconsistent results in modifying TagElements | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Edwin Chan <edwin> | ||||||||||
Component: | Core | Assignee: | Martin Aeschlimann <martinae> | ||||||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||||||
Severity: | normal | ||||||||||||
Priority: | P3 | ||||||||||||
Version: | 3.1 | ||||||||||||
Target Milestone: | 3.1 RC1 | ||||||||||||
Hardware: | PC | ||||||||||||
OS: | Windows XP | ||||||||||||
Whiteboard: | |||||||||||||
Attachments: |
|
Description
Edwin Chan
2005-03-15 17:27:20 EST
Created attachment 18814 [details]
A plugin to modify Javadoc tags
Here's a plugin to demostrate the problem
Created attachment 18815 [details]
A project to be used as a test case
To use the plugin, right-click on the compilation unit (test.Test) in the
project and select "Modify Selected Javadoc Tags" to see what happens.
Created attachment 18816 [details]
Sample output
This is the result I got from running my plugin on the test case.
I wrote some code to modify the Javadoc tags via the Eclipse DOM (TagElement.setTagName), but it doesn't seem to do what I expected. I had expected setTagName to replace the existing tag with whatever I set it to. However, it doesn't seem to do the right thing if the tag includes '.' or '-', but it almost does for '_', except for the trailing space. Created attachment 18817 [details]
A project to be used as a test case (restored to how it should start out)
Fixed the Javadoc to restore it to how it was before I ran my plugin
Problem is not in setTagName(String) which works correctly until you include @ in tag name. So, I've modified your rewriter as follow: static class JavadocRewriter extends ASTVisitor { JavadocRewriter() { super(true); } public boolean visit(TagElement n) { String tag = n.getTagName(); if (tag == null) { // No tags yet. } else if (tag.startsWith("@-")) { n.setTagName("@DASH"); } else if (tag.startsWith("@.")) { n.setTagName("@PERIOD"); } else if (tag.startsWith("@_")) { n.setTagName("@UNDERSCORE"); } return true; } } Then, setting a breakpoint in Test.rewriteJavadoc(ICompilationUnit) method at line: TextEdit te = cu.rewrite(doc, null); shows that Javadoc is correct: /** * @PERIOD and more stuff * @DASH and more stuff * @UNDERSCORE and more stuff */ So it seems that it's during rewritting operation that new tag names are incorrectly inserted in document... Assign to Martin as he owns rewritting code. fixed > 20050524 Verified in I20050526-2000. |