Java Code Examples for org.eclipse.core.variables.IValueVariable#getValue()

The following examples show how to use org.eclipse.core.variables.IValueVariable#getValue() . 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: GwtSdk.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 2
Source File: StringSubstitutionEngine.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * 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));
}