Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "JDT Core Programmer Guide"

(Search Engine)
(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.
 +
 +
Searching steps:
 +
# Get the file names from indexes
 +
# Parse the file and find out matching nodes
 +
# Resolve types and narrow down matches reported from index
 +
# Create the appropriate model element
 +
 
=== Using the APIs, an example ===
 
=== Using the APIs, an example ===
  

Revision as of 12:16, 18 June 2012

Overview

Java Model

Java model is a lightweight model for views.

Search Engine

Indexes of declarations, references and type hierarchy relationships.

Searching steps:

  1. Get the file names from indexes
  2. Parse the file and find out matching nodes
  3. Resolve types and narrow down matches reported from index
  4. Create the appropriate model element

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.

Back to the top