Package org.eclipse.core.variables

Examples of org.eclipse.core.variables.IStringVariableManager


        String path = javaProject.getOutputLocation().toString();
        return varManager.generateVariableExpression("workspace_loc", path);
    }

    private String absolutePathToWorkspacePath(String path) {
        IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager();
        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        IContainer[] containers = root.findContainersForLocationURI(new File(path).toURI());
        if (containers.length == 0) {
            return null;
        }
        IContainer container = containers[0];
        String suffix = "";
        while (!(container instanceof IProject)) {
            suffix = "/" + container.getName() + suffix;
            container = container.getParent();
        }
        path = container.getFullPath().toString();
        return varManager.generateVariableExpression("workspace_loc", path) + suffix;
    }
View Full Code Here


    super(key, defaultValue);
  }
 
  public String[] getParsedArguments(IProject project) throws CoreException {
    String extraOptionsString = get(project);
    IStringVariableManager varMgr = VariablesPlugin.getDefault().getStringVariableManager();
    extraOptionsString = varMgr.performStringSubstitution(extraOptionsString, true);
    return DebugPlugin.parseArguments(extraOptionsString);
  }
View Full Code Here

    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 = PydevPlugin.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.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.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.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.PYTHON_VERSION_LATEST, IPythonNature.DEFAULT_INTERPRETER);
            variableManager.removeVariables(new IValueVariable[] { myCustomVariable });
        }
    }
View Full Code Here

        this.loadSettingsOnDemand = setup.loadSettingsOnDemand;
    }

    public String getResolvedIvySettingsPath(IProject project) throws IvyDEException {
        String url;
        IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
        String path;
        if (project != null) {
            path = ivySettingsPath.replaceAll("\\$\\{ivyproject_loc\\}", "\\${workspace_loc:"
                + project.getName() + "}");
        } else {
            path = ivySettingsPath;           
        }
        try {
            url = manager.performStringSubstitution(path, false);
        } catch (CoreException e) {
            throw new IvyDEException("Unrecognized variables",
                    "Unrecognized variables in the Ivy settings file " + ivySettingsPath, e);
        }
        if (ivySettingsPath.trim().startsWith("$")) {
View Full Code Here

        return propertyFiles;
    }

    public List getResolvedPropertyFiles() throws IvyDEException {
        List resolvedProps = new ArrayList();
        IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
        try {
            Iterator it = propertyFiles.iterator();
            while (it.hasNext()) {
                String propFile = (String) it.next();
                String resolvedProp = manager.performStringSubstitution(propFile, false);
                resolvedProps.add(resolvedProp);
            }
        } catch (CoreException e) {
            throw new IvyDEException("Unrecognized variables",
                    "Unrecognized variables in the Ivy settings file " + ivySettingsPath, e);
View Full Code Here

        if (path.length() > 0) {
            IResource res = null;
            IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
           
            if (path.startsWith("${workspace_loc:")) { //$NON-NLS-1$
                IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
                try {
                    path = manager.performStringSubstitution(path, false);
                    IContainer[] containers = root.findContainersForLocation(new Path(path));
                    if (containers.length > 0) {
                        res = containers[0];
                    }
                } catch (CoreException e) {
View Full Code Here

        setMessage(null);
       
        // if variables are present, we cannot resolve the directory
        String workingDirPath = getResourceBaseText();
        if (workingDirPath.indexOf("${") >= 0) { //$NON-NLS-1$
            IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
            try {
                manager.validateStringVariables(workingDirPath);
            } catch (CoreException e) {
                setErrorMessage(e.getMessage());
                return false;
            }
        } else if (workingDirPath.length() > 0) {
View Full Code Here

TOP

Related Classes of org.eclipse.core.variables.IStringVariableManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.