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.
While debugging issue 119696, I found that the Lookup in nodes does yield different results when different calls are used. This is the root case of the mentioned issue, as it needs to conditionally add the node into a lookup used for context aware actions, but it uses different lookup call than the ContextAwareAction implementations. I used the following debugging code in TreeView.TakeAction: Lookup contextLookup = nodes[0].getLookup (); System.err.println(" self type in lkp: " + contextLookup.lookup(nodes[0].getClass()); System.err.println(" node in lkp: " + contextLookup.lookup(Node.class)); System.err.println(" lookupResult: " + contextLookup.lookupResult(Node.class).allInstances()); and the result was, surprisingly: self type in lkp: org.netbeans.modules.favorites.Favorites$ProjectFilterNode@17f2faa[Name=test, displayName=test.dummy] node in lkp: org.netbeans.modules.favorites.Favorites$ProjectFilterNode@17f2faa[Name=test, displayName=test.dummy] lookupResult: [] The bug might actually be in FilterNode's lookup implementation at the end, but I'd still like to ask Yarda to look at it.
So far it works for me: IDE:------------------------------------------------- IDE: [24.10.07 16:04] Committing "FilterNodeTest.java" started Checking in FilterNodeTest.java; /shared/data/ccvs/repository/openide/nodes/test/unit/src/org/openide/nodes/FilterNodeTest.java,v <-- FilterNodeTest.java new revision: 1.10; previous revision: 1.9 done IDE: [24.10.07 16:05] Committing "FilterNodeTest.java" finished
Simulated, here is the failing test: public void testBuggyIsWrongInFavoritesIssue119727() { class ProjectFilterNode extends FilterNode { public ProjectFilterNode (Node node, org.openide.nodes.Children children) { super (node, children); } } CookieSet set = CookieSet.createGeneric(null); Node pfn = new AbstractNode(Children.LEAF, set.getLookup()); FilterNode n = new ProjectFilterNode(pfn, Children.LEAF); Lookup contextLookup = n.getLookup(); Object o; o = contextLookup.lookup(ProjectFilterNode.class); assertEquals("found self", n, o); o = contextLookup.lookup(n.getClass()); assertEquals("found sefl2", n, o); o = contextLookup.lookup(Node.class); assertEquals("found node", n, o); Collection<? extends Node> all = contextLookup.lookupResult(Node.class).allInstances(); assertEquals("One found: " + all, 1, all.size()); assertEquals("It is the filter node", n, all.iterator().next()); }
Checking in test/unit/src/org/openide/nodes/FilterNodeTest.java; /shared/data/ccvs/repository/openide/nodes/test/unit/src/org/openide/nodes/FilterNodeTest.java,v <-- FilterNodeTest.java new revision: 1.11; previous revision: 1.10 done Checking in src/org/openide/nodes/FilterNode.java; /shared/data/ccvs/repository/openide/nodes/src/org/openide/nodes/FilterNode.java,v <-- FilterNode.java new revision: 1.12; previous revision: 1.11 done
Behaves as expected now.