This repository has been archived by the owner on Apr 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VariablesPlugin implementation for the path macro substitution
- Loading branch information
Anton Krug
committed
Jan 4, 2018
1 parent
ebad04b
commit c5cf13b
Showing
6 changed files
with
38 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 32 additions & 4 deletions
36
...ecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/utils/PathMacroReplacer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,39 @@ | ||
package com.googlecode.cppcheclipse.core.utils; | ||
|
||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.variables.IStringVariableManager; | ||
import org.eclipse.core.variables.VariablesPlugin; | ||
|
||
import com.googlecode.cppcheclipse.core.CppcheclipsePlugin; | ||
|
||
/** | ||
* This util class is helping replace path containing macros into real path. | ||
* | ||
* Following macros will resolve to: | ||
* ${eclipse_home} to a Eclipse's installation folder. | ||
* ${project_loc} to the folder of a active project. | ||
* ${workspace_loc} to the current open workspace. | ||
* | ||
* https://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fcpathvars.htm | ||
* | ||
* @author Anton Krug | ||
* | ||
*/ | ||
|
||
public class PathMacroReplacer { | ||
|
||
// TODO implement the VariablesPlugin | ||
|
||
public static String process(String input) { | ||
return input.replace("${eclipse_home}", System.getProperty("eclipse.home.location").replace("file:/", "")); | ||
public static String performMacroSubstitution(String input) { | ||
String ret = input; | ||
|
||
IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); | ||
try { | ||
ret = manager.performStringSubstitution(ret, false); | ||
} catch (CoreException e) { | ||
// in case of a issue, keep the path as it is and log error | ||
CppcheclipsePlugin.logError("Path macro subsitution failed", e); //$NON-NLS-1$ | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters