Search in sources :

Example 36 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project eclipse.platform.text by eclipse.

the class ReconcilerRegistry method syncHighlight.

private void syncHighlight() {
    Set<IConfigurationElement> toRemoveExtensions = new HashSet<>(this.extensions.keySet());
    for (IConfigurationElement extension : Platform.getExtensionRegistry().getConfigurationElementsFor(HIGHLIGHT_EXTENSION_POINT_ID)) {
        toRemoveExtensions.remove(extension);
        if (!this.highlightExtensions.containsKey(extension)) {
            try {
                this.highlightExtensions.put(extension, new GenericContentTypeRelatedExtension<IReconciler>(extension));
            } catch (Exception ex) {
                GenericEditorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, ex.getMessage(), ex));
            }
        }
    }
    for (IConfigurationElement toRemove : toRemoveExtensions) {
        this.highlightExtensions.remove(toRemove);
    }
    this.highlightOutOfSync = false;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IReconciler(org.eclipse.jface.text.reconciler.IReconciler) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) HashSet(java.util.HashSet)

Example 37 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project eclipse.platform.text by eclipse.

the class ReconcilerRegistry method sync.

private void sync() {
    Set<IConfigurationElement> toRemoveExtensions = new HashSet<>(this.extensions.keySet());
    for (IConfigurationElement extension : Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_ID)) {
        toRemoveExtensions.remove(extension);
        if (!this.extensions.containsKey(extension)) {
            try {
                this.extensions.put(extension, new GenericContentTypeRelatedExtension<IReconciler>(extension));
            } catch (Exception ex) {
                GenericEditorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, ex.getMessage(), ex));
            }
        }
    }
    for (IConfigurationElement toRemove : toRemoveExtensions) {
        this.extensions.remove(toRemove);
    }
    this.outOfSync = false;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IReconciler(org.eclipse.jface.text.reconciler.IReconciler) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) HashSet(java.util.HashSet)

Example 38 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project eclipse.platform.text by eclipse.

the class TextHoverRegistry method sync.

private void sync() {
    Set<IConfigurationElement> toRemoveExtensions = new HashSet<>();
    Map<IConfigurationElement, TextHoverExtension> ext = new HashMap<>();
    if (this.extensions != null) {
        ext = this.extensions.stream().collect(Collectors.toMap(TextHoverExtension::getConfigurationElement, Function.identity()));
        toRemoveExtensions = ext.keySet();
    }
    for (IConfigurationElement extension : Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_ID)) {
        toRemoveExtensions.remove(extension);
        if (!ext.containsKey(extension)) {
            try {
                ext.put(extension, new TextHoverExtension(extension));
            } catch (Exception ex) {
                GenericEditorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, ex.getMessage(), ex));
            }
        }
    }
    for (IConfigurationElement toRemove : toRemoveExtensions) {
        ext.remove(toRemove);
    }
    OrderedExtensionComparator comparator = new OrderedExtensionComparator(ext.values());
    this.extensions = new TreeSet<>(comparator);
    this.extensions.addAll(ext.values());
    this.outOfSync = false;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) HashMap(java.util.HashMap) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) HashSet(java.util.HashSet)

Example 39 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project eclipse.platform.text by eclipse.

the class AnnotationTypeHierarchy method readTypes.

private Map<String, String> readTypes() {
    HashMap<String, String> allTypes = new HashMap<>();
    // $NON-NLS-1$
    IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EditorsUI.PLUGIN_ID, "annotationTypes");
    if (extensionPoint != null) {
        IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
        for (int i = 0; i < elements.length; i++) {
            IConfigurationElement element = elements[i];
            // $NON-NLS-1$
            String name = element.getAttribute("name");
            if (name == null || name.trim().length() == 0)
                continue;
            // $NON-NLS-1$
            String parent = element.getAttribute("super");
            if (parent == null || parent.trim().length() == 0)
                // $NON-NLS-1$
                parent = "";
            allTypes.put(name, parent);
        }
    }
    return allTypes;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) HashMap(java.util.HashMap) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 40 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project eclipse.platform.text by eclipse.

the class CodeMiningProviderRegistry method reloadExtensions.

/**
 * Reads all extensions.
 * <p>
 * This method can be called more than once in order to reload from a changed
 * extension registry.
 * </p>
 */
public synchronized void reloadExtensions() {
    List<CodeMiningProviderDescriptor> descriptors = new ArrayList<>();
    IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(TextEditorPlugin.PLUGIN_ID, CODEMINING_PROVIDERS_EXTENSION_POINT);
    for (int i = 0; i < elements.length; i++) {
        IConfigurationElement element = elements[i];
        try {
            CodeMiningProviderDescriptor descriptor = new CodeMiningProviderDescriptor(element);
            descriptors.add(descriptor);
        } catch (CoreException e) {
            TextEditorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, element.getNamespaceIdentifier(), e.getMessage()));
        }
    }
    fDescriptors = descriptors.toArray(new CodeMiningProviderDescriptor[descriptors.size()]);
    fLoaded = true;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) CoreException(org.eclipse.core.runtime.CoreException) ArrayList(java.util.ArrayList) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Aggregations

IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)189 CoreException (org.eclipse.core.runtime.CoreException)75 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)64 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)50 ArrayList (java.util.ArrayList)39 IExtension (org.eclipse.core.runtime.IExtension)30 IStatus (org.eclipse.core.runtime.IStatus)24 Status (org.eclipse.core.runtime.Status)24 HashMap (java.util.HashMap)16 HashSet (java.util.HashSet)16 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)11 List (java.util.List)9 Map (java.util.Map)9 Platform (org.eclipse.core.runtime.Platform)9 File (java.io.File)8 Collection (java.util.Collection)8 Stream (java.util.stream.Stream)8 LinkedList (java.util.LinkedList)7 Optional (java.util.Optional)5 IFile (org.eclipse.core.resources.IFile)5