/** @since 7.3 */ protected String resolve(String path) { try { IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); path = manager.performStringSubstitution(path, false); } catch (Exception e) { // if anything happens here just use the non-resolved one } return path; }
/** * Tests that a Java project must exist * * @throws Exception */ public void testProjectDoesNotExist() throws Exception { IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); try { manager.performStringSubstitution("${project_classpath:a_non_existant_project}"); } catch (CoreException e) { return; // expected } assertNotNull("Test should have thrown an exception due to project does not exist", null); }
/** * @return The default repository directory as configured in the preferences, with variables * substituted. An empty string if there was an error during substitution. */ public static String getDefaultRepositoryDir() { String dir = Activator.getDefault().getPreferenceStore().getString(UIPreferences.DEFAULT_REPO_DIR); IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); try { return manager.performStringSubstitution(dir); } catch (CoreException e) { return ""; //$NON-NLS-1$ } }
/** * Tests that a project name must be specified. * * @throws Exception */ public void testMissingProjectName() throws Exception { IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); setSelection(null); try { manager.performStringSubstitution("${project_classpath}"); } catch (CoreException e) { return; // expected } assertNotNull("Test should have thrown an exception due to missing project name", null); }
public void testProjectClasspath() throws Exception { IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); String projectName = get14Project().getElementName(); String cp = manager.performStringSubstitution("${project_classpath:" + projectName + "}"); StringBuffer buffer = new StringBuffer(); // expecting default output location and A.jar buffer.append( ResourcesPlugin.getWorkspace() .getRoot() .getFolder(get14Project().getOutputLocation()) .getLocation() .toOSString()); buffer.append(File.pathSeparatorChar); buffer.append( get14Project().getProject().getFolder("src").getFile("A.jar").getLocation().toOSString()); assertEquals("Wrong classpath", buffer.toString(), cp); }
private IFile getIFile(ILaunchConfigurationWorkingCopy configuration) { IFile file = null; if (fNewFile != null) { file = fNewFile; fNewFile = null; } else { IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); try { String location = configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String) null); if (location != null) { String expandedLocation = manager.performStringSubstitution(location); if (expandedLocation != null) { file = AntUtil.getFileForLocation(expandedLocation, null); } } } catch (CoreException e) { // do nothing } } return file; }