Class LanguageSettingsManager

java.lang.Object
org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager

public class LanguageSettingsManager extends Object
A collection of utility methods to manage language settings providers. See ILanguageSettingsProvider.
Since:
5.4
  • Constructor Details

    • LanguageSettingsManager

      public LanguageSettingsManager()
  • Method Details

    • getSettingEntriesByKind

      public static List<ICLanguageSettingEntry> getSettingEntriesByKind(ICConfigurationDescription cfgDescription, org.eclipse.core.resources.IResource rc, String languageId, int kind)
      Returns the list of setting entries of a certain kind (such as include paths) for the given configuration description, resource and language. This is a combined list for all providers taking into account settings of parent folder if settings for the given resource are not defined. For include paths both local (#include "...") and system (#include <...>) entries are returned.
      Parameters:
      cfgDescription - - configuration description.
      rc - - resource such as file or folder.
      languageId - - language id.
      kind - - kind of language settings entries, such as ICSettingEntry.INCLUDE_PATH etc. This is a binary flag and it is possible to specify composite kind. Use ICSettingEntry.ALL to get all kinds.
      Returns:
      the list of setting entries.
      Since:
      5.5
    • getSettingEntriesUpResourceTree

      public static List<ICLanguageSettingEntry> getSettingEntriesUpResourceTree(ILanguageSettingsProvider provider, ICConfigurationDescription cfgDescription, org.eclipse.core.resources.IResource rc, String languageId)
      Returns the list of setting entries of the given provider for the given configuration description, resource and language. This method reaches to the parent folder of the resource recursively if the resource does not define the entries for the given provider.
      Parameters:
      provider - - language settings provider.
      cfgDescription - - configuration description.
      rc - - resource such as file or folder.
      languageId - - language id.
      Returns:
      the list of setting entries. Never returns null although individual providers return null if no settings defined.
    • getWorkspaceProvider

      public static ILanguageSettingsProvider getWorkspaceProvider(String id)
      Get Language Settings Provider from the list of workspace providers, see getWorkspaceProviders().
      Parameters:
      id - - id of provider to find.
      Returns:
      the workspace provider. If workspace provider is not defined a new instance is created and returned.
    • getWorkspaceProviders

      public static List<ILanguageSettingsProvider> getWorkspaceProviders()
      Get Language Settings Providers defined in the workspace. That includes user-defined providers and after that providers defined as extensions via org.eclipse.cdt.core.LanguageSettingsProvider extension point. Note that this returns wrappers around workspace provider so underlying provider could be replaced internally without need to change configuration. See also getRawProvider(ILanguageSettingsProvider).
      Returns:
      list of workspace providers.
    • isWorkspaceProvider

      public static boolean isWorkspaceProvider(ILanguageSettingsProvider provider)
      Checks if the provider is a workspace level provider. This method is intended to check providers retrieved from a configuration. Raw providers from getRawProvider(ILanguageSettingsProvider) are not considered as workspace providers.
      Parameters:
      provider - - provider to check.
      Returns:
      true if the given provider is workspace provider, false otherwise.
    • getRawProvider

      public static ILanguageSettingsProvider getRawProvider(ILanguageSettingsProvider provider)
      Helper method to get to real underlying provider collecting entries as opposed to wrapper which is normally used for workspace provider.
      Parameters:
      provider - - the provider to get raw provider for. Can be either workspace provider or regular one.
      Returns:
      raw underlying provider for workspace provider or provider itself if no wrapper is used.
      See Also:
      • LanguageSettingsProvidersSerializer.isWorkspaceProvider(ILanguageSettingsProvider)
    • setWorkspaceProviders

      public static void setWorkspaceProviders(List<ILanguageSettingsProvider> providers) throws org.eclipse.core.runtime.CoreException
      Set and store in workspace area user defined providers.
      Parameters:
      providers - - array of user defined workspace providers. Note that those providers will shadow extension providers with the same ID. All not shadowed extension providers will be added to the list to be present as workspace providers. null is equivalent to passing an empty array and so will reset workspace providers to match extension providers.
      Throws:
      org.eclipse.core.runtime.CoreException - in case of problems (such as problems with persistence).
    • getProviderCopy

      public static ILanguageSettingsEditableProvider getProviderCopy(ILanguageSettingsEditableProvider provider, boolean deep)
      Copy language settings provider. It is different from clone() methods in that it does not throw CloneNotSupportedException but returns null instead.
      Parameters:
      provider - - language settings provider to copy.
      deep - - true to request deep copy including copying settings entries or false to return shallow copy with no settings entries.
      Returns:
      a copy of the provider or null if copying is not possible.
    • getExtensionProviderIds

      public static Set<String> getExtensionProviderIds()
      Returns list of provider id-s contributed by all extensions.
      Returns:
      the provider id-s.
    • getExtensionProviderCopy

      public static ILanguageSettingsProvider getExtensionProviderCopy(String id, boolean deep)
      Get language settings provider defined via extension point org.eclipse.cdt.core.LanguageSettingsProvider. A new copy of the extension provider is returned.
      Parameters:
      id - - ID of the extension provider.
      deep - - true to request deep copy including copying settings entries or false to return shallow copy with no settings entries.
      Returns:
      the copy of the extension provider if possible (i.e. for ILanguageSettingsEditableProvider) or null if provider is not copyable.
    • isEqualExtensionProvider

      public static boolean isEqualExtensionProvider(ILanguageSettingsProvider provider, boolean deep)
      Test if the provider is equal to the one defined via extension point org.eclipse.cdt.core.LanguageSettingsProvider.
      Parameters:
      provider - - the provider to test.
      deep - - true to check for deep equality testing also settings entries or false to test shallow copy with no settings entries.
      Returns:
      - true if the provider matches the extension or false otherwise.
    • getLanguages

      public static List<String> getLanguages(ICResourceDescription rcDescription)
      Find language IDs for the resource represented by resource description. Under the hood build component is inquired and the language IDs would commonly come from the input type(s).
      Parameters:
      rcDescription - - resource description
      Returns:
      list of language IDs for the resource. The list can contain null ID. Never returns null but empty list if no languages can be found.
    • getLanguages

      public static List<String> getLanguages(org.eclipse.core.resources.IResource resource, ICConfigurationDescription cfgDescription)
      Find language IDs for the resource in given build configuration. Under the hood build component is inquired and the language IDs would commonly come from the input type(s).
      Parameters:
      resource - - the resource to find languages for.
      cfgDescription -
      Returns:
      list of language IDs for the resource. Never returns null but empty list if no languages can be found.
    • registerLanguageSettingsChangeListener

      public static void registerLanguageSettingsChangeListener(ILanguageSettingsChangeListener listener)
      Adds a listener that will be notified of changes in language settings.
      Parameters:
      listener - the listener to add
    • unregisterLanguageSettingsChangeListener

      public static void unregisterLanguageSettingsChangeListener(ILanguageSettingsChangeListener listener)
      Removes a language settings change listener.
      Parameters:
      listener - the listener to remove.
    • isPreferShared

      public static boolean isPreferShared(String id)
      Tells if the provider is meant to be shared between projects in workspace or belong to a specific configuration. This attribute is defined in org.eclipse.cdt.core.LanguageSettingsProvider extension point.
      Note that only ILanguageSettingsEditableProvider can be owned by a configuration.
      Parameters:
      id - - ID of the provider to inquire.
      Returns:
      true if the provider is designed to be shared, false if configuration-owned.
    • isStoringEntriesInProjectArea

      public static boolean isStoringEntriesInProjectArea(LanguageSettingsSerializableProvider provider)
      Tells if language settings entries of the provider are persisted with the project (under .settings/ folder) or in workspace area. Persistence in the project area lets the entries migrate with the project.
      Parameters:
      provider - - provider to check the persistence mode.
      Returns:
      true if LSE persisted with the project or false if in the workspace.
    • setStoringEntriesInProjectArea

      public static void setStoringEntriesInProjectArea(LanguageSettingsSerializableProvider provider, boolean storeEntriesWithProject)
      Define where language settings are persisted for the provider.
      Parameters:
      provider - - provider to set the persistence mode.
      storeEntriesWithProject - - true if with the project, false if in workspace area.
    • serializeLanguageSettings

      public static void serializeLanguageSettings(ICProjectDescription prjDescription) throws org.eclipse.core.runtime.CoreException
      Save language settings providers of a project to persistent storage.
      Parameters:
      prjDescription - - project description of the project.
      Throws:
      org.eclipse.core.runtime.CoreException - if something goes wrong.
    • serializeLanguageSettingsWorkspace

      public static void serializeLanguageSettingsWorkspace() throws org.eclipse.core.runtime.CoreException
      Save language settings providers of the workspace (global providers) to persistent storage.
      Throws:
      org.eclipse.core.runtime.CoreException - if something goes wrong.
    • serializeLanguageSettingsInBackground

      public static void serializeLanguageSettingsInBackground(ICProjectDescription prjDescription)
      Save language settings providers of a project to persistent storage in a background job.
      Parameters:
      prjDescription - - project description of the project.
    • serializeLanguageSettingsWorkspaceInBackground

      public static void serializeLanguageSettingsWorkspaceInBackground()
      Save language settings providers of the workspace (global providers) to persistent storage in a background job.
    • createLanguageSettingsProviders

      public static List<ILanguageSettingsProvider> createLanguageSettingsProviders(String[] ids)
      Create a list of providers with intention to assign to a configuration description. The list will contain global providers for ones where attribute "prefer-non-shared" is true and a new copy for those where attribute "prefer-non-shared" is false. Attribute "prefer-non-shared" is defined in extension point org.eclipse.cdt.core.LanguageSettingsProvider.
      Parameters:
      ids - - list of providers id which cannot be null.
      Returns:
      a list of language settings providers with given ids.
      Since:
      5.5