Eclipse CDT
Pre-release 3.0

org.eclipse.cdt.core.search
Class DOMSearchUtil

java.lang.Object
  extended by org.eclipse.cdt.core.search.DOMSearchUtil

public class DOMSearchUtil
extends Object

Utility class to have commonly used algorithms in one place for searching with the DOM.


Nested Class Summary
static class DOMSearchUtil.CNameCollector
          The CNameCollector used to get IASTNames from an IASTNode.
static class DOMSearchUtil.CPPNameCollector
          The CPPNameCollector used to get IASTNames from an IASTNode.
 
Constructor Summary
DOMSearchUtil()
           
 
Method Summary
static org.eclipse.cdt.core.parser.ParserLanguage getLanguage(IPath path, IProject project)
          Returns the ParserLanguage corresponding to the IPath and IProject.
static org.eclipse.cdt.core.parser.ParserLanguage getLanguageFromFile(IFile file)
          This retrieves the ParserLanguage from an IFile.
static Set getMatchesFromSearchEngine(ICSearchScope scope, IASTName searchName, ICSearchConstants.LimitTo limitTo)
          This is a convenience method that uses the SearchEngine to find declarations, references, or both that correspond to the IASTName searchName found in the index.
static Set getMatchesFromSearchEngine(ICSearchScope scope, String searchPattern, ICSearchConstants.LimitTo limitTo)
          This is a convenience method that uses the SearchEngine to find everything in the index that matches to a String.
static IASTName[] getNamesFromDOM(IASTName searchName, ICSearchConstants.LimitTo limitTo)
          This is used to get the names from the TU that the IASTName searchName belongs to.
static String getSearchPattern(IASTName name)
          Generates a search pattern String based on the IASTName passed as a parameter.
static IASTName[] getSelectedNamesFrom(IASTTranslationUnit tu, int offset, int length, org.eclipse.cdt.core.parser.ParserLanguage lang)
          This is used to get an array of selected names in an IASTTranslationUnit based on the offset and length into that IASTTranslationUnit.
static IASTName[] getSelectedNamesFrom(IFile file, int offset, int length)
          This is used to get an array of selected names in an IFile based on the offset and length into that IFile.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMSearchUtil

public DOMSearchUtil()
Method Detail

getMatchesFromSearchEngine

public static Set getMatchesFromSearchEngine(ICSearchScope scope,
                                             IASTName searchName,
                                             ICSearchConstants.LimitTo limitTo)
This is a convenience method that uses the SearchEngine to find declarations, references, or both that correspond to the IASTName searchName found in the index.

Parameters:
scope - is used to limit the scope that SearchEngine searches the index against
searchName - is the IASTName whose delcarations/references are sought after
limitTo - used to specify whether to get declarations, references, or both, one of: ( CSearchPattern.DECLARATION | CSearchPattern.REFERENCES | CSearchPattern.ALL_OCCURRENCES )
Returns:

getMatchesFromSearchEngine

public static Set getMatchesFromSearchEngine(ICSearchScope scope,
                                             String searchPattern,
                                             ICSearchConstants.LimitTo limitTo)
This is a convenience method that uses the SearchEngine to find everything in the index that matches to a String.

Parameters:
scope - the scope to search within the index
searchPattern - the string used to search the index with
Returns:

getSelectedNamesFrom

public static IASTName[] getSelectedNamesFrom(IASTTranslationUnit tu,
                                              int offset,
                                              int length,
                                              org.eclipse.cdt.core.parser.ParserLanguage lang)
This is used to get an array of selected names in an IASTTranslationUnit based on the offset and length into that IASTTranslationUnit. ex: IASTTranslationUnit contains: int foo; then getSelectedNamesFrom(file, 4, 3) will return the IASTName corresponding to foo

Parameters:
tu -
offset -
length -
lang -
Returns:

getSelectedNamesFrom

public static IASTName[] getSelectedNamesFrom(IFile file,
                                              int offset,
                                              int length)
This is used to get an array of selected names in an IFile based on the offset and length into that IFile. NOTE: Invoking this method causes a parse, if an IASTTranslationUnit is already obtained then invoke getSelectedNamesFrom(IASTTranslationUnit, int, int, ParserLanguage) instead. ex: IFile contains: int foo; then getSelectedNamesFrom(file, 4, 3) will return the IASTName corresponding to foo

Parameters:
file - the IFile whose selection
offset -
length -
Returns:

getLanguageFromFile

public static org.eclipse.cdt.core.parser.ParserLanguage getLanguageFromFile(IFile file)
This retrieves the ParserLanguage from an IFile.

Parameters:
file -
Returns:

getNamesFromDOM

public static IASTName[] getNamesFromDOM(IASTName searchName,
                                         ICSearchConstants.LimitTo limitTo)
This is used to get the names from the TU that the IASTName searchName belongs to.

Parameters:
searchName - the IASTName whose references/delcarations are to be retrieved
limitTo - used to specify whether to get declarations, references, or both, one of: ( CSearchPattern.DECLARATION | CSearchPattern.REFERENCES | CSearchPattern.ALL_OCCURRENCES )
Returns:
IASTName[] declarations, references, or both depending on limitTo that correspond to the IASTName searchName searched for

getLanguage

public static org.eclipse.cdt.core.parser.ParserLanguage getLanguage(IPath path,
                                                                     IProject project)
Returns the ParserLanguage corresponding to the IPath and IProject. Returns ParserLanguage.CPP if the file type is a header.

Parameters:
path -
project -
Returns:

getSearchPattern

public static String getSearchPattern(IASTName name)
Generates a search pattern String based on the IASTName passed as a parameter. Used to generate a string to present to the user as well as a string used by the SearchEngine to parse for qualified names and parameters.

Parameters:
name -
Returns:

Eclipse CDT
Pre-release 3.0

Copyright (c) IBM Corp. and others 2004. All Rights Reserved.