/** * Reloads the extensions to the extension point. * * <p>This method can be called more than once in order to reload from a changed extension * registry. */ public void reload() { IExtensionRegistry registry = Platform.getExtensionRegistry(); List elements = new ArrayList( Arrays.asList( registry.getConfigurationElementsFor( DartToolsPlugin.getPluginId(), EXTENSION_POINT))); Map map = new HashMap(); List all = new ArrayList(); List categories = getCategories(elements); for (Iterator iter = elements.iterator(); iter.hasNext(); ) { IConfigurationElement element = (IConfigurationElement) iter.next(); try { CompletionProposalComputerDescriptor desc = new CompletionProposalComputerDescriptor(element, this, categories); Set partitions = desc.getPartitions(); for (Iterator it = partitions.iterator(); it.hasNext(); ) { String partition = (String) it.next(); List list = (List) map.get(partition); if (list == null) { list = new ArrayList(); map.put(partition, list); } list.add(desc); } all.add(desc); } catch (InvalidRegistryObjectException x) { /* * Element is not valid any longer as the contributing plug-in was unloaded or for some * other reason. Do not include the extension in the list and inform the user about it. */ Object[] args = {element.toString()}; String message = Messages.format( DartTextMessages.CompletionProposalComputerRegistry_invalid_message, args); IStatus status = new Status(IStatus.WARNING, DartToolsPlugin.getPluginId(), IStatus.OK, message, x); informUser(status); } } synchronized (this) { fCategories.clear(); fCategories.addAll(categories); Set partitions = map.keySet(); fDescriptorsByPartition.keySet().retainAll(partitions); fPublicDescriptorsByPartition.keySet().retainAll(partitions); for (Iterator it = partitions.iterator(); it.hasNext(); ) { String partition = (String) it.next(); List old = (List) fDescriptorsByPartition.get(partition); List current = (List) map.get(partition); if (old != null) { old.clear(); old.addAll(current); } else { fDescriptorsByPartition.put(partition, current); fPublicDescriptorsByPartition.put(partition, Collections.unmodifiableList(current)); } } fDescriptors.clear(); fDescriptors.addAll(all); } }