Class LanguageSettingsManager
java.lang.Object
org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager
A collection of utility methods to manage language settings providers.
See
ILanguageSettingsProvider.- Since:
- 5.4
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<ILanguageSettingsProvider> Create a list of providers with intention to assign to a configuration description.static ILanguageSettingsProvidergetExtensionProviderCopy(String id, boolean deep) Get language settings provider defined via extension pointorg.eclipse.cdt.core.LanguageSettingsProvider.Returns list of provider id-s contributed by all extensions.getLanguages(ICResourceDescription rcDescription) Find language IDs for the resource represented by resource description.getLanguages(org.eclipse.core.resources.IResource resource, ICConfigurationDescription cfgDescription) Find language IDs for the resource in given build configuration.getProviderCopy(ILanguageSettingsEditableProvider provider, boolean deep) Copy language settings provider.static ILanguageSettingsProvidergetRawProvider(ILanguageSettingsProvider provider) Helper method to get to real underlying provider collecting entries as opposed to wrapper which is normally used for workspace provider.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.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.static ILanguageSettingsProviderGet Language Settings Provider from the list of workspace providers, seegetWorkspaceProviders().static List<ILanguageSettingsProvider> Get Language Settings Providers defined in the workspace.static booleanisEqualExtensionProvider(ILanguageSettingsProvider provider, boolean deep) Test if the provider is equal to the one defined via extension pointorg.eclipse.cdt.core.LanguageSettingsProvider.static booleanisPreferShared(String id) Tells if the provider is meant to be shared between projects in workspace or belong to a specific configuration.static booleanTells if language settings entries of the provider are persisted with the project (under .settings/ folder) or in workspace area.static booleanisWorkspaceProvider(ILanguageSettingsProvider provider) Checks if the provider is a workspace level provider.static voidAdds a listener that will be notified of changes in language settings.static voidserializeLanguageSettings(ICProjectDescription prjDescription) Save language settings providers of a project to persistent storage.static voidserializeLanguageSettingsInBackground(ICProjectDescription prjDescription) Save language settings providers of a project to persistent storage in a background job.static voidSave language settings providers of the workspace (global providers) to persistent storage.static voidSave language settings providers of the workspace (global providers) to persistent storage in a background job.static voidsetStoringEntriesInProjectArea(LanguageSettingsSerializableProvider provider, boolean storeEntriesWithProject) Define where language settings are persisted for the provider.static voidsetWorkspaceProviders(List<ILanguageSettingsProvider> providers) Set and store in workspace area user defined providers.static voidRemoves a language settings change listener.
-
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 asICSettingEntry.INCLUDE_PATHetc. This is a binary flag and it is possible to specify composite kind. UseICSettingEntry.ALLto 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
nullalthough individual providers returnnullif no settings defined.
-
getWorkspaceProvider
Get Language Settings Provider from the list of workspace providers, seegetWorkspaceProviders().- 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
Get Language Settings Providers defined in the workspace. That includes user-defined providers and after that providers defined as extensions viaorg.eclipse.cdt.core.LanguageSettingsProviderextension point. Note that this returns wrappers around workspace provider so underlying provider could be replaced internally without need to change configuration. See alsogetRawProvider(ILanguageSettingsProvider).- Returns:
- list of workspace providers.
-
isWorkspaceProvider
Checks if the provider is a workspace level provider. This method is intended to check providers retrieved from a configuration. Raw providers fromgetRawProvider(ILanguageSettingsProvider)are not considered as workspace providers.- Parameters:
provider- - provider to check.- Returns:
trueif the given provider is workspace provider,falseotherwise.
-
getRawProvider
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:
-
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.nullis 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 throwCloneNotSupportedExceptionbut returnsnullinstead.- Parameters:
provider- - language settings provider to copy.deep- -trueto request deep copy including copying settings entries orfalseto return shallow copy with no settings entries.- Returns:
- a copy of the provider or null if copying is not possible.
-
getExtensionProviderIds
Returns list of provider id-s contributed by all extensions.- Returns:
- the provider id-s.
-
getExtensionProviderCopy
Get language settings provider defined via extension pointorg.eclipse.cdt.core.LanguageSettingsProvider. A new copy of the extension provider is returned.- Parameters:
id- - ID of the extension provider.deep- -trueto request deep copy including copying settings entries orfalseto return shallow copy with no settings entries.- Returns:
- the copy of the extension provider if possible (i.e. for
ILanguageSettingsEditableProvider) ornullif provider is not copyable.
-
isEqualExtensionProvider
Test if the provider is equal to the one defined via extension pointorg.eclipse.cdt.core.LanguageSettingsProvider.- Parameters:
provider- - the provider to test.deep- -trueto check for deep equality testing also settings entries orfalseto test shallow copy with no settings entries.- Returns:
- -
trueif the provider matches the extension orfalseotherwise.
-
getLanguages
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
nullID. Never returnsnullbut 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
nullbut empty list if no languages can be found.
-
registerLanguageSettingsChangeListener
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.
-
isStoringEntriesInProjectArea
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:
trueif LSE persisted with the project orfalseif 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- -trueif with the project,falseif 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.CoreExceptionSave language settings providers of the workspace (global providers) to persistent storage.- Throws:
org.eclipse.core.runtime.CoreException- if something goes wrong.
-
serializeLanguageSettingsInBackground
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
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" istrueand a new copy for those where attribute "prefer-non-shared" isfalse. Attribute "prefer-non-shared" is defined in extension pointorg.eclipse.cdt.core.LanguageSettingsProvider.- Parameters:
ids- - list of providers id which cannot benull.- Returns:
- a list of language settings providers with given ids.
- Since:
- 5.5
-