Bug 38931 - org.eclipse.jdt.internal.corext.dom.NodeFinder needed in API
Summary: org.eclipse.jdt.internal.corext.dom.NodeFinder needed in API
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.0 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-06-15 22:54 EDT by David J. Orme CLA
Modified: 2003-10-08 09:38 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David J. Orme CLA 2003-06-15 22:54:21 EDT
Use case:

I've got an IMethod and I need to get its corresponding MethodDeclaration AST
node.  Unless I'm missing something, there's no easy way to do this using the
existing public API.  However, if NodeFinder were public, I could (legally) write:

CompilationUnit compilationUnitAST = 
    AST.parseCompilationUnit(someICompUnit, true);
ISourceRange sourceRange = myIMethod.getSourceRange();
MethodDeclaration decl = (MethodDeclaration) 
    NodeFinder.perform(compilationUnitAST, 
        sourceRange.getOffset(), 
        sourceRange.getLength());

(assuming appropriate try/catch clauses to trap for JavaModelException).
Comment 1 Olivier Thomann CLA 2003-08-26 14:15:49 EDT
Is the usage of the new API 
org.eclipse.jdt.core.dom.AST.parsePartialCompilationUnit(...) good enough for 
you?
You simply need to provide a position within the range of the IMethod source 
range. You get all bindings if you need them.
If yes, is it ok to close?
Comment 2 David J. Orme CLA 2003-09-08 10:15:16 EDT
It's good enough for me as long as it's at least as fast as NodeFinder. :-)

We're talking stuff that potentially runs between keystrokes here.

Thanks...
Comment 3 Olivier Thomann CLA 2003-09-08 10:28:36 EDT
If you want something fast, you should be careful about requesting the bindings.
Comment 4 Olivier Thomann CLA 2003-09-16 14:16:50 EDT
Could you please provide feedback about the performances? Is it fast enough for you?
If yes, I will close this PR.
Comment 5 David J. Orme CLA 2003-09-16 14:55:46 EDT
Resolving as FIXED because I won't have time to look at this for a few weeks at
least.  If I discover a performance problem, I'll reopen the bug or create a new
one.
Comment 6 Olivier Thomann CLA 2003-09-16 15:02:34 EDT
Change milestone.
Comment 7 David Audel CLA 2003-10-08 09:38:05 EDT
Verified.