Jump to: navigation, search

Difference between revisions of "JDT Core Programmer Guide"

(New page: = Overview = == Java Model == Java model is a lightweight model for views. == Search Engine == Indexes of declarations, references and type hierarchy relationships. == AST == Precise, full...)
 
(Search Engine)
Line 4: Line 4:
 
== Search Engine ==
 
== Search Engine ==
 
Indexes of declarations, references and type hierarchy relationships.
 
Indexes of declarations, references and type hierarchy relationships.
 +
=== Using the APIs, an example ===
 +
 +
Create a search pattern:
 +
 +
SearchPattern pattern = SearchPattern.createPattern(
 +
  "foo(*) int",
 +
  IJavaSearchConstants.METHOD,
 +
  IJavaSearchConstants.DECLARATIONS,
 +
  SearchPattern.R_PATTERN_MATCH
 +
);
 +
 +
Create a search scope:
 +
 +
IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
 +
 +
Collect results using SearchRequestor subclass:
 +
 +
SearchRequestor requestor = new SearchRequestor() {
 +
  public void acceptSearchMatch(SearchMatch match) {
 +
    System.out.println(match.getElement());
 +
  }
 +
};
 +
 +
Start search:
 +
 +
new SearchEngine().search(
 +
  pattern,
 +
  new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant()},
 +
  scope,
 +
  requestor,
 +
  null /*progress monitor*/
 +
);
 +
 
== AST ==
 
== AST ==
 
Precise, fully resolved compiler parse tree.
 
Precise, fully resolved compiler parse tree.
  
 
[[Category:JDT]]
 
[[Category:JDT]]

Revision as of 12:10, 18 June 2012

Overview

Java Model

Java model is a lightweight model for views.

Search Engine

Indexes of declarations, references and type hierarchy relationships.

Using the APIs, an example

Create a search pattern:

SearchPattern pattern = SearchPattern.createPattern(
 "foo(*) int", 
 IJavaSearchConstants.METHOD, 
 IJavaSearchConstants.DECLARATIONS, 
 SearchPattern.R_PATTERN_MATCH
);

Create a search scope:

IJavaSearchScope scope = SearchEngine.createWorkspaceScope();

Collect results using SearchRequestor subclass:

SearchRequestor requestor = new SearchRequestor() {
 public void acceptSearchMatch(SearchMatch match) {
   System.out.println(match.getElement());
 }
};

Start search:

new SearchEngine().search(
 pattern, 
 new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant()}, 
 scope, 
 requestor, 
 null /*progress monitor*/
);

AST

Precise, fully resolved compiler parse tree.