Class LanguageSettingsSerializableProvider
java.lang.Object
org.eclipse.cdt.core.AbstractExecutableExtensionBase
org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider
org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializableProvider
- All Implemented Interfaces:
ILanguageSettingsBroadcastingProvider,ILanguageSettingsProvider
- Direct Known Subclasses:
LanguageSettingsGenericProvider
public class LanguageSettingsSerializableProvider
extends LanguageSettingsBaseProvider
implements ILanguageSettingsBroadcastingProvider
This class is the base class for language settings providers able to serialize
into XML storage.
Although this class has setter methods, by design its instances are not editable in UI
nor instances can be assigned to a configuration (cannot be global or non-shared).
Implement
ILanguageSettingsEditableProvider interface for that. There is a generic
implementation of this interface available to be used, see LanguageSettingsGenericProvider.
For more on the suggested way of extending this class see the description of
ILanguageSettingsProvider.- Since:
- 5.4
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final StringFields inherited from class org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider
languageScope, properties -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.LanguageSettingsSerializableProvider(String id, String name) Constructor.LanguageSettingsSerializableProvider(Element elementProvider) Constructor which allows to instantiate provider defined via XML markup. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all the entries for all configurations, all resources and all languages.protected LanguageSettingsSerializableProviderclone()protected LanguageSettingsSerializableProviderShallow clone of the provider.voidconfigureProvider(String id, String name, List<String> languages, List<ICLanguageSettingEntry> entries, Map<String, String> properties) A method to configure the provider.Return a copy of internal storage.booleangetSettingEntries(ICConfigurationDescription cfgDescription, org.eclipse.core.resources.IResource rc, String languageId) Returns the list of setting entries for the given configuration description, resource and language.inthashCode()booleanisEmpty()final voidLoad provider from XML provider element.voidloadAttributes(Element providerNode) Load attributes from XML provider element.voidloadEntries(Element providerNode) Load provider entries from XML provider element.final ElementSerialize the provider under parent XML element.serializeAttributes(Element parentElement) Serialize the provider attributes under parent XML element.voidserializeEntries(Element elementProvider) Serialize the provider entries under parent XML element.org.eclipse.core.runtime.IStatusserializeLanguageSettings(ICConfigurationDescription cfgDescription) Convenience method to persist language settings entries for the project or workspace as often-used operation.voidserializeLanguageSettingsInBackground(ICConfigurationDescription cfgDescription) Convenience method to persist language settings entries in background for the project or workspace as often-used operation.voidsetLanguageScope(List<String> languages) Sets the language scope of the provider.voidsetProperty(String key, String value) Set a custom property of the provider.voidsetPropertyBool(String key, boolean value) Set a custom boolean property of the provider.voidsetSettingEntries(ICConfigurationDescription cfgDescription, org.eclipse.core.resources.IResource rc, String languageId, List<? extends ICLanguageSettingEntry> entries) Sets language settings entries for the provider.Methods inherited from class org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider
getLanguageScope, getProperty, getPropertyBoolMethods inherited from class org.eclipse.cdt.core.AbstractExecutableExtensionBase
getId, getName, setId, setName, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsBroadcastingProvider
getId, getName
-
Field Details
-
ATTR_ID
- See Also:
-
ATTR_NAME
- See Also:
-
ATTR_CLASS
- See Also:
-
ELEM_PROVIDER
- See Also:
-
ELEM_LANGUAGE_SCOPE
- See Also:
-
-
Constructor Details
-
LanguageSettingsSerializableProvider
public LanguageSettingsSerializableProvider()Default constructor. This constructor has to be always followed with setting id and name of the provider. This constructor is necessary to instantiate the class via the extension point in plugin.xml. -
LanguageSettingsSerializableProvider
Constructor.- Parameters:
id- - id of the provider.name- - name of the provider. Note that this name shows up in UI.
-
LanguageSettingsSerializableProvider
Constructor which allows to instantiate provider defined via XML markup.- Parameters:
elementProvider-
-
-
Method Details
-
configureProvider
public void configureProvider(String id, String name, List<String> languages, List<ICLanguageSettingEntry> entries, Map<String, String> properties) Description copied from class:LanguageSettingsBaseProviderA method to configure the provider. The initialization of provider from the extension point is done in 2 steps. First, the class is created as an executable extension using the default provider. Then this method is used to configure the provider.
It is not allowed to reconfigure the provider.- Overrides:
configureProviderin classLanguageSettingsBaseProvider- Parameters:
id- - id of the provider.name- - name of the provider to be presented to a user.languages- - list of languages theentriesprovided for.languagescan benull, in this case theentriesare provided for any language.entries- - the list of language settings entries this provider provides. Ifnullis passed, the provider creates an empty list.properties- - custom properties as the means to customize providers.
-
isEmpty
public boolean isEmpty()- Returns:
trueif the provider does not keep any settings yet orfalseif there are some.
-
setLanguageScope
Sets the language scope of the provider.- Parameters:
languages- - the list of languages this provider provides for. Ifnull, the provider provides for any language.- See Also:
-
clear
public void clear()Clears all the entries for all configurations, all resources and all languages. -
setSettingEntries
public void setSettingEntries(ICConfigurationDescription cfgDescription, org.eclipse.core.resources.IResource rc, String languageId, List<? extends ICLanguageSettingEntry> entries) Sets language settings entries for the provider. Note that the entries are not persisted at that point. Use this method to set the entries for all resources one by one and after all done persist in one shot usingserializeLanguageSettings(ICConfigurationDescription). See for exampleAbstractBuildCommandParserandAbstractBuiltinSpecsDetectorin build plugins.- Parameters:
cfgDescription- - configuration description.rc- - resource such as file or folder. Ifnullthe entries are considered to be being defined as default entries for resources.languageId- - language id. Ifnull, then entries are considered to be defined for the language scope. SeeLanguageSettingsBaseProvider.getLanguageScope()entries- - language settings entries to set.
-
getSettingEntries
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, org.eclipse.core.resources.IResource rc, String languageId) Returns the list of setting entries for the given configuration description, resource and language.
Note to implementers - this method should not be used to do any long running operations such as extensive calculations or reading files. If you need to do so, the recommended way is to do the calculations outside of this function call - in advance and on appropriate event. For example, Build Output Parser prepares the list and stores it in internal cache while parsing output.ILanguageSettingsProvider.getSettingEntries(ICConfigurationDescription, IResource, String)will return cached entries when asked. You can also implementICListenerAgentinterface to get registered and listen to arbitrary events.
Note that this list is unmodifiable. To modify the list copy it, change and usesetSettingEntries(ICConfigurationDescription, IResource, String, List).
Note also that you can compare these lists with simple equality operator ==, as the lists themselves are backed by WeakHashSet<List<ICLanguageSettingEntry>> where identical copies (deep comparison is used) are replaced with the same one instance.- Specified by:
getSettingEntriesin interfaceILanguageSettingsBroadcastingProvider- Specified by:
getSettingEntriesin interfaceILanguageSettingsProvider- Overrides:
getSettingEntriesin classLanguageSettingsBaseProvider- Parameters:
cfgDescription- - configuration description.rc- - resource such as file or folder. Ifnull, the default entries for all resources are returned.languageId- - language id. Ifnull, then entries defined for the language scope are returned. SeeLanguageSettingsBaseProvider.getLanguageScope()- Returns:
- unmodifiable list of setting entries or
nullif no settings defined. the list is internally pooled and guaranteed to be the same object for equal lists.
-
serialize
Serialize the provider under parent XML element. This is convenience method not intended to be overridden on purpose. OverrideserializeAttributes(Element)orserializeEntries(Element)instead.- Parameters:
parentElement- - element where to serialize.- Returns:
- - newly created "provider" element. That element will already be attached to the parent element.
-
serializeAttributes
Serialize the provider attributes under parent XML element. That is equivalent to serializing everything (including language scope) except entries.- Parameters:
parentElement- - element where to serialize.- Returns:
- - newly created "provider" element. That element will already be attached to the parent element.
-
serializeEntries
Serialize the provider entries under parent XML element.- Parameters:
elementProvider- - element where to serialize the entries.
-
serializeLanguageSettings
public org.eclipse.core.runtime.IStatus serializeLanguageSettings(ICConfigurationDescription cfgDescription) Convenience method to persist language settings entries for the project or workspace as often-used operation. Note that configuration description is passed as an argument but the current implementation saves all configurations.- Parameters:
cfgDescription- - configuration description. If notnull, all providers of the project are serialized. Ifnull, global workspace providers are serialized.- Returns:
- - status of operation.
-
serializeLanguageSettingsInBackground
Convenience method to persist language settings entries in background for the project or workspace as often-used operation. Note that configuration description is passed as an argument but the current implementation saves all configurations.- Parameters:
cfgDescription- - configuration description. If notnull, all providers of the project are serialized. Ifnull, global workspace providers are serialized.
-
load
Load provider from XML provider element. This is convenience method not intended to be overridden on purpose. OverrideloadAttributes(Element)orloadEntries(Element)instead.- Parameters:
providerNode- - XML element "provider" to load provider from.
-
loadAttributes
Load attributes from XML provider element.- Parameters:
providerNode- - XML element "provider" to load attributes from.
-
loadEntries
Load provider entries from XML provider element.- Parameters:
providerNode- - parent XML element "provider" where entries are defined.
-
setProperty
Set a custom property of the provider.
A note of caution - do not use default values for a provider which are different from empty ornullvalue. When providers are checked for equality (during internal operations in core) the missing properties are evaluated as empty ones.- Parameters:
key- - name of the property.value- - value of the property. If value isnullthe property is removed from the list.- See Also:
-
setPropertyBool
Set a custom boolean property of the provider.
Please, note that default value is alwaysfalse.- Parameters:
key- - name of the property.value- -booleanvalue of the property.- See Also:
-
cloneShallow
Shallow clone of the provider. "Shallow" is defined here as the exact copy except that the copy will have zero language settings entries.- Returns:
- shallow copy of the provider.
- Throws:
CloneNotSupportedException- in caseclone()throws the exception.
-
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
copyStorage
Description copied from interface:ILanguageSettingsBroadcastingProviderReturn a copy of internal storage. This should be a deep copy/clone of the storage. It is used to calculate the delta and being kept in the last state object of configuration description to compare to a new state later.- Specified by:
copyStoragein interfaceILanguageSettingsBroadcastingProvider- Returns:
- a copy of internal storage.
-
hashCode
public int hashCode()- Overrides:
hashCodein classLanguageSettingsBaseProvider
-
equals
- Overrides:
equalsin classLanguageSettingsBaseProvider- Returns:
trueif the objects are equal,falseotherwise.- See Also:
-