Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlena Laskavaia2011-02-25 20:47:10 -0500
committerAlena Laskavaia2011-02-25 20:47:10 -0500
commit352e59b270bd5fb8bb2fde9e8d1472d1abb8bece (patch)
treecfc8be384641ca70383d4fa2946de74a039730e5 /codan/org.eclipse.cdt.codan.examples
parent7e3b1acf38c76ebdb9c80ffa81d7185de13f5568 (diff)
downloadorg.eclipse.cdt-352e59b270bd5fb8bb2fde9e8d1472d1abb8bece.tar.gz
org.eclipse.cdt-352e59b270bd5fb8bb2fde9e8d1472d1abb8bece.tar.xz
org.eclipse.cdt-352e59b270bd5fb8bb2fde9e8d1472d1abb8bece.zip
fixed grep example and added details provider for it
Diffstat (limited to 'codan/org.eclipse.cdt.codan.examples')
-rw-r--r--codan/org.eclipse.cdt.codan.examples/plugin.xml8
-rw-r--r--codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/GrepChecker.java2
-rw-r--r--codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/GrepCheckerHelpLink.java32
3 files changed, 39 insertions, 3 deletions
diff --git a/codan/org.eclipse.cdt.codan.examples/plugin.xml b/codan/org.eclipse.cdt.codan.examples/plugin.xml
index 25b67e72be..f12f7a82af 100644
--- a/codan/org.eclipse.cdt.codan.examples/plugin.xml
+++ b/codan/org.eclipse.cdt.codan.examples/plugin.xml
@@ -29,7 +29,7 @@
defaultSeverity="Warning"
description="Finds a strings in the code defined by user"
id="org.eclipse.cdt.codan.examples.checkers.GrepCheckerProblemWarning"
- messagePattern="{0}"
+ messagePattern="Found string {0}"
name="Search string warning">
</problem>
<problem
@@ -38,7 +38,7 @@
defaultSeverity="Error"
description="Finds a strings in the code defined by user"
id="org.eclipse.cdt.codan.examples.checkers.GrepCheckerProblemError"
- messagePattern="{0}"
+ messagePattern="Found string {0}"
name="Search string error">
</problem>
</checker>
@@ -49,5 +49,9 @@
class="org.eclipse.cdt.codan.examples.uicontrib.FlexlintHelpLink"
>
</problemDetails>
+ <problemDetails
+ class="org.eclipse.cdt.codan.examples.uicontrib.GrepCheckerHelpLink"
+ >
+ </problemDetails>
</extension>
</plugin>
diff --git a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/GrepChecker.java b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/GrepChecker.java
index 44e55695d2..76629292cc 100644
--- a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/GrepChecker.java
+++ b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/GrepChecker.java
@@ -78,7 +78,7 @@ public class GrepChecker extends AbstractCheckerWithProblemPreferences {
for (int i = 0; i < values.length; i++) {
String str = (String) values[i];
if (line.contains(str)) {
- reportProblem(problem.getId(), file, iline, "Found " + str);
+ reportProblem(problem.getId(), file, iline, str);
}
}
}
diff --git a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/GrepCheckerHelpLink.java b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/GrepCheckerHelpLink.java
new file mode 100644
index 0000000000..bfed0b3497
--- /dev/null
+++ b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/GrepCheckerHelpLink.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Alena Laskavaia and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alena Laskavaia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.codan.examples.uicontrib;
+
+import org.eclipse.cdt.codan.internal.core.model.CodanProblemMarker;
+import org.eclipse.cdt.codan.ui.AbstractCodanProblemDetailsProvider;
+
+/**
+ * Example of codan problem details provider for flexlint integration
+ */
+public class GrepCheckerHelpLink extends AbstractCodanProblemDetailsProvider {
+ @Override
+ public boolean isApplicable(String id) {
+ return id.startsWith("org.eclipse.cdt.codan.examples.checkers.GrepCheckerProblem");
+ }
+
+
+ @Override
+ public String getStyledProblemDescription() {
+ String arg = CodanProblemMarker.getProblemArgument(marker, 0);
+ String url = "http://www.google.ca/search?q=" + arg;
+ return "Google " + "<a href=\"" + url + "\">" + arg + "</a>";
+ }
+}

Back to the top