Bug 69308 - All ASTNodes that deal with modifiers should offer a method setModifiers(List modifiers)
Summary: All ASTNodes that deal with modifiers should offer a method setModifiers(List...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M1   Edit
Assignee: Jim des Rivieres CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-05 13:41 EDT by Dirk Baeumer CLA
Modified: 2005-01-11 11:02 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2004-07-05 13:41:59 EDT
3.0

Dealing with modifiers in the new 3.0 API is complicated especially if you 
want to copy modifiers of an existing node into a new node. To ease this all 
ASTNodes that deal with modifiers should offer a method setModifiers(List 
modifiers). This methods copies the modifiers from the parameter list into the 
modifier list managed by the node. The current list should be emptied first.
Comment 1 Olivier Thomann CLA 2004-07-05 17:31:01 EDT
Jim,

Do you want to add this API?
Comment 2 Martin Aeschlimann CLA 2004-07-06 06:37:17 EDT
Me and Dirk had a lengthy discussion about the topic and Dirk still couldn't 
convince me that 'setModifiers' is a good idea. I think ASTNode.copySubtrees 
would do the job

-> newDecl.modifiers().addAll(
       ASTNode.copySubtrees(newAST, oldDecl.modifiers()));

But in general I agree with Dirk that working with modifiers got quite nasty 
with the AST-3 and we should think about if we can add a bit more convenience 
for working with the modifier nodes.

A first suggestion from my side would be an addition to ast.newModifier
       ast.newModifiers(int modifierFlags) : List
creating modifier nodes from a bitSet (in a default order)
  
Comment 3 Jim des Rivieres CLA 2004-07-06 10:51:00 EDT
Martin, I agree that setModifiers does not seem like much of a value-add. I 
like the idea of adding a convenience method for creating modifier nodes from 
modifier bit flags, and automatically arranging them in JLS-recommended order.
Comment 4 Jim des Rivieres CLA 2004-07-08 14:28:08 EDT
Added convenience methods to AST:
   public List newModifiers(int flags);

Added tests. Updated build notes. Released to HEAD.

Dirk/Martin, Please reopen if there are additional things that could make JLS3 
modifiers more useable.