Search in sources :

Example 1 with TargetType

use of org.eclipse.wst.json.ui.contentassist.ICompletionProposalCollector.TargetType in project webtools.sourceediting by eclipse.

the class CompletionProposalCollectorsRegistryReader method readElement.

protected void readElement(IConfigurationElement element) {
    if (TAG_CONTRIBUTION.equals(element.getName())) {
        try {
            ICompletionProposalCollector collector = (ICompletionProposalCollector) element.createExecutableExtension("class");
            JSONPath[] paths = createPaths(element.getAttribute("paths"));
            Collection<TargetType> targets = createTargets(element.getAttribute("targets"));
            String contentTypeId = element.getAttribute("contentTypeId");
            CompletionProposalMatcher matcher = new CompletionProposalMatcher(targets, paths, collector);
            Collection<CompletionProposalMatcher> matchersByContentType = matchers.get(contentTypeId);
            if (matchersByContentType == null) {
                matchersByContentType = new ArrayList<CompletionProposalMatcher>();
                matchers.put(contentTypeId, matchersByContentType);
            }
            matchersByContentType.add(matcher);
        } catch (CoreException e) {
            Logger.logException(e);
        }
    }
}
Also used : ICompletionProposalCollector(org.eclipse.wst.json.ui.contentassist.ICompletionProposalCollector) JSONPath(org.eclipse.json.jsonpath.JSONPath) CoreException(org.eclipse.core.runtime.CoreException) TargetType(org.eclipse.wst.json.ui.contentassist.ICompletionProposalCollector.TargetType)

Example 2 with TargetType

use of org.eclipse.wst.json.ui.contentassist.ICompletionProposalCollector.TargetType in project webtools.sourceediting by eclipse.

the class CompletionProposalCollectorsRegistryReader method createTargets.

private Collection<TargetType> createTargets(String value) {
    String[] s = value.split(",");
    Collection<TargetType> targets = new ArrayList<ICompletionProposalCollector.TargetType>();
    for (int i = 0; i < s.length; i++) {
        targets.add(TargetType.valueOf(s[i].trim()));
    }
    return targets;
}
Also used : ICompletionProposalCollector(org.eclipse.wst.json.ui.contentassist.ICompletionProposalCollector) TargetType(org.eclipse.wst.json.ui.contentassist.ICompletionProposalCollector.TargetType) ArrayList(java.util.ArrayList) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Aggregations

ICompletionProposalCollector (org.eclipse.wst.json.ui.contentassist.ICompletionProposalCollector)2 TargetType (org.eclipse.wst.json.ui.contentassist.ICompletionProposalCollector.TargetType)2 ArrayList (java.util.ArrayList)1 CoreException (org.eclipse.core.runtime.CoreException)1 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1 JSONPath (org.eclipse.json.jsonpath.JSONPath)1