/** * Removes the updater from the map and disconnects it from the registry. * * @param updater to be disconnected and removed from the map */ public void removeUpdater(XtextIndexBasedRegistryUpdater updater) { Preconditions.checkArgument(updater != null, "Updater cannot be null!"); IQuerySpecificationRegistry registry = updater.getConnectedRegistry(); if (updater.equals(updaters.get(registry))) { updaters.remove(registry); updater.disconnectIndexFromRegistry(); } }
/** * Returns an updater connecting the Xtext index with the given registry. If an updater for the * given registry exists, it is returned instead. * * @param registry to connect with the index * @return the connected updater */ public XtextIndexBasedRegistryUpdater getUpdater(IQuerySpecificationRegistry registry) { Preconditions.checkArgument(registry != null, "Registry cannot be null!"); if (updaters.containsKey(registry)) { return updaters.get(registry); } else { Injector injector = EMFPatternLanguageActivator.getInstance() .getInjector( EMFPatternLanguageActivator .ORG_ECLIPSE_VIATRA_QUERY_PATTERNLANGUAGE_EMF_EMFPATTERNLANGUAGE); XtextIndexBasedRegistryUpdater updater = injector.getInstance(XtextIndexBasedRegistryUpdater.class); updaters.put(registry, updater); updater.connectIndexToRegistry(QuerySpecificationRegistry.getInstance()); return updater; } }