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.
To track last comments from issue #45361.
So the current state is that there is in java/javacore public interface JMIElementCookie extends Node.Cookie { Element getElement(); } and in java, JavaSourceNodeFactory.CompatibleNode which has Javadoc saying "supplies cookies to ensure proper functionality of code that uses the old source hierarchy api" and - extends FilterNode - does not use any special Lookup - overrides getCookie to return an org.openide.src.Element (which has always extended Node.Cookie)
So the desired style for new APIs is not to use Node.Cookie; you can make JMIElementCookie not extend it, and put it into lookup, or put the org.netbeans.jmi.javamodel.Element directly into the node's lookup. (If it is too slow to compute, you could perhaps put in a placeholder proxy object.) For the compatibility layer of course you want to support getting the o.o.s.Element from getCookie and perhaps also from lookup.
The desired style is to provide o.n.j.j.Element directly in lookup. The cookie was introduced just due to FilterNode malfunction. The element is available during the node construction, no need for placeholder. The compatibility is guaranteed even now. You can get o.o.s.Element from getCookie and from lookup. The cookie is pretty spread out (java, refactoring, javadoc, editor, clazz) but except the java bridge (issue #49741) it should not be difficult to remove it. Will I have to go through some review process?
Please use fasttrack and attache diff of updated documentation describing what you do here. I'd like to suggest improvements to javadoc of JMIElement to mention where to obtain the instance and also write into javamodel or javacore arch document something like <api ... group="lookup">Various nodes like ... offer <a href="@TOP@/.../Element.html">JMIElement</a> from its lookup you can use node.getLookup().lookup(JMIElement.class or subclass), blablabla</api>. As this might be one of the main usecases you want to support I also suggest to update answer for usecases with something like <usecase id="get-java-element" name="How to get org...Element">same description and sample code</usecase>.
I've added the documentation. The diff is attached.
Created attachment 18085 [details] Arch document diff.
ok, so the review can start
If you do change or remove this, please let me know - it will break a couple features of Navigator/Javagator.
No objection, so I am going to commit the remove of JMIElementCookie.
Please post exactly how I should modify Navigator so I can still find the Element from the activated node.
replace JMIElementCookie jc = (JMIElementCookie) node.getCookie(JMIElementCookie.class); Element el = jc.getElement(); with Element el = (Element) node.getLookup.lookup(Element.class); See also usecase in http://www.netbeans.org/download/dev/javadoc/usecases.html#usecase-Java%20Language%20Model%20API I will integrate the change tomorrow to comply with fast review rules.
fixed in /cvs/java/javacore/src/org/netbeans/modules/javacore/internalapi/JMIElementCookie.java new revision: delete; previous revision: 1.3 /cvs/editor/src/org/netbeans/modules/editor/java/JavaKit.java new revision: 1.111; previous revision: 1.110 /cvs/java/src/org/netbeans/modules/java/tools/OverrideAction.java new revision: 1.20; previous revision: 1.19 /cvs/java/src/org/netbeans/modules/java/tools/OverridePanel2.java new revision: 1.8; previous revision: 1.7 /cvs/java/src/org/netbeans/modules/java/ui/NavigationView.java new revision: 1.32; previous revision: 1.31 /cvs/java/src/org/netbeans/modules/java/ui/actions/SynchronizeAction.java new revision: 1.8; previous revision: 1.7 /cvs/java/src/org/netbeans/modules/java/ui/nodes/JavaSourceNodeFactory.java new revision: 1.14; previous revision: 1.13 /cvs/java/src/org/netbeans/modules/java/ui/nodes/elements/ElementNode.java new revision: 1.13; previous revision: 1.12 /cvs/javadoc/src/org/netbeans/modules/javadoc/comments/AutoCommentAction.java new revision: 1.30; previous revision: 1.29 /cvs/javadoc/src/org/netbeans/modules/javadoc/comments/AutoCommenter.java new revision: 1.43; previous revision: 1.42 /cvs/javadoc/src/org/netbeans/modules/javadoc/comments/CorrectJavaDocAction.java new revision: 1.11; previous revision: 1.10 /cvs/javadoc/src/org/netbeans/modules/javadoc/comments/JavaDocPropertySupportFactory.java new revision: 1.14; previous revision: 1.13 /cvs/refactoring/src/org/netbeans/modules/refactoring/ui/ChangeParametersAction.java new revision: 1.8; previous revision: 1.7 /cvs/refactoring/src/org/netbeans/modules/refactoring/ui/EncapsulateFieldAction.java new revision: 1.8; previous revision: 1.7 /cvs/refactoring/src/org/netbeans/modules/refactoring/ui/MoveClassAction.java new revision: 1.10; previous revision: 1.9 /cvs/refactoring/src/org/netbeans/modules/refactoring/ui/RenameAction.java new revision: 1.20; previous revision: 1.19 /cvs/refactoring/src/org/netbeans/modules/refactoring/ui/WhereUsedAction.java new revision: 1.9; previous revision: 1.8
Reorganization of java component