private static EvaluationContext createEvaluationContext(RefactoringProcessor processor, Object element, String[] affectedNatures) { EvaluationContext result= new EvaluationContext(null, element); result.addVariable("element", element); //$NON-NLS-1$ result.addVariable("affectedNatures", Arrays.asList(affectedNatures)); //$NON-NLS-1$ result.addVariable("processorIdentifier", processor.getIdentifier()); //$NON-NLS-1$ return result; } }
private static EvaluationContext createEvaluationContext(RefactoringProcessor processor, Object element, String[] affectedNatures) { EvaluationContext result= new EvaluationContext(null, element); result.setAllowPluginActivation(true); result.addVariable("element", element); //$NON-NLS-1$ result.addVariable("affectedNatures", Arrays.asList(affectedNatures)); //$NON-NLS-1$ result.addVariable("processorIdentifier", processor.getIdentifier()); //$NON-NLS-1$ return result; } }
private static IEvaluationContext createDefaultContext() { EvaluationContext context = new EvaluationContext(null, Platform.class); context.addVariable(VARIABLE_PLATFORM, Platform.class); return context; }
public static EvaluationContext getContext() { if (context == null) { context = new EvaluationContext(null, Platform.class); context.addVariable(VARIABLE_PLATFORM, Platform.class); context.addVariable(VARIABLE_WORKBENCH, PlatformUI.getWorkbench()); } return context; }
private static EvaluationContext createEvaluationContext(RefactoringProcessor processor, Object element, String[] affectedNatures) { EvaluationContext result= new EvaluationContext(null, element); result.setAllowPluginActivation(true); result.addVariable("element", element); //$NON-NLS-1$ result.addVariable("affectedNatures", Arrays.asList(affectedNatures)); //$NON-NLS-1$ result.addVariable("processorIdentifier", processor.getIdentifier()); //$NON-NLS-1$ return result; } }
public static EvaluationContext getContext() { if (context == null) { context = new EvaluationContext(null, Platform.class); context.addVariable(VARIABLE_PLATFORM, Platform.class); context.addVariable(VARIABLE_WORKBENCH, PlatformUI.getWorkbench()); } return context; }
public boolean matches(Object element, String variableName) throws CoreException { Assert.isNotNull(element); Assert.isNotNull(variableName); Expression exp= getExpression(); EvaluationContext evaluationContext= new EvaluationContext(null, element); evaluationContext.addVariable(variableName, element); if (exp.evaluate(evaluationContext) == EvaluationResult.FALSE) return false; return true; }
/** * Returns true if the given viewer, editor matches the enabledWhen expression * and false otherwise. * * @param viewer * the viewer * @param editor * the editor * @return true if the given viewer, editor matches the enabledWhen expression * and false otherwise. */ public boolean matches(ISourceViewer viewer, ITextEditor editor) { EvaluationContext context = new EvaluationContext(null, editor); context.setAllowPluginActivation(true); context.addVariable("viewer", viewer); //$NON-NLS-1$ context.addVariable("editor", editor); //$NON-NLS-1$ context.addVariable("editorInput", editor.getEditorInput()); //$NON-NLS-1$ try { return fEnabledWhen.evaluate(context) == EvaluationResult.TRUE; } catch (CoreException e) { TextEditorPlugin.getDefault().getLog().log( new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, "Error while 'enabledWhen' evaluation", e)); //$NON-NLS-1$ return false; } }
public boolean matches(IJavaProject javaProject) { if (fStatus != null) { return fStatus.booleanValue(); } IConfigurationElement[] children= fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT); if (children.length == 1) { try { ExpressionConverter parser= ExpressionConverter.getDefault(); Expression expression= parser.perform(children[0]); EvaluationContext evalContext= new EvaluationContext(null, javaProject); evalContext.addVariable("project", javaProject); //$NON-NLS-1$ evalContext.addVariable("sourceLevel", javaProject.getOption(JavaCore.COMPILER_SOURCE, true)); //$NON-NLS-1$ return expression.evaluate(evalContext) == EvaluationResult.TRUE; } catch (CoreException e) { JavaPlugin.log(e); } return false; } fStatus= Boolean.FALSE; return false; }
public boolean matches(IJavaProject javaProject) { if (fStatus != null) { return fStatus.booleanValue(); } IConfigurationElement[] children= fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT); if (children.length == 1) { try { ExpressionConverter parser= ExpressionConverter.getDefault(); Expression expression= parser.perform(children[0]); EvaluationContext evalContext= new EvaluationContext(null, javaProject); evalContext.addVariable("project", javaProject); //$NON-NLS-1$ evalContext.addVariable("sourceLevel", javaProject.getOption(JavaCore.COMPILER_SOURCE, true)); //$NON-NLS-1$ return expression.evaluate(evalContext) == EvaluationResult.TRUE; } catch (CoreException e) { JavaPlugin.log(e); } return false; } fStatus= Boolean.FALSE; return false; }
/** * Determines if the project matches any enablement expression defined on the extension. * * @param javaProject the Java project against which to test the enablement expression, can be * <code>null</code> * @return <code>true</code> if any enablement expression matches the given project or if the * project is <code>null</code> or no enablement expression is specified, * <code>false</code> otherwise * @since 3.8 */ public boolean matches(IJavaProject javaProject) { if (fEnablementExpression == null) { return true; } if (javaProject == null) { return false; } try { EvaluationContext evalContext= new EvaluationContext(null, javaProject); evalContext.addVariable("project", javaProject); //$NON-NLS-1$ return fEnablementExpression.evaluate(evalContext) == EvaluationResult.TRUE; } catch (CoreException e) { JavaPlugin.log(e); } return false; }
/** * Determines if the project matches any enablement expression defined on the extension. * * @param javaProject the Java project against which to test the enablement expression, can be * <code>null</code> * @return <code>true</code> if any enablement expression matches the given project or if the * project is <code>null</code> or no enablement expression is specified, * <code>false</code> otherwise * @since 3.8 */ public boolean matches(IJavaProject javaProject) { if (fEnablementExpression == null) { return true; } if (javaProject == null) { return false; } try { EvaluationContext evalContext= new EvaluationContext(null, javaProject); evalContext.addVariable("project", javaProject); //$NON-NLS-1$ return fEnablementExpression.evaluate(evalContext) == EvaluationResult.TRUE; } catch (CoreException e) { JavaPlugin.log(e); } return false; }
Expression expression= parser.perform(children[0]); EvaluationContext evalContext= new EvaluationContext(null, cunit); evalContext.addVariable("compilationUnit", cunit); //$NON-NLS-1$ IJavaProject javaProject= cunit.getJavaProject(); String[] natures= javaProject.getProject().getDescription().getNatureIds(); evalContext.addVariable("projectNatures", Arrays.asList(natures)); //$NON-NLS-1$ evalContext.addVariable("sourceLevel", javaProject.getOption(JavaCore.COMPILER_SOURCE, true)); //$NON-NLS-1$ fLastResult= !(expression.evaluate(evalContext) != EvaluationResult.TRUE); return fLastResult;
private boolean matches(ICompilationUnit cunit) { if (fRequiredSourceLevel != null) { String current= cunit.getJavaProject().getOption(JavaCore.COMPILER_SOURCE, true); if (JavaModelUtil.isVersionLessThan(current, fRequiredSourceLevel)) { return false; } } if (fStatus != null) { return fStatus.booleanValue(); } IConfigurationElement[] children= fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT); if (children.length == 1) { try { ExpressionConverter parser= ExpressionConverter.getDefault(); Expression expression= parser.perform(children[0]); EvaluationContext evalContext= new EvaluationContext(null, cunit); evalContext.addVariable("compilationUnit", cunit); //$NON-NLS-1$ IJavaProject javaProject= cunit.getJavaProject(); String[] natures= javaProject.getProject().getDescription().getNatureIds(); evalContext.addVariable("projectNatures", Arrays.asList(natures)); //$NON-NLS-1$ evalContext.addVariable("sourceLevel", javaProject.getOption(JavaCore.COMPILER_SOURCE, true)); //$NON-NLS-1$ return expression.evaluate(evalContext) == EvaluationResult.TRUE; } catch (CoreException e) { JavaPlugin.log(e); } return false; } fStatus= Boolean.FALSE; return false; }
private boolean matches(ICompilationUnit cunit) { if (fRequiredSourceLevel != null) { String current= cunit.getJavaProject().getOption(JavaCore.COMPILER_SOURCE, true); if (JavaModelUtil.isVersionLessThan(current, fRequiredSourceLevel)) { return false; } } if (fStatus != null) { return fStatus.booleanValue(); } IConfigurationElement[] children= fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT); if (children.length == 1) { try { ExpressionConverter parser= ExpressionConverter.getDefault(); Expression expression= parser.perform(children[0]); EvaluationContext evalContext= new EvaluationContext(null, cunit); evalContext.addVariable("compilationUnit", cunit); //$NON-NLS-1$ IJavaProject javaProject= cunit.getJavaProject(); String[] natures= javaProject.getProject().getDescription().getNatureIds(); evalContext.addVariable("projectNatures", Arrays.asList(natures)); //$NON-NLS-1$ evalContext.addVariable("sourceLevel", javaProject.getOption(JavaCore.COMPILER_SOURCE, true)); //$NON-NLS-1$ return expression.evaluate(evalContext) == EvaluationResult.TRUE; } catch (CoreException e) { JavaPlugin.log(e); } return false; } fStatus= Boolean.FALSE; return false; }
c = new EvaluationContext(handlerService .createContextSnapshot(false), selection.toList()); c.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection);
handlerService.createContextSnapshot(false), selection.toList()); c.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection); c.removeVariable(ISources.ACTIVE_MENU_SELECTION_NAME);