Bug 53024 - [DOM] Move NodeFinder to a non-internal package
Summary: [DOM] Move NodeFinder to a non-internal package
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.5 M3   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 220185 (view as bug list)
Depends on:
Blocks: 292345 250944
  Show dependency tree
 
Reported: 2004-02-25 03:07 EST by Martin Kersten CLA
Modified: 2010-08-05 17:23 EDT (History)
9 users (show)

See Also:


Attachments
add boolean ASTVisitor#preVisit2(ASTNode) (4.37 KB, patch)
2008-09-12 08:34 EDT, Markus Keller CLA
no flags Details | Diff
Proposed fix (11.31 KB, patch)
2008-10-14 14:00 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix (11.68 KB, patch)
2008-10-15 11:21 EDT, Olivier Thomann CLA
no flags Details | Diff
Fix that removes outdated comments. (2.25 KB, patch)
2009-10-05 06:30 EDT, Dani Megert CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Kersten CLA 2004-02-25 03:07:59 EST
The NodeFinder class is part of the package org.eclipse.jdt.internal.corext.dom
and provides very usefull logic. Therefore I would like to use some similar
functions in my plugin. Sadly the NodeFinder is part of an internal package and
should only be used by plugins strongly related to jdt. (My isn't).

Would be nice if the node finder (or a similar one) is becomes part of the AST API. 


Thanks,

Martin (Kersten)
Comment 1 Martin Kersten CLA 2004-02-25 03:20:45 EST
Also the GenericVisitor would be a nice to have feature. Maybe the
ASTNodeVisitor may replicate the behaviour. But may be you need it for other
purpose. Don't know. But I think the AST API still lacks ways to find a
particular node. Would be nice to have the NodeFinder and GenericVisitor in a
non-internal package.
Comment 2 Philipe Mulet CLA 2004-05-17 10:02:52 EDT
Deferred
Comment 3 Naci Dai CLA 2006-09-05 04:46:38 EDT
I would like to repoen this bug for comments:

It would be nice to make NodeFinder or at least GenericVisitor API.  WTP EJB code generation makes use of them (for a simple task to find ASTNodes of TypeDecleration) I think they are useful outside the boundaries of JST
Comment 4 Naci Dai CLA 2006-09-05 04:47:28 EDT
Adding david to CC
Comment 5 Jerome Lanneluc CLA 2008-09-11 10:18:54 EDT
Olivier, please look at this for M3
Comment 6 Olivier Thomann CLA 2008-09-11 10:25:01 EDT
Need to synchronize with JDT/UI since they could then use the core version of the class.
Right now this class is inside the JDT/UI component.
Markus, can we see this together post M2 ?
Comment 7 Markus Keller CLA 2008-09-12 08:34:25 EDT
Created attachment 112408 [details]
add boolean ASTVisitor#preVisit2(ASTNode) 

> Markus, can we see this together post M2 ?
Sure, but unfortunately I'll be away till 2008-10-06, so I can only give feedback in 3 weeks.

NodeFinder needs some Javadoc cleanup, and I would
- make it final or @noextend, and
- use a private class to implement the actual ASTVisitor

I think the GenericVisitor is only there because of a deficiency in the ASTVisitor API. The problem is that the generic preVisit(ASTNode) should return a boolean like all the type-specific visit(*) methods. See the attached patch for how to make the GenericVistor obsolete.
Comment 8 Olivier Thomann CLA 2008-10-14 14:00:43 EDT
Created attachment 115071 [details]
Proposed fix

This patch overrides the previous one by defining a new NodeFinder class inside the org.eclipse.jdt.core.dom package.
Comment 9 Olivier Thomann CLA 2008-10-14 14:01:14 EDT
It might evolve over time to meet more specific requirements.
Comment 10 Markus Keller CLA 2008-10-15 10:27:13 EDT
(In reply to comment #7)
> The problem is that the generic preVisit(ASTNode) should return
> a boolean like all the type-specific visit(*) methods.

Hmm, 'boolean preVisit2(ASTNode)' is enough for NodeFinder, but it's not a full
replacement for the GenericVisitor. We have cases where subclasses of
GenericVisitor override visitNode(ASTNode) as well as some visit(...) methods.

We have to see case-by case whether preVisit2(ASTNode) is actually sufficient
to implement all these cases, but I guess it's not. I don't have time to do
this analysis for M3, so I opened bug 250944. We will probably still need
GenericVisitor, either as a separate class, or integrated into the ASTVisitor.
Comment 11 Olivier Thomann CLA 2008-10-15 10:33:23 EDT
So Markus, should I release the actual patch and let you adapt to it to see if you need more changes ?
Comment 12 Markus Keller CLA 2008-10-15 10:52:27 EDT
> So Markus, should I release the actual patch and let you adapt to it to see if
> you need more changes ?

Yes, and if you want to be nice to other clients, you could add a warning that the API is still in flux to NodeFinder and ASTVisitor#preVisit2(ASTNode).
Comment 13 Olivier Thomann CLA 2008-10-15 10:55:43 EDT
So I could add something like:
This API is still subject to modifications before the 3.5 release.
Comment 14 Markus Keller CLA 2008-10-15 11:13:40 EDT
> This API is still subject to modifications before the 3.5 release.
Yeah, or:
This API is still under discussion, see https://bugs.eclipse.org/53024 .
Comment 15 Olivier Thomann CLA 2008-10-15 11:21:59 EDT
Created attachment 115150 [details]
Proposed fix

New patch with the warning in NodeFinder and ASTVisitor.preVisit2.
Comment 16 Olivier Thomann CLA 2008-10-15 11:29:22 EDT
Released for 3.5M3.
These is nothing to verify as is. Once JDT/UI will adopt this new API, all existing refactoring tests will extensively use it.
Comment 17 Frederic Fusier CLA 2008-10-27 12:53:58 EDT
Verified for 3.5M3 using JDT/Core plug-in source code of I20081026-2000.
Comment 18 Stephan Herrmann CLA 2009-10-02 11:36:56 EDT
(In reply to comment #15)
> Created an attachment (id=115150) [details]
> Proposed fix
> 
> New patch with the warning in NodeFinder and ASTVisitor.preVisit2.

The warning is still in the sources.
Since the bug is closed, should the comments be removed now?
Comment 19 Dani Megert CLA 2009-10-05 06:30:03 EDT
>Since the bug is closed, should the comments be removed now?
Yes. Olivier please commit my patch.
Comment 20 Dani Megert CLA 2009-10-05 06:30:59 EDT
Created attachment 148752 [details]
Fix that removes outdated comments.
Comment 21 Olivier Thomann CLA 2009-10-05 10:27:49 EDT
(In reply to comment #19)
> Yes. Olivier please commit my patch.
Done.
Comment 22 Olivier Thomann CLA 2010-08-05 17:23:14 EDT
*** Bug 220185 has been marked as a duplicate of this bug. ***