Class CCorePlugin

java.lang.Object
org.eclipse.core.runtime.Plugin
org.eclipse.cdt.core.CCorePlugin
All Implemented Interfaces:
org.osgi.framework.BundleActivator

public class CCorePlugin extends org.eclipse.core.runtime.Plugin
CCorePlugin is the life-cycle owner of the core plug-in, and starting point for access to many core APIs.
Restriction:
This class is not intended to be subclassed by clients.
Restriction:
This class is not intended to be instantiated by clients.
  • Field Details

  • Constructor Details

    • CCorePlugin

      public CCorePlugin()
      Restriction:
      This constructor is not intended to be referenced by clients.
  • Method Details

    • getSharedWorkingCopies

      public static IWorkingCopy[] getSharedWorkingCopies()
      Returns the shared working copies currently registered for the default buffer factory.
      Since:
      5.1
    • getResourceString

      public static String getResourceString(String key)
    • getWorkspace

      public static org.eclipse.core.resources.IWorkspace getWorkspace()
    • getFormattedString

      public static String getFormattedString(String key, String arg)
    • getFormattedString

      public static String getFormattedString(String key, String[] args)
    • getResourceBundle

      public static ResourceBundle getResourceBundle()
    • getPositionTrackerManager

      public static IPositionTrackerManager getPositionTrackerManager()
    • getDefault

      public static CCorePlugin getDefault()
    • stop

      public void stop(org.osgi.framework.BundleContext context) throws Exception
      Specified by:
      stop in interface org.osgi.framework.BundleActivator
      Overrides:
      stop in class org.eclipse.core.runtime.Plugin
      Throws:
      Exception
      See Also:
      • Plugin.shutdown()
    • start

      public void start(org.osgi.framework.BundleContext context) throws Exception
      Specified by:
      start in interface org.osgi.framework.BundleActivator
      Overrides:
      start in class org.eclipse.core.runtime.Plugin
      Throws:
      Exception
      See Also:
      • Plugin.startup()
    • getDefaultOptions

      public static HashMap<String,String> getDefaultOptions()
      TODO: Add all options here Returns a table of all known configurable options with their default values. These options allow to configure the behavior of the underlying components. The client may safely use the result as a template that they can modify and then pass to setOptions. Helper constants have been defined on CCorePlugin for each of the option ID and their possible constant values. Note: more options might be added in further releases.
       RECOGNIZED OPTIONS:
      
       CORE / Specify Default Source Encoding Format
          Get the encoding format for translated sources. This setting is read-only, it is equivalent
          to 'ResourcesPlugin.getEncoding()'.
           - option id:         "org.eclipse.cdt.core.encoding"
           - possible values:   { any of the supported encoding names}.
           - default:           
       
      Returns:
      a mutable map containing the default settings of all known options (key type: String; value type: String)
      See Also:
    • getOption

      public static String getOption(String optionName)
      Helper method for returning one option value only. Equivalent to (String)CCorePlugin.getOptions().get(optionName) Note that it may answer null if this option does not exist.

      For a complete description of the configurable options, see getDefaultOptions.

      Parameters:
      optionName - the name of an option
      Returns:
      the String value of a given option
      See Also:
    • getOptions

      public static HashMap<String,String> getOptions()
      Returns the table of the current options. Initially, all options have their default values, and this method returns a table that includes all known options.

      For a complete description of the configurable options, see getDefaultOptions.

      Returns:
      table of current settings of all options (key type: String; value type: String)
      See Also:
    • setOptions

      public static void setOptions(HashMap<String,String> newOptions)
      Sets the current table of options. All and only the options explicitly included in the given table are remembered; all previous option settings are forgotten, including ones not explicitly mentioned.

      For a complete description of the configurable options, see getDefaultOptions.

      Parameters:
      newOptions - the new options (key type: String; value type: String), or null to reset all options to their default values
      See Also:
    • getConsole

      public IConsole getConsole(String extConsoleId, String contextId, String name, URL iconUrl)
      Create CDT console adapter for build console defined as an extension. See org.eclipse.cdt.core.CBuildConsole extension point. If the console class is instance of ICConsole it is initialized with context id, name and icon to be shown in the list of consoles in the Console view.
      Parameters:
      extConsoleId - - console id defined in the extension point.
      contextId - - context menu id in the Console view. A caller needs to define a distinct one for own use.
      name - - name of console to appear in the list of consoles in context menu in the Console view.
      iconUrl - - a URL of the icon for the context menu of the Console view. The url is expected to point to an image in eclipse OSGi bundle. Here is an example how to retrieve URL:
      URL iconUrl = CUIPlugin.getDefault().getBundle().getEntry("icons/obj16/flask.png");
      Returns:
      CDT console adapter.
      Since:
      5.4
    • getConsole

      public IConsole getConsole(String id)
      Create CDT console adapter. The adapter serves as a bridge between core plugin and UI console API in a way that a user can create a UI console from plugins having no dependencies to UI.
      Parameters:
      id - - id of the console specified in extension point to instantiate console adapter.
      Returns:
      CDT console adapter.
    • getBuildConsole

      public IConsole getBuildConsole(String contextId, String name, URL iconUrl)
      Create CDT console adapter for build console. A new instance of class org.eclipse.cdt.internal.ui.buildconsole.CBuildConsole is created and initialized with the parameters.
      Parameters:
      contextId - - context menu id in the Console view. A caller needs to define a distinct one for own use.
      name - - name of console to appear in the list of consoles in context menu in the Console view.
      iconUrl - - a URL of the icon for the context menu of the Console view. The url is expected to point to an image in eclipse OSGi bundle. Here is an example how to retrieve URL:
      URL iconUrl = CUIPlugin.getDefault().getBundle().getResource("icons/obj16/flask.png");
      iconUrl can be null, in that case the default image is used. See org.eclipse.cdt.internal.ui.buildconsole.BuildConsole(IBuildConsoleManager, String, String, URL)
      Returns:
      CDT console adapter.
      Since:
      5.3
    • getConsole

      public IConsole getConsole()
      Create CDT console adapter connected to the default build console.
    • getBinaryParserExtensions

      @Deprecated public ICExtensionReference[] getBinaryParserExtensions(org.eclipse.core.resources.IProject project) throws org.eclipse.core.runtime.CoreException
      Throws:
      org.eclipse.core.runtime.CoreException
    • getDefaultBinaryParserExtensions

      public ICConfigExtensionReference[] getDefaultBinaryParserExtensions(org.eclipse.core.resources.IProject project) throws org.eclipse.core.runtime.CoreException
      Returns the binary parser extensions for the default settings configuration.
      Throws:
      org.eclipse.core.runtime.CoreException
      Since:
      5.2
    • getBinaryParser

      @Deprecated public IBinaryParser[] getBinaryParser(org.eclipse.core.resources.IProject project) throws org.eclipse.core.runtime.CoreException
      Deprecated.
      - use getBinaryParserExtensions(IProject project)
      Throws:
      org.eclipse.core.runtime.CoreException
    • getDefaultBinaryParser

      public IBinaryParser getDefaultBinaryParser() throws org.eclipse.core.runtime.CoreException
      Throws:
      org.eclipse.core.runtime.CoreException
    • getBinaryParser

      public IBinaryParser getBinaryParser(String id) throws org.eclipse.core.runtime.CoreException
      Returns the binary parser with the given id.
      Parameters:
      id - id of binary parser
      Returns:
      binary parser
      Throws:
      org.eclipse.core.runtime.CoreException
      Since:
      6.0
    • getCoreModel

      public CoreModel getCoreModel()
    • getIndexManager

      public static IIndexManager getIndexManager()
    • getTagService

      public static ITagService getTagService()
      Since:
      5.5
    • getPathEntryVariableManager

      public IPathEntryVariableManager getPathEntryVariableManager()
    • getCProjectDescription

      @Deprecated public ICDescriptor getCProjectDescription(org.eclipse.core.resources.IProject project) throws org.eclipse.core.runtime.CoreException
      Throws:
      org.eclipse.core.runtime.CoreException
    • getCProjectDescription

      @Deprecated public ICDescriptor getCProjectDescription(org.eclipse.core.resources.IProject project, boolean create) throws org.eclipse.core.runtime.CoreException
      Deprecated.
      Please use getProjectDescription(IProject, boolean) to fetch the ICProjectDescription for the project. And use ICProjectDescription.getConfigurations() to get an array of ICConfigurationDescriptions, which have similar API to ICDescriptor, allowing you to store settings and configure extensions at the Configuration level rather than at the project level.
      Parameters:
      project -
      create -
      Returns:
      ICDescriptor or null if create is false and no .cdtproject file exists on disk.
      Throws:
      org.eclipse.core.runtime.CoreException
    • mapCProjectOwner

      public void mapCProjectOwner(org.eclipse.core.resources.IProject project, String id, boolean override) throws org.eclipse.core.runtime.CoreException
      Throws:
      org.eclipse.core.runtime.CoreException
    • getCDescriptorManager

      @Deprecated public ICDescriptorManager getCDescriptorManager()
      Deprecated.
      Settings should be set per ICConfigurationDescription rather than global to the project. Please use getProjectDescription(IProject, boolean) to fetch the ICProjectDescription for the project. And use ICProjectDescription.getConfigurations() to get an array of ICConfigurationDescriptions, which have similar API to ICDescriptor, allowing you to store settings and configure extensions at the Configuration level rather than at the project level.
    • createCProject

      public org.eclipse.core.resources.IProject createCProject(org.eclipse.core.resources.IProjectDescription description, org.eclipse.core.resources.IProject projectHandle, org.eclipse.core.runtime.IProgressMonitor monitor, String projectID) throws org.eclipse.core.runtime.CoreException, org.eclipse.core.runtime.OperationCanceledException
      Creates a C project resource given the project handle and description.
      Parameters:
      description - the project description to create a project resource for
      projectHandle - the project handle to create a project resource for
      monitor - the progress monitor to show visual progress with
      projectID - required for mapping the project to an owner
      Throws:
      org.eclipse.core.runtime.CoreException - if the operation fails
      org.eclipse.core.runtime.OperationCanceledException - if the operation is canceled
    • createCDTProject

      public org.eclipse.core.resources.IProject createCDTProject(org.eclipse.core.resources.IProjectDescription description, org.eclipse.core.resources.IProject projectHandle, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException, org.eclipse.core.runtime.OperationCanceledException
      Throws:
      org.eclipse.core.runtime.CoreException
      org.eclipse.core.runtime.OperationCanceledException
    • createCDTProject

      public org.eclipse.core.resources.IProject createCDTProject(org.eclipse.core.resources.IProjectDescription description, org.eclipse.core.resources.IProject projectHandle, String bsId, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException, org.eclipse.core.runtime.OperationCanceledException
      Throws:
      org.eclipse.core.runtime.CoreException
      org.eclipse.core.runtime.OperationCanceledException
    • convertProjectFromCtoCC

      public void convertProjectFromCtoCC(org.eclipse.core.resources.IProject projectHandle, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
      Method convertProjectFromCtoCC converts a C Project to a C++ Project The newProject MUST, not be null, already have a C Nature && must NOT already have a C++ Nature
      Parameters:
      projectHandle -
      monitor -
      Throws:
      org.eclipse.core.runtime.CoreException
    • convertProjectToC

      public void convertProjectToC(org.eclipse.core.resources.IProject projectHandle, org.eclipse.core.runtime.IProgressMonitor monitor, String projectID) throws org.eclipse.core.runtime.CoreException
      Method to convert a project to a C nature All checks should have been done externally (as in the Conversion Wizards). This method blindly does the conversion.
      Throws:
      org.eclipse.core.runtime.CoreException
    • convertProjectToNewC

      public void convertProjectToNewC(org.eclipse.core.resources.IProject projectHandle, String bsId, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
      Throws:
      org.eclipse.core.runtime.CoreException
    • convertProjectToCC

      public void convertProjectToCC(org.eclipse.core.resources.IProject projectHandle, org.eclipse.core.runtime.IProgressMonitor monitor, String projectID) throws org.eclipse.core.runtime.CoreException
      Method to convert a project to a C++ nature
      Throws:
      org.eclipse.core.runtime.CoreException
    • convertProjectToNewCC

      public void convertProjectToNewCC(org.eclipse.core.resources.IProject projectHandle, String bsId, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
      Throws:
      org.eclipse.core.runtime.CoreException
    • getProcessList

      public IProcessList getProcessList() throws org.eclipse.core.runtime.CoreException
      Get the IProcessList contributed interface for the platform.
      Returns:
      IProcessList
      Throws:
      org.eclipse.core.runtime.CoreException
    • getAllErrorParsersIDs

      @Deprecated public String[] getAllErrorParsersIDs()
      Deprecated.
    • getErrorParser

      @Deprecated public IErrorParser[] getErrorParser(String id)
      Deprecated.
    • getScannerInfoProvider

      public IScannerInfoProvider getScannerInfoProvider(org.eclipse.core.resources.IProject project)
    • resetCachedScannerInfoProvider

      public void resetCachedScannerInfoProvider(org.eclipse.core.resources.IProject project)
      Clears cached scanner info provider for the given project so that the next call to getScannerInfoProvider(IProject) would return an up to date scanner info provider.
      Restriction:
      This method is not intended to be referenced by clients.
    • getContentType

      public static org.eclipse.core.runtime.content.IContentType getContentType(String filename)
      Helper function, returning the content type for a filename Same as:
       getContentType(null, filename)
       
      Parameters:
      filename -
      Returns:
      the content type found, or null
    • getContentType

      public static org.eclipse.core.runtime.content.IContentType getContentType(org.eclipse.core.resources.IProject project, String filename)
      Returns the content type for a filename. The method respects project specific content type definitions. The lookup prefers case- sensitive matches over the others.
      Parameters:
      project - a project with possible project specific settings. Can be null
      filename - a filename to compute the content type for
      Returns:
      the content type found or null
    • usesProjectSpecificContentTypes

      public static boolean usesProjectSpecificContentTypes(org.eclipse.core.resources.IProject project)
      Tests whether the given project uses its project specific content types.
    • setUseProjectSpecificContentTypes

      public static void setUseProjectSpecificContentTypes(org.eclipse.core.resources.IProject project, boolean val)
      Enables or disables the project specific content types.
    • configurePluginDebugOptions

      public void configurePluginDebugOptions()
      Configure the plug-in with respect to option settings defined in ".options" file
    • setStructuralParseMode

      public void setStructuralParseMode(boolean useNewParser)
    • useStructuralParseMode

      public boolean useStructuralParseMode()
    • getDOM

      @Deprecated public CDOM getDOM()
      Deprecated.
      use ITranslationUnit or ILanguage to construct ASTs, instead.
      Restriction:
      This method is not intended to be referenced by clients.
    • getCdtVariableManager

      public ICdtVariableManager getCdtVariableManager()
    • getBuildEnvironmentManager

      public IEnvironmentVariableManager getBuildEnvironmentManager()
    • getPreferenceConfiguration

      public ICConfigurationDescription getPreferenceConfiguration(String buildSystemId) throws org.eclipse.core.runtime.CoreException
      Throws:
      org.eclipse.core.runtime.CoreException
    • getPreferenceConfiguration

      public ICConfigurationDescription getPreferenceConfiguration(String buildSystemId, boolean write) throws org.eclipse.core.runtime.CoreException
      Throws:
      org.eclipse.core.runtime.CoreException
    • setPreferenceConfiguration

      public void setPreferenceConfiguration(String buildSystemId, ICConfigurationDescription des) throws org.eclipse.core.runtime.CoreException
      Throws:
      org.eclipse.core.runtime.CoreException
    • createProjectDescription

      public ICProjectDescription createProjectDescription(org.eclipse.core.resources.IProject project, boolean loadIfExists) throws org.eclipse.core.runtime.CoreException
      Equivalent to createProjectDescription(IProject, boolean, 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
      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 the 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.
      Parameters:
      projects - if null, all projects within the workspace are updated
      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
    • getProjectDescriptionManager

      public ICProjectDescriptionManager getProjectDescriptionManager()
    • getUserVarSupplier

      public static IUserVarSupplier getUserVarSupplier()
      Returns:
      editable User-variable's supplier
    • log

      public static void log(String e)
      Restriction:
      This method is not intended to be referenced by clients.
    • log

      public static void log(int severity, String msg)
      Prints a message in the log
      Parameters:
      severity - - desired severity of the message in the log, one of IStatus.INFO, IStatus.WARNING or IStatus.ERROR
      msg - - message
      Since:
      5.5
      Restriction:
      This method is not intended to be referenced by clients.
    • logStackTrace

      public static void logStackTrace(int severity, String msg)
      Prints a message in the log accompanied by stack trace
      Parameters:
      severity - - desired severity of the message in the log, one of IStatus.INFO, IStatus.WARNING or IStatus.ERROR
      msg - - message
      Since:
      5.5
      Restriction:
      This method is not intended to be referenced by clients.
    • log

      public static void log(Throwable e)
      Restriction:
      This method is not intended to be referenced by clients.
    • log

      public static void log(String message, Throwable e)
      Restriction:
      This method is not intended to be referenced by clients.
    • createStatus

      public static org.eclipse.core.runtime.IStatus createStatus(String msg)
      Restriction:
      This method is not intended to be referenced by clients.
    • createStatus

      public static org.eclipse.core.runtime.IStatus createStatus(String msg, Throwable e)
      Restriction:
      This method is not intended to be referenced by clients.
    • log

      public static void log(org.eclipse.core.runtime.IStatus status)
      Restriction:
      This method is not intended to be referenced by clients.
    • getPDOMManager

      @Deprecated public static IPDOMManager getPDOMManager()
      Deprecated.
      use getIndexManager().
      Restriction:
      This method is not intended to be referenced by clients.
    • showSourceRootsAtTopOfProject

      public static boolean showSourceRootsAtTopOfProject()
      Returns the preference controlling whether source roots are shown at the top of projects or embedded within the resource tree of projects when they are not top level folders.
      Returns:
      boolean preference value
      Since:
      5.2
    • getService

      public static <T> T getService(Class<T> service)
      Return the given OSGi service.
      Parameters:
      service - service class
      Returns:
      service
      Since:
      6.0
    • getCDTFeatureVersion

      public static org.osgi.framework.Version getCDTFeatureVersion()
      Return the version of the CDT feature in this Eclipse installation, if any. Note that, while this is a method in CCorePlugin, it's not specific to the org.eclipse.cdt.core plugin; it returns the version of the entire org.eclipse.cdt feature.
      Since:
      6.3