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
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<ILanguageSettingsProvider>
Create a list of providers with intention to assign to a configuration description.static ILanguageSettingsProvider
getExtensionProviderCopy
(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 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.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 ILanguageSettingsProvider
Get Language Settings Provider from the list of workspace providers, seegetWorkspaceProviders()
.static List<ILanguageSettingsProvider>
Get Language Settings Providers defined in the workspace.static boolean
isEqualExtensionProvider
(ILanguageSettingsProvider provider, boolean deep) Test if the provider is equal to the one defined via extension pointorg.eclipse.cdt.core.LanguageSettingsProvider
.static boolean
isPreferShared
(String id) Tells if the provider is meant to be shared between projects in workspace or belong to a specific configuration.static boolean
Tells if language settings entries of the provider are persisted with the project (under .settings/ folder) or in workspace area.static boolean
isWorkspaceProvider
(ILanguageSettingsProvider provider) Checks if the provider is a workspace level provider.static void
Adds a listener that will be notified of changes in language settings.static void
serializeLanguageSettings
(ICProjectDescription prjDescription) Save language settings providers of a project to persistent storage.static void
serializeLanguageSettingsInBackground
(ICProjectDescription prjDescription) Save language settings providers of a project to persistent storage in a background job.static void
Save language settings providers of the workspace (global providers) to persistent storage.static void
Save language settings providers of the workspace (global providers) to persistent storage in a background job.static void
setStoringEntriesInProjectArea
(LanguageSettingsSerializableProvider provider, boolean storeEntriesWithProject) Define where language settings are persisted for the provider.static void
setWorkspaceProviders
(List<ILanguageSettingsProvider> providers) Set and store in workspace area user defined providers.static void
Removes 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_PATH
etc. This is a binary flag and it is possible to specify composite kind. UseICSettingEntry.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 returnnull
if 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.LanguageSettingsProvider
extension 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:
true
if the given provider is workspace provider,false
otherwise.
-
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:
-
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 throwCloneNotSupportedException
but returnsnull
instead.- Parameters:
provider
- - language settings provider to copy.deep
- -true
to request deep copy including copying settings entries orfalse
to 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
- -true
to request deep copy including copying settings entries orfalse
to return shallow copy with no settings entries.- Returns:
- the copy of the extension provider if possible (i.e. for
ILanguageSettingsEditableProvider
) ornull
if 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
- -true
to check for deep equality testing also settings entries orfalse
to test shallow copy with no settings entries.- Returns:
- -
true
if the provider matches the extension orfalse
otherwise.
-
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
null
ID. Never returnsnull
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
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:
true
if LSE persisted with the project orfalse
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.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" istrue
and 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
-