Eclipse CDT
Pre-release 3.0

org.eclipse.cdt.core.model
Class CoreModel

java.lang.Object
  extended by org.eclipse.cdt.core.model.CoreModel

public class CoreModel
extends Object


Field Summary
static String CORE_MODEL_ID
           
 
Method Summary
 void addElementChangedListener(IElementChangedListener listener)
           
 ICElement create(IPath path)
          Creates an ICElement form and IPath.
 ITranslationUnit createTranslationUnitFrom(ICProject cproject, IPath path)
          Creates a translation form and IPath.
 ICModel getCModel()
          Returns the default ICModel.
static CoreModel getDefault()
          Return the singleton.
static IIncludeEntry[] getIncludeEntries(IPath path)
          This method returns the include entries associated with a translation unit if the path does not refer to a valid translation unit an empty array is return.
static IIncludeFileEntry[] getIncludeFileEntries(IPath path)
          This method returns the include file entries associated with a translation unit if the path does not refer to a valid translation unit an empty array is return.
 IndexManager getIndexManager()
           
static IMacroEntry[] getMacroEntries(IPath path)
          This method returns the macro entries associated with a translation unit if the path does not refer to a valid translation unit an empty array is return.
static IMacroFileEntry[] getMacroFileEntries(IPath path)
          This method returns the macro file entries associated with a translation unit if the path does not refer to a valid translation unit an empty array is return.
static IPathEntryContainer getPathEntryContainer(IPath containerPath, ICProject project)
          Answers the project specific value for a given container.
static PathEntryContainerInitializer getPathEntryContainerInitializer(String containerID)
          Helper method finding the pathentry container initializer registered for a given container ID or null if none was found while iterating over the contributions to extension point to the extension point "org.eclipse.cdt.core.PathEntryContainerInitializer".
static IPathEntryStore getPathEntryStore(IProject project)
          Return the IPathEntryStore of the project.
static IPathEntry[] getRawPathEntries(ICProject cproject)
          Returns the raw pathentries for the project.
static String getRegistedContentTypeId(IProject project, String name)
          Return the registed content type id, for example: CONTENT_TYPE_CHEADER CONTENT_TYPE_CXXHEADER CONTENT_TYPE_CSOURCE CONTENT_TYPE_CXXSOURCE CONTENT_TYPE_ASMSOURCE or null is return if no id match the list
static String[] getRegistedContentTypeIds()
          Return an array of the register contentTypes.
static IPathEntry[] getResolvedPathEntries(ICProject cproject)
          This method returns the resolved pathentries for the project All pathEntry.CDT_CONTAINER entries in the project's will be replaced by the entries they resolve to.
static boolean hasCCNature(IProject project)
          Return true if project has C++ nature.
static boolean hasCNature(IProject project)
          Return true if project has C nature.
 boolean isArchive(IFile file)
          Return true if IFile is an Achive, *.a
 boolean isBinary(IFile file)
          Return true if IFile is an ELF.
 boolean isExecutable(IFile file)
          Return true if IFile is an ELF executable
 boolean isObject(IFile file)
          Return true if IFile is a an object(ELF), i.e. *.o
static boolean isScannerInformationEmpty(IResource resource)
          The method returns whether scanner information for a resource is empty or not.
 boolean isSharedLib(IFile file)
          Return true if IFile is a shared library, i.e. libxx.so
static boolean isTranslationUnit(IFile file)
          Return true if IFile is a possible TranslationUnit.
static boolean isValidASMSourceUnitName(IProject project, String name)
          Return true if name is a valid name for a translation unit.
static boolean isValidCHeaderUnitName(IProject project, String name)
          Return true if name is a valid name for a translation unit.
static boolean isValidCSourceUnitName(IProject project, String name)
          Return true if name is a valid name for a translation unit.
static boolean isValidCXXHeaderUnitName(IProject project, String name)
          Return true if name is a valid name for a translation unit.
static boolean isValidCXXSourceUnitName(IProject project, String name)
          Return true if name is a valid name for a translation unit.
static boolean isValidHeaderUnitName(IProject project, String name)
          Return true if name is a valid name for a translation unit.
static boolean isValidSourceUnitName(IProject project, String name)
          Return true if name is a valid name for a translation unit.
static boolean isValidTranslationUnitName(IProject project, String name)
          Return true if name is a valid name for a translation unit.
static IContainerEntry newContainerEntry(IPath id)
          Creates and returns a new entry of kind CDT_CONTAINER for the given path.
static IContainerEntry newContainerEntry(IPath id, boolean isExported)
          Creates and returns a new entry of kind CDT_CONTAINER for the given path.
static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath basePath, IPath includePath)
          Creates and returns a new entry of kind CDT_INCLUDE
static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath basePath, IPath includePath, boolean isSystemInclude)
          * Creates and returns a new entry of kind CDT_INCLUDE
static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath basePath, IPath includePath, boolean isSystemInclude, IPath[] exclusionPatterns)
          Creates and returns a new entry of kind CDT_INCLUDE
static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath basePath, IPath includePath, boolean isSystemInclude, IPath[] exclusionPatterns, boolean isExported)
          Creates and returns a new entry of kind CDT_INCLUDE
static IIncludeFileEntry newIncludeFileEntry(IPath resourcePath, IPath includeFile)
          Creates a new entry of kind CDT_INCLUDE_FILE
static IIncludeFileEntry newIncludeFileEntry(IPath resourcePath, IPath baseRef, IPath basePath, IPath includeFilePath, IPath[] exclusionPatterns, boolean isExported)
          Creates and returns a new entry of kind CDT_INCLUDE_FILE
static IIncludeEntry newIncludeRefEntry(IPath resourcePath, IPath baseRef, IPath includePath)
          Creates and returns a new entry of kind CDT_INCLUDE
static ILibraryEntry newLibraryEntry(IPath resourcePath, IPath basePath, IPath libraryPath, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, IPath sourceAttachmentPrefixMapping, boolean isExported)
          Creates and returns a new entry of kind CDT_LIBRARY for the archive or folder identified by the given absolute path.
static ILibraryEntry newLibraryRefEntry(IPath resourcePath, IPath baseRef, IPath libraryPath)
          Creates and returns a new entry of kind CDT_LIBRARY for the archive or folder identified by the given absolute path.
static IMacroEntry newMacroEntry(IPath resourcePath, String macroName, String macroValue)
          Creates and returns an entry kind CDT_MACRO
static IMacroEntry newMacroEntry(IPath resourcePath, String macroName, String macroValue, IPath[] exclusionPatterns)
          Creates and returns an entry kind CDT_MACRO
static IMacroEntry newMacroEntry(IPath resourcePath, String macroName, String macroValue, IPath[] exclusionPatterns, boolean isExported)
          Creates and returns an entry kind CDT_MACRO
static IMacroFileEntry newMacroFileEntry(IPath resourcePath, IPath macroFile)
          Creates an entry kind CDT_MACRO_FILE
static IMacroFileEntry newMacroFileEntry(IPath resourcePath, IPath basePath, IPath baseRef, IPath macroFilePath, IPath[] exclusionPatterns, boolean isExported)
          Creates and returns an entry kind CDT_MACRO_FILE
static IMacroEntry newMacroRefEntry(IPath resourcePath, IPath baseRef, String macroName)
          Creates and returns an entry kind CDT_MACRO
static IOutputEntry newOutputEntry(IPath outputPath)
          Creates and returns a new entry of kind CDT_OUTPUT for the project's output folder
static IOutputEntry newOutputEntry(IPath outputPath, IPath[] exclusionPatterns)
          Creates and returns a new entry of kind CDT_OUPUT for the project
static IProjectEntry newProjectEntry(IPath projectPath)
          Creates and returns a new non-exported entry of kind CDT_PROJECT for the project identified by the given absolute path.
static IProjectEntry newProjectEntry(IPath projectPath, boolean isExported)
          Creates and returns a new entry of kind CDT_PROJECT for the project identified by the given workspace-relative path.
static ISourceEntry newSourceEntry(IPath sourcePath)
          Creates and returns a new entry of kind CDT_SOURCE for the project's source folder identified by the given absolute workspace-relative path.
static ISourceEntry newSourceEntry(IPath sourcePath, IPath[] exclusionPatterns)
          Creates and returns a new entry of kind CDT_SOURCE for the project's source folder identified by the given absolute workspace-relative path but excluding all source files with paths matching any of the given patterns.
static void pathEntryContainerUpdates(IPathEntryContainerExtension container, PathEntryContainerChanged[] changes, IProgressMonitor monitor)
          Helper method use by a pathentry container implementing IPathEntryContainerExtension It notify the model of changes.
 void removeElementChangedListener(IElementChangedListener listener)
          Removes the given element changed listener.
static void run(IWorkspaceRunnable action, IProgressMonitor monitor)
          Runs the given action as an atomic C model operation.
static void run(IWorkspaceRunnable action, ISchedulingRule rule, IProgressMonitor monitor)
          Runs the given action as an atomic C model operation.
static void setPathEntryContainer(ICProject[] affectedProjects, IPathEntryContainer container, IProgressMonitor monitor)
          Bind a container reference path to some actual containers (IPathEntryContainer).
static void setPathEntryStore(IProject project, IPathEntryStore store)
          Set in the map the store, but not persisted.
static void setRawPathEntries(ICProject cproject, IPathEntry[] newEntries, IProgressMonitor monitor)
          Sets the pathentries of this project using a list of entries.
 void shutdown()
           
 void startIndexing()
           
 void startup()
           
static ICModelStatus validatePathEntries(ICProject cProject, IPathEntry[] entries)
          Validate a given path entries for a project, using the following rules: Entries cannot collide with each other; that is, all entry paths must be unique.
static ICModelStatus validatePathEntry(ICProject cProject, IPathEntry entry, boolean checkSourceAttachment, boolean recurseInContainers)
          Returns a C model status describing the problem related to this entry if any, a status object with code IStatus.OK if the entry is fine (that is, if the given entry denotes a valid element).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CORE_MODEL_ID

public static final String CORE_MODEL_ID
Method Detail

create

public ICElement create(IPath path)
Creates an ICElement form and IPath. Returns null if not found.


createTranslationUnitFrom

public ITranslationUnit createTranslationUnitFrom(ICProject cproject,
                                                  IPath path)
Creates a translation form and IPath. Returns null if not found.


getCModel

public ICModel getCModel()
Returns the default ICModel.


isSharedLib

public boolean isSharedLib(IFile file)
Return true if IFile is a shared library, i.e. libxx.so


isObject

public boolean isObject(IFile file)
Return true if IFile is a an object(ELF), i.e. *.o


isExecutable

public boolean isExecutable(IFile file)
Return true if IFile is an ELF executable


isBinary

public boolean isBinary(IFile file)
Return true if IFile is an ELF.


isArchive

public boolean isArchive(IFile file)
Return true if IFile is an Achive, *.a


isTranslationUnit

public static boolean isTranslationUnit(IFile file)
Return true if IFile is a possible TranslationUnit.


getRegistedContentTypeIds

public static String[] getRegistedContentTypeIds()
Return an array of the register contentTypes.

Returns:
String[] ids

isValidTranslationUnitName

public static boolean isValidTranslationUnitName(IProject project,
                                                 String name)
Return true if name is a valid name for a translation unit.


isValidHeaderUnitName

public static boolean isValidHeaderUnitName(IProject project,
                                            String name)
Return true if name is a valid name for a translation unit.


isValidSourceUnitName

public static boolean isValidSourceUnitName(IProject project,
                                            String name)
Return true if name is a valid name for a translation unit.


isValidCSourceUnitName

public static boolean isValidCSourceUnitName(IProject project,
                                             String name)
Return true if name is a valid name for a translation unit.


isValidCXXSourceUnitName

public static boolean isValidCXXSourceUnitName(IProject project,
                                               String name)
Return true if name is a valid name for a translation unit.


isValidASMSourceUnitName

public static boolean isValidASMSourceUnitName(IProject project,
                                               String name)
Return true if name is a valid name for a translation unit.


isValidCXXHeaderUnitName

public static boolean isValidCXXHeaderUnitName(IProject project,
                                               String name)
Return true if name is a valid name for a translation unit.


isValidCHeaderUnitName

public static boolean isValidCHeaderUnitName(IProject project,
                                             String name)
Return true if name is a valid name for a translation unit.


getRegistedContentTypeId

public static String getRegistedContentTypeId(IProject project,
                                              String name)
Return the registed content type id, for example: or null is return if no id match the list

Parameters:
file -
Returns:
the know id or null

hasCNature

public static boolean hasCNature(IProject project)
Return true if project has C nature.


hasCCNature

public static boolean hasCCNature(IProject project)
Return true if project has C++ nature.


newProjectEntry

public static IProjectEntry newProjectEntry(IPath projectPath)
Creates and returns a new non-exported entry of kind CDT_PROJECT for the project identified by the given absolute path.

A project entry is used to denote a prerequisite project. The exported IPathEntry[] entries of the project will be contributed.

The prerequisite project is referred to using an absolute path relative to the workspace root.

The resulting entry is not exported to dependent projects. This method is equivalent to newProjectEntry(path,false).

Parameters:
projectPath - the workspace-relative path of the project
Returns:
a new project entry
See Also:
newProjectEntry(IPath, boolean)

newProjectEntry

public static IProjectEntry newProjectEntry(IPath projectPath,
                                            boolean isExported)
Creates and returns a new entry of kind CDT_PROJECT for the project identified by the given workspace-relative path.

A project entry is used to denote a prerequisite project. All the IPathEntries of the project will be contributed as a whole. The prerequisite project is referred to using an absolute path relative to the workspace root.

Parameters:
projectPath - the absolute workspace-relative path of the prerequisite project
isExported - indicates whether this entry is contributed to dependent projects
Returns:
a new project entry

newContainerEntry

public static IContainerEntry newContainerEntry(IPath id)
Creates and returns a new entry of kind CDT_CONTAINER for the given path. The path of the container will be used during resolution so as to map this container entry to a set of other entries the container is acting for.

The resulting entry is not exported to dependent projects. This method is equivalent to newContainerEntry(path,false).

Parameters:
containerPath - the id of the container
Returns:
a new container entry

newContainerEntry

public static IContainerEntry newContainerEntry(IPath id,
                                                boolean isExported)
Creates and returns a new entry of kind CDT_CONTAINER for the given path. The path of the container will be used during resolution so as to map this container entry to a set of other entries the container is acting for.

The resulting entry is not exported to dependent projects. This method is equivalent to newContainerEntry(path,false).


newLibraryRefEntry

public static ILibraryEntry newLibraryRefEntry(IPath resourcePath,
                                               IPath baseRef,
                                               IPath libraryPath)
Creates and returns a new entry of kind CDT_LIBRARY for the archive or folder identified by the given absolute path.

Parameters:
resourcePath - the affected project-relative resource path
baseRef - the base reference path to find the library
libraryPath - the library name.
Returns:
a new library entry

newLibraryEntry

public static ILibraryEntry newLibraryEntry(IPath resourcePath,
                                            IPath basePath,
                                            IPath libraryPath,
                                            IPath sourceAttachmentPath,
                                            IPath sourceAttachmentRootPath,
                                            IPath sourceAttachmentPrefixMapping,
                                            boolean isExported)
Creates and returns a new entry of kind CDT_LIBRARY for the archive or folder identified by the given absolute path. Note that this operation does not attempt to validate or access the resources at the given paths.

Parameters:
resourcePath - the affected project-relative resource path
basePath - the base path of the library
libraryPath - the path of the library
sourceAttachmentPath - the project-relative path of the corresponding source archive or folder, or null if none.
sourceAttachmentRootPath - the location of the root within the source archive or folder or null.
sourceAttachmentPrefixMapping - prefix mapping or null.
isExported - whether the entry is exported
Returns:
a new library entry

newOutputEntry

public static IOutputEntry newOutputEntry(IPath outputPath)
Creates and returns a new entry of kind CDT_OUTPUT for the project's output folder

Parameters:
outputPath - the project-relative path of a folder
Returns:
a new source entry with not exclusion patterns

newOutputEntry

public static IOutputEntry newOutputEntry(IPath outputPath,
                                          IPath[] exclusionPatterns)
Creates and returns a new entry of kind CDT_OUPUT for the project

Parameters:
outputPath - the project-relative path of a folder
exclusionPatterns - the possibly empty list of exclusion patterns represented as relative paths
Returns:
a new source entry with the given exclusion patterns

newSourceEntry

public static ISourceEntry newSourceEntry(IPath sourcePath)
Creates and returns a new entry of kind CDT_SOURCE for the project's source folder identified by the given absolute workspace-relative path.

The source folder is referred to using an absolute path relative to the workspace root, e.g. /Project/src. A project's source folders are located with that project. That is, a source entry specifying the path /P1/src is only usable for project P1.

Note that all sources/binaries inside a project are contributed as a whole through a project entry (see newProjectEntry). Particular source entries cannot be selectively exported.

Parameters:
sourcePath - the project-relative path of a source folder
Returns:
a new source entry with not exclusion patterns

newSourceEntry

public static ISourceEntry newSourceEntry(IPath sourcePath,
                                          IPath[] exclusionPatterns)
Creates and returns a new entry of kind CDT_SOURCE for the project's source folder identified by the given absolute workspace-relative path but excluding all source files with paths matching any of the given patterns. This specifies that all package fragments within the root will have children of type ICompilationUnit.

The source folder is referred to using an absolute path relative to the workspace root, e.g. /Project/src. A project's source folders are located with that project. That is, a source entry specifying the path /P1/src is only usable for project P1.

Parameters:
sourcePath - the absolute project-relative path of a source folder
exclusionPatterns - the possibly empty list of exclusion patterns represented as relative paths
Returns:
a new source entry with the given exclusion patterns

newIncludeEntry

public static IIncludeEntry newIncludeEntry(IPath resourcePath,
                                            IPath basePath,
                                            IPath includePath)
Creates and returns a new entry of kind CDT_INCLUDE

Parameters:
resourcePath - the affected project-relative resource path
basePath - the base path of the includePath
includePath - the absolute path of the include
Returns:
IIncludeEntry

newIncludeEntry

public static IIncludeEntry newIncludeEntry(IPath resourcePath,
                                            IPath basePath,
                                            IPath includePath,
                                            boolean isSystemInclude)
* Creates and returns a new entry of kind CDT_INCLUDE

Parameters:
resourcePath - the affected project-relative resource path
basePath - the base path of the includePath
includePath - the absolute path of the include
isSystemInclude - whether this include path should be consider a system include path
Returns:
IIncludeEntry

newIncludeEntry

public static IIncludeEntry newIncludeEntry(IPath resourcePath,
                                            IPath basePath,
                                            IPath includePath,
                                            boolean isSystemInclude,
                                            IPath[] exclusionPatterns)
Creates and returns a new entry of kind CDT_INCLUDE

Parameters:
resoourcePath - the affected project-relative resource path
basePath - the base path of the includePath
includePath - the absolute path of the include
isSystemInclude - wheter this include path should be consider the system include path
exclusionPatterns - exclusion patterns in the resource if a container
Returns:
IIincludeEntry

newIncludeEntry

public static IIncludeEntry newIncludeEntry(IPath resourcePath,
                                            IPath basePath,
                                            IPath includePath,
                                            boolean isSystemInclude,
                                            IPath[] exclusionPatterns,
                                            boolean isExported)
Creates and returns a new entry of kind CDT_INCLUDE

Parameters:
resourcePath - the affected project-relative resource path
basePath - the base path of the include
includePath - the path of the include
isSystemInclude - wheter this include path should be consider the system include path
exclusionPatterns - exclusion patterns in the resource if a container
isExported - if the entry ix exported to reference projects
Returns:
IIincludeEntry

newIncludeRefEntry

public static IIncludeEntry newIncludeRefEntry(IPath resourcePath,
                                               IPath baseRef,
                                               IPath includePath)
Creates and returns a new entry of kind CDT_INCLUDE

Parameters:
resourcePath - the affected project-relative resource path
baseRef - the base reference path of the include
includePath - the path of the include
Returns:
IIincludeEntry

newIncludeFileEntry

public static IIncludeFileEntry newIncludeFileEntry(IPath resourcePath,
                                                    IPath includeFile)
Creates a new entry of kind CDT_INCLUDE_FILE

Parameters:
resourcePath -
includeFile -
Returns:

newIncludeFileEntry

public static IIncludeFileEntry newIncludeFileEntry(IPath resourcePath,
                                                    IPath baseRef,
                                                    IPath basePath,
                                                    IPath includeFilePath,
                                                    IPath[] exclusionPatterns,
                                                    boolean isExported)
Creates and returns a new entry of kind CDT_INCLUDE_FILE

Parameters:
resourcePath - the affected project-relative resource path
basePath - the base path of the include
includeFilePath - the path of the include
exclusionPatterns - exclusion patterns in the resource if a container
isExported - if the entry ix exported to reference projects
Returns:
IIincludeEntry

newMacroEntry

public static IMacroEntry newMacroEntry(IPath resourcePath,
                                        String macroName,
                                        String macroValue)
Creates and returns an entry kind CDT_MACRO

Parameters:
path - the affected project-relative resource path
macroName - the name of the macro
macroValue - the value of the macro
Returns:
IMacroEntry

newMacroEntry

public static IMacroEntry newMacroEntry(IPath resourcePath,
                                        String macroName,
                                        String macroValue,
                                        IPath[] exclusionPatterns)
Creates and returns an entry kind CDT_MACRO

Parameters:
resourcePath - the affected project-relative resource path
macroName - the name of the macro
macroValue - the value of the macro
exclusionPatterns - exclusion patterns in the resource if a container
Returns:

newMacroEntry

public static IMacroEntry newMacroEntry(IPath resourcePath,
                                        String macroName,
                                        String macroValue,
                                        IPath[] exclusionPatterns,
                                        boolean isExported)
Creates and returns an entry kind CDT_MACRO

Parameters:
resourcePath - the affected workspace-relative resource path
macroName - the name of the macro
macroValue - the value of the macro
exclusionPatterns - exclusion patterns in the resource if a container
Returns:

newMacroRefEntry

public static IMacroEntry newMacroRefEntry(IPath resourcePath,
                                           IPath baseRef,
                                           String macroName)
Creates and returns an entry kind CDT_MACRO

Parameters:
resourcePath - the affected workspace-relative resource path
baseRef - the base reference path
macroName - the name of the macro
Returns:
IMacroEntry

newMacroFileEntry

public static IMacroFileEntry newMacroFileEntry(IPath resourcePath,
                                                IPath macroFile)
Creates an entry kind CDT_MACRO_FILE

Parameters:
resourcePath -
macroFile -
Returns:

newMacroFileEntry

public static IMacroFileEntry newMacroFileEntry(IPath resourcePath,
                                                IPath basePath,
                                                IPath baseRef,
                                                IPath macroFilePath,
                                                IPath[] exclusionPatterns,
                                                boolean isExported)
Creates and returns an entry kind CDT_MACRO_FILE

Parameters:
resourcePath - the affected workspace-relative resource path
basePath - the base path
macroFilePath - the file path where the macros are define
exclusionPatterns - exclusion patterns in the resource if a container
Returns:

getPathEntryContainer

public static IPathEntryContainer getPathEntryContainer(IPath containerPath,
                                                        ICProject project)
                                                 throws CModelException
Answers the project specific value for a given container. In case this container path could not be resolved, then will answer null. Both the container path and the project context are supposed to be non-null.

The containerPath is a formed by a first ID segment followed with extra segments, which can be used as additional hints for resolution. If no container was ever recorded for this container path onto this project (using setPathEntryContainer, then a PathEntryContainerInitializer will be activated if any was registered for this container ID onto the extension point "org.eclipse.cdt.core.PathEntryContainerInitializer".

PathEntry container values are persisted locally to the workspace, but are not preserved from a session to another. It is thus highly recommended to register a PathEntryContainerInitializer for each referenced container (through the extension point "org.eclipse.cdt.core.PathEntryContainerInitializer").

Parameters:
containerPath - the name of the container, which needs to be resolved
project - a specific project in which the container is being resolved
Returns:
the corresponding container or null if unable to find one.
Throws:
CModelException - if an exception occurred while resolving the container, or if the resolved container contains illegal entries (contains CDT_CONTAINER entries or null entries).
See Also:
PathEntryContainerInitializer, IPathEntryContainer, #setPathEntryContainer(IPath, ICProject[], IPathEntryContainer, IProgressMonitor)

setPathEntryContainer

public static void setPathEntryContainer(ICProject[] affectedProjects,
                                         IPathEntryContainer container,
                                         IProgressMonitor monitor)
                                  throws CModelException
Bind a container reference path to some actual containers (IPathEntryContainer). This API must be invoked whenever changes in container need to be reflected onto the CModel.

In reaction to changing container values, the CModel will be updated to reflect the new state of the updated container.

This functionality cannot be used while the resource tree is locked.

PathEntry container values are persisted locally to the workspace, but are not preserved from a session to another. It is thus highly recommended to register a PathEntryContainerInitializer for each referenced container (through the extension point "org.eclipse.cdt.core.PathEntryContainerInitializer").

Note: setting a container to null will cause it to be lazily resolved again whenever its value is required. In particular, this will cause a registered initializer to be invoked again.

Parameters:
affectedProjects - - the set of projects for which this container is being bound
newContainer - - the container for the affected projects
monitor - a monitor to report progress
Throws:
CModelException
See Also:
PathEntryContainerInitializer, #getPathEntryContainer(IPath, IJavaProject), IPathEntryContainer

pathEntryContainerUpdates

public static void pathEntryContainerUpdates(IPathEntryContainerExtension container,
                                             PathEntryContainerChanged[] changes,
                                             IProgressMonitor monitor)
Helper method use by a pathentry container implementing IPathEntryContainerExtension It notify the model of changes. Note: the paths in the PathEntryContainerChanged[] array must be on source that the container was set too. If not the changes will be silently ignore.

Parameters:
container -
changes - array of changes.
monitor - progress monitor

setRawPathEntries

public static void setRawPathEntries(ICProject cproject,
                                     IPathEntry[] newEntries,
                                     IProgressMonitor monitor)
                              throws CModelException
Sets the pathentries of this project using a list of entries.

Setting the pathentries to null specifies a default classpath (the project root). Setting the pathentry to an empty array specifies an empty pathentry.

Parameters:
entries - a list of entries
monitor - the given progress monitor
Throws:
CModelException - if the entries could not be set. Reasons include:

getRawPathEntries

public static IPathEntry[] getRawPathEntries(ICProject cproject)
                                      throws CModelException
Returns the raw pathentries for the project. This corresponds to the exact set of entries which were assigned using setRawPathEntries

Returns:
the raw entires for the project
Throws:
CModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource
See Also:
IPathEntry

getResolvedPathEntries

public static IPathEntry[] getResolvedPathEntries(ICProject cproject)
                                           throws CModelException
This method returns the resolved pathentries for the project All pathEntry.CDT_CONTAINER entries in the project's will be replaced by the entries they resolve to.

The resulting resolved entries are accurate for the given point in time. If the project's raw entries are later modified they can become out of date. Because of this, hanging on resolved pathentries is not recommended.

Returns:
the resolved entries for the project
Throws:
CModelException
See Also:
IPathEntry

getIncludeEntries

public static IIncludeEntry[] getIncludeEntries(IPath path)
                                         throws CModelException
This method returns the include entries associated with a translation unit if the path does not refer to a valid translation unit an empty array is return.

The resulting resolved entries are accurate for the given point in time. If the project's raw entries are later modified they can become out of date. Because of this, hanging on resolved pathentries is not recommended.

Returns:
the include entries for the translation unit
Throws:
CModelException
See Also:
IPathEntry

getIncludeFileEntries

public static IIncludeFileEntry[] getIncludeFileEntries(IPath path)
                                                 throws CModelException
This method returns the include file entries associated with a translation unit if the path does not refer to a valid translation unit an empty array is return.

The resulting resolved entries are accurate for the given point in time. If the project's raw entries are later modified they can become out of date. Because of this, hanging on resolved pathentries is not recommended.

Returns:
the include file entries for the translation unit
Throws:
CModelException
See Also:
IPathEntry

getMacroEntries

public static IMacroEntry[] getMacroEntries(IPath path)
                                     throws CModelException
This method returns the macro entries associated with a translation unit if the path does not refer to a valid translation unit an empty array is return.

The resulting resolved entries are accurate for the given point in time. If the project's raw entries are later modified they can become out of date. Because of this, hanging on resolved pathentries is not recommended.

Returns:
the resolved entries for the project
Throws:
CModelException
See Also:
IPathEntry

getMacroFileEntries

public static IMacroFileEntry[] getMacroFileEntries(IPath path)
                                             throws CModelException
This method returns the macro file entries associated with a translation unit if the path does not refer to a valid translation unit an empty array is return.

The resulting resolved entries are accurate for the given point in time. If the project's raw entries are later modified they can become out of date. Because of this, hanging on resolved pathentries is not recommended.

Returns:
the macro file entries for the translation unit
Throws:
CModelException
See Also:
IPathEntry

getPathEntryContainerInitializer

public static PathEntryContainerInitializer getPathEntryContainerInitializer(String containerID)
Helper method finding the pathentry container initializer registered for a given container ID or null if none was found while iterating over the contributions to extension point to the extension point "org.eclipse.cdt.core.PathEntryContainerInitializer".

A containerID is the first segment of any container path, used to identify the registered container initializer.

Parameters:
containerID - - a containerID identifying a registered initializer
Returns:
ClasspathContainerInitializer - the registered classpath container initializer or null if none was found.

getPathEntryStore

public static IPathEntryStore getPathEntryStore(IProject project)
                                         throws CoreException
Return the IPathEntryStore of the project.

Parameters:
project -
Returns:
Throws:
CoreException

setPathEntryStore

public static void setPathEntryStore(IProject project,
                                     IPathEntryStore store)
Set in the map the store, but not persisted.

Parameters:
project -
store -

validatePathEntries

public static ICModelStatus validatePathEntries(ICProject cProject,
                                                IPathEntry[] entries)
Validate a given path entries for a project, using the following rules: Note that the entries are not validated automatically. Only bound variables or containers are considered in the checking process (this allows to perform a consistency check on an entry which has references to yet non existing projects, folders, ...).

This validation is intended to anticipate issues prior to assigning it to a project. In particular, it will automatically be performed during the setting operation (if validation fails, the classpath setting will not complete) and during getResolvedPathEntries.

Parameters:
cProject - the given C project
PathEntry - entries
Returns:
a status object with code IStatus.OK if the entries location are compatible, otherwise a status object indicating what is wrong with them

validatePathEntry

public static ICModelStatus validatePathEntry(ICProject cProject,
                                              IPathEntry entry,
                                              boolean checkSourceAttachment,
                                              boolean recurseInContainers)
Returns a C model status describing the problem related to this entry if any, a status object with code IStatus.OK if the entry is fine (that is, if the given entry denotes a valid element).

Parameters:
cProject - the given C project
entry - the given entry
checkSourceAttachment - a flag to determine if source attachement should be checked
recurseInContainers - flag indicating whether validation should be applied to container entries recursively
Returns:
a c model status describing the problem related to this entry if any, a status object with code IStatus.OK if the entry is fine

getDefault

public static CoreModel getDefault()
Return the singleton.


addElementChangedListener

public void addElementChangedListener(IElementChangedListener listener)

removeElementChangedListener

public void removeElementChangedListener(IElementChangedListener listener)
Removes the given element changed listener. Has no affect if an identical listener is not registered.

Parameters:
listener - the listener

startup

public void startup()
See Also:
Plugin#startup

shutdown

public void shutdown()

run

public static void run(IWorkspaceRunnable action,
                       IProgressMonitor monitor)
                throws CoreException
Runs the given action as an atomic C model operation.

After running a method that modifies C elements, registered listeners receive after-the-fact notification of what just transpired, in the form of a element changed event. This method allows clients to call a number of methods that modify C elements and only have element changed event notifications reported at the end of the entire batch.

If this method is called outside the dynamic scope of another such call, this method runs the action and then reports a single element changed event describing the net effect of all changes done to C elements by the action.

If this method is called in the dynamic scope of another such call, this method simply runs the action.

Parameters:
action - the action to perform
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Throws:
CoreException - if the operation failed.
Since:
2.1

run

public static void run(IWorkspaceRunnable action,
                       ISchedulingRule rule,
                       IProgressMonitor monitor)
                throws CoreException
Runs the given action as an atomic C model operation.

After running a method that modifies C elements, registered listeners receive after-the-fact notification of what just transpired, in the form of a element changed event. This method allows clients to call a number of methods that modify C elements and only have element changed event notifications reported at the end of the entire batch.

If this method is called outside the dynamic scope of another such call, this method runs the action and then reports a single element changed event describing the net effect of all changes done to C elements by the action.

If this method is called in the dynamic scope of another such call, this method simply runs the action.

The supplied scheduling rule is used to determine whether this operation can be run simultaneously with workspace changes in other threads. See IWorkspace.run(...) for more details.

Parameters:
action - the action to perform
rule - the scheduling rule to use when running this operation, or null if there are no scheduling restrictions for this operation.
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Throws:
CoreException - if the operation failed.
Since:
3.0

startIndexing

public void startIndexing()

getIndexManager

public IndexManager getIndexManager()

isScannerInformationEmpty

public static boolean isScannerInformationEmpty(IResource resource)
The method returns whether scanner information for a resource is empty or not.

Although this looks like IScannerInfoProvider method, eventually this interface will be deprecated and the service will be moved to CoreModel.

Parameters:
resource -
Since:
3.0

Eclipse CDT
Pre-release 3.0

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