org.eclipse.core.variables.IValueVariable Java Examples
The following examples show how to use
org.eclipse.core.variables.IValueVariable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MechanicConfigurationVariableInitializer.java From workspacemechanic with Eclipse Public License 1.0 | 6 votes |
public void initialize(IValueVariable variable) { String separator = getProperties().getProperty("file.separator"); String eclipseInstallationLocation = getProperties().getProperty("osgi.install.area"); try { if (eclipseInstallationLocation != null){ URI uri = new URI(eclipseInstallationLocation); String fullLocation = new File(uri).getPath() + separator + "configuration" + separator + "com.google.eclipse.mechanic"; variable.setValue(fullLocation); } else { this.mechanicLog.logWarning("Eclipse installation location not found"); } } catch (URISyntaxException e) { this.mechanicLog.logError(e, "Can't compute Mechanic Configuration directory: %s", eclipseInstallationLocation); } }
Example #2
Source File: MechanicConfigurationVariableInitializerTest.java From workspacemechanic with Eclipse Public License 1.0 | 5 votes |
public void testSanity() { IValueVariable variable = new FakeValueVariable(); final Properties properties = new Properties(); properties.put("file.separator", "!"); properties.put("osgi.install.area", "file:/path/to/eclipse/"); new MechanicConfigurationVariableInitializer() { @Override protected Properties getProperties() { return properties; } }.initialize(variable); assertEquals("/path/to/eclipse!configuration!com.google.eclipse.mechanic", variable.getValue()); }
Example #3
Source File: GwtSdk.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Returns the value of the gwt_devjar variable or <code>null</code> if the variable is not defined. */ private IPath computeGwtDevJarVariableValue() { IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager(); IValueVariable valueVariable = variableManager.getValueVariable("gwt_devjar"); if (valueVariable != null) { String value = valueVariable.getValue(); if (value != null) { IPath path = new Path(value); return path.removeLastSegments(1); } } return null; }
Example #4
Source File: VariablesResolver.java From goclipse with Eclipse Public License 1.0 | 5 votes |
@Override public IStringVariable[] getVariables() { IValueVariable[] valueVars = getValueVariables(); IDynamicVariable[] dynVars = getDynamicVariables(); ArrayList2<IStringVariable> variables = new ArrayList2<>(valueVars.length + dynVars.length); variables.addElements(dynVars); variables.addElements(valueVars); return variables.toArray(IStringVariable.class); }
Example #5
Source File: ForwardingVariableManager.java From goclipse with Eclipse Public License 1.0 | 4 votes |
@Override public void removeVariables(IValueVariable[] variables) { parentVarMgr.removeVariables(variables); }
Example #6
Source File: UserHomeVariableInitializer.java From workspacemechanic with Eclipse Public License 1.0 | 4 votes |
public void initialize(IValueVariable variable) { variable.setValue(System.getProperty("user.home")); }
Example #7
Source File: ForwardingVariableManager.java From goclipse with Eclipse Public License 1.0 | 4 votes |
@Override public void addVariables(IValueVariable[] variables) throws CoreException { parentVarMgr.addVariables(variables); }
Example #8
Source File: ForwardingVariableManager.java From goclipse with Eclipse Public License 1.0 | 4 votes |
@Override public IValueVariable newValueVariable(String name, String description, boolean readOnly, String value) { return parentVarMgr.newValueVariable(name, description, readOnly, value); }
Example #9
Source File: ForwardingVariableManager.java From goclipse with Eclipse Public License 1.0 | 4 votes |
@Override public IValueVariable newValueVariable(String name, String description) { return parentVarMgr.newValueVariable(name, description); }
Example #10
Source File: ForwardingVariableManager.java From goclipse with Eclipse Public License 1.0 | 4 votes |
@Override public IValueVariable getValueVariable(String name) { return parentVarMgr.getValueVariable(name); }
Example #11
Source File: ForwardingVariableManager.java From goclipse with Eclipse Public License 1.0 | 4 votes |
@Override public IValueVariable[] getValueVariables() { return parentVarMgr.getValueVariables(); }
Example #12
Source File: StringSubstitutionEngine.java From goclipse with Eclipse Public License 1.0 | 4 votes |
/** * Resolve and return the value of the given variable reference, * possibly <code>null</code>. * * @param var the {@link VariableReference} to try and resolve * @param reportUndefinedVariables whether to report undefined variables as * an error * @param resolveVariables whether to resolve the variables value or just to validate that this variable is valid * @param manager variable registry * @return variable value, possibly <code>null</code> * @exception CoreException if unable to resolve a value */ private String resolve(VariableReference var, boolean reportUndefinedVariables, boolean resolveVariables, IStringVariableManager manager) throws CoreException { String text = var.getText(); int pos = text.indexOf(VARIABLE_ARG); String name = null; String arg = null; if (pos > 0) { name = text.substring(0, pos); pos++; if (pos < text.length()) { arg = text.substring(pos); } } else { name = text; } IValueVariable valueVariable = manager.getValueVariable(name); if (valueVariable == null) { IDynamicVariable dynamicVariable = manager.getDynamicVariable(name); if (dynamicVariable == null) { // no variables with the given name if (reportUndefinedVariables) { throw new CoreException(new Status(IStatus.ERROR, VariablesPlugin.getUniqueIdentifier(), VariablesPlugin.INTERNAL_ERROR, NLS.bind(VariablesMessages.StringSubstitutionEngine_3, new String[]{name}), null)); } // leave as is return getOriginalVarText(var); } if (resolveVariables) { fSubs = true; return dynamicVariable.getValue(arg); } //leave as is return getOriginalVarText(var); } if (arg == null) { if (resolveVariables) { fSubs = true; return valueVariable.getValue(); } //leave as is return getOriginalVarText(var); } // error - an argument specified for a value variable throw new CoreException(new Status(IStatus.ERROR, VariablesPlugin.getUniqueIdentifier(), VariablesPlugin.INTERNAL_ERROR, NLS.bind(VariablesMessages.StringSubstitutionEngine_4, new String[]{valueVariable.getName()}), null)); }
Example #13
Source File: VariablesResolver.java From goclipse with Eclipse Public License 1.0 | 4 votes |
@Override public IValueVariable[] getValueVariables() { return super.getValueVariables(); }
Example #14
Source File: VariablesResolver.java From goclipse with Eclipse Public License 1.0 | 4 votes |
@Override public IValueVariable getValueVariable(String name) { return super.getValueVariable(name); }
Example #15
Source File: PythonRunnerConfigTestWorkbench.java From Pydev with Eclipse Public License 1.0 | 4 votes |
public void testPythonCommandLine() throws Exception { PythonNature nature = PythonNature.getPythonNature(mod1); // Create a temporary variable for testing IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager(); IValueVariable myCustomVariable = variableManager.newValueVariable("pydev_python_runner_config_test_var", "", true, "my_custom_value"); variableManager.addVariables(new IValueVariable[] { myCustomVariable }); try { IInterpreterManager manager = InterpreterManagersAPI.getPythonInterpreterManager(true); InterpreterInfo info = (InterpreterInfo) manager.getDefaultInterpreterInfo(false); info.setEnvVariables(new String[] { "MY_CUSTOM_VAR_FOR_TEST=FOO", "MY_CUSTOM_VAR_FOR_TEST2=FOO2", "MY_CUSTOM_VAR_WITH_VAR=${pydev_python_runner_config_test_var}" }); // Make sure variable hasn't been expanded too early assertTrue(arrayContains(info.getEnvVariables(), "MY_CUSTOM_VAR_WITH_VAR=${pydev_python_runner_config_test_var}")); PythonRunnerConfig runnerConfig = createConfig(); assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_FOR_TEST=FOO")); assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_FOR_TEST2=FOO2")); assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_WITH_VAR=my_custom_value")); String[] argv = runnerConfig.getCommandLine(false); assertFalse(arrayContains(argv, PythonRunnerConfig.getRunFilesScript())); assertTrue(arrayContains(argv, mod1.getLocation().toOSString())); nature.setVersion(IPythonNature.Versions.PYTHON_VERSION_LATEST, IPythonNature.DEFAULT_INTERPRETER); assertEquals(manager.getDefaultInterpreterInfo(false).getExecutableOrJar(), nature.getProjectInterpreter() .getExecutableOrJar()); runnerConfig = createConfig(); argv = runnerConfig.getCommandLine(false); assertEquals(manager.getDefaultInterpreterInfo(false).getExecutableOrJar(), argv[0]); IInterpreterManager interpreterManager = nature.getRelatedInterpreterManager(); InterpreterInfo info2 = new InterpreterInfo(IPythonNature.PYTHON_VERSION_2_6, "c:\\interpreter\\py25.exe", new ArrayList<String>()); interpreterManager.setInfos(new IInterpreterInfo[] { info, info2 }, null, null); nature.setVersion(IPythonNature.Versions.PYTHON_VERSION_LATEST, "c:\\interpreter\\py25.exe"); assertEquals("c:\\interpreter\\py25.exe", nature.getProjectInterpreter().getExecutableOrJar()); runnerConfig = createConfig(); argv = runnerConfig.getCommandLine(false); assertEquals("c:\\interpreter\\py25.exe", argv[0]); nature.setVersion(IPythonNature.Versions.PYTHON_VERSION_LATEST, IPythonNature.DEFAULT_INTERPRETER); ILaunchConfiguration config; config = new LaunchShortcut().createDefaultLaunchConfiguration(FileOrResource .createArray(new IResource[] { mod1 })); ILaunchConfigurationWorkingCopy workingCopy = config.getWorkingCopy(); HashMap<String, String> map = new HashMap<String, String>(); map.put("VAR_SPECIFIED_IN_LAUNCH", "BAR"); map.put("MY_CUSTOM_VAR_FOR_TEST2", "BAR2"); //The one in the launch configuration always has preference. workingCopy.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, map); config = workingCopy.doSave(); runnerConfig = new PythonRunnerConfig(config, ILaunchManager.RUN_MODE, PythonRunnerConfig.RUN_REGULAR); assertTrue(arrayContains(runnerConfig.envp, "VAR_SPECIFIED_IN_LAUNCH=BAR")); assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_FOR_TEST=FOO")); assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_FOR_TEST2=BAR2")); assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_WITH_VAR=my_custom_value")); } catch (Throwable e) { e.printStackTrace(); throw new RuntimeException(e); } finally { //restore the default! nature.setVersion(IPythonNature.Versions.PYTHON_VERSION_LATEST, IPythonNature.DEFAULT_INTERPRETER); variableManager.removeVariables(new IValueVariable[] { myCustomVariable }); } }
Example #16
Source File: MockStringVariableManager.java From Pydev with Eclipse Public License 1.0 | 4 votes |
@Override public void addVariables(IValueVariable[] variables) throws CoreException { throw new AssertionFailedError("Unexpected method call in MockStringVariableManager"); }
Example #17
Source File: MockStringVariableManager.java From Pydev with Eclipse Public License 1.0 | 4 votes |
@Override public IValueVariable getValueVariable(String name) { throw new AssertionFailedError("Unexpected method call in MockStringVariableManager"); }
Example #18
Source File: MockStringVariableManager.java From Pydev with Eclipse Public License 1.0 | 4 votes |
@Override public IValueVariable[] getValueVariables() { throw new AssertionFailedError("Unexpected method call in MockStringVariableManager"); }
Example #19
Source File: MockStringVariableManager.java From Pydev with Eclipse Public License 1.0 | 4 votes |
@Override public IValueVariable newValueVariable(String name, String description) { throw new AssertionFailedError("Unexpected method call in MockStringVariableManager"); }
Example #20
Source File: MockStringVariableManager.java From Pydev with Eclipse Public License 1.0 | 4 votes |
@Override public IValueVariable newValueVariable(String name, String description, boolean readOnly, String value) { throw new AssertionFailedError("Unexpected method call in MockStringVariableManager"); }
Example #21
Source File: MockStringVariableManager.java From Pydev with Eclipse Public License 1.0 | 4 votes |
@Override public void removeVariables(IValueVariable[] variables) { throw new AssertionFailedError("Unexpected method call in MockStringVariableManager"); }