use of org.eclipse.core.expressions.ExpressionConverter in project eclipse.platform.text by eclipse.
the class GenericContentTypeRelatedExtension method buildEnabledWhen.
/**
* Returns the expression {@link Expression} declared in the
* <code>enabledWhen</code> element.
*
* @param configElement the configuration element
* @return the expression {@link Expression} declared in the enabledWhen
* element.
* @throws CoreException when enabledWhen expression is not valid.
*/
private static Expression buildEnabledWhen(IConfigurationElement configElement) throws CoreException {
final IConfigurationElement[] children = configElement.getChildren(ENABLED_WHEN_ATTRIBUTE);
if (children.length > 0) {
IConfigurationElement[] subChildren = children[0].getChildren();
if (subChildren.length != 1) {
throw new CoreException(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, // $NON-NLS-1$
"One <enabledWhen> element is accepted. Disabling " + configElement.getAttribute(ID_ATTRIBUTE)));
}
final ElementHandler elementHandler = ElementHandler.getDefault();
final ExpressionConverter converter = ExpressionConverter.getDefault();
return elementHandler.create(converter, subChildren[0]);
}
return null;
}
use of org.eclipse.core.expressions.ExpressionConverter in project eclipse.platform.text by eclipse.
the class CodeMiningProviderDescriptor method createEnabledWhen.
/**
* Returns the expression {@link Expression} declared in the
* <code>enabledWhen</code> element.
*
* @param configElement
* the configuration element
* @param id
* the id of the codemining provider.
* @return the expression {@link Expression} declared in the enabledWhen
* element.
* @throws CoreException
* when enabledWhen expression is not valid.
*/
private static Expression createEnabledWhen(IConfigurationElement configElement, String id) throws CoreException {
final IConfigurationElement[] children = configElement.getChildren(ENABLED_WHEN_ATTR);
if (children.length > 0) {
IConfigurationElement[] subChildren = children[0].getChildren();
if (subChildren.length != 1) {
throw new CoreException(new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, // $NON-NLS-1$
"One <enabledWhen> element is accepted. Disabling " + id));
}
final ElementHandler elementHandler = ElementHandler.getDefault();
final ExpressionConverter converter = ExpressionConverter.getDefault();
return elementHandler.create(converter, subChildren[0]);
}
throw new CoreException(new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, // $NON-NLS-1$
"<enabledWhen> element is required. Disabling " + id));
}
Aggregations