This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 138225

Summary: Tree Tagging support for Java Source
Product: java Reporter: Max Sauer <msauer>
Component: SourceAssignee: apireviews <apireviews>
Status: RESOLVED FIXED    
Severity: blocker CC: jlahoda
Priority: P2 Keywords: API_REVIEW_FAST
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: added methods, sample implementation for CreateMethodFix
tagging test

Description Max Sauer 2008-06-25 14:17:49 UTC
An API change is required to be able to select trees inside java editor, which is useful for java hints.

    /**
     * Provides span of tree tagged with {@code tag}
     * @param tag
     * @return borders in target document
     * @since 0.37
     */
    public int[] getSpan(Object tag)
...

    /**
     * Tags a tree. Used in {@code ModificationResult} to determine position of tree inside document.
     * @param t the tree to be tagged
     * @param tag an {@code Object} used as tag
     * @since 0.37
     */
    public synchronized void tag(Tree t, Object tag)

Proposed change is compatible. I'll attach a diff.
Comment 1 Max Sauer 2008-06-25 14:22:07 UTC
I propose to add two above mentioned methods.
Comment 2 Max Sauer 2008-06-25 14:30:13 UTC
Created attachment 63426 [details]
added methods, sample implementation for CreateMethodFix
Comment 3 Jan Pokorsky 2008-06-25 14:57:52 UTC
Could you describe use cases?
Comment 4 Max Sauer 2008-06-26 06:47:44 UTC
Yes, sure.

- Using hint to create method leads to a new method created, with default method body (ie. 'throw new UOE'). Presumably, user would like to change it to 
something more reasonable. Currently, the method body (the throw statement) is not selected inside editor and the caret position is two lines below the 
created method. This would enable selection of generated method body automatically right after method creation.

- Initialize variable hint -- selection of newly created default value (not yet implemented)

- Possibly some other hints also
 
Comment 5 Jaroslav Tulach 2008-06-26 08:37:48 UTC
Y01 little bit of tests would be nice
Y02 why is the setter synchronized and getter not synchronized?
Comment 6 Max Sauer 2008-06-26 09:48:55 UTC
re Y01: ok.
re Y02: its not exactly getter and setter. The 'tag' method is inside WorkingCopy class and will be typically called from modifactiontask's run. The so-called 
getter, on the other hand, is a method of ModificationResult class and will be called after the modification task is finished (no need to be synchronised 
imho).
Comment 7 Max Sauer 2008-06-27 16:21:04 UTC
Created attachment 63607 [details]
tagging test
Comment 8 Max Sauer 2008-06-30 15:24:45 UTC
http://hg.netbeans.org/main/rev/25b7ec83be0c