Class CoreModel

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

public class CoreModel extends Object
Restriction:
This class is not intended to be subclassed by clients.
Restriction:
This class is not intended to be instantiated by clients.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
     
    static ICElement
    create(String handleIdentifier)
    Returns the C model element corresponding to the given handle identifier generated by ICElement.getHandleIdentifier(), or null if unable to create the associated element.
    create(org.eclipse.core.resources.IFile file)
    Creates an ICElement for an IFile.
    create(org.eclipse.core.resources.IFolder folder)
    Creates an ICElement for an IFolder.
    create(org.eclipse.core.resources.IProject project)
    Creates an ICElement for an IProject.
    create(org.eclipse.core.resources.IResource resource)
    Creates an ICElement for an IResource.
    static ICModel
    create(org.eclipse.core.resources.IWorkspaceRoot root)
    Returns the C model.
    create(org.eclipse.core.runtime.IPath path)
    Creates an ICElement for an IPath.
    createProjectDescription(org.eclipse.core.resources.IProject project, boolean loadIfExists)
    This method is a full equivalent to createProjectDescription(project, loadIfExists, false).
    createProjectDescription(org.eclipse.core.resources.IProject project, boolean loadIfExists, boolean creating)
    Creates and returns a writable project description
    createTranslationUnitFrom(ICProject cproject, URI locationURI)
    Creates a translation from a location URI.
    createTranslationUnitFrom(ICProject cproject, org.eclipse.core.runtime.IPath path)
    Creates a translation from an IPath.
    Returns the default ICModel.
    static CoreModel
    Returns the singleton.
    static IIncludeEntry[]
    getIncludeEntries(org.eclipse.core.runtime.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.
    getIncludeFileEntries(org.eclipse.core.runtime.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.
    static IMacroEntry[]
    getMacroEntries(org.eclipse.core.runtime.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.
    getMacroFileEntries(org.eclipse.core.runtime.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.
    getPathEntryContainer(org.eclipse.core.runtime.IPath containerPath, ICProject project)
    Answers the project specific value for a given container.
    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".
    getPathEntryStore(org.eclipse.core.resources.IProject project)
    Returns the IPathEntryStore of the project.
    getProjectDescription(org.eclipse.core.resources.IProject project)
    Returns the project description associated with this project or null if the project does not contain the CDT data associated with it.
    getProjectDescription(org.eclipse.core.resources.IProject project, boolean write)
    returns the project description associated with this project or null if the project does not contain the CDT data associated with it.
     
    static IPathEntry[]
    Returns the raw pathentries for the project.
    static String
    getRegistedContentTypeId(org.eclipse.core.resources.IProject project, String name)
    Return the registered 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[]
    Returns an array of the register contentTypes.
    static IPathEntry[]
    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(org.eclipse.core.resources.IProject project)
    Returns true if project has C++ nature.
    static boolean
    hasCNature(org.eclipse.core.resources.IProject project)
    Returns true if project has C nature.
    boolean
    isArchive(org.eclipse.core.resources.IFile file)
    Returns true if IFile is an Achive, *.a
    boolean
    isBinary(org.eclipse.core.resources.IFile file)
    Returns true if IFile is an ELF.
    boolean
    isExecutable(org.eclipse.core.resources.IFile file)
    Returns true if IFile is an ELF executable
    boolean
    Answers whether the given project is a new-style project, i.e.
    boolean
    isNewStyleProject(org.eclipse.core.resources.IProject project)
    Answers whether the given project is a new-style project, i.e.
    boolean
    isObject(org.eclipse.core.resources.IFile file)
    Returns true if IFile is a an object(ELF), i.e.
    static boolean
    isScannerInformationEmpty(org.eclipse.core.resources.IResource resource)
    The method returns whether scanner information for a resource is empty or not.
    boolean
    isSharedLib(org.eclipse.core.resources.IFile file)
    Returns true if IFile is a shared library, i.e.
    static boolean
    isTranslationUnit(org.eclipse.core.resources.IFile file)
    Returns true if IFile is a possible TranslationUnit.
    static boolean
    isValidASMSourceUnitName(org.eclipse.core.resources.IProject project, String name)
    Returns true if name is a valid name for a translation unit.
    static boolean
    isValidCHeaderUnitName(org.eclipse.core.resources.IProject project, String name)
    Returns true if name is a valid name for a translation unit.
    static boolean
    isValidCSourceUnitName(org.eclipse.core.resources.IProject project, String name)
    Returns true if name is a valid name for a translation unit.
    static boolean
    isValidCXXHeaderUnitName(org.eclipse.core.resources.IProject project, String name)
    Returns true if name is a valid name for a translation unit.
    static boolean
    isValidCXXSourceUnitName(org.eclipse.core.resources.IProject project, String name)
    Returns true if name is a valid name for a translation unit.
    static boolean
    isValidHeaderUnitName(org.eclipse.core.resources.IProject project, String name)
    Returns true if name is a valid name for a translation unit.
    static boolean
    isValidSourceUnitName(org.eclipse.core.resources.IProject project, String name)
    Returns true if name is a valid name for a translation unit.
    static boolean
    isValidTranslationUnitName(org.eclipse.core.resources.IProject project, String name)
    Returns true if name is a valid name for a translation unit.
    newContainerEntry(org.eclipse.core.runtime.IPath id)
    Creates and returns a new entry of kind CDT_CONTAINER for the given path.
    newContainerEntry(org.eclipse.core.runtime.IPath id, boolean isExported)
    Creates and returns a new entry of kind CDT_CONTAINER for the given path.
    newIncludeEntry(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath basePath, org.eclipse.core.runtime.IPath includePath)
    Creates and returns a new entry of kind CDT_INCLUDE
    newIncludeEntry(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath basePath, org.eclipse.core.runtime.IPath includePath, boolean isSystemInclude)
    * Creates and returns a new entry of kind CDT_INCLUDE
    newIncludeEntry(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath basePath, org.eclipse.core.runtime.IPath includePath, boolean isSystemInclude, org.eclipse.core.runtime.IPath[] exclusionPatterns)
    Creates and returns a new entry of kind CDT_INCLUDE
    newIncludeEntry(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath basePath, org.eclipse.core.runtime.IPath includePath, boolean isSystemInclude, org.eclipse.core.runtime.IPath[] exclusionPatterns, boolean isExported)
    Creates and returns a new entry of kind CDT_INCLUDE
    newIncludeFileEntry(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath includeFile)
    Creates a new entry of kind CDT_INCLUDE_FILE
    newIncludeFileEntry(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath baseRef, org.eclipse.core.runtime.IPath basePath, org.eclipse.core.runtime.IPath includeFilePath, org.eclipse.core.runtime.IPath[] exclusionPatterns, boolean isExported)
    Creates and returns a new entry of kind CDT_INCLUDE_FILE
    newIncludeRefEntry(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath baseRef, org.eclipse.core.runtime.IPath includePath)
    Creates and returns a new entry of kind CDT_INCLUDE
    newLibraryEntry(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath basePath, org.eclipse.core.runtime.IPath libraryPath, org.eclipse.core.runtime.IPath sourceAttachmentPath, org.eclipse.core.runtime.IPath sourceAttachmentRootPath, org.eclipse.core.runtime.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.
    newLibraryRefEntry(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath baseRef, org.eclipse.core.runtime.IPath libraryPath)
    Creates and returns a new entry of kind CDT_LIBRARY for the archive or folder identified by the given absolute path.
    newMacroEntry(org.eclipse.core.runtime.IPath resourcePath, String macroName, String macroValue)
    Creates and returns an entry kind CDT_MACRO
    newMacroEntry(org.eclipse.core.runtime.IPath resourcePath, String macroName, String macroValue, org.eclipse.core.runtime.IPath[] exclusionPatterns)
    Creates and returns an entry kind CDT_MACRO
    newMacroEntry(org.eclipse.core.runtime.IPath resourcePath, String macroName, String macroValue, org.eclipse.core.runtime.IPath[] exclusionPatterns, boolean isExported)
    Creates and returns an entry kind CDT_MACRO
    newMacroFileEntry(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath macroFile)
    Creates an entry kind CDT_MACRO_FILE
    newMacroFileEntry(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath basePath, org.eclipse.core.runtime.IPath baseRef, org.eclipse.core.runtime.IPath macroFilePath, org.eclipse.core.runtime.IPath[] exclusionPatterns, boolean isExported)
    Creates and returns an entry kind CDT_MACRO_FILE
    newMacroRefEntry(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath baseRef, String macroName)
    Creates and returns an entry kind CDT_MACRO
    newOutputEntry(org.eclipse.core.runtime.IPath outputPath)
    Creates and returns a new entry of kind CDT_OUTPUT for the project's output folder
    newOutputEntry(org.eclipse.core.runtime.IPath outputPath, org.eclipse.core.runtime.IPath[] exclusionPatterns)
    Creates and returns a new entry of kind CDT_OUPUT for the project
    newProjectEntry(org.eclipse.core.runtime.IPath projectPath)
    Creates and returns a new non-exported entry of kind CDT_PROJECT for the project identified by the given absolute path.
    newProjectEntry(org.eclipse.core.runtime.IPath projectPath, boolean isExported)
    Creates and returns a new entry of kind CDT_PROJECT for the project identified by the given workspace-relative path.
    newSourceEntry(org.eclipse.core.runtime.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.
    newSourceEntry(org.eclipse.core.runtime.IPath sourcePath, org.eclipse.core.runtime.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, org.eclipse.core.runtime.IProgressMonitor monitor)
    Helper method use by a path entry container implementing IPathEntryContainerExtension It notify the model of changes.
    void
     
    void
    Removes the given element changed listener.
    static void
    run(org.eclipse.core.resources.IWorkspaceRunnable action, org.eclipse.core.runtime.IProgressMonitor monitor)
    Runs the given action as an atomic C model operation.
    static void
    run(org.eclipse.core.resources.IWorkspaceRunnable action, org.eclipse.core.runtime.jobs.ISchedulingRule rule, org.eclipse.core.runtime.IProgressMonitor monitor)
    Runs the given action as an atomic C model operation.
    static void
    setPathEntryContainer(ICProject[] affectedProjects, IPathEntryContainer container, org.eclipse.core.runtime.IProgressMonitor monitor)
    Bind a container reference path to some actual containers (IPathEntryContainer).
    static void
    setPathEntryStore(org.eclipse.core.resources.IProject project, IPathEntryStore store)
    Set in the map the store, but not persisted.
    void
    setProjectDescription(org.eclipse.core.resources.IProject project, ICProjectDescription des)
    This method is called to save/apply the project description the method should be called to apply changes made to the project description returned by the getProjectDescription(IProject, boolean) or createProjectDescription(IProject, boolean)
    void
    setProjectDescription(org.eclipse.core.resources.IProject project, ICProjectDescription des, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor)
     
    static void
    setRawPathEntries(ICProject cproject, IPathEntry[] newEntries, org.eclipse.core.runtime.IProgressMonitor monitor)
    Sets the pathentries of this project using a list of entries.
    void
     
    void
     
    void
    updateProjectDescriptions(org.eclipse.core.resources.IProject[] projects, org.eclipse.core.runtime.IProgressMonitor monitor)
    Forces the cached data of the specified projects to be re-calculated.
    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.
    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 Details

  • Method Details

    • create

      public ICElement create(org.eclipse.core.runtime.IPath path)
      Creates an ICElement for an IPath. Returns null if not found.
    • createTranslationUnitFrom

      public ITranslationUnit createTranslationUnitFrom(ICProject cproject, org.eclipse.core.runtime.IPath path)
      Creates a translation from an IPath. Returns null if not found.
    • createTranslationUnitFrom

      public ITranslationUnit createTranslationUnitFrom(ICProject cproject, URI locationURI)
      Creates a translation from a location URI. Returns null if not found.
      Since:
      5.0
    • create

      public static ICElement create(String handleIdentifier)
      Returns the C model element corresponding to the given handle identifier generated by ICElement.getHandleIdentifier(), or null if unable to create the associated element.
      Parameters:
      handleIdentifier - the given handle identifier
      Returns:
      the C element corresponding to the handle identifier
      Since:
      5.0
    • create

      public ICElement create(org.eclipse.core.resources.IFile file)
      Creates an ICElement for an IFile. Returns null if not found.
    • create

      public ICContainer create(org.eclipse.core.resources.IFolder folder)
      Creates an ICElement for an IFolder. Returns null if not found.
    • create

      public ICProject create(org.eclipse.core.resources.IProject project)
      Creates an ICElement for an IProject. Returns null if not found.
    • create

      public ICElement create(org.eclipse.core.resources.IResource resource)
      Creates an ICElement for an IResource. Returns null if not found.
    • create

      public static ICModel create(org.eclipse.core.resources.IWorkspaceRoot root)
      Returns the C model.
      Parameters:
      root - the given root
      Returns:
      the C model, or null if the root is null
    • getCModel

      public ICModel getCModel()
      Returns the default ICModel.
    • isSharedLib

      public boolean isSharedLib(org.eclipse.core.resources.IFile file)
      Returns true if IFile is a shared library, i.e. libxx.so
    • isObject

      public boolean isObject(org.eclipse.core.resources.IFile file)
      Returns true if IFile is a an object(ELF), i.e. *.o
    • isExecutable

      public boolean isExecutable(org.eclipse.core.resources.IFile file)
      Returns true if IFile is an ELF executable
    • isBinary

      public boolean isBinary(org.eclipse.core.resources.IFile file)
      Returns true if IFile is an ELF.
    • isArchive

      public boolean isArchive(org.eclipse.core.resources.IFile file)
      Returns true if IFile is an Achive, *.a
    • isTranslationUnit

      public static boolean isTranslationUnit(org.eclipse.core.resources.IFile file)
      Returns true if IFile is a possible TranslationUnit.
    • getRegistedContentTypeIds

      public static String[] getRegistedContentTypeIds()
      Returns an array of the register contentTypes.
      Returns:
      String[] ids
    • isValidTranslationUnitName

      public static boolean isValidTranslationUnitName(org.eclipse.core.resources.IProject project, String name)
      Returns true if name is a valid name for a translation unit.
    • isValidHeaderUnitName

      public static boolean isValidHeaderUnitName(org.eclipse.core.resources.IProject project, String name)
      Returns true if name is a valid name for a translation unit.
    • isValidSourceUnitName

      public static boolean isValidSourceUnitName(org.eclipse.core.resources.IProject project, String name)
      Returns true if name is a valid name for a translation unit.
    • isValidCSourceUnitName

      public static boolean isValidCSourceUnitName(org.eclipse.core.resources.IProject project, String name)
      Returns true if name is a valid name for a translation unit.
    • isValidCXXSourceUnitName

      public static boolean isValidCXXSourceUnitName(org.eclipse.core.resources.IProject project, String name)
      Returns true if name is a valid name for a translation unit.
    • isValidASMSourceUnitName

      public static boolean isValidASMSourceUnitName(org.eclipse.core.resources.IProject project, String name)
      Returns true if name is a valid name for a translation unit.
    • isValidCXXHeaderUnitName

      public static boolean isValidCXXHeaderUnitName(org.eclipse.core.resources.IProject project, String name)
      Returns true if name is a valid name for a translation unit.
    • isValidCHeaderUnitName

      public static boolean isValidCHeaderUnitName(org.eclipse.core.resources.IProject project, String name)
      Returns true if name is a valid name for a translation unit.
    • getRegistedContentTypeId

      public static String getRegistedContentTypeId(org.eclipse.core.resources.IProject project, String name)
      Return the registered 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
      Returns:
      the know id or null
    • hasCNature

      public static boolean hasCNature(org.eclipse.core.resources.IProject project)
      Returns true if project has C nature.
    • hasCCNature

      public static boolean hasCCNature(org.eclipse.core.resources.IProject project)
      Returns true if project has C++ nature.
    • newProjectEntry

      public static IProjectEntry newProjectEntry(org.eclipse.core.runtime.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

      public static IProjectEntry newProjectEntry(org.eclipse.core.runtime.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(org.eclipse.core.runtime.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:
      id - the id of the container
      Returns:
      a new container entry
    • newContainerEntry

      public static IContainerEntry newContainerEntry(org.eclipse.core.runtime.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(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath baseRef, org.eclipse.core.runtime.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(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath basePath, org.eclipse.core.runtime.IPath libraryPath, org.eclipse.core.runtime.IPath sourceAttachmentPath, org.eclipse.core.runtime.IPath sourceAttachmentRootPath, org.eclipse.core.runtime.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(org.eclipse.core.runtime.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(org.eclipse.core.runtime.IPath outputPath, org.eclipse.core.runtime.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(org.eclipse.core.runtime.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(org.eclipse.core.runtime.IPath sourcePath, org.eclipse.core.runtime.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(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath basePath, org.eclipse.core.runtime.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(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath basePath, org.eclipse.core.runtime.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(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath basePath, org.eclipse.core.runtime.IPath includePath, boolean isSystemInclude, org.eclipse.core.runtime.IPath[] exclusionPatterns)
      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 the system include path
      exclusionPatterns - exclusion patterns in the resource if a container
      Returns:
      IIincludeEntry
    • newIncludeEntry

      public static IIncludeEntry newIncludeEntry(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath basePath, org.eclipse.core.runtime.IPath includePath, boolean isSystemInclude, org.eclipse.core.runtime.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 - whether 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(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath baseRef, org.eclipse.core.runtime.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(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath includeFile)
      Creates a new entry of kind CDT_INCLUDE_FILE
    • newIncludeFileEntry

      public static IIncludeFileEntry newIncludeFileEntry(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath baseRef, org.eclipse.core.runtime.IPath basePath, org.eclipse.core.runtime.IPath includeFilePath, org.eclipse.core.runtime.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(org.eclipse.core.runtime.IPath resourcePath, String macroName, String macroValue)
      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
      Returns:
      IMacroEntry
    • newMacroEntry

      public static IMacroEntry newMacroEntry(org.eclipse.core.runtime.IPath resourcePath, String macroName, String macroValue, org.eclipse.core.runtime.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
    • newMacroEntry

      public static IMacroEntry newMacroEntry(org.eclipse.core.runtime.IPath resourcePath, String macroName, String macroValue, org.eclipse.core.runtime.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
    • newMacroRefEntry

      public static IMacroEntry newMacroRefEntry(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.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
    • newMacroFileEntry

      public static IMacroFileEntry newMacroFileEntry(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath macroFile)
      Creates an entry kind CDT_MACRO_FILE
    • newMacroFileEntry

      public static IMacroFileEntry newMacroFileEntry(org.eclipse.core.runtime.IPath resourcePath, org.eclipse.core.runtime.IPath basePath, org.eclipse.core.runtime.IPath baseRef, org.eclipse.core.runtime.IPath macroFilePath, org.eclipse.core.runtime.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
    • getPathEntryContainer

      public static IPathEntryContainer getPathEntryContainer(org.eclipse.core.runtime.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:
    • setPathEntryContainer

      public static void setPathEntryContainer(ICProject[] affectedProjects, IPathEntryContainer container, org.eclipse.core.runtime.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
      container - - the container for the affected projects
      monitor - a monitor to report progress
      Throws:
      CModelException
      See Also:
    • pathEntryContainerUpdates

      public static void pathEntryContainerUpdates(IPathEntryContainerExtension container, PathEntryContainerChanged[] changes, org.eclipse.core.runtime.IProgressMonitor monitor)
      Helper method use by a path entry 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, org.eclipse.core.runtime.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:
      newEntries - 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:
    • 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:
    • getIncludeEntries

      public static IIncludeEntry[] getIncludeEntries(org.eclipse.core.runtime.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:
    • getIncludeFileEntries

      public static IIncludeFileEntry[] getIncludeFileEntries(org.eclipse.core.runtime.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:
    • getMacroEntries

      public static IMacroEntry[] getMacroEntries(org.eclipse.core.runtime.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:
    • getMacroFileEntries

      public static IMacroFileEntry[] getMacroFileEntries(org.eclipse.core.runtime.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:
    • 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(org.eclipse.core.resources.IProject project) throws org.eclipse.core.runtime.CoreException
      Returns the IPathEntryStore of the project.
      Throws:
      org.eclipse.core.runtime.CoreException
    • setPathEntryStore

      public static void setPathEntryStore(org.eclipse.core.resources.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:
      • Entries cannot collide with each other; that is, all entry paths must be unique.
      • The output entry location path can be empty, if not they must be located inside the project.
      • Source entry location can be null, if not they must be located inside the project,
      • A project entry cannot refer to itself directly (that is, a project cannot prerequisite itself).
      • Source entries or output locations cannot coincide or be nested in each other, except for the following scenarios listed below:
        • A source folder can coincide with its own output location, in which case this output can then contain library archives. However, a specific output location cannot coincide with any library or a distinct source folder than the one referring to it.
        • A source/library folder can be nested in any source folder as long as the nested folder is excluded from the enclosing one.
        • An output location can be nested in a source folder, if the source folder coincides with the project itself, or if the output location is excluded from the source folder.
      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(org.eclipse.cdt.core.model.ICProject).

      Parameters:
      cProject - the given C project
      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 attachment 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()
      Returns 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(org.eclipse.core.resources.IWorkspaceRunnable action, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.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:
      org.eclipse.core.runtime.CoreException - if the operation failed.
      Since:
      2.1
    • run

      public static void run(org.eclipse.core.resources.IWorkspaceRunnable action, org.eclipse.core.runtime.jobs.ISchedulingRule rule, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.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(org.eclipse.core.runtime.ICoreRunnable, org.eclipse.core.runtime.jobs.ISchedulingRule, int, org.eclipse.core.runtime.IProgressMonitor) 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:
      org.eclipse.core.runtime.CoreException - if the operation failed.
      Since:
      3.0
    • isScannerInformationEmpty

      public static boolean isScannerInformationEmpty(org.eclipse.core.resources.IResource resource)
      The method returns whether scanner information for a resource is empty or not. If null is supplied the method returns true.
      Parameters:
      resource -
      Since:
      3.0
    • createProjectDescription

      public ICProjectDescription createProjectDescription(org.eclipse.core.resources.IProject project, boolean loadIfExists) throws org.eclipse.core.runtime.CoreException
      This method is a full equivalent to createProjectDescription(project, loadIfExists, false).
      Throws:
      org.eclipse.core.runtime.CoreException
      See Also:
    • createProjectDescription

      public ICProjectDescription createProjectDescription(org.eclipse.core.resources.IProject project, boolean loadIfExists, boolean creating) throws org.eclipse.core.runtime.CoreException
      Creates and returns a writable project description
      Parameters:
      project - project for which the project description is requested
      loadIfExists - if true the method first tries to load and return the project description from the settings file (.cproject) if false, the stored settings are ignored and the new (empty) project description is created
      creating - if true the created project description will be contain the true "isCdtProjectCreating" state. NOTE: in case the project already contains the project description AND its "isCdtProjectCreating" is false the resulting description will be created with the false "isCdtProjectCreating" state NOTE: changes made to the returned project description will not be applied until the setProjectDescription(IProject, ICProjectDescription) is called
      Returns:
      ICProjectDescription
      Throws:
      org.eclipse.core.runtime.CoreException
    • getProjectDescription

      public ICProjectDescription getProjectDescription(org.eclipse.core.resources.IProject project)
      Returns the project description associated with this project or null if the project does not contain the CDT data associated with it. this is a convenience method fully equivalent to getProjectDescription(project, true) see getProjectDescription(IProject, boolean) for more detail
      Parameters:
      project -
      Returns:
      a writable copy of the ICProjectDescription or null if the project does not contain the CDT data associated with it. Note: changes to the project description will not be reflected/used by the core until the setProjectDescription(IProject, ICProjectDescription) is called
      See Also:
    • setProjectDescription

      public void setProjectDescription(org.eclipse.core.resources.IProject project, ICProjectDescription des) throws org.eclipse.core.runtime.CoreException
      This method is called to save/apply the project description the method should be called to apply changes made to the project description returned by the getProjectDescription(IProject, boolean) or createProjectDescription(IProject, boolean)
      Parameters:
      project -
      des -
      Throws:
      org.eclipse.core.runtime.CoreException
      See Also:
    • setProjectDescription

      public void setProjectDescription(org.eclipse.core.resources.IProject project, ICProjectDescription des, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
      Throws:
      org.eclipse.core.runtime.CoreException
    • getProjectDescription

      public ICProjectDescription getProjectDescription(org.eclipse.core.resources.IProject project, boolean write)
      returns the project description associated with this project or null if the project does not contain the CDT data associated with it.
      Parameters:
      project - project for which the description is requested
      write - if true, the writable description copy is returned. If false the cached read-only description is returned. CDT core maintains the cached project description settings. If only read access is needed to description, then the read-only project description should be obtained. This description always operates with cached data and thus it is better to use it for performance reasons All set* calls to the read-only description result in the WriteAccessException When the writable description is requested, the description copy is created. Changes to this description will not be reflected/used by the core and Build System until the setProjectDescription(IProject, ICProjectDescription) is called Each getProjectDescription(project, true) returns a new copy of the project description The writable description uses the cached data until the first set call after that the description communicates directly to the Build System i.e. the implementer of the org.eclipse.cdt.core.CConfigurationDataProvider extension This ensures the Core<->Build System settings integrity
      Returns:
      ICProjectDescription or null if the project does not contain the CDT data associated with it.
    • updateProjectDescriptions

      public void updateProjectDescriptions(org.eclipse.core.resources.IProject[] projects, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
      Forces the cached data of the specified projects to be re-calculated. If the projects argument is null, all projects within the workspace are updated.
      Parameters:
      projects -
      monitor -
      Throws:
      org.eclipse.core.runtime.CoreException
    • isNewStyleProject

      public boolean isNewStyleProject(org.eclipse.core.resources.IProject project)
      Answers whether the given project is a new-style project, i.e. CConfigurationDataProvider-driven.
    • isNewStyleProject

      public boolean isNewStyleProject(ICProjectDescription des)
      Answers whether the given project is a new-style project, i.e. CConfigurationDataProvider-driven
    • addCProjectDescriptionListener

      public void addCProjectDescriptionListener(ICProjectDescriptionListener listener, int eventTypes)
    • removeCProjectDescriptionListener

      public void removeCProjectDescriptionListener(ICProjectDescriptionListener listener)
    • getProjectDescriptionManager

      public ICProjectDescriptionManager getProjectDescriptionManager()