Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Trying to update Javadoc tag via AST; space between tag and text is lost!
Trying to update Javadoc tag via AST; space between tag and text is lost! [message #243870] Fri, 18 May 2007 12:02 Go to next message
Eclipse UserFriend
Originally posted by: myawn.ebay.com

I'm trying to use the AST to manipulate some Java code.

If I try to manipulate a Javadoc tag, required whitespace is being
stripped. For example, if I have a Javadoc tag

@author Mike Yawn

and change the TextElement to Bob Smith, what gets rewritten is

@authorBob Smith

Same behavior is seen on the @version tag, which is the only other one
I've tried this on.

If I try to insert extra leading whitespace, it just gets stripped.
If I try to delete the TextElement altogether, and replace it with a new
one (rather than just do .setText), it still has the same problem.

Am I missing something, or is this a bug?

Code that is failing (this is inside visit(Javadoc node) )

if (tag.getTagName().equals("@author")) {
//((TextElement)tag.fragments().get(0)).setText(m_info.getDe veloper());
for (int i=0; i< tag.fragments().size(); i++) {
ASTNode n = (ASTNode) tag.fragments().get(i);
//System.out.println("Removing Fragment:" + n + ":");
tag.fragments().remove(i);
}
TextElement value = ast.newTextElement();
value.setText(m_info.getDeveloper());
//System.out.println("Adding Fragment:" + value + ":");
tag.fragments().add(value);
}

I can do this with the 'old' and 'new' tag values identical, and that
display the same if I uncomment the printlns, yet the formatting of the
element changes and the separation between tag name and tag value is lost.

I guess my next test will be to delete the tag entirely, and create a
new tag, but it doesn't seem like that should be necessary.

Mike
Re: Trying to update Javadoc tag via AST; space between tag and text is lost! [message #243876 is a reply to message #243870] Fri, 18 May 2007 13:25 Go to previous message
Eclipse UserFriend
Mike Yawn a écrit :
> I'm trying to use the AST to manipulate some Java code.
>
> If I try to manipulate a Javadoc tag, required whitespace is being
> stripped. For example, if I have a Javadoc tag
>
> @author Mike Yawn
>
> and change the TextElement to Bob Smith, what gets rewritten is
>
> @authorBob Smith
Enter a bug report against JDT/Core with steps to reproduce and as many
details as possible.
Thanks,
--
Olivier
Previous Topic:javaCompletionProposalComputer
Next Topic:Auto detect of JRE 6 not working
Goto Forum:
  


Current Time: Sun May 11 18:35:25 EDT 2025

Powered by FUDForum. Page generated in 0.02567 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top