Class LanguageSettingsManager
- java.lang.Object
-
- org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager
-
public class LanguageSettingsManager extends java.lang.ObjectA collection of utility methods to manage language settings providers. SeeILanguageSettingsProvider.- Since:
- 5.4
-
-
Constructor Summary
Constructors Constructor Description LanguageSettingsManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<ILanguageSettingsProvider>createLanguageSettingsProviders(java.lang.String[] ids)Create a list of providers with intention to assign to a configuration description.static ILanguageSettingsProvidergetExtensionProviderCopy(java.lang.String id, boolean deep)Get language settings provider defined via extension pointorg.eclipse.cdt.core.LanguageSettingsProvider.static java.util.Set<java.lang.String>getExtensionProviderIds()Returns list of provider id-s contributed by all extensions.static java.util.List<java.lang.String>getLanguages(ICResourceDescription rcDescription)Find language IDs for the resource represented by resource description.static java.util.List<java.lang.String>getLanguages(org.eclipse.core.resources.IResource resource, ICConfigurationDescription cfgDescription)Find language IDs for the resource in given build configuration.static ILanguageSettingsEditableProvidergetProviderCopy(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 java.util.List<ICLanguageSettingEntry>getSettingEntriesByKind(ICConfigurationDescription cfgDescription, org.eclipse.core.resources.IResource rc, java.lang.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 java.util.List<ICLanguageSettingEntry>getSettingEntriesUpResourceTree(ILanguageSettingsProvider provider, ICConfigurationDescription cfgDescription, org.eclipse.core.resources.IResource rc, java.lang.String languageId)Returns the list of setting entries of the given provider for the given configuration description, resource and language.static ILanguageSettingsProvidergetWorkspaceProvider(java.lang.String id)Get Language Settings Provider from the list of workspace providers, seegetWorkspaceProviders().static java.util.List<ILanguageSettingsProvider>getWorkspaceProviders()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(java.lang.String id)Tells if the provider is meant to be shared between projects in workspace or belong to a specific configuration.static booleanisStoringEntriesInProjectArea(LanguageSettingsSerializableProvider provider)Tells 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 voidregisterLanguageSettingsChangeListener(ILanguageSettingsChangeListener listener)Adds 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 voidserializeLanguageSettingsWorkspace()Save language settings providers of the workspace (global providers) to persistent storage.static voidserializeLanguageSettingsWorkspaceInBackground()Save 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(java.util.List<ILanguageSettingsProvider> providers)Set and store in workspace area user defined providers.static voidunregisterLanguageSettingsChangeListener(ILanguageSettingsChangeListener listener)Removes a language settings change listener.
-
-
-
Method Detail
-
getSettingEntriesByKind
public static java.util.List<ICLanguageSettingEntry> getSettingEntriesByKind(ICConfigurationDescription cfgDescription, org.eclipse.core.resources.IResource rc, java.lang.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 java.util.List<ICLanguageSettingEntry> getSettingEntriesUpResourceTree(ILanguageSettingsProvider provider, ICConfigurationDescription cfgDescription, org.eclipse.core.resources.IResource rc, java.lang.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
public static ILanguageSettingsProvider getWorkspaceProvider(java.lang.String id)
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
public static java.util.List<ILanguageSettingsProvider> 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
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 fromgetRawProvider(ILanguageSettingsProvider)are not considered as workspace providers.- Parameters:
provider- - provider to check.- Returns:
trueif the given provider is workspace provider,falseotherwise.
-
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(java.util.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
public static java.util.Set<java.lang.String> getExtensionProviderIds()
Returns list of provider id-s contributed by all extensions.- Returns:
- the provider id-s.
-
getExtensionProviderCopy
public static ILanguageSettingsProvider getExtensionProviderCopy(java.lang.String id, boolean deep)
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
public static boolean isEqualExtensionProvider(ILanguageSettingsProvider provider, boolean deep)
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
public static java.util.List<java.lang.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
nullID. Never returnsnullbut empty list if no languages can be found.
-
getLanguages
public static java.util.List<java.lang.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
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(java.lang.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 inorg.eclipse.cdt.core.LanguageSettingsProviderextension point.
Note that onlyILanguageSettingsEditableProvidercan be owned by a configuration.- Parameters:
id- - ID of the provider to inquire.- Returns:
trueif the provider is designed to be shared,falseif 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:
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
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 java.util.List<ILanguageSettingsProvider> createLanguageSettingsProviders(java.lang.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" 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
-
-