diff --git a/com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/Problem.java b/com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/Problem.java
index 7acce85..1a1dfe4 100644
--- a/com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/Problem.java
+++ b/com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/Problem.java
@@ -18,7 +18,7 @@
public class Problem implements Cloneable {
private static final String DELIMITER = ";";
- private final String id, message, category;
+ private final String id, message, category, stack;
private final int lineNumber;
private final File file; // either absolute or relative filename (to
// project), maybe null for problem profiles or
@@ -33,7 +33,7 @@ public class Problem implements Cloneable {
* Constructor is called for default problems (in problem profiles).
*/
public Problem(String id, String message, String category) {
- this(id, message, category, null, null, -1);
+ this(id, message, category, null, null, -1, "");
}
/**
@@ -49,13 +49,14 @@ public Problem(String id, String message, String category) {
* (might be 0 for non line-specific problems)
*/
public Problem(String id, String message, String category, File file,
- IProject project, int line) {
+ IProject project, int line, String stack) {
this.id = id;
this.message = message;
this.category = category;
this.lineNumber = line;
this.file = file;
this.project = project;
+ this.stack = stack;
setToDefault();
}
@@ -76,6 +77,10 @@ public String getMessage() {
public String getCategory() {
return category;
}
+
+ public String getStack() {
+ return stack;
+ }
public ProblemSeverity getSeverity() {
return severity;
diff --git a/com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/command/CppcheckCommand.java b/com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/command/CppcheckCommand.java
index 0ca866f..323fca0 100644
--- a/com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/command/CppcheckCommand.java
+++ b/com.googlecode.cppcheclipse.core/src/com/googlecode/cppcheclipse/core/command/CppcheckCommand.java
@@ -38,7 +38,7 @@ public class CppcheckCommand extends AbstractCppcheckCommand {
private final static String DELIMITER = ";";
private final static String ERROR_FORMAT = "{file}" + DELIMITER + "{line}"
+ DELIMITER + "{severity}" + DELIMITER + "{id}" + DELIMITER
- + "{message}";
+ + "{message}" + DELIMITER + "{callstack}";
private final static String[] DEFAULT_ARGUMENTS = { "--template="
+ ERROR_FORMAT };
@@ -322,10 +322,10 @@ public static void parseResultLines(IProject project,
}
public static Problem parseResult(String line, IProject project) {
- String[] lineParts = line.split(DELIMITER, 5);
- if (lineParts.length < 5) {
+ String[] lineParts = line.split(DELIMITER, 6);
+ if (lineParts.length < 6) {
throw new IllegalArgumentException("Not enough tokens in line '"
- + line + "'. Expected 5 tokens but got " + lineParts.length);
+ + line + "'. Expected 6 tokens but got " + lineParts.length);
}
/**
@@ -352,8 +352,9 @@ public static Problem parseResult(String line, IProject project) {
String severity = lineParts[2];
String id = lineParts[3];
String message = lineParts[4];
+ String stack = lineParts[5];
return new Problem(id, message, severity, filename, project,
- lineNumber);
+ lineNumber, stack);
} catch (NumberFormatException e2) {
throw new IllegalArgumentException(
diff --git a/com.googlecode.cppcheclipse.ui/plugin.xml b/com.googlecode.cppcheclipse.ui/plugin.xml
index 036fedb..63b81e2 100644
--- a/com.googlecode.cppcheclipse.ui/plugin.xml
+++ b/com.googlecode.cppcheclipse.ui/plugin.xml
@@ -38,6 +38,7 @@
+
diff --git a/com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/marker/ProblemReporter.java b/com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/marker/ProblemReporter.java
index 49ac1bd..4a7f6aa 100644
--- a/com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/marker/ProblemReporter.java
+++ b/com.googlecode.cppcheclipse.ui/src/com/googlecode/cppcheclipse/ui/marker/ProblemReporter.java
@@ -23,6 +23,7 @@ public class ProblemReporter implements IProblemReporter {
public static final String ATTRIBUTE_ID = "problemId"; //$NON-NLS-1$
public static final String ATTRIBUTE_ORIGINAL_LINE_NUMBER = "originalLineNumber"; //$NON-NLS-1$
public static final String ATTRIBUTE_FILE = "file"; //$NON-NLS-1$
+ public static final String ATTRIBUTE_STACK = "stack"; //$NON-NLS-1$
public ProblemReporter() {
}
@@ -53,13 +54,13 @@ public void reportProblem(Problem problem) throws CoreException {
// for each resource
reportProblem(resource, completeMessage, problem
.getSeverity().intValue(), lineNumber, problem.getId(),
- problem.getFile(), problem.getLineNumber());
+ problem.getFile(), problem.getLineNumber(), problem.getStack());
}
}
private void reportProblem(IResource resource, String message,
int severity, int lineNumber, String id, File file,
- int originalLineNumber) throws CoreException {
+ int originalLineNumber, String stack) throws CoreException {
// TODO: open external file, see
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=151005 on how to
// generate markers for external files
@@ -81,6 +82,13 @@ private void reportProblem(IResource resource, String message,
}
}
}
+
+ // Only display stack if it contains multiple locations
+ String message_display = message;
+ int locationCount = (stack.length() - stack.replace("->", "").length())/2;
+ if (locationCount > 0) {
+ message_display = message + " " + stack;
+ }
// see
// http://wiki.eclipse.org/FAQ_Why_don%27t_my_markers_appear_in_the_editor%27s_vertical_ruler%3F
@@ -88,13 +96,14 @@ private void reportProblem(IResource resource, String message,
if (lineNumber != 0) {
MarkerUtilities.setLineNumber(attributes, lineNumber);
}
- MarkerUtilities.setMessage(attributes, message);
+ MarkerUtilities.setMessage(attributes, message_display);
attributes.put(IMarker.SEVERITY, severity);
// the following attributes are only used for the quick fixes
attributes.put(ATTRIBUTE_ID, id);
if (file != null) {
attributes.put(ATTRIBUTE_FILE, file.toString());
}
+ attributes.put(ATTRIBUTE_STACK, stack);
attributes.put(ATTRIBUTE_ORIGINAL_LINE_NUMBER, originalLineNumber);
MarkerUtilities.createMarker(resource, attributes, CHECKER_MARKER_TYPE);
}