views:

31

answers:

2

hi,

I want to know how AST(Abstract Syntax Tree ) is used in the search button of eclipse.Can anyone provide me the link or some info about it .Help

A: 

Here is one link that I found:

The Abstract Syntax Tree is the base framework for many powerful tools of the Eclipse IDE, including refactoring, Quick Fix and Quick Assist. The Abstract Syntax Tree maps plain Java source code in a tree form. This tree is more convenient and reliable to analyse and modify programmatically than text-based source. This article shows how you can use the Abstract Syntax Tree for your own applications.

pkaeding
+1  A: 

This is a small example for that:

 SearchPattern pattern = SearchPattern.createPattern(fTarget.getDeclaringType()
         .getFullyQualifiedName()
         + "." + fTarget.getElementName(), type, IJavaSearchConstants.REFERENCES,
         SearchPattern.R_PREFIX_MATCH | SearchPattern.R_ERASURE_MATCH);
 SearchEngine engine = new SearchEngine();
 engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() },
         scope, new SearchRequestor() {

             @Override public void acceptSearchMatch(SearchMatch match) throws CoreException {
                 if (match.getAccuracy() == SearchMatch.A_ACCURATE && !match.isInsideDocComment()) {
                     invocations.add(match);
                 }
             }
         }, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
nanda