Community
Participate
Working Groups
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).
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?
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...
If you want something fast, you should be careful about requesting the bindings.
Could you please provide feedback about the performances? Is it fast enough for you? If yes, I will close this PR.
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.
Change milestone.
Verified.