Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlena Laskavaia2011-02-22 21:54:00 -0500
committerAlena Laskavaia2011-02-22 21:54:00 -0500
commit7b8eb1ed1ada12302321c27bb200fa87b7c43d44 (patch)
tree2e7d63db3c7df1ab8540ca22e4b35adbd1b1015b /codan/org.eclipse.cdt.codan.examples
parent35b59fe44610bebcacd53de843520ec13aad21f9 (diff)
downloadorg.eclipse.cdt-7b8eb1ed1ada12302321c27bb200fa87b7c43d44.tar.gz
org.eclipse.cdt-7b8eb1ed1ada12302321c27bb200fa87b7c43d44.tar.xz
org.eclipse.cdt-7b8eb1ed1ada12302321c27bb200fa87b7c43d44.zip
added example grep checker and updated some comments
Diffstat (limited to 'codan/org.eclipse.cdt.codan.examples')
-rw-r--r--codan/org.eclipse.cdt.codan.examples/.settings/org.eclipse.jdt.core.prefs67
-rw-r--r--codan/org.eclipse.cdt.codan.examples/plugin.xml23
-rw-r--r--codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/GrepChecker.java110
-rw-r--r--codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/FlexlintHelpLink.java3
4 files changed, 202 insertions, 1 deletions
diff --git a/codan/org.eclipse.cdt.codan.examples/.settings/org.eclipse.jdt.core.prefs b/codan/org.eclipse.cdt.codan.examples/.settings/org.eclipse.jdt.core.prefs
index 3d823e3cf6..022c362758 100644
--- a/codan/org.eclipse.cdt.codan.examples/.settings/org.eclipse.jdt.core.prefs
+++ b/codan/org.eclipse.cdt.codan.examples/.settings/org.eclipse.jdt.core.prefs
@@ -1,8 +1,73 @@
-#Thu Mar 18 10:08:06 EDT 2010
+#Mon Feb 21 20:13:32 EST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=error
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=error
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=disabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=error
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.5
diff --git a/codan/org.eclipse.cdt.codan.examples/plugin.xml b/codan/org.eclipse.cdt.codan.examples/plugin.xml
index c9cd76bf72..25b67e72be 100644
--- a/codan/org.eclipse.cdt.codan.examples/plugin.xml
+++ b/codan/org.eclipse.cdt.codan.examples/plugin.xml
@@ -19,6 +19,29 @@
markerType="org.eclipse.cdt.codan.core.codanProblem">
</problem>
</checker>
+ <checker
+ class="org.eclipse.cdt.codan.examples.checkers.GrepChecker"
+ id="org.eclipse.cdt.codan.examples.checkers.GrepChecker"
+ name="Search string">
+ <problem
+ category="org.eclipse.cdt.codan.core.categories.CodeStyle"
+ defaultEnabled="false"
+ defaultSeverity="Warning"
+ description="Finds a strings in the code defined by user"
+ id="org.eclipse.cdt.codan.examples.checkers.GrepCheckerProblemWarning"
+ messagePattern="{0}"
+ name="Search string warning">
+ </problem>
+ <problem
+ category="org.eclipse.cdt.codan.core.categories.CodeStyle"
+ defaultEnabled="false"
+ defaultSeverity="Error"
+ description="Finds a strings in the code defined by user"
+ id="org.eclipse.cdt.codan.examples.checkers.GrepCheckerProblemError"
+ messagePattern="{0}"
+ name="Search string error">
+ </problem>
+ </checker>
</extension>
<extension
point="org.eclipse.cdt.codan.ui.codanProblemDetails">
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
new file mode 100644
index 0000000000..5829ce0da2
--- /dev/null
+++ b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/GrepChecker.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2009,2010 QNX Software Systems
+ * 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:
+ * QNX Software Systems (Alena Laskavaia) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.codan.examples.checkers;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.cdt.codan.core.model.AbstractCheckerWithProblemPreferences;
+import org.eclipse.cdt.codan.core.model.IProblem;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * This is sample of non AST checker integration. This one is not
+ * external checker because it does not actually call other process, but it
+ * can easily made into one.
+ *
+ * This checker is parametrized by the search strings
+ */
+public class GrepChecker extends AbstractCheckerWithProblemPreferences {
+ private static final String PARAM_STRING_LIST = "searchlist";
+
+ public synchronized boolean processResource(IResource resource) {
+ if (!shouldProduceProblems(resource))
+ return false;
+ if (resource instanceof IFile) {
+ IFile file = (IFile) resource;
+ processFile(file);
+ return false;
+ }
+ return true;
+ }
+
+ void processFile(IFile file) {
+ Collection<IProblem> refProblems = getRuntime().getCheckersRegistry()
+ .getRefProblems(this);
+ for (Iterator<IProblem> iterator = refProblems.iterator(); iterator
+ .hasNext();) {
+ IProblem checkerProblem = iterator.next();
+ IProblem problem = getProblemById(checkerProblem.getId(), file);
+ if (shouldProduceProblem(problem, file.getLocation())) {
+ // do something
+ Object[] values = (Object[]) getPreference(problem,
+ PARAM_STRING_LIST);
+ if (values.length == 0)
+ continue; // nothing to do
+ externalRun(file, values, problem);
+ }
+ }
+ }
+
+ /**
+ * @param file
+ * @param checkerProblem
+ * @param values
+ * @param problem
+ * @return
+ */
+ private void externalRun(IFile file, Object[] values, IProblem problem) {
+ try {
+ InputStream is = file.getContents();
+ BufferedReader bis = new BufferedReader(new InputStreamReader(is));
+ String line;
+ int iline = 0;
+ while ((line = bis.readLine()) != null) {
+ iline++;
+ for (int i = 0; i < values.length; i++) {
+ String str = (String) values[i];
+ if (line.contains(str)) {
+ reportProblem(problem.getId(), file, iline, "Found "
+ + str);
+ }
+ }
+ }
+ bis.close();
+ } catch (IOException e) {
+ // ignore
+ } catch (CoreException e) {
+ // ignore
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.cdt.codan.core.model.AbstractCheckerWithProblemPreferences
+ * #initPreferences(org.eclipse.cdt.codan.core.model.IProblemWorkingCopy)
+ */
+ @Override
+ public void initPreferences(IProblemWorkingCopy problem) {
+ super.initPreferences(problem);
+ addListPreference(problem, PARAM_STRING_LIST, "Search strings",
+ "Search string");
+ }
+}
diff --git a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/FlexlintHelpLink.java b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/FlexlintHelpLink.java
index 34ff6920ae..f37dabdbf9 100644
--- a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/FlexlintHelpLink.java
+++ b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/FlexlintHelpLink.java
@@ -15,6 +15,9 @@ import java.util.regex.Pattern;
import org.eclipse.cdt.codan.ui.AbstractCodanProblemDetailsProvider;
+/**
+ * Example of codan problem details provider for flexlint integration
+ */
public class FlexlintHelpLink extends AbstractCodanProblemDetailsProvider {
@Override
public boolean isApplicable(String id) {

Back to the top