Skip to content

Commit 28174e4

Browse files
authored
Merge pull request #82 from AntonKrug/master
Binary path resolves ${eclipse_home} macro and few other small changes This fixes #81
2 parents b6f7ea3 + 37b9196 commit 28174e4

File tree

12 files changed

+122
-25
lines changed

12 files changed

+122
-25
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: java
2+
sudo: false
3+
script: cd com.googlecode.cppcheclipse.parent && mvn clean verify

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
cppcheclipse is an Eclipse plugin which integrates [cppcheck](http://sourceforge.net/projects/cppcheck/) with the [CDT project](https://eclipse.org/cdt/). You can run/configure cppcheck from the Eclipse UI.
22

3+
To build the project on the command line it requires maven, Run the following commands:
4+
```bash
5+
cd com.googlecode.cppcheclipse.parent
6+
mvn clean verify
7+
```
8+
It will not increment the version number nor deploy/publish/release the artifact. You can find the built p2 repository now in ../com.googlecode.cppcheclipse.repository/target in zip format.
9+
10+
**NOTES:**
11+
12+
* Under Windows the `mvn clean verify` will fail because the unit test paths in unix format. As workaround skip the tests `mvn clean package` should build successfully, but it will not create.
13+
* Maven build will fail if Java 9 is used, while it will work under Java 8.
14+
15+
316
Further information on how to use and install cppcheclipse can be found in the [wiki](https://github.com/kwin/cppcheclipse/wiki).

com.googlecode.cppcheclipse.core/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.5.0",
1111
com.google.guava;bundle-version="12.0.0",
1212
org.apache.commons.codec;bundle-version="1.4.0",
1313
org.apache.commons.io;bundle-version="2.0.1",
14-
org.apache.commons.exec;bundle-version="1.1.0"
14+
org.apache.commons.exec;bundle-version="1.1.0",
15+
org.eclipse.core.variables
1516
Bundle-ActivationPolicy: lazy
1617
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
1718
Export-Package: com.googlecode.cppcheclipse.core,

com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/Checker.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import com.googlecode.cppcheclipse.core.command.CppcheckCommand;
1919
import com.googlecode.cppcheclipse.core.command.ProcessExecutionException;
20+
import com.googlecode.cppcheclipse.core.utils.PathMacroReplacer;
2021

2122
/**
2223
* This class should abstract from the eclipse concepts for easier testability.
@@ -73,8 +74,8 @@ public Checker(IConsole console, IPreferenceStore projectPreferences,
7374
symbols = new Symbols();
7475
}
7576

76-
String binaryPath = CppcheclipsePlugin.getConfigurationPreferenceStore()
77-
.getString(IPreferenceConstants.P_BINARY_PATH);
77+
String binaryPath = PathMacroReplacer.performMacroSubstitution(CppcheclipsePlugin.getConfigurationPreferenceStore()
78+
.getString(IPreferenceConstants.P_BINARY_PATH));
7879

7980
command = new CppcheckCommand(console, binaryPath, settingsPreferences,
8081
projectPreferences, toolchainSettings.getUserIncludes(), toolchainSettings.getSystemIncludes(), symbols);

com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/CppcheclipsePlugin.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import com.googlecode.cppcheclipse.core.command.ProcessExecutionException;
2828
import com.googlecode.cppcheclipse.core.utils.IHttpClientService;
29+
import com.googlecode.cppcheclipse.core.utils.PathMacroReplacer;
2930

3031
/**
3132
* The activator class controls the plug-in life cycle
@@ -156,8 +157,8 @@ public boolean removeChangeListener(IPropertyChangeListener listener) {
156157

157158
private synchronized ProblemProfile getInternalNewProblemProfile(IConsole console, IPreferenceStore store) throws CloneNotSupportedException, XPathExpressionException, IOException, InterruptedException, ParserConfigurationException, SAXException, ProcessExecutionException {
158159
if (profile == null) {
159-
String binaryPath = CppcheclipsePlugin.getConfigurationPreferenceStore()
160-
.getString(IPreferenceConstants.P_BINARY_PATH);
160+
String binaryPath = PathMacroReplacer.performMacroSubstitution(CppcheclipsePlugin.getConfigurationPreferenceStore()
161+
.getString(IPreferenceConstants.P_BINARY_PATH));
161162
profile = new ProblemProfile(console, binaryPath);
162163
registerChangeListener();
163164
addChangeListener(profile);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.googlecode.cppcheclipse.core.utils;
2+
3+
import org.eclipse.core.runtime.CoreException;
4+
import org.eclipse.core.variables.IStringVariableManager;
5+
import org.eclipse.core.variables.VariablesPlugin;
6+
7+
import com.googlecode.cppcheclipse.core.CppcheclipsePlugin;
8+
9+
/**
10+
* This util class is helping replace path containing macros into real path.
11+
*
12+
* Following macros will resolve to:
13+
* ${eclipse_home} to a Eclipse's installation folder.
14+
* ${project_loc} to the folder of a active project.
15+
* ${workspace_loc} to the current open workspace.
16+
*
17+
* https://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fcpathvars.htm
18+
*
19+
* @author Anton Krug
20+
*
21+
*/
22+
23+
public class PathMacroReplacer {
24+
25+
public static String performMacroSubstitution(String input) {
26+
String ret = input;
27+
28+
IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
29+
try {
30+
ret = manager.performStringSubstitution(ret, false);
31+
} catch (CoreException e) {
32+
// in case of a issue, keep the path as it is and log error
33+
CppcheclipsePlugin.logError("Path macro subsitution failed", e); //$NON-NLS-1$
34+
}
35+
36+
return ret;
37+
}
38+
39+
}

com.googlecode.cppcheclipse.ui/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.4.0",
1212
org.eclipse.cdt.core;bundle-version="5.0.0",
1313
org.eclipse.ui.editors;bundle-version="3.4.0",
1414
org.eclipse.jface.text;bundle-version="3.4.0",
15-
org.eclipse.cdt.make.core;bundle-version="5.0.0"
15+
org.eclipse.cdt.make.core;bundle-version="5.0.0",
16+
org.eclipse.debug.ui
1617
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
1718
Bundle-ActivationPolicy: lazy
1819
Import-Package: org.eclipse.cdt.core.model,

com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/Messages.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ public class Messages extends NLS {
2525
public static String BinaryPathPreferencePage_ButtonSave;
2626
public static String BinaryPathPreferencePage_CheckForUpdate;
2727
public static String BinaryPathPreferencePage_Description;
28+
public static String BinaryPathPreferencePage_FileDialogButton;
29+
public static String BinaryPathPreferencePage_FileDialogTitle;
2830
public static String BinaryPathPreferencePage_NoValidPath;
2931
public static String BinaryPathPreferencePage_PathToBinary;
3032
public static String BinaryPathPreferencePage_UnknownVersion;
3133
public static String BinaryPathPreferencePage_UpdateCheckNever;
3234
public static String BinaryPathPreferencePage_UpdateCheckNotice;
3335
public static String BinaryPathPreferencePage_UpdateInterval;
36+
public static String BinaryPathPreferencePage_VariablesButton;
37+
3438
public static String BinaryPathPreferencePage_VersionTooOld;
3539
public static String BinaryPathPreferencePage_LinkToCppcheck;
3640
public static String Builder_IncrementalBuilderTask;

com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/UpdateCheck.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.googlecode.cppcheclipse.core.IPreferenceConstants;
2323
import com.googlecode.cppcheclipse.core.command.UpdateCheckCommand;
2424
import com.googlecode.cppcheclipse.core.command.Version;
25+
import com.googlecode.cppcheclipse.core.utils.PathMacroReplacer;
2526

2627
public class UpdateCheck {
2728
private static final String DATE_PATTERN = "yyyy.MM.dd HH:mm:ss"; //$NON-NLS-1$
@@ -93,8 +94,8 @@ private static boolean needUpdateCheck() {
9394
public static boolean startUpdateCheck() {
9495
// do not start another update check, if one is already running
9596
if (UpdateCheck.needUpdateCheck()) {
96-
String binaryPath = CppcheclipsePlugin.getConfigurationPreferenceStore()
97-
.getString(IPreferenceConstants.P_BINARY_PATH);
97+
String binaryPath = PathMacroReplacer.performMacroSubstitution(CppcheclipsePlugin.getConfigurationPreferenceStore()
98+
.getString(IPreferenceConstants.P_BINARY_PATH));
9899
new UpdateCheck(true).check(binaryPath);
99100
return true;
100101
}

com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/marker/CheckDescriptionResolution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
public class CheckDescriptionResolution implements IMarkerResolution {
1111

12-
private static final String CHECK_DESCRIPTION_URL = "http://sourceforge.net/apps/mediawiki/cppcheck/index.php?title=Main_Page#Checks"; //$NON-NLS-1$
12+
private static final String CHECK_DESCRIPTION_URL = "https://sourceforge.net/p/cppcheck/wiki/Home/#checks"; //$NON-NLS-1$
1313
public String getLabel() {
1414
return Messages.CheckDescriptionResolution_Label;
1515
}

0 commit comments

Comments
 (0)