Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/codan
diff options
context:
space:
mode:
authorAlena Laskavaia2009-08-22 21:16:50 +0000
committerAlena Laskavaia2009-08-22 21:16:50 +0000
commitac758f71fbd5f660abddbb5fa70465d0bd11ea75 (patch)
treeabff1ccc764fd9f10eaa10f0658f80d32f9992be /codan
parent0888fe2ffedf7eed508c8a38fe9cfbb074988c79 (diff)
downloadorg.eclipse.cdt-ac758f71fbd5f660abddbb5fa70465d0bd11ea75.tar.gz
org.eclipse.cdt-ac758f71fbd5f660abddbb5fa70465d0bd11ea75.tar.xz
org.eclipse.cdt-ac758f71fbd5f660abddbb5fa70465d0bd11ea75.zip
[279740] - Trying to separate public API and some clean-up
Diffstat (limited to 'codan')
-rw-r--r--codan/org.eclipse.cdt.codan.core/META-INF/MANIFEST.MF1
-rw-r--r--codan/org.eclipse.cdt.codan.core/plugin.xml4
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanApplication.java11
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java2
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanPreferencesLoader.java (renamed from codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/builder/CodanPreferencesLoader.java)4
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanRuntime.java54
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java40
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractIndexAstChecker.java14
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java66
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanAstReconciler.java (renamed from codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanRuntime.java)24
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanBuilder.java22
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java16
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocation.java54
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java28
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemLocation.java109
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.java2
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegisry.java (renamed from codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CheckersRegisry.java)47
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanBuilder.java (renamed from codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/builder/CodanBuilder.java)61
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodeAnlysisNature.java (renamed from codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/builder/CodeAnlysisNature.java)2
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanMarkerProblemReporter.java (renamed from codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanProblemReporter.java)72
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblem.java (renamed from codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanProblem.java)45
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemCategory.java (renamed from codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanProblemCategory.java)6
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java2
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java17
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java13
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanCReconciler.java5
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/RunCodeAnalysis.java47
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/ToggleNatureAction.java8
28 files changed, 655 insertions, 121 deletions
diff --git a/codan/org.eclipse.cdt.codan.core/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.core/META-INF/MANIFEST.MF
index 5c061964f07..b77eb2ca230 100644
--- a/codan/org.eclipse.cdt.codan.core/META-INF/MANIFEST.MF
+++ b/codan/org.eclipse.cdt.codan.core/META-INF/MANIFEST.MF
@@ -11,5 +11,4 @@ Require-Bundle: org.eclipse.core.runtime,
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.eclipse.cdt.codan.core,
- org.eclipse.cdt.codan.core.builder,
org.eclipse.cdt.codan.core.model
diff --git a/codan/org.eclipse.cdt.codan.core/plugin.xml b/codan/org.eclipse.cdt.codan.core/plugin.xml
index 64d7402159f..b7b10a04e5f 100644
--- a/codan/org.eclipse.cdt.codan.core/plugin.xml
+++ b/codan/org.eclipse.cdt.codan.core/plugin.xml
@@ -10,7 +10,7 @@
<builder
hasNature="true">
<run
- class="org.eclipse.cdt.codan.core.builder.CodanBuilder">
+ class="org.eclipse.cdt.codan.internal.core.CodanBuilder">
</run>
</builder>
</extension>
@@ -20,7 +20,7 @@
point="org.eclipse.core.resources.natures">
<runtime>
<run
- class="org.eclipse.cdt.codan.core.builder.CodeAnlysisNature">
+ class="org.eclipse.cdt.codan.internal.core.CodeAnlysisNature">
</run>
</runtime>
<builder
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanApplication.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanApplication.java
index 5f04cb63c4f..e0287b10621 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanApplication.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanApplication.java
@@ -3,9 +3,8 @@ package org.eclipse.cdt.codan.core;
import java.util.ArrayList;
import java.util.Collection;
-import org.eclipse.cdt.codan.core.builder.CodanBuilder;
-import org.eclipse.cdt.codan.core.model.CodanProblemReporter;
-import org.eclipse.cdt.codan.core.model.CodanRuntime;
+import org.eclipse.cdt.codan.internal.core.CodanBuilder;
+import org.eclipse.cdt.codan.internal.core.model.CodanMarkerProblemReporter;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
@@ -28,10 +27,10 @@ public class CodanApplication implements IApplication {
extractArguments(args);
CodanBuilder codanBuilder = new CodanBuilder();
CodanRuntime runtime = CodanRuntime.getInstance();
- runtime.setProblemReporter(new CodanProblemReporter() {
+ runtime.setProblemReporter(new CodanMarkerProblemReporter() {
@Override
- public void reportProblem(String id, IFile file, int lineNumber,
- String message) {
+ public void reportProblem(String id, int severity, IFile file,
+ int lineNumber, int startChar, int endChar, String message) {
System.out.println(file.getLocation() + ":" + lineNumber + ": "
+ message);
}
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java
index 00b554abd86..d60262b419b 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java
@@ -1,5 +1,6 @@
package org.eclipse.cdt.codan.core;
+import org.eclipse.cdt.codan.internal.core.CodeAnlysisNature;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
@@ -13,6 +14,7 @@ import org.osgi.framework.BundleContext;
public class CodanCorePlugin extends Plugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.cdt.codan.core";
+ public static final String NATURE_ID = CodeAnlysisNature.NATURE_ID;
// The shared instance
private static CodanCorePlugin plugin;
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/builder/CodanPreferencesLoader.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanPreferencesLoader.java
index bf17ba3b362..6fd6318d8b3 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/builder/CodanPreferencesLoader.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanPreferencesLoader.java
@@ -8,12 +8,12 @@
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.codan.core.builder;
+package org.eclipse.cdt.codan.core;
-import org.eclipse.cdt.codan.core.model.CodanProblem;
import org.eclipse.cdt.codan.core.model.CodanSeverity;
import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.model.IProblemProfile;
+import org.eclipse.cdt.codan.internal.core.model.CodanProblem;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
/**
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanRuntime.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanRuntime.java
new file mode 100644
index 00000000000..16375cfe7d2
--- /dev/null
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanRuntime.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Alena Laskavaia
+ * 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.core;
+
+import org.eclipse.cdt.codan.core.model.ICheckersRegistry;
+import org.eclipse.cdt.codan.core.model.ICodanAstReconciler;
+import org.eclipse.cdt.codan.core.model.ICodanBuilder;
+import org.eclipse.cdt.codan.core.model.IProblemReporter;
+import org.eclipse.cdt.codan.internal.core.CheckersRegisry;
+import org.eclipse.cdt.codan.internal.core.CodanBuilder;
+import org.eclipse.cdt.codan.internal.core.model.CodanMarkerProblemReporter;
+
+/**
+ * Runtime singleton class to get access to Codan framework parts
+ *
+ */
+public class CodanRuntime {
+ private static CodanRuntime instance = new CodanRuntime();
+ private IProblemReporter problemReporter = new CodanMarkerProblemReporter();
+ private CodanBuilder builder = new CodanBuilder();
+ private CheckersRegisry checkers = CheckersRegisry.getInstance();
+
+ public IProblemReporter getProblemReporter() {
+ return problemReporter;
+ }
+
+ public void setProblemReporter(IProblemReporter reporter) {
+ problemReporter = reporter;
+ }
+
+ public static CodanRuntime getInstance() {
+ return instance;
+ }
+
+ public ICodanBuilder getBuilder() {
+ return builder;
+ }
+
+ public ICodanAstReconciler getAstQuickBuilder() {
+ return builder;
+ }
+
+ public ICheckersRegistry getChechersRegistry() {
+ return checkers;
+ }
+}
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java
index e0aa16437a7..3b6ac37a47d 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java
@@ -10,22 +10,54 @@
*******************************************************************************/
package org.eclipse.cdt.codan.core.model;
+import org.eclipse.cdt.codan.core.CodanRuntime;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
public abstract class AbstractChecker implements IChecker {
- String name;
+ protected String name;
public AbstractChecker() {
}
+ /**
+ * @return true if checker is enabled in context of resource, if returns false checker's "processResource"
+ * method won't be called
+ */
public boolean enabledInContext(IResource res) {
return true;
}
+ /**
+ * Reports a simple problem for given file and line
+ * @param id - problem id
+ * @param file - file
+ * @param lineNumber - line
+ * @param arg - problem argument, if problem does not define error message it will be error message
+ * (not recommended because of internationalization)
+ */
public void reportProblem(String id, IFile file, int lineNumber,
- String message) {
- CodanRuntime.getInstance().getProblemReporter().reportProblem(id, file,
- lineNumber, message);
+ String arg) {
+ getProblemReporter().reportProblem(id, new ProblemLocation(file,
+ lineNumber), arg);
+ }
+
+
+ /**
+ * Reports a simple problem for given file and line, error message comes from problem definition
+ * @param id - problem id
+ * @param file - file
+ * @param lineNumber - line
+ */
+ public void reportProblem(String id, IFile file, int lineNumber) {
+ getProblemReporter().reportProblem(id, new ProblemLocation(file,
+ lineNumber), new Object[]{});
+ }
+
+ /**
+ * @return problem reporter for given checker
+ */
+ protected IProblemReporter getProblemReporter() {
+ return CodanRuntime.getInstance().getProblemReporter();
}
}
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractIndexAstChecker.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractIndexAstChecker.java
index ee8c2925b43..998491bff78 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractIndexAstChecker.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractIndexAstChecker.java
@@ -79,13 +79,15 @@ public abstract class AbstractIndexAstChecker extends AbstractChecker implements
public void reportProblem(String id, IASTNode astNode, String message) {
IASTFileLocation astLocation = astNode.getFileLocation();
- IFile astFile = file;
+ IPath location = new Path(astLocation.getFileName());
+ IFile astFile = ResourcesPlugin.getWorkspace().getRoot()
+ .getFileForLocation(location);
if (astFile == null) {
- IPath location = new Path(astLocation.getFileName());
- astFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(location);
+ astFile = file;
}
-
- CodanRuntime.getInstance().getProblemReporter().reportProblem(id,
- astFile, astLocation.getStartingLineNumber(), message);
+ getProblemReporter().reportProblem(
+ id,
+ new ProblemLocation(astFile, astLocation
+ .getStartingLineNumber()), message);
}
}
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java
new file mode 100644
index 00000000000..052d868059d
--- /dev/null
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Alena Laskavaia
+ * 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.core.model;
+
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IResource;
+
+/**
+ * @author Alena
+ *
+ */
+public interface ICheckersRegistry {
+ public abstract Iterator<IChecker> iterator();
+
+ public abstract void addChecker(IChecker checker);
+
+ public abstract void addProblem(IProblem p, String category);
+
+ public abstract void addCategory(IProblemCategory p, String category);
+
+ public abstract void addRefProblem(IChecker c, IProblem p);
+
+ /**
+ * @return
+ */
+ public abstract IProblemProfile getDefaultProfile();
+
+ /**
+ * @return
+ */
+ public abstract IProblemProfile getWorkspaceProfile();
+
+ /**
+ * @param element
+ * @return
+ */
+ public abstract IProblemProfile getResourceProfile(IResource element);
+
+ /**
+ * @param element
+ * @return
+ */
+ public abstract IProblemProfile getResourceProfileWorkingCopy(
+ IResource element);
+
+ /**
+ * Set profile for resource. This method is called by UI, and should not be
+ * called by clients directly
+ *
+ * @param resource
+ * - resource
+ * @param profile
+ * - problems profile
+ */
+ public abstract void updateProfile(IResource resource,
+ IProblemProfile profile);
+} \ No newline at end of file
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanRuntime.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanAstReconciler.java
index d7b3be7462f..17bc8f70180 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanRuntime.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanAstReconciler.java
@@ -10,23 +10,13 @@
*******************************************************************************/
package org.eclipse.cdt.codan.core.model;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.core.runtime.IProgressMonitor;
+
/**
- * Runtime singleton class to get access to Codan framework parts
+ * @author Alena
*
*/
-public class CodanRuntime {
- private static CodanRuntime instance = new CodanRuntime();
- private CodanProblemReporter problemReporter = new CodanProblemReporter();
-
- public CodanProblemReporter getProblemReporter() {
- return problemReporter;
- }
-
- public void setProblemReporter(CodanProblemReporter reporter) {
- problemReporter = reporter;
- }
-
- public static CodanRuntime getInstance() {
- return instance;
- }
-}
+public interface ICodanAstReconciler {
+ public void reconcileAst(IASTTranslationUnit ast, IProgressMonitor monitor);
+} \ No newline at end of file
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanBuilder.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanBuilder.java
new file mode 100644
index 00000000000..ce1f66872c1
--- /dev/null
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanBuilder.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Alena Laskavaia
+ * 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.core.model;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * @author Alena
+ *
+ */
+public interface ICodanBuilder {
+ public void processResource(IResource resource, IProgressMonitor monitor);
+} \ No newline at end of file
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java
index 5f262a6dedc..52cfff26c20 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.codan.core.model;
+import java.util.Collection;
+
public interface IProblem extends IProblemElement {
String getName();
@@ -19,5 +21,17 @@ public interface IProblem extends IProblemElement {
CodanSeverity getSeverity();
- IProblemCategory getCategory();
+ String getMessagePattern();
+
+ void setSeverity(CodanSeverity sev);
+
+ void setEnabled(boolean checked);
+
+ void setMessagePattern(String message);
+
+ public void setProperty(Object key, Object value);
+
+ public Object getProperty(Object key);
+
+ public Collection<Object> getPropertyKeys();
}
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocation.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocation.java
new file mode 100644
index 00000000000..f5e4f23f275
--- /dev/null
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocation.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Alena Laskavaia
+ * 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.core.model;
+
+import org.eclipse.core.resources.IFile;
+
+/**
+ * Interface to describe problem location. Usually contains file and linenumber,
+ * also supports character positions for sophisticated errors.
+ *
+ */
+public interface IProblemLocation {
+ /**
+ *
+ * @return File for the problem - absolute full paths
+ */
+ IFile getFile();
+
+ /**
+ *
+ * @return Primary line for the problem, lines start with 1 for file. If -1
+ * char position would be used.
+ */
+ int getLineNumber();
+
+ /**
+ *
+ * @return character position where problem starts within file, first char
+ * is 0, inclusive, tab count as one. If unknown return -1.
+ */
+ int getStartingChar();
+
+ /**
+ *
+ * @return character position where problem ends within file, first char is
+ * 0, exclusive, tab count as one. If unknown return -1.
+ */
+ int getEndingChar();
+
+ /**
+ *
+ * @return extra data for problem location, checker specific, can be
+ * backtrace for example
+ */
+ Object getData();
+}
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java
new file mode 100644
index 00000000000..814cc40e086
--- /dev/null
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Alena Laskavaia
+ * 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.core.model;
+
+
+/**
+ * IProblemReporter - interface to report problems
+ *
+ */
+public interface IProblemReporter {
+ /**
+ * Report a problem with "problemId" id on location determined by "loc",
+ * using problem specific error message customised by args.
+ * @param problemId - id of the problem registers with checker
+ * @param loc - location object
+ * @param args - custom args, can be null, in this case default message is reported
+ */
+ public void reportProblem(String problemId, IProblemLocation loc,
+ Object ... args);
+} \ No newline at end of file
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemLocation.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemLocation.java
new file mode 100644
index 00000000000..ced12f0259a
--- /dev/null
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemLocation.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Alena Laskavaia
+ * 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.core.model;
+
+import org.eclipse.core.resources.IFile;
+
+/**
+ * Implementation of IProblemLocation
+ *
+ */
+public class ProblemLocation implements IProblemLocation {
+ protected IFile file;
+ protected int line;
+ protected int posStart;
+ protected int posEnd;
+ protected Object extra;
+
+ /**
+ * @param file
+ * @param line
+ * @param lineEnd
+ * @param posStart
+ * @param posEnd
+ */
+ public ProblemLocation(IFile file, int line) {
+ this.file = file;
+ this.line = line;
+ this.posStart = -1;
+ this.posEnd = -1;
+ }
+
+ /**
+ * @param file
+ * @param startingLineNumber
+ * @param endingLineNumber
+ */
+ public ProblemLocation(IFile file, int startChar, int endChar) {
+ this.file = file;
+ this.line = -1;
+ this.posStart = startChar;
+ this.posEnd = endChar;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.IProblemLocation#getData()
+ */
+ public Object getData() {
+ return extra;
+ }
+
+ public void setData(Object data) {
+ this.extra = data;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.IProblemLocation#getFile()
+ */
+ public IFile getFile() {
+ return file;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.IProblemLocation#getLine()
+ */
+ public int getLineNumber() {
+ return getStartingLineNumber();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.IProblemLocation#getStartLine()
+ */
+ public int getStartingLineNumber() {
+ return line;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.IProblemLocation#getStartPos()
+ */
+ public int getStartingChar() {
+ return posStart;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.IProblemLocation#getEndingChar()
+ */
+ public int getEndingChar() {
+ return posEnd;
+ }
+}
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.java
index 28f5ff4f8de..ae90e76c8d9 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.java
@@ -13,6 +13,8 @@ package org.eclipse.cdt.codan.core.model;
import java.util.ArrayList;
import java.util.Collection;
+import org.eclipse.cdt.codan.internal.core.model.CodanProblemCategory;
+
/**
* @author Alena
*
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CheckersRegisry.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegisry.java
index e2370c9d86c..82ace802583 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CheckersRegisry.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegisry.java
@@ -8,7 +8,7 @@
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.codan.core.model;
+package org.eclipse.cdt.codan.internal.core;
import java.util.ArrayList;
import java.util.Collection;
@@ -16,8 +16,16 @@ import java.util.HashMap;
import java.util.Iterator;
import org.eclipse.cdt.codan.core.CodanCorePlugin;
+import org.eclipse.cdt.codan.core.CodanPreferencesLoader;
import org.eclipse.cdt.codan.core.PreferenceConstants;
-import org.eclipse.cdt.codan.core.builder.CodanPreferencesLoader;
+import org.eclipse.cdt.codan.core.model.IChecker;
+import org.eclipse.cdt.codan.core.model.ICheckersRegistry;
+import org.eclipse.cdt.codan.core.model.IProblem;
+import org.eclipse.cdt.codan.core.model.IProblemCategory;
+import org.eclipse.cdt.codan.core.model.IProblemProfile;
+import org.eclipse.cdt.codan.core.model.ProblemProfile;
+import org.eclipse.cdt.codan.internal.core.model.CodanProblem;
+import org.eclipse.cdt.codan.internal.core.model.CodanProblemCategory;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ProjectScope;
@@ -28,7 +36,7 @@ import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-public class CheckersRegisry implements Iterable<IChecker> {
+public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
private static final String EXTENSION_POINT_NAME = "checkers";
private static final String CHECKER_ELEMENT = "checker";
private static final String PROBLEM_ELEMENT = "problem";
@@ -176,6 +184,9 @@ public class CheckersRegisry implements Iterable<IChecker> {
return elementValue;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#iterator()
+ */
public Iterator<IChecker> iterator() {
return checkers.iterator();
}
@@ -186,10 +197,16 @@ public class CheckersRegisry implements Iterable<IChecker> {
return instance;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#addChecker(org.eclipse.cdt.codan.core.model.IChecker)
+ */
public void addChecker(IChecker checker) {
checkers.add(checker);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#addProblem(org.eclipse.cdt.codan.core.model.IProblem, java.lang.String)
+ */
public void addProblem(IProblem p, String category) {
IProblemCategory cat = getDefaultProfile().findCategory(category);
if (cat == null)
@@ -197,6 +214,9 @@ public class CheckersRegisry implements Iterable<IChecker> {
((ProblemProfile) getDefaultProfile()).addProblem(p, cat);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#addCategory(org.eclipse.cdt.codan.core.model.IProblemCategory, java.lang.String)
+ */
public void addCategory(IProblemCategory p, String category) {
IProblemCategory cat = getDefaultProfile().findCategory(category);
if (cat == null)
@@ -204,18 +224,21 @@ public class CheckersRegisry implements Iterable<IChecker> {
((ProblemProfile) getDefaultProfile()).addCategory(p, cat);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#addRefProblem(org.eclipse.cdt.codan.core.model.IChecker, org.eclipse.cdt.codan.core.model.IProblem)
+ */
public void addRefProblem(IChecker c, IProblem p) {
}
- /**
- * @return
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#getDefaultProfile()
*/
public IProblemProfile getDefaultProfile() {
return profiles.get(DEFAULT);
}
- /**
- * @return
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#getWorkspaceProfile()
*/
public IProblemProfile getWorkspaceProfile() {
IProblemProfile wp = profiles.get(ResourcesPlugin.getWorkspace());
@@ -239,9 +262,8 @@ public class CheckersRegisry implements Iterable<IChecker> {
profiles.put(element, profile);
}
- /**
- * @param element
- * @return
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#getResourceProfile(org.eclipse.core.resources.IResource)
*/
public IProblemProfile getResourceProfile(IResource element) {
IProblemProfile prof = profiles.get(element);
@@ -274,9 +296,8 @@ public class CheckersRegisry implements Iterable<IChecker> {
return prof;
}
- /**
- * @param element
- * @return
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#getResourceProfileWorkingCopy(org.eclipse.core.resources.IResource)
*/
public IProblemProfile getResourceProfileWorkingCopy(IResource element) {
if (element instanceof IProject) {
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/builder/CodanBuilder.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanBuilder.java
index d12a8cf6652..434a0f0ef7b 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/builder/CodanBuilder.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanBuilder.java
@@ -8,17 +8,20 @@
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.codan.core.builder;
+package org.eclipse.cdt.codan.internal.core;
import java.io.File;
import java.net.URI;
import java.util.Map;
import org.eclipse.cdt.codan.core.CodanCorePlugin;
-import org.eclipse.cdt.codan.core.model.CheckersRegisry;
-import org.eclipse.cdt.codan.core.model.CodanRuntime;
+import org.eclipse.cdt.codan.core.CodanRuntime;
import org.eclipse.cdt.codan.core.model.ICAstChecker;
import org.eclipse.cdt.codan.core.model.IChecker;
+import org.eclipse.cdt.codan.core.model.ICodanAstReconciler;
+import org.eclipse.cdt.codan.core.model.ICodanBuilder;
+import org.eclipse.cdt.codan.core.model.IProblemReporter;
+import org.eclipse.cdt.codan.internal.core.model.CodanMarkerProblemReporter;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -32,8 +35,10 @@ import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
-public class CodanBuilder extends IncrementalProjectBuilder {
+public class CodanBuilder extends IncrementalProjectBuilder implements
+ ICodanBuilder, ICodanAstReconciler {
public static final String BUILDER_ID = "org.eclipse.cdt.codan.core.codanBuilder";
public class CodanDeltaVisitor implements IResourceDeltaVisitor {
@@ -44,19 +49,26 @@ public class CodanBuilder extends IncrementalProjectBuilder {
* org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse
* .core.resources.IResourceDelta)
*/
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.cdt.codan.internal.core.ICodanBuilder#visit(org.eclipse
+ * .core.resources.IResourceDelta)
+ */
public boolean visit(IResourceDelta delta) throws CoreException {
IResource resource = delta.getResource();
switch (delta.getKind()) {
case IResourceDelta.ADDED:
// handle added resource
- processResource(resource);
+ processResource(resource, new NullProgressMonitor());
break;
case IResourceDelta.REMOVED:
// handle removed resource
break;
case IResourceDelta.CHANGED:
// handle changed resource
- processResource(resource);
+ processResource(resource, new NullProgressMonitor());
break;
}
// return true to continue visiting children.
@@ -66,7 +78,8 @@ public class CodanBuilder extends IncrementalProjectBuilder {
public class CodanResourceVisitor implements IResourceVisitor {
public boolean visit(IResource resource) {
- processResource(resource);
+ if (!(resource instanceof IProject))
+ processResource(resource, new NullProgressMonitor());
// return true to continue visiting children.
return true;
}
@@ -93,12 +106,17 @@ public class CodanBuilder extends IncrementalProjectBuilder {
return null;
}
- public void processResource(IResource resource) {
+ public void processResource(IResource resource, IProgressMonitor monitor) {
// String string = Platform.getPreferencesService().getString(
// CodanCorePlugin.PLUGIN_ID, "problems", "", null);
// System.err.println("set = " + string);
// delete general markers
- CodanRuntime.getInstance().getProblemReporter().deleteMarkers(resource);
+ IProblemReporter problemReporter = CodanRuntime.getInstance()
+ .getProblemReporter();
+ if (problemReporter instanceof CodanMarkerProblemReporter) {
+ ((CodanMarkerProblemReporter) problemReporter)
+ .deleteMarkers(resource);
+ }
for (IChecker checker : CheckersRegisry.getInstance()) {
try {
boolean run = false;
@@ -110,12 +128,18 @@ public class CodanBuilder extends IncrementalProjectBuilder {
CodanCorePlugin.log(e);
}
}
+ if (resource instanceof IProject) {
+ try {
+ resource.accept(getResourceVisitor());
+ } catch (CoreException e) {
+ CodanCorePlugin.log(e);
+ }
+ }
}
public void reconcileAst(IASTTranslationUnit ast, IProgressMonitor monitor) {
if (ast == null)
return;
-
String filePath = ast.getFilePath();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
@@ -124,8 +148,12 @@ public class CodanBuilder extends IncrementalProjectBuilder {
resources = root.findFilesForLocationURI(uri);
if (resources != null && resources.length > 0) {
IFile resource = resources[0];
- CodanRuntime.getInstance().getProblemReporter().deleteMarkers(
- resource);
+ IProblemReporter problemReporter = CodanRuntime.getInstance()
+ .getProblemReporter();
+ if (problemReporter instanceof CodanMarkerProblemReporter) {
+ ((CodanMarkerProblemReporter) problemReporter)
+ .deleteMarkers(resource);
+ }
for (IChecker checker : CheckersRegisry.getInstance()) {
try {
boolean run = false;
@@ -153,4 +181,13 @@ public class CodanBuilder extends IncrementalProjectBuilder {
// the visitor does the work.
delta.accept(new CodanDeltaVisitor());
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.ICodanBuilder#getResourceVisitor()
+ */
+ public CodanResourceVisitor getResourceVisitor() {
+ return new CodanResourceVisitor();
+ }
}
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/builder/CodeAnlysisNature.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodeAnlysisNature.java
index 4f06e716c36..5157e163eb5 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/builder/CodeAnlysisNature.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodeAnlysisNature.java
@@ -8,7 +8,7 @@
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.codan.core.builder;
+package org.eclipse.cdt.codan.internal.core;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanProblemReporter.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanMarkerProblemReporter.java
index 84dffad37d9..ebf00c94111 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanProblemReporter.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanMarkerProblemReporter.java
@@ -8,31 +8,67 @@
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.codan.core.model;
+package org.eclipse.cdt.codan.internal.core.model;
+import java.text.MessageFormat;
+
+import org.eclipse.cdt.codan.core.model.IProblem;
+import org.eclipse.cdt.codan.core.model.IProblemLocation;
+import org.eclipse.cdt.codan.core.model.IProblemReporter;
+import org.eclipse.cdt.codan.internal.core.CheckersRegisry;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-public class CodanProblemReporter {
+public class CodanMarkerProblemReporter implements IProblemReporter {
public static final String GENERIC_CODE_ANALYSIS_MARKER_TYPE = "org.eclipse.cdt.codan.core.codanProblem";
- public void reportProblem(String id, IFile file, int lineNumber,
- String message) {
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.cdt.codan.core.model.IProblemReporter#reportProblem(java.
+ * lang.String, org.eclipse.cdt.codan.core.model.IProblemLocation,
+ * java.lang.Object[])
+ */
+ public void reportProblem(String id, IProblemLocation loc, Object... args) {
+ IFile file = loc.getFile();
+ int lineNumber = loc.getLineNumber();
+ if (file == null)
+ throw new NullPointerException("file");
+ if (id == null)
+ throw new NullPointerException("id");
+ IProblem problem = CheckersRegisry.getInstance().getResourceProfile(
+ file).findProblem(id);
+ if (problem == null)
+ throw new IllegalArgumentException("Id is not registered");
+ if (problem.isEnabled() == false)
+ return; // skip
+ int severity = problem.getSeverity().intValue();
+ String messagePattern = problem.getMessagePattern();
+ String message = id;
+ if (messagePattern == null) {
+ if (args != null && args.length > 0 && args[0] instanceof String)
+ message = (String) args[0];
+ } else {
+ MessageFormat.format(messagePattern, args);
+ }
+ reportProblem(id, severity, file, lineNumber, loc.getStartingChar(),
+ loc.getEndingChar(), message);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.cdt.codan.core.model.IProblemReporter#reportProblem(java.
+ * lang.String, org.eclipse.core.resources.IFile, int, java.lang.String)
+ */
+ public void reportProblem(String id, int severity, IFile file,
+ int lineNumber, int startChar, int endChar, String message) {
try {
- if (file == null)
- throw new NullPointerException("file");
- if (id == null)
- throw new NullPointerException("id");
- IProblem problem = CheckersRegisry.getInstance()
- .getResourceProfile(file).findProblem(id);
- if (problem == null)
- throw new IllegalArgumentException("Id is not registered");
- if (problem.isEnabled() == false)
- return; // skip
- int severity = problem.getSeverity().intValue();
// Do not put in duplicates
IMarker[] cur = file.findMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE,
false, IResource.DEPTH_ZERO);
@@ -54,10 +90,10 @@ public class CodanProblemReporter {
.createMarker(GENERIC_CODE_ANALYSIS_MARKER_TYPE);
marker.setAttribute(IMarker.MESSAGE, message);
marker.setAttribute(IMarker.SEVERITY, severity);
- if (lineNumber == -1) {
- lineNumber = 1;
- }
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
+ marker.setAttribute(IMarker.PROBLEM, id);
+ marker.setAttribute(IMarker.CHAR_END, endChar);
+ marker.setAttribute(IMarker.CHAR_START, startChar);
} catch (CoreException e) {
e.printStackTrace();
}
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanProblem.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblem.java
index b83ab1509d6..a094cc1a3c0 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanProblem.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblem.java
@@ -8,21 +8,30 @@
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.codan.core.model;
+package org.eclipse.cdt.codan.internal.core.model;
+
+import java.util.Collection;
+import java.util.HashMap;
+
+import org.eclipse.cdt.codan.core.model.CodanSeverity;
+import org.eclipse.cdt.codan.core.model.IProblem;
+import org.eclipse.cdt.codan.core.model.IProblemCategory;
public class CodanProblem implements IProblem {
private String id;
private String name;
+ private String message;
private CodanSeverity severity = CodanSeverity.Warning;
private boolean enabled = true;
+ private HashMap<Object, Object> properties = new HashMap<Object, Object>(0);
public CodanSeverity getSeverity() {
return severity;
}
- public CodanProblem(String id2, String name2) {
- this.id = id2;
- this.name = name2;
+ public CodanProblem(String problemId, String name) {
+ this.id = problemId;
+ this.name = name;
}
public String getName() {
@@ -66,4 +75,32 @@ public class CodanProblem implements IProblem {
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
+
+ public void setProperty(Object key, Object value) {
+ properties.put(key, value);
+ }
+
+ public Object getProperty(Object key) {
+ return properties.get(key);
+ };
+
+ public Collection<Object> getPropertyKeys() {
+ return properties.keySet();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.IProblem#getMessagePattern()
+ */
+ public String getMessagePattern() {
+ return message;
+ }
+
+ /**
+ * @param message the message to set
+ */
+ public void setMessagePattern(String message) {
+ this.message = message;
+ }
}
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanProblemCategory.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemCategory.java
index efc320476c8..289e0fdec02 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanProblemCategory.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemCategory.java
@@ -8,11 +8,15 @@
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.codan.core.model;
+package org.eclipse.cdt.codan.internal.core.model;
import java.util.ArrayList;
import java.util.Iterator;
+import org.eclipse.cdt.codan.core.model.IProblem;
+import org.eclipse.cdt.codan.core.model.IProblemCategory;
+import org.eclipse.cdt.codan.core.model.IProblemElement;
+
public class CodanProblemCategory implements IProblemCategory, Cloneable {
private String id;
private String name;
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java
index 2f2a2de473d..95f7ff67e79 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java
@@ -55,7 +55,7 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements
// "Confirmation",
// "Do you want to remove existing problems? If build is disabled they won't be updated anymore.");
// if (openQuestion == true) {
- // CodanProblemReporter.deleteAllMarkers();
+ // CodanMarkerProblemReporter.deleteAllMarkers();
// }
// }
return true;
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java
index 412b6f06a6c..35b9a8f733d 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java
@@ -11,7 +11,8 @@
package org.eclipse.cdt.codan.internal.ui.preferences;
import org.eclipse.cdt.codan.core.CodanCorePlugin;
-import org.eclipse.cdt.codan.core.model.CheckersRegisry;
+import org.eclipse.cdt.codan.core.CodanRuntime;
+import org.eclipse.cdt.codan.core.model.ICheckersRegistry;
import org.eclipse.cdt.codan.core.model.IProblemProfile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.preferences.InstanceScope;
@@ -50,14 +51,21 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements
* editor knows how to save and restore itself.
*/
public void createFieldEditors() {
- profile = isPropertyPage() ? CheckersRegisry.getInstance()
+ profile = isPropertyPage() ? getRegistry()
.getResourceProfileWorkingCopy((IResource) getElement())
- : CheckersRegisry.getInstance().getWorkspaceProfile();
+ : getRegistry().getWorkspaceProfile();
CheckedTreeEditor checkedTreeEditor = new ProblemsTreeEditor(
getFieldEditorParent(), profile);
addField(checkedTreeEditor);
}
+ /**
+ * @return
+ */
+ protected ICheckersRegistry getRegistry() {
+ return CodanRuntime.getInstance().getChechersRegistry();
+ }
+
/*
* (non-Javadoc)
*
@@ -66,8 +74,7 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements
@Override
public boolean performOk() {
if (isPropertyPage())
- CheckersRegisry.getInstance().updateProfile(
- (IResource) getElement(), null);
+ getRegistry().updateProfile((IResource) getElement(), null);
return super.performOk();
}
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java
index 10f6a6d788e..6ba82c63e36 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java
@@ -10,9 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.codan.internal.ui.preferences;
+import org.eclipse.cdt.codan.core.CodanPreferencesLoader;
import org.eclipse.cdt.codan.core.PreferenceConstants;
-import org.eclipse.cdt.codan.core.builder.CodanPreferencesLoader;
-import org.eclipse.cdt.codan.core.model.CodanProblem;
import org.eclipse.cdt.codan.core.model.CodanSeverity;
import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.model.IProblemCategory;
@@ -139,8 +138,8 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
public void checkStateChanged(CheckStateChangedEvent event) {
Object element = event.getElement();
- if (element instanceof CodanProblem) {
- ((CodanProblem) element).setEnabled(event.getChecked());
+ if (element instanceof IProblem) {
+ ((IProblem) element).setEnabled(event.getChecked());
}
}
@@ -209,7 +208,7 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
});
column2.setEditingSupport(new EditingSupport(getTreeViewer()) {
protected boolean canEdit(Object element) {
- return element instanceof CodanProblem;
+ return element instanceof IProblem;
}
protected CellEditor getCellEditor(Object element) {
@@ -218,13 +217,13 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
}
protected Object getValue(Object element) {
- return ((CodanProblem) element).getSeverity().intValue();
+ return ((IProblem) element).getSeverity().intValue();
}
protected void setValue(Object element, Object value) {
int index = ((Integer) value).intValue();
CodanSeverity val = CodanSeverity.values()[index];
- ((CodanProblem) element).setSeverity(val);
+ ((IProblem) element).setSeverity(val);
getTreeViewer().update(element, null);
}
});
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanCReconciler.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanCReconciler.java
index 82fefee09a7..5bec1c101ba 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanCReconciler.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanCReconciler.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.codan.ui;
-import org.eclipse.cdt.codan.core.builder.CodanBuilder;
+import org.eclipse.cdt.codan.core.CodanRuntime;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
@@ -64,7 +64,8 @@ public class CodanCReconciler implements ICReconcilingListener {
*/
public void reconciled(IASTTranslationUnit ast, boolean force,
IProgressMonitor progressMonitor) {
- new CodanBuilder().reconcileAst(ast, progressMonitor);
+ CodanRuntime.getInstance().getAstQuickBuilder().reconcileAst(ast,
+ progressMonitor);
// System.err.println("ast reconsiled");
}
}
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/RunCodeAnalysis.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/RunCodeAnalysis.java
index 39f52b6e0ce..01d7c25bdb1 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/RunCodeAnalysis.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/RunCodeAnalysis.java
@@ -12,9 +12,13 @@ package org.eclipse.cdt.codan.ui.actions;
import java.util.Iterator;
-import org.eclipse.cdt.codan.core.builder.CodanBuilder;
+import org.eclipse.cdt.codan.core.CodanRuntime;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -25,23 +29,38 @@ public class RunCodeAnalysis implements IObjectActionDelegate {
private ISelection sel;
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- // TODO Auto-generated method stub
+ // nothing
}
public void run(IAction action) {
- for (Iterator iterator = ((IStructuredSelection) sel).iterator(); iterator
- .hasNext();) {
- Object o = iterator.next();
- if (o instanceof IResource) {
- IResource res = (IResource) o;
- try {
- res.accept(new CodanBuilder().new CodanResourceVisitor());
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Job job = new Job("Running Code Analysis") {
+ @SuppressWarnings("unchecked")
+ @Override
+ protected IStatus run(final IProgressMonitor monitor) {
+ IStructuredSelection ss = (IStructuredSelection) sel;
+ int count = ss.size();
+ monitor.beginTask(getName(), count * 100);
+ if (monitor.isCanceled())
+ return Status.CANCEL_STATUS;
+ for (Iterator iterator = ss.iterator(); iterator.hasNext();) {
+ Object o = iterator.next();
+ if (o instanceof IResource) {
+ IResource res = (IResource) o;
+ SubProgressMonitor subMon = new SubProgressMonitor(
+ monitor, 100);
+ CodanRuntime.getInstance().getBuilder()
+ .processResource(res, subMon);
+ if (subMon.isCanceled())
+ return Status.CANCEL_STATUS;
+ }
+ if (monitor.isCanceled())
+ return Status.CANCEL_STATUS;
}
+ return Status.OK_STATUS;
}
- }
+ };
+ job.setUser(true);
+ job.schedule();
}
public void selectionChanged(IAction action, ISelection selection) {
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/ToggleNatureAction.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/ToggleNatureAction.java
index efc9f756cc6..3993621c33b 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/ToggleNatureAction.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/ToggleNatureAction.java
@@ -12,7 +12,7 @@ package org.eclipse.cdt.codan.ui.actions;
import java.util.Iterator;
-import org.eclipse.cdt.codan.core.builder.CodeAnlysisNature;
+import org.eclipse.cdt.codan.core.CodanCorePlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
@@ -77,7 +77,7 @@ public class ToggleNatureAction implements IObjectActionDelegate {
description = project.getDescription();
String[] natures = description.getNatureIds();
for (int i = 0; i < natures.length; ++i) {
- if (CodeAnlysisNature.NATURE_ID.equals(natures[i])) {
+ if (CodanCorePlugin.NATURE_ID.equals(natures[i])) {
return true;
}
}
@@ -99,7 +99,7 @@ public class ToggleNatureAction implements IObjectActionDelegate {
IProjectDescription description = project.getDescription();
String[] natures = description.getNatureIds();
for (int i = 0; i < natures.length; ++i) {
- if (CodeAnlysisNature.NATURE_ID.equals(natures[i])) {
+ if (CodanCorePlugin.NATURE_ID.equals(natures[i])) {
if (add == false) {
// Remove the nature
String[] newNatures = new String[natures.length - 1];
@@ -120,7 +120,7 @@ public class ToggleNatureAction implements IObjectActionDelegate {
// Add the nature
String[] newNatures = new String[natures.length + 1];
System.arraycopy(natures, 0, newNatures, 0, natures.length);
- newNatures[natures.length] = CodeAnlysisNature.NATURE_ID;
+ newNatures[natures.length] = CodanCorePlugin.NATURE_ID;
description.setNatureIds(newNatures);
project.setDescription(description, null);
}

Back to the top