Markus
Markus

Reputation: 2053

How can I access variable resolving of Eclipse run configurations for an Eclipse plugin?

I want to extend the Sysdeo Tomcat Plugin to be capable of resolving variables like you can specify in run configurations for Java applications, e.g. ${workspace_loc}.

I have tried to use this, but the resulting array has no contents:

ResourcesPlugin.getWorkspace().getPathVariableManager().getPathVariableNames();

Using this one does not give me the wanted variables:

JavaCore.getClasspathVariableNames();

Further I search for the code doing the actual variable replacement in a string.

Upvotes: 1

Views: 432

Answers (1)

greg-449
greg-449

Reputation: 111142

Use the IStringVariableManager to access variables such as ${workspace_loc}. You get the manager with:

IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();

To process the variables in a string use:

String newString = manager.performStringSubstitution(string);

You can also use the org.eclipse.core.variables.dynamicVariables and org.eclipse.core.variables.valueVariables extension points to add new variables.

Upvotes: 3

Related Questions