Bug 138225 - Tree Tagging support for Java Source
Tree Tagging support for Java Source
Status: RESOLVED FIXED
Product: java
Classification: Unclassified
Component: Source
6.x
All All
: P2 (vote)
: 6.x
Assigned To: apireviews
issues@java
: API_REVIEW_FAST
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-06-25 14:17 UTC by Max Sauer
Modified: 2008-06-30 15:24 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments
added methods, sample implementation for CreateMethodFix (28.34 KB, patch)
2008-06-25 14:30 UTC, Max Sauer
Details | Diff
tagging test (5.67 KB, text/plain)
2008-06-27 16:21 UTC, Max Sauer
Details

Note You need to log in before you can comment on or make changes to this bug.
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


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo