diff options
author | Tom Schindl | 2015-11-25 23:22:18 +0000 |
---|---|---|
committer | Tom Schindl | 2015-11-25 23:25:29 +0000 |
commit | 6bba38d194f90ef28a6500ada1eddf547b8e8c26 (patch) | |
tree | b972c94f534f33c8cd9b7d278af1fba89c6a2677 /bundles/code/org.eclipse.fx.code.editor.configuration.text/src/org/eclipse/fx/code/editor/configuration/text/ConfigurationModelDependentTypeProvider.java | |
parent | c6eb653d23b0e2a2849344210ae279ea0d8a82c7 (diff) | |
download | org.eclipse.efxclipse-6bba38d194f90ef28a6500ada1eddf547b8e8c26.tar.gz org.eclipse.efxclipse-6bba38d194f90ef28a6500ada1eddf547b8e8c26.tar.xz org.eclipse.efxclipse-6bba38d194f90ef28a6500ada1eddf547b8e8c26.zip |
Bug 483038 - Allow to configures editor highlightings based on JSON
Diffstat (limited to 'bundles/code/org.eclipse.fx.code.editor.configuration.text/src/org/eclipse/fx/code/editor/configuration/text/ConfigurationModelDependentTypeProvider.java')
-rw-r--r-- | bundles/code/org.eclipse.fx.code.editor.configuration.text/src/org/eclipse/fx/code/editor/configuration/text/ConfigurationModelDependentTypeProvider.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/bundles/code/org.eclipse.fx.code.editor.configuration.text/src/org/eclipse/fx/code/editor/configuration/text/ConfigurationModelDependentTypeProvider.java b/bundles/code/org.eclipse.fx.code.editor.configuration.text/src/org/eclipse/fx/code/editor/configuration/text/ConfigurationModelDependentTypeProvider.java new file mode 100644 index 000000000..17c992fbb --- /dev/null +++ b/bundles/code/org.eclipse.fx.code.editor.configuration.text/src/org/eclipse/fx/code/editor/configuration/text/ConfigurationModelDependentTypeProvider.java @@ -0,0 +1,30 @@ +package org.eclipse.fx.code.editor.configuration.text; + +import static org.eclipse.fx.core.RankedObjectRegistry.getOSGiServiceRank; + +import java.util.Map; + +import org.eclipse.fx.code.editor.Input; +import org.eclipse.fx.code.editor.services.InputDependentTypeProviderService; +import org.eclipse.fx.core.RankedObjectRegistry; + +@SuppressWarnings("restriction") +public abstract class ConfigurationModelDependentTypeProvider<T> implements InputDependentTypeProviderService<T> { + private RankedObjectRegistry<ConfigurationModelProvider> modelProviders = new RankedObjectRegistry<>(); + + public void registerModelProvider(ConfigurationModelProvider provider, Map<String, Object> properties) { + modelProviders.registerObject(getOSGiServiceRank(properties), provider); + } + + public void unregisterModelProvider(ConfigurationModelProvider provider) { + modelProviders.unregisterObject(provider); + } + + @Override + public boolean test(Input<?> s) { + synchronized (modelProviders) { + return modelProviders.unsynchronizedStream().filter( m -> m.applies(s)).findFirst().isPresent(); + } + } + +} |