public interface IIndex
Modifier and Type | Field and Description |
---|---|
static int |
DEPTH_INFINITE
Constant to specify infinite depth.
|
static int |
DEPTH_ZERO
Constant to find direct includes, only.
|
static int |
FIND_ALL_OCCURRENCES
Constant to search for all occurrences of a binding.
|
static int |
FIND_DECLARATIONS
Constant to search for declarations.
|
static int |
FIND_DECLARATIONS_DEFINITIONS
Constant to search for all declarations including definitions.
|
static int |
FIND_DEFINITIONS
Constant to search for definitions.
|
static int |
FIND_POTENTIAL_MATCHES
Constant to include potential matches in the results of a search.
|
static int |
FIND_REFERENCES
Constant to search for references.
|
static int |
SEARCH_ACROSS_LANGUAGE_BOUNDARIES
Constant to search for occurrences across language boundaries.
|
Modifier and Type | Method and Description |
---|---|
void |
acquireReadLock()
Before making calls to an index you have to obtain a lock.
|
IIndexBinding |
adaptBinding(IBinding binding)
Returns an
IIndexBinding for this index that is equivalent to the specified binding,
or null if such a binding does not exist in this index. |
IIndexFileSet |
createFileSet()
Creates a file-set that can be used with this index as long as the caller holds a read-lock.
|
IIndexBinding |
findBinding(IName name)
Searches for the binding of a name.
|
IIndexBinding[] |
findBindings(char[][] names,
IndexFilter filter,
org.eclipse.core.runtime.IProgressMonitor monitor)
Searches for all bindings in global scope with a given name.
|
IIndexBinding[] |
findBindings(char[] name,
boolean fileScopeOnly,
IndexFilter filter,
org.eclipse.core.runtime.IProgressMonitor monitor)
Searches the global scope and optionally all other scopes for bindings with a given name.
|
IIndexBinding[] |
findBindings(char[] name,
IndexFilter filter,
org.eclipse.core.runtime.IProgressMonitor monitor)
Searches the global scope for all bindings with a given name.
|
IIndexBinding[] |
findBindings(Pattern[] patterns,
boolean isFullyQualified,
IndexFilter filter,
org.eclipse.core.runtime.IProgressMonitor monitor)
Searches for all bindings with qualified names that seen as an array of simple names match
the given array of patterns.
|
IIndexBinding[] |
findBindings(Pattern pattern,
boolean isFullyQualified,
IndexFilter filter,
org.eclipse.core.runtime.IProgressMonitor monitor)
Searches for all bindings with simple names that match the given pattern.
|
IIndexBinding[] |
findBindingsForContentAssist(char[] prefix,
boolean fileScopeOnly,
IndexFilter filter,
org.eclipse.core.runtime.IProgressMonitor monitor) |
IIndexBinding[] |
findBindingsForPrefix(char[] prefix,
boolean fileScopeOnly,
IndexFilter filter,
org.eclipse.core.runtime.IProgressMonitor monitor)
Searches for all bindings with names that start with the given prefix.
|
IIndexName[] |
findDeclarations(IBinding binding)
Searches for all declarations and definitions that resolve to the given binding.
|
IIndexName[] |
findDefinitions(IBinding binding)
Searches for all definitions that resolve to the given binding.
|
IIndexInclude[] |
findIncludedBy(IIndexFile file)
Looks for include relations pointing to the given file.
|
IIndexInclude[] |
findIncludedBy(IIndexFile file,
int depth)
Looks recursively for include relations pointing to the given file.
|
IIndexInclude[] |
findIncludes(IIndexFile file)
Looks for include relations originated by the given file.
|
IIndexInclude[] |
findIncludes(IIndexFile file,
int depth)
Looks recursively for include relations originated by the given file.
|
IIndexBinding[] |
findMacroContainers(Pattern pattern,
IndexFilter filter,
org.eclipse.core.runtime.IProgressMonitor monitor)
Searches for all macro containers (one for macros with the same name) with names that
match the given pattern.
|
IIndexMacro[] |
findMacros(char[] name,
IndexFilter filter,
org.eclipse.core.runtime.IProgressMonitor monitor)
Searches for all macros with a given name.
|
IIndexMacro[] |
findMacrosForPrefix(char[] prefix,
IndexFilter filter,
org.eclipse.core.runtime.IProgressMonitor monitor)
Searches for all macros with names that start with the given prefix.
|
IIndexName[] |
findNames(IBinding binding,
int flags)
Searches for all names that resolve to the given binding.
|
IIndexName[] |
findReferences(IBinding binding)
Searches for all references that resolve to the given binding.
|
IIndexFile[] |
getAllFiles()
Returns an array of all files that are part of this index.
|
IIndexFile[] |
getDefectiveFiles()
Returns an array of files that were indexed with I/O errors.
|
IIndexFile |
getFile(int linkageID,
IIndexFileLocation location)
|
IIndexFile |
getFile(int linkageID,
IIndexFileLocation location,
ISignificantMacros significantMacros)
Returns the file for the given location, linkage, and significant macros
May return
null , if no such file exists. |
IIndexFile[] |
getFiles(IIndexFileLocation location)
Returns the file objects for the given location in any linkage.
|
IIndexFile[] |
getFiles(int linkageID,
IIndexFileLocation location)
Returns the file objects for the given location and linkage.
|
IIndexFile[] |
getFilesWithUnresolvedIncludes()
Returns an array of files containing unresolved includes.
|
IScope[] |
getInlineNamespaces()
Returns the global inline c++ namespaces.
|
long |
getLastWriteAccess()
Returns a timestamp of when the index was last written to.
|
boolean |
hasWaitingReaders() |
boolean |
isFullyInitialized()
Returns
true if the index is fully initialized. |
void |
releaseReadLock()
Any lock obtained by
acquireReadLock() must be released. |
IIndexFile |
resolveInclude(IIndexInclude include)
Resolves the file that is included by the given include directive.
|
static final int DEPTH_INFINITE
static final int DEPTH_ZERO
static final int FIND_DECLARATIONS
static final int FIND_DEFINITIONS
static final int FIND_REFERENCES
static final int SEARCH_ACROSS_LANGUAGE_BOUNDARIES
static final int FIND_POTENTIAL_MATCHES
static final int FIND_DECLARATIONS_DEFINITIONS
static final int FIND_ALL_OCCURRENCES
void acquireReadLock() throws InterruptedException
void releaseReadLock()
acquireReadLock()
must be released.boolean hasWaitingReaders()
true
if there are threads waiting for read locks.long getLastWriteAccess()
long timestamp; IBinding binding= null; index.acquireReadLock(); try { timestamp= index.getLastWriteAccess(); binding= index.findBinding(...); } finally { index.releaseReadLock(); } ... index.acqureReadLock(); try { if (index.getLastWriteAccess() != timestamp) { // don't use binding, it's not valid anymore binding= index.findBinding(...); } String name= binding.getName(); ... } finally { index.releaseReadLock(); }
@Deprecated IIndexFile getFile(int linkageID, IIndexFileLocation location) throws org.eclipse.core.runtime.CoreException
getFile(int, IIndexFileLocation, ISignificantMacros)
or
getFiles(int, IIndexFileLocation)
.org.eclipse.core.runtime.CoreException
IIndexFile getFile(int linkageID, IIndexFileLocation location, ISignificantMacros significantMacros) throws org.eclipse.core.runtime.CoreException
null
, if no such file exists.linkageID
- the id of the linkage in which the file has been parsed.location
- the IIndexFileLocation representing the location of the filesignificantMacros
- The names and definitions of the macros used to disambiguate between
variants of the file contents corresponding to different inclusion points.null
if the file is not present in
the indexorg.eclipse.core.runtime.CoreException
IIndexFile[] getFiles(int linkageID, IIndexFileLocation location) throws org.eclipse.core.runtime.CoreException
linkageID
- the id of the linkage in which the file has been parsed.location
- the IIndexFileLocation representing the location of the fileorg.eclipse.core.runtime.CoreException
IIndexFile[] getFiles(IIndexFileLocation location) throws org.eclipse.core.runtime.CoreException
location
- an IIndexFileLocation representing the location of the fileorg.eclipse.core.runtime.CoreException
IIndexInclude[] findIncludes(IIndexFile file) throws org.eclipse.core.runtime.CoreException
findIncludes(file, DEPTH_ZERO);
file
- the file containing the include directivesorg.eclipse.core.runtime.CoreException
IIndexInclude[] findIncludedBy(IIndexFile file) throws org.eclipse.core.runtime.CoreException
findIncludedBy(file, DEPTH_ZERO);
file
- the file included by the directives to be foundorg.eclipse.core.runtime.CoreException
IIndexInclude[] findIncludes(IIndexFile file, int depth) throws org.eclipse.core.runtime.CoreException
file
- the file containing the include directivesdepth
- depth to which includes are followed, should be one of
DEPTH_ZERO
or DEPTH_INFINITE
org.eclipse.core.runtime.CoreException
IIndexInclude[] findIncludedBy(IIndexFile file, int depth) throws org.eclipse.core.runtime.CoreException
file
- the file the include directives point todepth
- depth to which includes are followed, should be one of
DEPTH_ZERO
or DEPTH_INFINITE
org.eclipse.core.runtime.CoreException
IIndexFile resolveInclude(IIndexInclude include) throws org.eclipse.core.runtime.CoreException
null
in case the file cannot be found. This is usually more efficient than using:
getFiles(include.getIncludesLocation())
include
- null
.org.eclipse.core.runtime.CoreException
IIndexMacro[] findMacros(char[] name, IndexFilter filter, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
name
- a name, that has to be matched by the macros.filter
- a filter that allows for skipping parts of the indexmonitor
- a monitor to report progress, may be null
.org.eclipse.core.runtime.CoreException
IIndexMacro[] findMacrosForPrefix(char[] prefix, IndexFilter filter, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
prefix
- the prefix with which all returned macros must startfilter
- a filter that allows for skipping parts of the indexmonitor
- a monitor for progress reporting and cancellation, may be null
org.eclipse.core.runtime.CoreException
IIndexBinding findBinding(IName name) throws org.eclipse.core.runtime.CoreException
null
.name
- a name to find the binding fornull
org.eclipse.core.runtime.CoreException
IIndexBinding[] findBindings(Pattern pattern, boolean isFullyQualified, IndexFilter filter, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
findBindings(new Pattern[] {pattern}, isFullyQualified, filter, monitor);
pattern
- the pattern the name of the binding has to match.isFullyQualified
- if true
, binding must be in global scopefilter
- a filter that allows for skipping parts of the indexmonitor
- a monitor to report progress, may be null
.org.eclipse.core.runtime.CoreException
IIndexBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified, IndexFilter filter, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
patterns
- an array of patterns the components of the qualified name of the bindings
have to match.isFullyQualified
- if true
, the array of pattern specifies the fully
qualified namefilter
- a filter that allows for skipping parts of the indexmonitor
- a monitor to report progress, may be null
.org.eclipse.core.runtime.CoreException
IIndexBinding[] findMacroContainers(Pattern pattern, IndexFilter filter, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
pattern
- a pattern the name of the bindings have to match.filter
- a filter that allows for skipping parts of the indexmonitor
- a monitor to report progress, may be null
org.eclipse.core.runtime.CoreException
IIndexBinding[] findBindings(char[][] names, IndexFilter filter, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
names
- an array of names, which has to be matched by the qualified name of
the bindings.filter
- a filter that allows for skipping parts of the indexmonitor
- a monitor to report progress, may be null
.org.eclipse.core.runtime.CoreException
IIndexBinding[] findBindings(char[] name, IndexFilter filter, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
findBindings(name, true, filter, monitor);
name
- a name, which has to be matched by the qualified name of the bindings.filter
- a filter that allows for skipping parts of the indexmonitor
- a monitor to report progress, may be null
.org.eclipse.core.runtime.CoreException
IIndexBinding[] findBindings(char[] name, boolean fileScopeOnly, IndexFilter filter, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
name
- a name, which has to be matched by the qualified name of the bindings.fileScopeOnly
- if true, only bindings at file scope are returnedfilter
- a filter that allows for skipping parts of the indexmonitor
- a monitor to report progress, may be null
.org.eclipse.core.runtime.CoreException
IIndexBinding[] findBindingsForPrefix(char[] prefix, boolean fileScopeOnly, IndexFilter filter, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
prefix
- the prefix with which all returned bindings must startfileScopeOnly
- if true, only bindings at file scope are returnedfilter
- a filter that allows for skipping parts of the indexmonitor
- a monitor for progress reporting and cancellation, may be null
org.eclipse.core.runtime.CoreException
IIndexBinding[] findBindingsForContentAssist(char[] prefix, boolean fileScopeOnly, IndexFilter filter, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
org.eclipse.core.runtime.CoreException
IIndexName[] findNames(IBinding binding, int flags) throws org.eclipse.core.runtime.CoreException
binding
- a binding for which names are searched forflags
- a combination of FIND_DECLARATIONS
, FIND_DEFINITIONS
,
FIND_REFERENCES
, SEARCH_ACROSS_LANGUAGE_BOUNDARIES
, and
FIND_POTENTIAL_MATCHES
.org.eclipse.core.runtime.CoreException
IIndexName[] findReferences(IBinding binding) throws org.eclipse.core.runtime.CoreException
findNames(binding, IIndex.FIND_REFERENCES);
binding
- a binding for which references are searched fororg.eclipse.core.runtime.CoreException
IIndexName[] findDeclarations(IBinding binding) throws org.eclipse.core.runtime.CoreException
findNames(binding, IIndex.FIND_DECLARATIONS_DEFINITIONS);
binding
- a binding for which declarations are searched fororg.eclipse.core.runtime.CoreException
IIndexName[] findDefinitions(IBinding binding) throws org.eclipse.core.runtime.CoreException
findNames(binding, IIndex.FIND_DEFINITIONS);
binding
- a binding for which declarations are searched fororg.eclipse.core.runtime.CoreException
IIndexBinding adaptBinding(IBinding binding)
IIndexBinding
for this index that is equivalent to the specified binding,
or null if such a binding does not exist in this index. This is useful for adapting
bindings obtained from IIndex objects that might have been created for a different scope
or for IBinding objects obtained directly from the AST.binding
- an AST or an index bindingIIndexFileSet createFileSet()
IIndexFile[] getAllFiles() throws org.eclipse.core.runtime.CoreException
org.eclipse.core.runtime.CoreException
IIndexFile[] getDefectiveFiles() throws org.eclipse.core.runtime.CoreException
org.eclipse.core.runtime.CoreException
IIndexFile[] getFilesWithUnresolvedIncludes() throws org.eclipse.core.runtime.CoreException
org.eclipse.core.runtime.CoreException
IScope[] getInlineNamespaces() throws org.eclipse.core.runtime.CoreException
org.eclipse.core.runtime.CoreException
boolean isFullyInitialized()
true
if the index is fully initialized. An index may not be fully initialized
during Eclipse startup, or soon after adding a new project to the workspace.Copyright (c) IBM Corp. and others 2004, 2020. All Rights Reserved.