The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at http://www.eclipse.org/legal/epl-v10.html.
+For purposes of the EPL, "Program" will mean the Content.
+
+
If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at http://www.eclipse.org.
+
+
\ No newline at end of file
diff --git a/org.eclipse.cdt.codan.checkers.ui/build.properties b/org.eclipse.cdt.codan.checkers.ui/build.properties
index 34d2e4d..106258a 100644
--- a/org.eclipse.cdt.codan.checkers.ui/build.properties
+++ b/org.eclipse.cdt.codan.checkers.ui/build.properties
@@ -1,4 +1,18 @@
+###############################################################################
+# Copyright (c) 2009, 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
+###############################################################################
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
- .
+ .,\
+ plugin.xml,\
+ OSGI-INF/l10n/bundle.properties,\
+ about.html
+
diff --git a/org.eclipse.cdt.codan.checkers.ui/plugin.xml b/org.eclipse.cdt.codan.checkers.ui/plugin.xml
index 783ff1d..7052603 100644
--- a/org.eclipse.cdt.codan.checkers.ui/plugin.xml
+++ b/org.eclipse.cdt.codan.checkers.ui/plugin.xml
@@ -1,11 +1,22 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/CVS/Tag b/org.eclipse.cdt.codan.checkers.ui/src/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/CVS/Tag b/org.eclipse.cdt.codan.checkers.ui/src/org/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/CVS/Tag b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/CVS/Tag b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Entries
index 513604d..97de449 100644
--- a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Entries
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Entries
@@ -1 +1,2 @@
D/checkers////
+D/internal////
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Tag b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Entries
deleted file mode 100644
index 7f0205c..0000000
--- a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Entries
+++ /dev/null
@@ -1 +0,0 @@
-D/ui////
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Repository
deleted file mode 100644
index 24fc549..0000000
--- a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Root
deleted file mode 100644
index 04efa23..0000000
--- a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Template
deleted file mode 100644
index e69de29..0000000
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Entries
deleted file mode 100644
index fc31844..0000000
--- a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Entries
+++ /dev/null
@@ -1,2 +0,0 @@
-/CheckersUiActivator.java/1.1/Sat Apr 18 02:11:07 2009//
-D/quickfix////
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Repository
deleted file mode 100644
index 25cd7cf..0000000
--- a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Root
deleted file mode 100644
index 04efa23..0000000
--- a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Template
deleted file mode 100644
index e69de29..0000000
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CheckersUiActivator.java b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CheckersUiActivator.java
deleted file mode 100644
index 1635684..0000000
--- a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CheckersUiActivator.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.eclipse.cdt.codan.checkers.ui;
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class CheckersUiActivator extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.cdt.codan.checkers.ui";
-
- // The shared instance
- private static CheckersUiActivator plugin;
-
- /**
- * The constructor
- */
- public CheckersUiActivator() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static CheckersUiActivator getDefault() {
- return plugin;
- }
-
-}
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Entries
deleted file mode 100644
index 641ef34..0000000
--- a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Entries
+++ /dev/null
@@ -1,2 +0,0 @@
-/CodanProblemMarkerResolutionGenerator.java/1.2/Tue Apr 21 00:36:20 2009//
-/QuickFixAssignmentInCondition.java/1.1/Sat Apr 18 02:11:07 2009//
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Repository
deleted file mode 100644
index 3bdd833..0000000
--- a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Root
deleted file mode 100644
index 04efa23..0000000
--- a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Template
deleted file mode 100644
index e69de29..0000000
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CodanProblemMarkerResolutionGenerator.java b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CodanProblemMarkerResolutionGenerator.java
deleted file mode 100644
index 1470e7f..0000000
--- a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CodanProblemMarkerResolutionGenerator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Andrew Gvozdev
- * 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:
- * Andrew Gvozdev - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.codan.checkers.ui.quickfix;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.ui.IMarkerResolution;
-import org.eclipse.ui.IMarkerResolutionGenerator;
-
-public class CodanProblemMarkerResolutionGenerator implements IMarkerResolutionGenerator {
- public IMarkerResolution[] getResolutions(IMarker marker) {
- final Pattern patternBuildDependsAdd = Pattern.compile("Possible assignment in condition.*");
- String description = marker.getAttribute(IMarker.MESSAGE, "no message");
- Matcher matcherBuildDependsAdd = patternBuildDependsAdd.matcher(description);
- if (matcherBuildDependsAdd.matches()) {
- return new IMarkerResolution[] { new QuickFixAssignmentInCondition() };
- }
- return new IMarkerResolution[0];
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/QuickFixAssignmentInCondition.java b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/QuickFixAssignmentInCondition.java
deleted file mode 100644
index 5c28d53..0000000
--- a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/QuickFixAssignmentInCondition.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Andrew Gvozdev
- * 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:
- * Andrew Gvozdev - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.codan.checkers.ui.quickfix;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.FindReplaceDocumentAdapter;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IMarkerResolution;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-public class QuickFixAssignmentInCondition implements IMarkerResolution {
- public String getLabel() {
- return "Change to '=='";
- }
-
- public void run(IMarker marker) {
- // See if there is an open editor on the file containing the marker
- IWorkbenchWindow w = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow();
- if (w == null) {
- return;
- }
- IWorkbenchPage page = w.getActivePage();
- if (page == null) {
- return;
- }
- IFileEditorInput input = new FileEditorInput((IFile) marker
- .getResource());
- IEditorPart editorPart = page.findEditor(input);
- if (editorPart == null) {
- // open an editor
- try {
- editorPart = IDE.openEditor(page, (IFile) marker.getResource(),
- true);
- } catch (PartInitException e) {
- e.printStackTrace();
- }
- }
- if (editorPart == null) {
- return;
- }
- if (editorPart instanceof ITextEditor) {
- ITextEditor editor = (ITextEditor) editorPart;
- IDocument doc = editor.getDocumentProvider().getDocument(
- editor.getEditorInput());
- int line = marker.getAttribute(IMarker.LINE_NUMBER, -1) - 1;
- FindReplaceDocumentAdapter dad = new FindReplaceDocumentAdapter(doc);
- try {
- dad.find(doc.getLineOffset(line), "=", /* forwardSearch */
- true, /* caseSensitive */false,
- /* wholeWord */false, /* regExSearch */false);
- dad.replace("==", /* regExReplace */false);
- marker.delete();
- } catch (BadLocationException e) {
- // TODO: log the error
- e.printStackTrace();
- } catch (CoreException e) {
- // TODO: log the error
- e.printStackTrace();
- }
- }
- }
-}
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Entries
new file mode 100644
index 0000000..513604d
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Entries
@@ -0,0 +1 @@
+D/checkers////
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Repository
new file mode 100644
index 0000000..65b8627
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Tag b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/CVS/Template
new file mode 100644
index 0000000..e69de29
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Entries
new file mode 100644
index 0000000..7f0205c
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Entries
@@ -0,0 +1 @@
+D/ui////
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Repository
new file mode 100644
index 0000000..f36ddb5
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Tag b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/CVS/Template
new file mode 100644
index 0000000..e69de29
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Entries
new file mode 100644
index 0000000..38f32cc
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Entries
@@ -0,0 +1,4 @@
+/CheckersUiActivator.java/1.4/Sun Jun 27 01:30:39 2010//TCDT_7_0_0
+/Messages.java/1.2/Sun May 2 02:31:03 2010//TCDT_7_0_0
+/messages.properties/1.3/Thu Jun 3 17:01:30 2010//TCDT_7_0_0
+D/quickfix////
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Repository
new file mode 100644
index 0000000..afa2081
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Tag b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CVS/Template
new file mode 100644
index 0000000..e69de29
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CheckersUiActivator.java b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CheckersUiActivator.java
new file mode 100644
index 0000000..7a3d418
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CheckersUiActivator.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * 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.internal.checkers.ui;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class CheckersUiActivator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.cdt.codan.checkers.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static CheckersUiActivator plugin;
+
+ /**
+ * The constructor
+ */
+ public CheckersUiActivator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static CheckersUiActivator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Logs the specified status with this plug-in's log.
+ *
+ * @param status
+ * status to log
+ */
+ public static void log(IStatus status) {
+ getDefault().getLog().log(status);
+ }
+
+ /**
+ * Logs an internal error with the specified throwable
+ *
+ * @param e
+ * the exception to be logged
+ */
+ public static void log(Throwable e) {
+ log(new Status(IStatus.ERROR, PLUGIN_ID, 1, "Internal Error", e)); //$NON-NLS-1$
+ }
+
+ /**
+ * Logs an internal error with the specified message.
+ *
+ * @param message
+ * the error message to log
+ */
+ public static void log(String message) {
+ log(new Status(IStatus.ERROR, PLUGIN_ID, 1, message, null));
+ }
+
+}
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/Messages.java b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/Messages.java
new file mode 100644
index 0000000..525de8a
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/Messages.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2009,2010 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.internal.checkers.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * TODO: add description
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.codan.internal.checkers.ui.messages"; //$NON-NLS-1$
+ public static String CatchByReferenceQuickFix_Message;
+ public static String QuickFixAssignmentInCondition_Message;
+ public static String SuggestedParenthesisQuickFix_Message;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/messages.properties b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/messages.properties
new file mode 100644
index 0000000..da262e0
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/messages.properties
@@ -0,0 +1,13 @@
+###############################################################################
+# 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
+###############################################################################
+CatchByReferenceQuickFix_Message=Change to use '&'
+QuickFixAssignmentInCondition_Message=Change to '=='
+SuggestedParenthesisQuickFix_Message=Surround with '()'
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Entries
new file mode 100644
index 0000000..e7497b1
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Entries
@@ -0,0 +1,3 @@
+/CatchByReferenceQuickFix.java/1.2/Sun May 2 01:47:22 2010//TCDT_7_0_0
+/QuickFixAssignmentInCondition.java/1.5/Sun Jun 27 01:30:39 2010//TCDT_7_0_0
+/SuggestedParenthesisQuickFix.java/1.2/Thu Jun 3 17:01:30 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Repository b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Repository
new file mode 100644
index 0000000..f74bc94
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Root b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Tag b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CVS/Template
new file mode 100644
index 0000000..e69de29
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByReferenceQuickFix.java b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByReferenceQuickFix.java
new file mode 100644
index 0000000..68c3884
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByReferenceQuickFix.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.internal.checkers.ui.quickfix;
+
+import org.eclipse.cdt.codan.internal.checkers.ui.CheckersUiActivator;
+import org.eclipse.cdt.codan.internal.checkers.ui.Messages;
+import org.eclipse.cdt.codan.ui.AbstarctCodanCMarkerResolution;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.FindReplaceDocumentAdapter;
+import org.eclipse.jface.text.IDocument;
+
+/**
+ * quick fix for catch by value
+ */
+public class CatchByReferenceQuickFix extends AbstarctCodanCMarkerResolution {
+ public String getLabel() {
+ return Messages.CatchByReferenceQuickFix_Message;
+ }
+
+ public void apply(IMarker marker, IDocument document) {
+ FindReplaceDocumentAdapter dad = new FindReplaceDocumentAdapter(
+ document);
+ try {
+ int pos = getOffset(marker, document);
+ dad.find(pos, " ", /* forwardSearch *///$NON-NLS-1$
+ true, /* caseSensitive */false,
+ /* wholeWord */false, /* regExSearch */false);
+ dad.replace(" & ", /* regExReplace */false); //$NON-NLS-1$
+ } catch (BadLocationException e) {
+ CheckersUiActivator.log(e);
+ }
+ }
+}
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixAssignmentInCondition.java b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixAssignmentInCondition.java
new file mode 100644
index 0000000..4e64cd1
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixAssignmentInCondition.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Andrew Gvozdev
+ * 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:
+ * Andrew Gvozdev - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.codan.internal.checkers.ui.quickfix;
+
+import org.eclipse.cdt.codan.internal.checkers.ui.CheckersUiActivator;
+import org.eclipse.cdt.codan.internal.checkers.ui.Messages;
+import org.eclipse.cdt.codan.ui.AbstarctCodanCMarkerResolution;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.FindReplaceDocumentAdapter;
+import org.eclipse.jface.text.IDocument;
+
+/**
+ * quick fix for assignment in condition
+ */
+public class QuickFixAssignmentInCondition extends
+ AbstarctCodanCMarkerResolution {
+ public String getLabel() {
+ return Messages.QuickFixAssignmentInCondition_Message;
+ }
+
+
+ @Override
+ public void apply(IMarker marker, IDocument document) {
+ int pos = getOffset(marker, document);
+ try {
+ FindReplaceDocumentAdapter dad = new FindReplaceDocumentAdapter(
+ document);
+ dad.find(pos, "=", /* forwardSearch *///$NON-NLS-1$
+ true, /* caseSensitive */false,
+ /* wholeWord */false, /* regExSearch */false);
+ dad.replace("==", /* regExReplace */false); //$NON-NLS-1$
+ } catch (BadLocationException e) {
+ CheckersUiActivator.log(e);
+ }
+ }
+}
diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/SuggestedParenthesisQuickFix.java b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/SuggestedParenthesisQuickFix.java
new file mode 100644
index 0000000..977d7a7
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/SuggestedParenthesisQuickFix.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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.internal.checkers.ui.quickfix;
+
+import org.eclipse.cdt.codan.internal.checkers.ui.CheckersUiActivator;
+import org.eclipse.cdt.codan.internal.checkers.ui.Messages;
+import org.eclipse.cdt.codan.ui.AbstarctCodanCMarkerResolution;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+
+public class SuggestedParenthesisQuickFix extends
+ AbstarctCodanCMarkerResolution {
+ public String getLabel() {
+ return Messages.SuggestedParenthesisQuickFix_Message;
+ }
+
+ @Override
+ public boolean isApplicable(IMarker marker) {
+ int charEnd = marker.getAttribute(IMarker.CHAR_END, -1);
+ if (charEnd == -1)
+ return false;
+ return true;
+ }
+
+ @Override
+ public void apply(IMarker marker, IDocument document) {
+ int charStart = marker.getAttribute(IMarker.CHAR_START, -1);
+ int charEnd = marker.getAttribute(IMarker.CHAR_END, -1);
+ if (charEnd == -1)
+ return;
+ try {
+ document.replace(charStart, 0, "("); //$NON-NLS-1$
+ document.replace(charEnd+1, 0, ")"); //$NON-NLS-1$
+ } catch (BadLocationException e) {
+ CheckersUiActivator.log(e);
+ }
+ }
+}
diff --git a/org.eclipse.cdt.codan.checkers/.project b/org.eclipse.cdt.codan.checkers/.project
index 6b76138..c99d7bb 100644
--- a/org.eclipse.cdt.codan.checkers/.project
+++ b/org.eclipse.cdt.codan.checkers/.project
@@ -20,9 +20,15 @@
+
+ org.eclipse.pde.api.tools.apiAnalysisBuilder
+
+
+ org.eclipse.pde.PluginNatureorg.eclipse.jdt.core.javanature
+ org.eclipse.pde.api.tools.apiAnalysisNature
diff --git a/org.eclipse.cdt.codan.checkers/.settings/CVS/Entries b/org.eclipse.cdt.codan.checkers/.settings/CVS/Entries
index c7206e9..d9b5490 100644
--- a/org.eclipse.cdt.codan.checkers/.settings/CVS/Entries
+++ b/org.eclipse.cdt.codan.checkers/.settings/CVS/Entries
@@ -1 +1 @@
-/org.eclipse.jdt.core.prefs/1.2/Tue Jun 2 21:11:37 2009//
+/org.eclipse.jdt.core.prefs/1.3/Wed Mar 24 03:31:58 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers/.settings/CVS/Tag b/org.eclipse.cdt.codan.checkers/.settings/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/.settings/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.cdt.codan.checkers/.settings/org.eclipse.jdt.core.prefs
index bd2d10b..58392e2 100644
--- a/org.eclipse.cdt.codan.checkers/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.cdt.codan.checkers/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Tue Jun 02 17:10:46 EDT 2009
+#Wed Mar 17 23:31:06 EDT 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
@@ -7,6 +7,69 @@ org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+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=enabled
+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=warning
+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=warning
+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.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=ignore
+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=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+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.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/org.eclipse.cdt.codan.checkers/CVS/Entries b/org.eclipse.cdt.codan.checkers/CVS/Entries
index f0bd9f5..5d283e5 100644
--- a/org.eclipse.cdt.codan.checkers/CVS/Entries
+++ b/org.eclipse.cdt.codan.checkers/CVS/Entries
@@ -1,7 +1,9 @@
-/.classpath/1.3/Wed Dec 16 21:48:51 2009//
-/.project/1.1/Thu Apr 9 12:48:43 2009//
+/.classpath/1.3/Wed Dec 16 21:48:51 2009//TCDT_7_0_0
+/.project/1.2/Wed Mar 24 03:31:58 2010//TCDT_7_0_0
D/.settings////
D/META-INF////
-/build.properties/1.1/Thu Apr 9 12:48:44 2009//
-/plugin.xml/1.7/Wed Dec 16 21:48:51 2009//
+D/OSGI-INF////
+/about.html/1.1/Mon Jun 14 18:35:55 2010//TCDT_7_0_0
+/build.properties/1.6/Sun Jun 27 01:30:37 2010//TCDT_7_0_0
+/plugin.xml/1.23/Sun Jun 27 01:30:37 2010//TCDT_7_0_0
D/src////
diff --git a/org.eclipse.cdt.codan.checkers/CVS/Tag b/org.eclipse.cdt.codan.checkers/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers/META-INF/CVS/Entries b/org.eclipse.cdt.codan.checkers/META-INF/CVS/Entries
index 011c155..2943796 100644
--- a/org.eclipse.cdt.codan.checkers/META-INF/CVS/Entries
+++ b/org.eclipse.cdt.codan.checkers/META-INF/CVS/Entries
@@ -1 +1 @@
-/MANIFEST.MF/1.4/Sat Apr 18 02:11:45 2009//
+/MANIFEST.MF/1.9/Sun Jun 27 01:30:37 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers/META-INF/CVS/Tag b/org.eclipse.cdt.codan.checkers/META-INF/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/META-INF/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers/META-INF/MANIFEST.MF b/org.eclipse.cdt.codan.checkers/META-INF/MANIFEST.MF
index 50e70f6..6d6406e 100644
--- a/org.eclipse.cdt.codan.checkers/META-INF/MANIFEST.MF
+++ b/org.eclipse.cdt.codan.checkers/META-INF/MANIFEST.MF
@@ -1,12 +1,16 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: Checkers
+Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.cdt.codan.checkers;singleton:=true
-Bundle-Version: 1.0.0
-Bundle-Activator: org.eclipse.cdt.codan.checkers.Activator
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.cdt.codan.checkers.CodanCheckersActivator
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources;bundle-version="3.5.0",
+ org.eclipse.cdt.codan.core;bundle-version="1.0.0",
org.eclipse.cdt.core;bundle-version="5.1.0",
- org.eclipse.cdt.codan.core;bundle-version="1.0.0"
+ org.eclipse.cdt.codan.core.cxx;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Vendor: %Bundle-Vendor
+Export-Package: org.eclipse.cdt.codan.checkers,
+ org.eclipse.cdt.codan.internal.checkers;x-friends:="org.eclipse.cdt.codan.checkers.ui"
diff --git a/org.eclipse.cdt.codan.checkers/OSGI-INF/CVS/Entries b/org.eclipse.cdt.codan.checkers/OSGI-INF/CVS/Entries
new file mode 100644
index 0000000..2928641
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/OSGI-INF/CVS/Entries
@@ -0,0 +1 @@
+D/l10n////
diff --git a/org.eclipse.cdt.codan.checkers/OSGI-INF/CVS/Repository b/org.eclipse.cdt.codan.checkers/OSGI-INF/CVS/Repository
new file mode 100644
index 0000000..0ba340a
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/OSGI-INF/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers/OSGI-INF
diff --git a/org.eclipse.cdt.codan.checkers/OSGI-INF/CVS/Root b/org.eclipse.cdt.codan.checkers/OSGI-INF/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/OSGI-INF/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.checkers/OSGI-INF/CVS/Tag b/org.eclipse.cdt.codan.checkers/OSGI-INF/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/OSGI-INF/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers/OSGI-INF/l10n/CVS/Entries b/org.eclipse.cdt.codan.checkers/OSGI-INF/l10n/CVS/Entries
new file mode 100644
index 0000000..6feb6a6
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/OSGI-INF/l10n/CVS/Entries
@@ -0,0 +1 @@
+/bundle.properties/1.2/Thu Jun 3 17:01:33 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers/OSGI-INF/l10n/CVS/Repository b/org.eclipse.cdt.codan.checkers/OSGI-INF/l10n/CVS/Repository
new file mode 100644
index 0000000..32fbdd6
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/OSGI-INF/l10n/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers/OSGI-INF/l10n
diff --git a/org.eclipse.cdt.codan.checkers/OSGI-INF/l10n/CVS/Root b/org.eclipse.cdt.codan.checkers/OSGI-INF/l10n/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/OSGI-INF/l10n/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.checkers/OSGI-INF/l10n/CVS/Tag b/org.eclipse.cdt.codan.checkers/OSGI-INF/l10n/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/OSGI-INF/l10n/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers/OSGI-INF/l10n/bundle.properties b/org.eclipse.cdt.codan.checkers/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 0000000..3f942ae
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,47 @@
+###############################################################################
+# 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
+###############################################################################
+#Properties file for org.eclipse.cdt.codan.checkers
+Bundle-Vendor = Eclipse CDT
+Bundle-Name = Codan Checkers
+checker.name.AssignmentInCondition = Assignment in condition
+problem.description.AssignmentInCondition = Finds statements like 'if (a=b)'
+problem.messagePattern.AssignmentInCondition = Possible assignment in condition ''{0}''
+problem.name.AssignmentInCondition = Assignment in condition
+checker.name.StatementHasNoEffect = StatementHasNoEffectChecker
+problem.description.StatementHasNoEffect = Finds statements like 'a;' or '-a;' or 'a-b;' which do no seems to have any side effect therefore suspicious
+problem.messagePattern.StatementHasNoEffect = Statement has no effect ''{0}''
+problem.name.StatementHasNoEffect = Statement has no effect
+checker.name.NonVirtualDescructor = NonVirtualDescructorChecker
+problem.description.NonVirtualDescructor = If destructor is not declared virtual - destructor of derived class would not be called.
+problem.messagePattern.NonVirtualDescructor = Class ''{0}'' has virtual method ''{1}'' but non-virtual destructor ''{2}''
+problem.name.NonVirtualDescructor = Class has a virtual method and non-virtual destructor
+checker.name.CatchByReference = CatchByReferenceChecker
+problem.description.CatchByReference = Catching by reference is recommended by C++ experts, "Throw by value, catch by reference". For one thing, this avoids copying and potentially slicing the exception.
+problem.messagePattern.CatchByReference = Catching by reference is recommended ''{0}''
+problem.name.CatchByReference = Catching by reference is recommended
+checker.name.SuggestedParenthesis = SuggestedParenthesisChecker
+problem.description.SuggestedParenthesis = This checker finds problems related to either lack of understanding precedence of operators or misspelling of operators in expression. For example (!a<10) or (a && b & c)
+problem.messagePattern.SuggestedParenthesis = Suggested parenthesis around expression ''{0}''
+problem.name.SuggestedParenthesis = Suggested parenthesis around expression
+checker.name.NamingConventionFunction = NamingConventionFunctionChecker
+problem.description.NamingConventionFunction = Finds and reports functions name of which does not match pattern parameter
+problem.messagePattern.NamingConventionFunction = Bad function name "{0}" (pattern /{1}/)
+problem.name.NamingConventionFunction = Name convention for function
+checker.name.ReturnChecker = Return inconsistencies
+problem.description.NoReturnValue = Return statment has no return value, if somebody would use return value from this function it would be random
+problem.messagePattern.NoReturnValue = Return without value, in function returning non-void
+problem.name.NoReturnValue = No return value
+problem.description.UnusedReturnValue = Return statement has a value, but function is declared to return void. Did you mean to declare function with return value?
+problem.messagePattern.UnusedReturnValue = Return has value, in function returning void
+problem.name.UnusedReturnValue = Unused return value
+problem.description.NoReturn = No return statement in a function which is declared to return value
+problem.messagePattern.NoReturn = No return, in function returning non-void
+problem.name.NoReturn = No return
\ No newline at end of file
diff --git a/org.eclipse.cdt.codan.checkers/about.html b/org.eclipse.cdt.codan.checkers/about.html
new file mode 100644
index 0000000..d7c5118
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/about.html
@@ -0,0 +1,24 @@
+
+
+About
+
+
+
About This Content
+
+
June 22, 2007
+
License
+
+
The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at http://www.eclipse.org/legal/epl-v10.html.
+For purposes of the EPL, "Program" will mean the Content.
+
+
If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at http://www.eclipse.org.
+
+
\ No newline at end of file
diff --git a/org.eclipse.cdt.codan.checkers/build.properties b/org.eclipse.cdt.codan.checkers/build.properties
index e9863e2..df3189f 100644
--- a/org.eclipse.cdt.codan.checkers/build.properties
+++ b/org.eclipse.cdt.codan.checkers/build.properties
@@ -1,5 +1,17 @@
+###############################################################################
+# Copyright (c) 2009, 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
+###############################################################################
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
- plugin.xml
+ plugin.xml,\
+ OSGI-INF/l10n/bundle.properties,\
+ about.html
diff --git a/org.eclipse.cdt.codan.checkers/plugin.xml b/org.eclipse.cdt.codan.checkers/plugin.xml
index 63b999e..d206032 100644
--- a/org.eclipse.cdt.codan.checkers/plugin.xml
+++ b/org.eclipse.cdt.codan.checkers/plugin.xml
@@ -3,65 +3,124 @@
+ id="org.eclipse.cdt.codan.core.internal.checkers">
+ class="org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionChecker"
+ id="org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionChecker"
+ name="%checker.name.AssignmentInCondition">
+ description="%problem.description.AssignmentInCondition"
+ id="org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem"
+ messagePattern="%problem.messagePattern.AssignmentInCondition"
+ name="%problem.name.AssignmentInCondition">
+ class="org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectChecker"
+ id="org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectChecker"
+ name="%checker.name.StatementHasNoEffect">
-
+ description="%problem.description.StatementHasNoEffect"
+ id="org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem"
+ messagePattern="%problem.messagePattern.StatementHasNoEffect"
+ name="%problem.name.StatementHasNoEffect"/>
+ class="org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructor"
+ id="org.eclipse.cdt.codan.internal.checkers.NonVirtualDescructor"
+ name="%checker.name.NonVirtualDescructor">
+ description="%problem.description.NonVirtualDescructor"
+ id="org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem"
+ messagePattern="%problem.messagePattern.NonVirtualDescructor"
+ name="%problem.name.NonVirtualDescructor">
+ class="org.eclipse.cdt.codan.internal.checkers.CatchByReference"
+ id="org.eclipse.cdt.codan.internal.checkers.CatchByReference"
+ name="%checker.name.CatchByReference">
+ description="%problem.description.CatchByReference"
+ id="org.eclipse.cdt.codan.internal.checkers.CatchByReference"
+ name="%problem.name.CatchByReference"
+ messagePattern="%problem.messagePattern.CatchByReference">
+ class="org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisChecker"
+ id="org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisChecker"
+ name="%checker.name.SuggestedParenthesis">
+ description="%problem.description.SuggestedParenthesis"
+ id="org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem"
+ messagePattern="%problem.messagePattern.SuggestedParenthesis"
+ name="%problem.name.SuggestedParenthesis">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/org.eclipse.cdt.codan.checkers/src/CVS/Tag b/org.eclipse.cdt.codan.checkers/src/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers/src/org/CVS/Tag b/org.eclipse.cdt.codan.checkers/src/org/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/CVS/Tag b/org.eclipse.cdt.codan.checkers/src/org/eclipse/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/CVS/Tag b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/CVS/Entries b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/CVS/Entries
index 513604d..83a5699 100644
--- a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/CVS/Entries
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/CVS/Entries
@@ -1 +1,3 @@
D/checkers////
+D/examples////
+D/internal////
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/CVS/Tag b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/Activator.java b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/Activator.java
deleted file mode 100644
index 2915e7d..0000000
--- a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/Activator.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.eclipse.cdt.codan.checkers;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends Plugin {
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.cdt.codan.checkers";
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
- * )
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
- * )
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
- /**
- * @param e
- */
- public static void log(Throwable e) {
- getDefault().getLog().log(getStatus(e));
- }
-
- public static void log(String message) {
- getDefault().getLog().log(new Status(Status.ERROR, PLUGIN_ID, message));
- }
-
- /**
- * @param e
- * @return
- */
- public static IStatus getStatus(Throwable e) {
- return new Status(Status.ERROR, PLUGIN_ID, e.getLocalizedMessage(), e);
- }
-}
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/CVS/Entries b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/CVS/Entries
index 0f9ebcd..2c318af 100644
--- a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/CVS/Entries
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/CVS/Entries
@@ -1,2 +1,2 @@
-/Activator.java/1.3/Sat May 9 01:36:37 2009//
+/CodanCheckersActivator.java/1.3/Sun Jun 27 01:30:37 2010//TCDT_7_0_0
D/sample////
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/CVS/Tag b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/CodanCheckersActivator.java b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/CodanCheckersActivator.java
new file mode 100644
index 0000000..c2e21c3
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/CodanCheckersActivator.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * 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.checkers;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class CodanCheckersActivator extends Plugin {
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.cdt.codan.checkers"; //$NON-NLS-1$
+ // The shared instance
+ private static CodanCheckersActivator plugin;
+
+ /**
+ * The constructor
+ */
+ public CodanCheckersActivator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
+ * )
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
+ * )
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static CodanCheckersActivator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * @param e
+ */
+ public static void log(Throwable e) {
+ getDefault().getLog().log(getStatus(e));
+ }
+
+ public static void log(String message) {
+ getDefault().getLog().log(new Status(Status.ERROR, PLUGIN_ID, message));
+ }
+
+ /**
+ * @param e
+ * @return
+ */
+ public static IStatus getStatus(Throwable e) {
+ return new Status(Status.ERROR, PLUGIN_ID, e.getLocalizedMessage(), e);
+ }
+}
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/AssignmentInConditionChecker.java b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/AssignmentInConditionChecker.java
deleted file mode 100644
index 5ce5661..0000000
--- a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/AssignmentInConditionChecker.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * 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.checkers.sample;
-
-import org.eclipse.cdt.codan.core.model.AbstractIndexAstChecker;
-import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
-import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
-import org.eclipse.cdt.core.dom.ast.IASTExpression;
-import org.eclipse.cdt.core.dom.ast.IASTForStatement;
-import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-
-public class AssignmentInConditionChecker extends AbstractIndexAstChecker {
- private static final String ER_ID = "org.eclipse.cdt.codan.checkers.sample.AssignmentInConditionProblem";
-
- public void processAst(IASTTranslationUnit ast) {
- // traverse the ast using the visitor pattern.
- ast.accept(new CheckCodeVisitor());
- }
-
- class CheckCodeVisitor extends ASTVisitor {
- CheckCodeVisitor() {
- shouldVisitExpressions = true;
- }
-
- public int visit(IASTExpression expression) {
- if (isAssignmentExpression(expression)
- && isUsedAsCondition(expression)) {
- reportProblem(ER_ID, expression, "Possible assignment in condition");
- }
- return PROCESS_CONTINUE;
- }
-
- private boolean isAssignmentExpression(IASTExpression e) {
- if (e instanceof IASTBinaryExpression) {
- IASTBinaryExpression binExpr = (IASTBinaryExpression) e;
- return binExpr.getOperator() == IASTBinaryExpression.op_assign;
- }
- return false;
- }
-
- private boolean isUsedAsCondition(IASTExpression expression) {
- ASTNodeProperty prop = expression.getPropertyInParent();
- if (prop == IASTForStatement.CONDITION
- || prop == IASTIfStatement.CONDITION)
- return true;
- return false;
- }
- }
-}
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/CVS/Entries b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/CVS/Entries
deleted file mode 100644
index 705d9ab..0000000
--- a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/CVS/Entries
+++ /dev/null
@@ -1,5 +0,0 @@
-/AssignmentInConditionChecker.java/1.4/Fri Jul 31 20:39:13 2009//
-/CatchUsesReference.java/1.2/Sat Nov 21 02:25:12 2009//
-/NonVirtualDestructor.java/1.4/Fri Jul 31 20:39:13 2009//
-/StatementHasNoEffectChecker.java/1.5/Fri Jul 31 20:39:13 2009//
-/SuggestedParenthesisChecker.java/1.2/Sat Nov 21 03:03:08 2009//
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/CVS/Repository b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/CVS/Repository
deleted file mode 100644
index 28a5431..0000000
--- a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/CVS/Root b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/CVS/Root
deleted file mode 100644
index 04efa23..0000000
--- a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/CVS/Template b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/CVS/Template
deleted file mode 100644
index e69de29..0000000
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/CatchUsesReference.java b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/CatchUsesReference.java
deleted file mode 100644
index b3556cc..0000000
--- a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/CatchUsesReference.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * 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.checkers.sample;
-
-import org.eclipse.cdt.codan.core.model.AbstractIndexAstChecker;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
-import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
-import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
-import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
-import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
-import org.eclipse.cdt.core.dom.ast.IASTStatement;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
-
-/**
- * @author Alena
- *
- */
-public class CatchUsesReference extends AbstractIndexAstChecker {
- private static final String ER_ID = "org.eclipse.cdt.codan.checkers.sample.CatchUsesReference";
-
- public void processAst(IASTTranslationUnit ast) {
- // traverse the ast using the visitor pattern.
- ast.accept(new OnCatch());
- }
-
- class OnCatch extends ASTVisitor {
- OnCatch() {
- shouldVisitStatements = true;
- }
- public int visit(IASTStatement stmt) {
- if (stmt instanceof ICPPASTTryBlockStatement) {
- ICPPASTTryBlockStatement tblock = (ICPPASTTryBlockStatement) stmt;
- ICPPASTCatchHandler[] catchHandlers = tblock.getCatchHandlers();
- for (int i = 0; i < catchHandlers.length; i++) {
- ICPPASTCatchHandler catchHandler = catchHandlers[i];
- if (usesReference(catchHandler)) {
- reportProblem(ER_ID, catchHandler.getDeclaration(), "Catch clause uses reference in declaration of exception");
- }
- }
-
- return PROCESS_SKIP;
- }
- return PROCESS_CONTINUE;
- }
- /**
- * @param catchHandler
- * @return
- */
- private boolean usesReference(ICPPASTCatchHandler catchHandler) {
- IASTDeclaration declaration = catchHandler.getDeclaration();
- if (declaration instanceof IASTSimpleDeclaration) {
- IASTDeclarator[] declarators = ((IASTSimpleDeclaration) declaration).getDeclarators();
- for (int i = 0; i < declarators.length; i++) {
- IASTDeclarator d = declarators[i];
- IASTPointerOperator[] pointerOperators = d.getPointerOperators();
- for (int j = 0; j < pointerOperators.length; j++) {
- IASTPointerOperator po = pointerOperators[j];
- if (po instanceof ICPPASTReferenceOperator) {
- return true;
- }
-
- }
- }
- }
- return false;
- }
- }
-
-
-}
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/NonVirtualDestructor.java b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/NonVirtualDestructor.java
deleted file mode 100644
index 45f7e72..0000000
--- a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/NonVirtualDestructor.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*******************************************************************************
- * 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.checkers.sample;
-
-import java.text.MessageFormat;
-
-import org.eclipse.cdt.codan.checkers.Activator;
-import org.eclipse.cdt.codan.core.model.AbstractIndexAstChecker;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
-import org.eclipse.cdt.core.dom.ast.DOMException;
-import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
-import org.eclipse.cdt.core.dom.ast.IASTName;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
-
-/**
- * Checker to find that class has virtual method and non virtual destructor
- *
- * @author Alena
- *
- */
-public class NonVirtualDestructor extends AbstractIndexAstChecker {
- private static final String ER_ID = "org.eclipse.cdt.codan.checkers.sample.NonVirtualDestructorProblem";
-
- public void processAst(IASTTranslationUnit ast) {
- // traverse the ast using the visitor pattern.
- ast.accept(new OnEachClass());
- }
-
- class OnEachClass extends ASTVisitor {
- private IASTName className;
- private IBinding virMethodName;
- private IBinding destName;
-
- OnEachClass() {
- // shouldVisitDeclarations = true;
- shouldVisitDeclSpecifiers = true;
- }
-
- public int visit(IASTDeclSpecifier decl) {
- if (isClassDecl(decl)) {
- try {
- boolean err = hasErrorCondition(decl);
- if (err) {
- String mess;
- String clazz = className.toString();
- String method = virMethodName.getName();
- IASTNode ast = decl;
- if (destName != null) {
- if (destName instanceof ICPPInternalBinding) {
- ICPPInternalBinding bin = (ICPPInternalBinding) destName;
- ast = bin.getDeclarations()[0];
- }
- mess = MessageFormat
- .format(
- "Class ''{0}'' has virtual method ''{1}'' but non-virtual destructor ''{2}''",
- clazz, method, destName.getName());
- reportProblem(ER_ID, ast, mess);
- }
- }
- } catch (DOMException e) {
- // ignore, no error
- } catch (Exception e) {
- Activator.log(e);
- }
- return PROCESS_SKIP;
- }
- return PROCESS_CONTINUE;
- }
-
- /**
- * @param decl
- * @throws DOMException
- */
- private boolean hasErrorCondition(IASTDeclSpecifier decl)
- throws DOMException {
- ICPPASTCompositeTypeSpecifier spec = (ICPPASTCompositeTypeSpecifier) decl;
- className = spec.getName();
- IBinding binding = className.getBinding();
- if (binding == null) {
- binding = className.resolveBinding();
- }
- if (binding instanceof ICPPClassType) {
- ICPPClassType type = (ICPPClassType) binding;
- virMethodName = null;
- destName = null;
- // check for the following conditions:
- // class has own virtual method and own non-virtual destructor
- // class has own virtual method and base non-virtual destructor
- // class has base virtual method and own non-virtual destructor
- ICPPMethod[] declaredMethods = type.getDeclaredMethods();
- boolean hasOwnVirtualMethod = false;
- boolean hasOwnNonVirDestructor = false;
- boolean hasDestructor = false;
- boolean hasVirtualMethod = false;
- for (int i = 0; i < declaredMethods.length; i++) {
- ICPPMethod icppMethod = declaredMethods[i];
- if (icppMethod.isVirtual() && !icppMethod.isDestructor()) {
- hasOwnVirtualMethod = true;
- virMethodName = icppMethod;
- }
- if (icppMethod.isDestructor()) {
- hasDestructor = true;
- if (!icppMethod.isVirtual()) {
- hasOwnNonVirDestructor = true;
- destName = icppMethod;
- }
- }
- }
- boolean hasVirDestructor = false;
- // class has own virtual method and own non-virtual destructor
- if (hasOwnVirtualMethod && hasOwnNonVirDestructor) {
- return true;
- }
- // class does not have virtual methods but has virtual
- // destructor
- // - not an error
- if (hasOwnVirtualMethod == false && hasDestructor == true
- && hasOwnNonVirDestructor == false) {
- return false;
- }
- ICPPMethod[] allDeclaredMethods = type.getAllDeclaredMethods();
- for (int i = 0; i < allDeclaredMethods.length; i++) {
- ICPPMethod icppMethod = allDeclaredMethods[i];
- if (icppMethod.isVirtual() && !icppMethod.isDestructor()) {
- hasVirtualMethod = true;
- if (virMethodName == null)
- virMethodName = icppMethod;
- }
- if (icppMethod.isDestructor()) {
- hasDestructor = true;
- if (icppMethod.isVirtual()) {
- hasVirDestructor = true;
- } else {
- if (destName == null)
- destName = icppMethod;
- }
- }
- }
- if (hasOwnVirtualMethod) {
- // class has own virtual method and base non-virtual
- // destructor
- if (hasDestructor == true && hasVirDestructor == false) {
- return true;
- }
- } else if (hasVirtualMethod) {
- // class has base virtual method and own non-virtual
- // destructor
- if (hasOwnNonVirDestructor == true) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * @param decl
- * @return
- */
- private boolean isClassDecl(IASTDeclSpecifier decl) {
- if (decl instanceof ICPPASTCompositeTypeSpecifier) {
- return true;
- }
- return false;
- }
- }
-}
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/StatementHasNoEffectChecker.java b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/StatementHasNoEffectChecker.java
deleted file mode 100644
index c08f58a..0000000
--- a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/StatementHasNoEffectChecker.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * 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.checkers.sample;
-
-import org.eclipse.cdt.codan.core.model.AbstractIndexAstChecker;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
-import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
-import org.eclipse.cdt.core.dom.ast.IASTExpression;
-import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
-import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
-import org.eclipse.cdt.core.dom.ast.IASTStatement;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
-import org.eclipse.cdt.core.dom.ast.IBasicType;
-import org.eclipse.cdt.core.dom.ast.IType;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression;
-
-/**
- * Checker that detects statements without effect such as
- *
- * a+b;
- *
- * or
- *
- * +b;
- *
- *
- */
-public class StatementHasNoEffectChecker extends AbstractIndexAstChecker {
- private static final String ER_ID = "org.eclipse.cdt.codan.checkers.sample.StatementHasNoEffectProblem";
-
- public void processAst(IASTTranslationUnit ast) {
- // traverse the ast using the visitor pattern.
- ast.accept(new CheckStmpVisitor());
- }
-
- class CheckStmpVisitor extends ASTVisitor {
- CheckStmpVisitor() {
- shouldVisitStatements = true;
- }
-
- public int visit(IASTStatement stmt) {
- if (stmt instanceof IASTExpressionStatement) {
- if (hasNoEffect(((IASTExpressionStatement) stmt)
- .getExpression())) {
- reportProblem(ER_ID, stmt, "Statement has no effect");
- }
- return PROCESS_SKIP;
- }
- return PROCESS_CONTINUE;
- }
-
- /**
- * We consider has not effect binary statements without assignment and
- * unary statement which is not dec and inc. If operator is overloaded
- * we not going to bother.
- *
- * @param e
- * @return
- */
- private boolean hasNoEffect(IASTExpression e) {
- if (e instanceof IASTBinaryExpression) {
- IASTBinaryExpression binExpr = (IASTBinaryExpression) e;
- if (binExpr.getOperator() == IASTBinaryExpression.op_assign)
- return false;
- if (binExpr instanceof CPPASTBinaryExpression) {
- // unfortunately ICPPASTBinaryExpression does not have
- // getOverload public method
- CPPASTBinaryExpression cppBin = (CPPASTBinaryExpression) binExpr;
- ICPPFunction overload = cppBin.getOverload();
- if (overload != null)
- return false;
- IType expressionType = binExpr.getOperand1()
- .getExpressionType();
- if (!(expressionType instanceof IBasicType)) {
- return false; // must be overloaded but parser could not
- // find it
- }
- }
- return true;
- }
- if (e instanceof IASTUnaryExpression) {
- IASTUnaryExpression unaryExpr = (IASTUnaryExpression) e;
- int operator = unaryExpr.getOperator();
- switch (operator) {
- case IASTUnaryExpression.op_postFixDecr:
- case IASTUnaryExpression.op_prefixDecr:
- case IASTUnaryExpression.op_postFixIncr:
- case IASTUnaryExpression.op_prefixIncr:
- return false;
- }
- return true;
- }
- if (e instanceof IASTIdExpression) {
- // simply a;
- return true;
- }
- return false;
- }
- }
-}
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/SuggestedParenthesisChecker.java b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/SuggestedParenthesisChecker.java
deleted file mode 100644
index 27712b4..0000000
--- a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/SuggestedParenthesisChecker.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * 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.checkers.sample;
-
-import org.eclipse.cdt.codan.core.model.AbstractIndexAstChecker;
-import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
-import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
-import org.eclipse.cdt.core.dom.ast.IASTExpression;
-import org.eclipse.cdt.core.dom.ast.IASTForStatement;
-import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
-
-/**
- * This checker finds a problems that cause by lack of understanding operator
- * precedence in C. In any case it is better to surround expressions in
- * parenthesis to improve readability. Example: ! x>0 && x<10 (this would be
- * (!x)>0 && x<10 in C) We only look for &&, || and ! operators (and binary | &
- * ^ ~)
- *
- * @author Alena
- *
- */
-public class SuggestedParenthesisChecker extends AbstractIndexAstChecker {
- private static final String ER_ID = "org.eclipse.cdt.codan.checkers.sample.SuggestedParenthesisProblem";
-
- public void processAst(IASTTranslationUnit ast) {
- // traverse the ast using the visitor pattern.
- ast.accept(new ExpressionVisitor());
- }
-
- class ExpressionVisitor extends ASTVisitor {
- private SuspiciousExpressionVisitor svis;
-
- ExpressionVisitor() {
- shouldVisitExpressions = true;
- svis = new SuspiciousExpressionVisitor();
- }
-
- public int visit(IASTExpression expression) {
- int precedence = getPrecedence(expression);
- if (precedence == 2) { // unary not
- if (isUsedAsOperand(expression)) {
- reportProblem(ER_ID, expression,
- "Suggested parenthesis around expression");
- return PROCESS_SKIP;
- }
- }
- if (precedence >= 0) {
- synchronized (svis) { // since we use only one instance of this
- // visitor sync just in case
- svis.init(expression);
- expression.accept(svis);
- if (svis.suspicious == true) {
- reportProblem(ER_ID, svis.other,
- "Suggested parenthesis around expression");
- return PROCESS_SKIP;
- }
- }
- }
- return PROCESS_CONTINUE;
- }
-
- private boolean isUsedAsOperand(IASTExpression expression) {
- ASTNodeProperty prop = expression.getPropertyInParent();
- if (prop == IASTBinaryExpression.OPERAND_ONE
- || prop == IASTBinaryExpression.OPERAND_TWO
- || prop == IASTUnaryExpression.OPERAND)
- return true;
- return false;
- }
- }
-
- private int getPrecedence(IASTExpression e) {
- if (e instanceof IASTBinaryExpression) {
- IASTBinaryExpression binExpr = (IASTBinaryExpression) e;
- int operator = binExpr.getOperator();
- if (operator == IASTBinaryExpression.op_binaryAnd)
- return 8;
- if (operator == IASTBinaryExpression.op_binaryXor)
- return 9;
- if (operator == IASTBinaryExpression.op_binaryOr)
- return 10;
- if (operator == IASTBinaryExpression.op_logicalAnd)
- return 11;
- if (operator == IASTBinaryExpression.op_logicalOr)
- return 12;
- }
- if (e instanceof IASTUnaryExpression) {
- IASTUnaryExpression binExpr = (IASTUnaryExpression) e;
- int operator = binExpr.getOperator();
- if (operator == IASTUnaryExpression.op_not)
- return 2;
- if (operator == IASTUnaryExpression.op_tilde)
- return 2;
- }
- return -1;
- }
-
- class SuspiciousExpressionVisitor extends ASTVisitor {
- IASTExpression parent;
- IASTExpression other;
- boolean suspicious = false;
-
- void init(IASTExpression e) {
- parent = e;
- suspicious = false;
- }
-
- SuspiciousExpressionVisitor() {
- shouldVisitExpressions = true;
- }
-
- public int visit(IASTExpression expression) {
- if (expression == parent)
- return PROCESS_CONTINUE;
- if (expression instanceof IASTUnaryExpression) {
- IASTUnaryExpression uExpr = (IASTUnaryExpression) expression;
- int operator = uExpr.getOperator();
- if (operator == IASTUnaryExpression.op_bracketedPrimary) {
- return PROCESS_SKIP;
- }
- }
- if (getPrecedence(expression) < 0) // not considered operator
- return PROCESS_CONTINUE;
- if (getPrecedence(expression) == getPrecedence(parent)) {
- return PROCESS_SKIP;
- }
- suspicious = true;
- other = expression;
- return PROCESS_ABORT;
- }
- }
-}
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/CVS/Entries b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/CVS/Entries
new file mode 100644
index 0000000..513604d
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/CVS/Entries
@@ -0,0 +1 @@
+D/checkers////
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/CVS/Repository b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/CVS/Repository
new file mode 100644
index 0000000..5afb44a
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/CVS/Root b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/CVS/Tag b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/CVS/Template b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/CVS/Template
new file mode 100644
index 0000000..e69de29
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentInConditionChecker.java b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentInConditionChecker.java
new file mode 100644
index 0000000..6a17ef8
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentInConditionChecker.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.checkers;
+
+import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
+import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTForStatement;
+import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+
+public class AssignmentInConditionChecker extends AbstractIndexAstChecker {
+ private static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem"; //$NON-NLS-1$
+
+ public void processAst(IASTTranslationUnit ast) {
+ // traverse the ast using the visitor pattern.
+ ast.accept(new CheckCodeVisitor());
+ }
+
+ class CheckCodeVisitor extends ASTVisitor {
+ CheckCodeVisitor() {
+ shouldVisitExpressions = true;
+ }
+
+ public int visit(IASTExpression expression) {
+ if (isAssignmentExpression(expression)
+ && isUsedAsCondition(expression)) {
+ reportProblem(ER_ID, expression, expression.getRawSignature());
+ }
+ return PROCESS_CONTINUE;
+ }
+
+ private boolean isAssignmentExpression(IASTExpression e) {
+ if (e instanceof IASTBinaryExpression) {
+ IASTBinaryExpression binExpr = (IASTBinaryExpression) e;
+ return binExpr.getOperator() == IASTBinaryExpression.op_assign;
+ }
+ return false;
+ }
+
+ private boolean isUsedAsCondition(IASTExpression expression) {
+ ASTNodeProperty prop = expression.getPropertyInParent();
+ if (prop == IASTForStatement.CONDITION
+ || prop == IASTIfStatement.CONDITION)
+ return true;
+ return false;
+ }
+ }
+}
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CVS/Entries b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CVS/Entries
new file mode 100644
index 0000000..2c93e0c
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CVS/Entries
@@ -0,0 +1,10 @@
+/AssignmentInConditionChecker.java/1.4/Sun Jun 27 01:30:37 2010//TCDT_7_0_0
+/CatchByReference.java/1.6/Thu Jun 3 17:01:33 2010//TCDT_7_0_0
+/CheckersMessages.java/1.6/Thu May 27 01:21:57 2010//TCDT_7_0_0
+/NamingConventionFunctionChecker.java/1.9/Sun Jun 27 01:30:37 2010//TCDT_7_0_0
+/NonVirtualDestructor.java/1.4/Sun Jun 27 01:30:37 2010//TCDT_7_0_0
+/ReturnChecker.java/1.12/Fri Jun 4 03:03:37 2010//TCDT_7_0_0
+/StatementHasNoEffectChecker.java/1.16/Sun Jun 27 01:30:37 2010//TCDT_7_0_0
+/SuggestedParenthesisChecker.java/1.8/Sun Jun 27 01:30:37 2010//TCDT_7_0_0
+/messages.properties/1.7/Thu Jun 3 17:01:33 2010//TCDT_7_0_0
+D/sample////
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CVS/Repository b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CVS/Repository
new file mode 100644
index 0000000..7543811
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CVS/Root b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CVS/Tag b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CVS/Template b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CVS/Template
new file mode 100644
index 0000000..e69de29
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CatchByReference.java b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CatchByReference.java
new file mode 100644
index 0000000..6f0afc8
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CatchByReference.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.checkers;
+
+import org.eclipse.cdt.codan.checkers.CodanCheckersActivator;
+import org.eclipse.cdt.codan.core.cxx.CxxAstUtils;
+import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTPointer;
+import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBasicType;
+import org.eclipse.cdt.core.dom.ast.IPointerType;
+import org.eclipse.cdt.core.dom.ast.IProblemBinding;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
+
+/**
+ * Catching by reference is recommended by C++ experts, for example Herb
+ * Sutter/Andrei Alexandresscu "C++ Coding Standards", Rule 73
+ * "Throw by value, catch by reference".
+ * For one thing, this avoids copying and potentially slicing the exception.
+ *
+ */
+public class CatchByReference extends AbstractIndexAstChecker {
+ public static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.CatchByReference"; //$NON-NLS-1$
+ public static final String PARAM_EXCEPT_ARG_LIST = "exceptions"; //$NON-NLS-1$
+ public static final String PARAM_UNKNOWN_TYPE = "unknown"; //$NON-NLS-1$
+
+ public void processAst(IASTTranslationUnit ast) {
+ // traverse the ast using the visitor pattern.
+ ast.accept(new OnCatch());
+ }
+
+ class OnCatch extends ASTVisitor {
+ OnCatch() {
+ shouldVisitStatements = true;
+ }
+
+ public int visit(IASTStatement stmt) {
+ if (stmt instanceof ICPPASTTryBlockStatement) {
+ try {
+ ICPPASTTryBlockStatement tblock = (ICPPASTTryBlockStatement) stmt;
+ ICPPASTCatchHandler[] catchHandlers = tblock
+ .getCatchHandlers();
+ for (int i = 0; i < catchHandlers.length; i++) {
+ ICPPASTCatchHandler catchHandler = catchHandlers[i];
+ IASTDeclaration decl = catchHandler.getDeclaration();
+ if (decl instanceof IASTSimpleDeclaration) {
+ IASTSimpleDeclaration sdecl = (IASTSimpleDeclaration) decl;
+ IASTDeclSpecifier spec = sdecl.getDeclSpecifier();
+ if (!usesReference(catchHandler)) {
+ if (spec instanceof IASTNamedTypeSpecifier) {
+ IASTName tname = ((IASTNamedTypeSpecifier) spec)
+ .getName();
+ IType typeName = (IType) tname
+ .resolveBinding();
+ typeName = CxxAstUtils.getInstance()
+ .unwindTypedef(typeName);
+ if (typeName instanceof IBasicType
+ || typeName instanceof IPointerType
+ || typeName == null)
+ continue;
+ if (typeName instanceof IProblemBinding && !shouldReportForUnknownType())
+ continue;
+ String arg = spec.getRawSignature();
+ if (!isFilteredArg(arg)) {
+ reportProblem(ER_ID, decl, arg);
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ CodanCheckersActivator.log(e);
+ }
+ return PROCESS_SKIP;
+ }
+ return PROCESS_CONTINUE;
+ }
+
+ /**
+ * If it uses reference or ponter
+ *
+ * @param catchHandler
+ * @return
+ */
+ private boolean usesReference(ICPPASTCatchHandler catchHandler) {
+ IASTDeclaration declaration = catchHandler.getDeclaration();
+ if (declaration instanceof IASTSimpleDeclaration) {
+ IASTDeclarator[] declarators = ((IASTSimpleDeclaration) declaration)
+ .getDeclarators();
+ for (int i = 0; i < declarators.length; i++) {
+ IASTDeclarator d = declarators[i];
+ IASTPointerOperator[] pointerOperators = d
+ .getPointerOperators();
+ for (int j = 0; j < pointerOperators.length; j++) {
+ IASTPointerOperator po = pointerOperators[j];
+ if (po instanceof ICPPASTReferenceOperator) {
+ return true;
+ }
+ if (po instanceof IASTPointer) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+ }
+
+ @Override
+ public void initPreferences(IProblemWorkingCopy problem) {
+ super.initPreferences(problem);
+ addPreference(problem, PARAM_UNKNOWN_TYPE,
+ CheckersMessages.CatchByReference_ReportForUnknownType, Boolean.FALSE);
+ addListPreference(problem, PARAM_EXCEPT_ARG_LIST,
+ CheckersMessages.GenericParameter_ParameterExceptions,
+ CheckersMessages.GenericParameter_ParameterExceptionsItem);
+ }
+
+ public boolean isFilteredArg(String arg) {
+ Object[] arr = (Object[]) getPreference(
+ getProblemById(ER_ID, getFile()), PARAM_EXCEPT_ARG_LIST);
+ for (int i = 0; i < arr.length; i++) {
+ String str = (String) arr[i];
+ if (arg.equals(str))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @return
+ */
+ public boolean shouldReportForUnknownType() {
+ return (Boolean) getPreference(getProblemById(ER_ID, getFile()),
+ PARAM_UNKNOWN_TYPE);
+ }
+}
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CheckersMessages.java b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CheckersMessages.java
new file mode 100644
index 0000000..089934f
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CheckersMessages.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2009,2010 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.internal.checkers;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Messages
+ */
+public class CheckersMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.codan.internal.checkers.messages"; //$NON-NLS-1$
+ public static String CatchByReference_ReportForUnknownType;
+ public static String NamingConventionFunctionChecker_LabelNamePattern;
+ public static String ReturnChecker_Param0;
+ public static String GenericParameter_ParameterExceptions;
+ public static String GenericParameter_ParameterExceptionsItem;
+ public static String StatementHasNoEffectChecker_ParameterMacro;
+ public static String SuggestedParenthesisChecker_SuggestParanthesesAroundNot;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, CheckersMessages.class);
+ }
+
+ private CheckersMessages() {
+ }
+}
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/NamingConventionFunctionChecker.java b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/NamingConventionFunctionChecker.java
new file mode 100644
index 0000000..4758ed1
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/NamingConventionFunctionChecker.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.checkers;
+
+import java.util.regex.Pattern;
+
+import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
+import org.eclipse.cdt.codan.core.model.ICheckerWithPreferences;
+import org.eclipse.cdt.codan.core.model.IProblem;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+
+/**
+ * This is style checker for function name code style. Pattern parameter is
+ * regular expression defining the style.
+ *
+ */
+public class NamingConventionFunctionChecker extends AbstractIndexAstChecker
+ implements ICheckerWithPreferences {
+ private static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker"; //$NON-NLS-1$
+ public static final String PARAM_KEY = "pattern"; //$NON-NLS-1$
+
+ public void processAst(IASTTranslationUnit ast) {
+ final IProblem pt = getProblemById(ER_ID, getFile());
+ try {
+ ast.accept(new ASTVisitor() {
+ {
+ shouldVisitDeclarations = true;
+ }
+
+ public int visit(IASTDeclaration element) {
+ if (element instanceof IASTFunctionDefinition) {
+ String parameter = (String) getPreference(pt,PARAM_KEY);
+ Pattern pattern = Pattern.compile(parameter);
+ IASTName astName = ((IASTFunctionDefinition) element)
+ .getDeclarator().getName();
+ String name = astName.toString();
+ if (!pattern.matcher(name).find()) {
+ reportProblem(ER_ID, astName, name, parameter);
+ }
+ }
+ return PROCESS_SKIP;
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.cdt.codan.core.model.ICheckerWithPreferences#initParameters
+ * (org.eclipse.cdt.codan.core.model.IProblemWorkingCopy)
+ */
+ public void initPreferences(IProblemWorkingCopy problem) {
+ super.initPreferences(problem);
+ addPreference(
+ problem,
+ PARAM_KEY,
+ CheckersMessages.NamingConventionFunctionChecker_LabelNamePattern,
+ "^[a-z]"); //$NON-NLS-1$
+ }
+
+ @Override
+ public boolean runInEditor() {
+ return true;
+ }
+}
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/NonVirtualDestructor.java b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/NonVirtualDestructor.java
new file mode 100644
index 0000000..c4bdbad
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/NonVirtualDestructor.java
@@ -0,0 +1,176 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.checkers;
+
+import org.eclipse.cdt.codan.checkers.CodanCheckersActivator;
+import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
+
+/**
+ * Checker to find that class has virtual method and non virtual destructor
+ *
+ * @author Alena
+ *
+ */
+public class NonVirtualDestructor extends AbstractIndexAstChecker {
+ private static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem"; //$NON-NLS-1$
+
+ public void processAst(IASTTranslationUnit ast) {
+ // traverse the ast using the visitor pattern.
+ ast.accept(new OnEachClass());
+ }
+
+ class OnEachClass extends ASTVisitor {
+ private IASTName className;
+ private IBinding virMethodName;
+ private IBinding destructorName;
+
+ OnEachClass() {
+ // shouldVisitDeclarations = true;
+ shouldVisitDeclSpecifiers = true;
+ }
+
+ public int visit(IASTDeclSpecifier decl) {
+ if (isClassDecl(decl)) {
+ try {
+ boolean err = hasErrorCondition(decl);
+ if (err) {
+ String clazz = className.toString();
+ String method = virMethodName.getName();
+ IASTNode ast = decl;
+ if (destructorName != null) {
+ if (destructorName instanceof ICPPInternalBinding) {
+ ICPPInternalBinding bin = (ICPPInternalBinding) destructorName;
+ IASTNode[] decls = bin.getDeclarations();
+ if (decls!=null && decls.length>0)
+ ast = decls[0];
+ }
+ reportProblem(ER_ID, ast, clazz, method, destructorName.getName());
+ }
+ }
+ } catch (DOMException e) {
+ // ignore, no error
+ } catch (Exception e) {
+ CodanCheckersActivator.log(e);
+ }
+ return PROCESS_SKIP;
+ }
+ return PROCESS_CONTINUE;
+ }
+
+ /**
+ * @param decl
+ * @throws DOMException
+ */
+ private boolean hasErrorCondition(IASTDeclSpecifier decl)
+ throws DOMException {
+ ICPPASTCompositeTypeSpecifier spec = (ICPPASTCompositeTypeSpecifier) decl;
+ className = spec.getName();
+ IBinding binding = className.getBinding();
+ if (binding == null) {
+ binding = className.resolveBinding();
+ }
+ if (binding instanceof ICPPClassType) {
+ ICPPClassType type = (ICPPClassType) binding;
+ virMethodName = null;
+ destructorName = null;
+ // check for the following conditions:
+ // class has own virtual method and own non-virtual destructor
+ // class has own virtual method and base non-virtual destructor
+ // class has base virtual method and own non-virtual destructor
+ ICPPMethod[] declaredMethods = type.getDeclaredMethods();
+ boolean hasOwnVirtualMethod = false;
+ boolean hasOwnNonVirDestructor = false;
+ boolean hasDestructor = false;
+ boolean hasVirtualMethod = false;
+ for (int i = 0; i < declaredMethods.length; i++) {
+ ICPPMethod icppMethod = declaredMethods[i];
+ if (icppMethod.isVirtual() && !icppMethod.isDestructor()) {
+ hasOwnVirtualMethod = true;
+ virMethodName = icppMethod;
+ }
+ if (icppMethod.isDestructor()) {
+ hasDestructor = true;
+ if (!icppMethod.isVirtual()) {
+ hasOwnNonVirDestructor = true;
+ destructorName = icppMethod;
+ }
+ }
+ }
+ boolean hasVirDestructor = false;
+ // class has own virtual method and own non-virtual destructor
+ if (hasOwnVirtualMethod && hasOwnNonVirDestructor) {
+ return true;
+ }
+ // class does not have virtual methods but has virtual
+ // destructor
+ // - not an error
+ if (hasOwnVirtualMethod == false && hasDestructor == true
+ && hasOwnNonVirDestructor == false) {
+ return false;
+ }
+ ICPPMethod[] allDeclaredMethods = type.getAllDeclaredMethods();
+ for (int i = 0; i < allDeclaredMethods.length; i++) {
+ ICPPMethod icppMethod = allDeclaredMethods[i];
+ if (icppMethod.isVirtual() && !icppMethod.isDestructor()) {
+ hasVirtualMethod = true;
+ if (virMethodName == null)
+ virMethodName = icppMethod;
+ }
+ if (icppMethod.isDestructor()) {
+ hasDestructor = true;
+ if (icppMethod.isVirtual()) {
+ hasVirDestructor = true;
+ } else {
+ if (destructorName == null)
+ destructorName = icppMethod;
+ }
+ }
+ }
+ if (hasOwnVirtualMethod) {
+ // class has own virtual method and base non-virtual
+ // destructor
+ if (hasDestructor == true && hasVirDestructor == false) {
+ return true;
+ }
+ } else if (hasVirtualMethod) {
+ // class has base virtual method and own non-virtual
+ // destructor
+ if (hasOwnNonVirDestructor == true) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param decl
+ * @return
+ */
+ private boolean isClassDecl(IASTDeclSpecifier decl) {
+ if (decl instanceof ICPPASTCompositeTypeSpecifier) {
+ return true;
+ }
+ return false;
+ }
+ }
+}
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java
new file mode 100644
index 0000000..e88c86d
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2009,2010 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.internal.checkers;
+
+import java.util.Iterator;
+
+import org.eclipse.cdt.codan.core.cxx.model.AbstractAstFunctionChecker;
+import org.eclipse.cdt.codan.core.cxx.model.CxxModelsCache;
+import org.eclipse.cdt.codan.core.model.IProblem;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
+import org.eclipse.cdt.codan.core.model.cfg.ICfgData;
+import org.eclipse.cdt.codan.core.model.cfg.IControlFlowGraph;
+import org.eclipse.cdt.codan.core.model.cfg.IExitNode;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IBasicType;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
+
+/**
+ * The checker suppose to find issue related to mismatched return value/function
+ * declaration
+ *
Function declared as returning non-void returns void
+ *
Function declared as returning void has non-void return
+ *
Function declared as returning non-void has no return (requires control
+ * flow graph)
+ */
+public class ReturnChecker extends AbstractAstFunctionChecker {
+ private static final String PARAM_IMPLICIT = "implicit"; //$NON-NLS-1$
+ public final String RET_NO_VALUE_ID = "org.eclipse.cdt.codan.checkers.noreturn"; //$NON-NLS-1$
+ public final String RET_ERR_VALUE_ID = "org.eclipse.cdt.codan.checkers.errreturnvalue"; //$NON-NLS-1$
+ public final String RET_NORET_ID = "org.eclipse.cdt.codan.checkers.errnoreturn"; //$NON-NLS-1$
+
+ class ReturnStmpVisitor extends ASTVisitor {
+ private IASTFunctionDefinition func;
+ boolean hasret;
+
+ ReturnStmpVisitor(IASTFunctionDefinition func) {
+ shouldVisitStatements = true;
+ shouldVisitDeclarations = true;
+ this.func = func;
+ this.hasret = false;
+ }
+ public int visit(IASTDeclaration element) {
+ if (element!=func)
+ return PROCESS_SKIP; // skip inner functions
+ return PROCESS_CONTINUE;
+ }
+ public int visit(IASTStatement stmt) {
+ if (stmt instanceof IASTReturnStatement) {
+ hasret = true;
+ IASTReturnStatement ret = (IASTReturnStatement) stmt;
+ if (!isVoid(func)) {
+ if (checkImplicitReturn(RET_NO_VALUE_ID)
+ || isExplicitReturn(func)) {
+ if (ret.getReturnValue() == null)
+ reportProblem(RET_NO_VALUE_ID, ret);
+ }
+ } else {
+ if (ret.getReturnValue() != null) {
+ IType type = ret.getReturnValue().getExpressionType();
+ if (isVoid(type))
+ return PROCESS_SKIP;
+ reportProblem(RET_ERR_VALUE_ID, ret.getReturnValue());
+ }
+ }
+
+ return PROCESS_SKIP;
+ }
+ return PROCESS_CONTINUE;
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.cxx.model.AbstractAstFunctionChecker#
+ * processFunction(org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition)
+ */
+ @Override
+ protected void processFunction(IASTFunctionDefinition func) {
+ ReturnStmpVisitor visitor = new ReturnStmpVisitor(func);
+ func.accept(visitor);
+ if (!visitor.hasret) {
+ // no return at all
+ if (!isVoid(func)
+ && (checkImplicitReturn(RET_NORET_ID) || isExplicitReturn(func))) {
+ if (endsWithNoExitNode(func))
+ reportProblem(RET_NORET_ID, func.getDeclSpecifier());
+ }
+ }
+ }
+
+ /**
+ * @param if - problem id
+ * @return true if need to check inside functions with implicit return
+ */
+ protected boolean checkImplicitReturn(String id) {
+ final IProblem pt = getProblemById(id, getFile());
+ return (Boolean) getPreference(pt,PARAM_IMPLICIT);
+ }
+
+ /**
+ * @param func
+ * @return
+ */
+ protected boolean endsWithNoExitNode(IASTFunctionDefinition func) {
+ IControlFlowGraph graph = CxxModelsCache.getInstance()
+ .getControlFlowGraph(func);
+ Iterator exitNodeIterator = graph.getExitNodeIterator();
+ boolean noexitop = false;
+ for (; exitNodeIterator.hasNext();) {
+ IExitNode node = exitNodeIterator.next();
+ if (((ICfgData) node).getData() == null) {
+ // if it real exit node such as return, exit or throw data
+ // will be an ast node, it is null it is fake node added by the
+ // graph builder
+ noexitop = true;
+ break;
+ }
+ }
+ return noexitop;
+ }
+
+ /**
+ * @param func
+ * @return
+ */
+ protected boolean isExplicitReturn(IASTFunctionDefinition func) {
+ return getDeclSpecType(func) != ICASTSimpleDeclSpecifier.t_unspecified;
+ }
+
+ /**
+ * @param func
+ * @return
+ */
+ public boolean isVoid(IASTFunctionDefinition func) {
+ int type = getDeclSpecType(func);
+ if (type == IASTSimpleDeclSpecifier.t_void) {
+ IASTFunctionDeclarator declarator = func.getDeclarator();
+ if (declarator.getPointerOperators().length == 0)
+ return true;
+ }
+ return false;
+ }
+ /**
+ * check if type if void
+ * (uses deprecated API for compatibility with 6.0)
+ * @param type
+ * @throws DOMException
+ */
+ @SuppressWarnings("deprecation")
+ public boolean isVoid(IType type) {
+ if (type instanceof IBasicType) {
+ try {
+ if (((IBasicType) type).getType()==IBasicType.t_void)
+ return true;
+ } catch (DOMException e) {
+ return false;
+ }
+ }
+ return false;
+ }
+ /**
+ * @param func
+ * @return
+ */
+ protected int getDeclSpecType(IASTFunctionDefinition func) {
+ IASTDeclSpecifier declSpecifier = func.getDeclSpecifier();
+ int type = -1;
+ if (declSpecifier instanceof IASTSimpleDeclSpecifier) {
+ type = ((IASTSimpleDeclSpecifier) declSpecifier).getType();
+ }
+ return type;
+ }
+
+ /* checker must implement @link ICheckerWithPreferences */
+ public void initPreferences(IProblemWorkingCopy problem) {
+ super.initPreferences(problem);
+ if (problem.getId().equals(RET_NO_VALUE_ID)
+ || problem.getId().equals(RET_NORET_ID)) {
+ addPreference(problem, PARAM_IMPLICIT,
+ CheckersMessages.ReturnChecker_Param0, Boolean.FALSE);
+ }
+ }
+}
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/StatementHasNoEffectChecker.java b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/StatementHasNoEffectChecker.java
new file mode 100644
index 0000000..331e86b
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/StatementHasNoEffectChecker.java
@@ -0,0 +1,196 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.checkers;
+
+import org.eclipse.cdt.codan.core.cxx.CxxAstUtils;
+import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
+import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
+import org.eclipse.cdt.core.dom.ast.IBasicType;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
+import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression;
+
+/**
+ * Checker that detects statements without effect such as
+ *
+ * a+b;
+ * or
+ * +b;
+ *
+ *
+ */
+public class StatementHasNoEffectChecker extends AbstractIndexAstChecker {
+ public static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem"; //$NON-NLS-1$
+ public static final String PARAM_MACRO_ID = "macro"; //$NON-NLS-1$
+ public static final String PARAM_EXCEPT_ARG_LIST = "exceptions"; //$NON-NLS-1$
+
+ public void processAst(IASTTranslationUnit ast) {
+ ast.accept(new CheckStmpVisitor());
+ }
+
+ class CheckStmpVisitor extends ASTVisitor {
+ CheckStmpVisitor() {
+ shouldVisitStatements = true;
+ }
+
+ public int visit(IASTStatement stmt) {
+ if (stmt instanceof IASTExpressionStatement) {
+ IASTExpression expression = ((IASTExpressionStatement) stmt)
+ .getExpression();
+ if (hasNoEffect(expression)) {
+ boolean inMacro = CxxAstUtils.getInstance().isInMacro(
+ expression);
+ boolean shouldReportInMacro = shouldReportInMacro();
+ if (inMacro && !shouldReportInMacro)
+ return PROCESS_SKIP;
+ String arg = expression.getRawSignature();
+ if (!isFilteredArg(arg))
+ reportProblem(ER_ID, stmt, arg);
+ }
+ return PROCESS_SKIP;
+ }
+ return PROCESS_CONTINUE;
+ }
+
+ /**
+ * We consider has not effect binary statements without assignment and
+ * unary statement which is not dec and inc. If operator is overloaded
+ * we not going to bother.
+ *
+ * @param e
+ * @return
+ */
+ private boolean hasNoEffect(IASTExpression e) {
+ if (e instanceof IASTBinaryExpression) {
+ IASTBinaryExpression binExpr = (IASTBinaryExpression) e;
+ if (isPossibleAssignment(binExpr))
+ return false;
+ switch (binExpr.getOperator()) {
+ case IASTBinaryExpression.op_logicalOr:
+ case IASTBinaryExpression.op_logicalAnd:
+ return hasNoEffect(binExpr.getOperand1())
+ && hasNoEffect(binExpr.getOperand2());
+ }
+ return true;
+ }
+ if (e instanceof IASTUnaryExpression) {
+ IASTUnaryExpression unaryExpr = (IASTUnaryExpression) e;
+ int operator = unaryExpr.getOperator();
+ switch (operator) {
+ case IASTUnaryExpression.op_postFixDecr:
+ case IASTUnaryExpression.op_prefixDecr:
+ case IASTUnaryExpression.op_postFixIncr:
+ case IASTUnaryExpression.op_prefixIncr:
+ case IASTUnaryExpression.op_throw:
+ return false;
+ case IASTUnaryExpression.op_bracketedPrimary:
+ return hasNoEffect(unaryExpr.getOperand());
+ }
+ return true;
+ }
+ // simply a;
+ if (e instanceof IASTIdExpression) {
+ // check if it is part of GNU comp stmt expression i.e. ({foo();a;})
+ IASTNode parent = e.getParent();
+ if (parent instanceof IASTExpressionStatement) {
+ IASTNode parent2 = parent.getParent();
+ if (parent2 instanceof IASTCompoundStatement) {
+ IASTNode parent3 = parent2.getParent();
+ if (parent3 instanceof IGNUASTCompoundStatementExpression) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+ }
+
+ public void initPreferences(IProblemWorkingCopy problem) {
+ super.initPreferences(problem);
+ addPreference(problem, PARAM_MACRO_ID,
+ CheckersMessages.StatementHasNoEffectChecker_ParameterMacro,
+ Boolean.TRUE);
+ addListPreference(
+ problem,
+ PARAM_EXCEPT_ARG_LIST,
+ CheckersMessages.GenericParameter_ParameterExceptions,
+ CheckersMessages.GenericParameter_ParameterExceptionsItem);
+ }
+
+ /**s
+ * @param paramExceptArgList
+ * @param arg
+ * @return
+ */
+ public boolean isFilteredArg(String arg) {
+ Object[] arr = (Object[]) getPreference(
+ getProblemById(ER_ID, getFile()), PARAM_EXCEPT_ARG_LIST);
+ for (int i = 0; i < arr.length; i++) {
+ String str = (String) arr[i];
+ if (arg.equals(str))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @return
+ */
+ public boolean shouldReportInMacro() {
+ return (Boolean) getPreference(getProblemById(ER_ID, getFile()),
+ PARAM_MACRO_ID);
+ }
+
+ @SuppressWarnings("restriction")
+ public boolean isPossibleAssignment(IASTBinaryExpression expr) {
+ switch (expr.getOperator()) {
+ case IASTBinaryExpression.op_assign:
+ case IASTBinaryExpression.op_binaryAndAssign:
+ case IASTBinaryExpression.op_binaryOrAssign:
+ case IASTBinaryExpression.op_binaryXorAssign:
+ case IASTBinaryExpression.op_divideAssign:
+ case IASTBinaryExpression.op_minusAssign:
+ case IASTBinaryExpression.op_moduloAssign:
+ case IASTBinaryExpression.op_multiplyAssign:
+ case IASTBinaryExpression.op_plusAssign:
+ case IASTBinaryExpression.op_shiftLeftAssign:
+ case IASTBinaryExpression.op_shiftRightAssign:
+ return true;
+ }
+ if (expr instanceof CPPASTBinaryExpression) {
+ // unfortunately ICPPASTBinaryExpression does not have
+ // getOverload public method
+ CPPASTBinaryExpression cppBin = (CPPASTBinaryExpression) expr;
+ ICPPFunction overload = cppBin.getOverload();
+ if (overload != null)
+ return true;
+ IType expressionType = cppBin.getOperand1().getExpressionType();
+ if (!(expressionType instanceof IBasicType)) {
+ return true; // must be overloaded but parser could not
+ // find it
+ }
+ }
+ return false;
+ }
+}
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/SuggestedParenthesisChecker.java b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/SuggestedParenthesisChecker.java
new file mode 100644
index 0000000..659703d
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/SuggestedParenthesisChecker.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.checkers;
+
+import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
+import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
+
+/**
+ * This checker finds a problems which are caused by lack of understanding
+ * operator
+ * precedence in C. In any case it is better to surround expressions in
+ * parenthesis to improve readability. Example: ! x>0 && x<10 (this would be
+ * (!x)>0 && x<10 in C) We only look for &&, || and ! operators (and binary | &
+ * ^ ~)
+ *
+ * @author Alena
+ *
+ */
+public class SuggestedParenthesisChecker extends AbstractIndexAstChecker {
+ public static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem"; //$NON-NLS-1$
+ public static final String PARAM_NOT = "paramNot"; //$NON-NLS-1$
+
+
+
+ public void processAst(IASTTranslationUnit ast) {
+ // traverse the ast using the visitor pattern.
+ ast.accept(new ExpressionVisitor());
+ }
+
+ class ExpressionVisitor extends ASTVisitor {
+ ExpressionVisitor() {
+ shouldVisitExpressions = true;
+ }
+
+ public int visit(IASTExpression expression) {
+ int precedence = getPrecedence(expression);
+ IASTNode parent = expression.getParent();
+ if (parent instanceof IASTExpression) {
+ IASTExpression parentExpr = (IASTExpression) parent;
+ if (isInParentesis(expression))
+ return PROCESS_CONTINUE;
+ if (precedence == 2) { // unary not
+ if (isParamNot() && isUsedAsOperand(expression)) {
+ reportProblem(ER_ID, expression, expression.getRawSignature());
+ return PROCESS_SKIP;
+ }
+ } else if (precedence >= 0) {
+ int pp = getPrecedence(parentExpr);
+ if (pp == -1 || pp == precedence)
+ return PROCESS_CONTINUE;
+ reportProblem(ER_ID, expression, expression.getRawSignature());
+ }
+ }
+ return PROCESS_CONTINUE;
+ }
+
+ private boolean isUsedAsOperand(IASTExpression expression) {
+ ASTNodeProperty prop = expression.getPropertyInParent();
+ if (prop == IASTBinaryExpression.OPERAND_ONE
+ // || prop == IASTBinaryExpression.OPERAND_TWO
+ || prop == IASTUnaryExpression.OPERAND)
+ return true;
+ return false;
+ }
+ }
+
+ private int getPrecedence(IASTExpression e) {
+ if (e instanceof IASTBinaryExpression) {
+ IASTBinaryExpression binExpr = (IASTBinaryExpression) e;
+ int operator = binExpr.getOperator();
+ if (operator == IASTBinaryExpression.op_binaryAnd)
+ return 8;
+ if (operator == IASTBinaryExpression.op_binaryXor)
+ return 9;
+ if (operator == IASTBinaryExpression.op_binaryOr)
+ return 10;
+ if (operator == IASTBinaryExpression.op_logicalAnd)
+ return 11;
+ if (operator == IASTBinaryExpression.op_logicalOr)
+ return 12;
+ }
+ if (e instanceof IASTUnaryExpression) {
+ IASTUnaryExpression binExpr = (IASTUnaryExpression) e;
+ int operator = binExpr.getOperator();
+ if (operator == IASTUnaryExpression.op_not)
+ return 2;
+ if (operator == IASTUnaryExpression.op_tilde)
+ return 2;
+ }
+ return -1;
+ }
+
+ /**
+ * @param parent
+ * @return
+ */
+ private boolean isInParentesis(IASTExpression node) {
+ IASTNode parent = node.getParent();
+ if (parent instanceof IASTUnaryExpression) {
+ IASTUnaryExpression br = (IASTUnaryExpression) parent;
+ if (br.getOperator() == IASTUnaryExpression.op_bracketedPrimary) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isParamNot() {
+ return (Boolean) getPreference(getProblemById(ER_ID, getFile()),
+ PARAM_NOT);
+ }
+
+ /*
+ * (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);
+ addPreference(problem, PARAM_NOT,
+ CheckersMessages.SuggestedParenthesisChecker_SuggestParanthesesAroundNot, Boolean.FALSE);
+ }
+}
diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/messages.properties b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/messages.properties
new file mode 100644
index 0000000..94c7757
--- /dev/null
+++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/messages.properties
@@ -0,0 +1,17 @@
+###############################################################################
+# 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
+###############################################################################
+CatchByReference_ReportForUnknownType=Report a problem if type cannot be resolved
+NamingConventionFunctionChecker_LabelNamePattern=Name Pattern
+ReturnChecker_Param0=Also check functions with implicit return value
+GenericParameter_ParameterExceptions=Exceptions (value of the problem argument)
+GenericParameter_ParameterExceptionsItem=Value of the argument
+StatementHasNoEffectChecker_ParameterMacro=Report problem in statements that comes from macro expansion
+SuggestedParenthesisChecker_SuggestParanthesesAroundNot=Suggest parentesis around not operator
diff --git a/org.eclipse.cdt.codan.core/.project b/org.eclipse.cdt.codan.core/.project
index 8ba33e6..4edd707 100644
--- a/org.eclipse.cdt.codan.core/.project
+++ b/org.eclipse.cdt.codan.core/.project
@@ -20,9 +20,15 @@
+
+ org.eclipse.pde.api.tools.apiAnalysisBuilder
+
+
+ org.eclipse.pde.PluginNatureorg.eclipse.jdt.core.javanature
+ org.eclipse.pde.api.tools.apiAnalysisNature
diff --git a/org.eclipse.cdt.codan.core/.settings/CVS/Entries b/org.eclipse.cdt.codan.core/.settings/CVS/Entries
index eb6c3d6..28056e4 100644
--- a/org.eclipse.cdt.codan.core/.settings/CVS/Entries
+++ b/org.eclipse.cdt.codan.core/.settings/CVS/Entries
@@ -1,3 +1,2 @@
-/org.eclipse.jdt.core.prefs/1.3/Mon Aug 10 18:31:46 2009//
-/org.eclipse.jdt.ui.prefs/1.1/Fri Nov 20 19:03:54 2009//
-D
+/org.eclipse.jdt.core.prefs/1.5/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/org.eclipse.jdt.ui.prefs/1.2/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/.settings/CVS/Tag b/org.eclipse.cdt.codan.core/.settings/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/.settings/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.cdt.codan.core/.settings/org.eclipse.jdt.core.prefs
index 4452aee..dc332d1 100644
--- a/org.eclipse.cdt.codan.core/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.cdt.codan.core/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Mon Aug 10 14:23:53 EDT 2009
+#Sun May 30 20:25:13 EDT 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
@@ -7,6 +7,84 @@ org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+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=enabled
+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.invalidJavadoc=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
+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.missingJavadocComments=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+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=warning
+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=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+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=ignore
+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/org.eclipse.cdt.codan.core/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.cdt.codan.core/.settings/org.eclipse.jdt.ui.prefs
index 2117213..17cb00c 100644
--- a/org.eclipse.cdt.codan.core/.settings/org.eclipse.jdt.ui.prefs
+++ b/org.eclipse.cdt.codan.core/.settings/org.eclipse.jdt.ui.prefs
@@ -1,4 +1,4 @@
-#Fri Nov 20 13:57:56 EST 2009
+#Sat May 15 15:20:42 EDT 2010
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
sp_cleanup.add_default_serial_version_id=true
@@ -8,6 +8,7 @@ sp_cleanup.add_missing_deprecated_annotations=true
sp_cleanup.add_missing_methods=false
sp_cleanup.add_missing_nls_tags=false
sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=false
sp_cleanup.add_serial_version_id=false
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
diff --git a/org.eclipse.cdt.codan.core/CVS/Entries b/org.eclipse.cdt.codan.core/CVS/Entries
index cb575f0..1e387b9 100644
--- a/org.eclipse.cdt.codan.core/CVS/Entries
+++ b/org.eclipse.cdt.codan.core/CVS/Entries
@@ -1,8 +1,10 @@
-/.classpath/1.3/Wed Dec 16 21:48:48 2009//
-/.project/1.1/Thu Apr 9 12:46:50 2009//
+/.classpath/1.3/Wed Dec 16 21:48:48 2009//TCDT_7_0_0
+/.project/1.2/Wed Mar 24 03:32:02 2010//TCDT_7_0_0
D/.settings////
D/META-INF////
-/build.properties/1.1/Thu Apr 9 12:46:50 2009//
-/plugin.xml/1.5/Sat Aug 22 21:16:49 2009//
+D/OSGI-INF////
+/about.html/1.1/Mon Jun 14 18:35:19 2010//TCDT_7_0_0
+/build.properties/1.6/Sun Jun 27 01:30:40 2010//TCDT_7_0_0
+/plugin.xml/1.11/Sun Jun 27 01:30:40 2010//TCDT_7_0_0
D/schema////
D/src////
diff --git a/org.eclipse.cdt.codan.core/CVS/Tag b/org.eclipse.cdt.codan.core/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/META-INF/CVS/Entries b/org.eclipse.cdt.codan.core/META-INF/CVS/Entries
index 222d593..f617c99 100644
--- a/org.eclipse.cdt.codan.core/META-INF/CVS/Entries
+++ b/org.eclipse.cdt.codan.core/META-INF/CVS/Entries
@@ -1,2 +1 @@
-/MANIFEST.MF/1.5/Wed Dec 16 21:48:48 2009//
-D
+/MANIFEST.MF/1.16/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/META-INF/CVS/Tag b/org.eclipse.cdt.codan.core/META-INF/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/META-INF/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/META-INF/MANIFEST.MF b/org.eclipse.cdt.codan.core/META-INF/MANIFEST.MF
index b6eba46..33aacc3 100644
--- a/org.eclipse.cdt.codan.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.cdt.codan.core/META-INF/MANIFEST.MF
@@ -1,15 +1,22 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: Code Analysis Core
+Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.cdt.codan.core;singleton:=true
-Bundle-Version: 1.0.0
+Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.eclipse.cdt.codan.core.CodanCorePlugin
-Bundle-Vendor: CDT
+Bundle-Vendor: %Bundle-Vendor
Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.core.resources,
- org.eclipse.cdt.core
+ org.eclipse.core.resources
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.eclipse.cdt.codan.core,
org.eclipse.cdt.codan.core.model,
- org.eclipse.cdt.codan.internal.core;x-friends:="org.eclipse.cdt.codan.core,org.eclipse.cdt.codan.core.test,org.eclipse.cdt.codan.ui"
+ org.eclipse.cdt.codan.core.model.cfg;x-friends:="org.eclipse.cdt.codan.core.cxx,org.eclipse.cdt.codan.checkers",
+ org.eclipse.cdt.codan.core.param,
+ org.eclipse.cdt.codan.internal.core;
+ x-friends:="org.eclipse.cdt.codan.core,
+ org.eclipse.cdt.codan.core.cxx,
+ org.eclipse.cdt.codan.core.test,
+ org.eclipse.cdt.codan.ui",
+ org.eclipse.cdt.codan.internal.core.cfg;x-friends:="org.eclipse.cdt.codan.core.cxx",
+ org.eclipse.cdt.codan.internal.core.model;x-friends:="org.eclipse.cdt.codan.core.cxx,org.eclipse.cdt.codan.core.test,org.eclipse.cdt.codan.ui"
diff --git a/org.eclipse.cdt.codan.core/OSGI-INF/CVS/Entries b/org.eclipse.cdt.codan.core/OSGI-INF/CVS/Entries
new file mode 100644
index 0000000..2928641
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/OSGI-INF/CVS/Entries
@@ -0,0 +1 @@
+D/l10n////
diff --git a/org.eclipse.cdt.codan.core/OSGI-INF/CVS/Repository b/org.eclipse.cdt.codan.core/OSGI-INF/CVS/Repository
new file mode 100644
index 0000000..897fbf9
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/OSGI-INF/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.core/OSGI-INF
diff --git a/org.eclipse.cdt.codan.core/OSGI-INF/CVS/Root b/org.eclipse.cdt.codan.core/OSGI-INF/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/OSGI-INF/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.core/OSGI-INF/CVS/Tag b/org.eclipse.cdt.codan.core/OSGI-INF/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/OSGI-INF/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/OSGI-INF/l10n/CVS/Entries b/org.eclipse.cdt.codan.core/OSGI-INF/l10n/CVS/Entries
new file mode 100644
index 0000000..3c7dd91
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/OSGI-INF/l10n/CVS/Entries
@@ -0,0 +1 @@
+/bundle.properties/1.2/Thu Jun 3 17:01:53 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/OSGI-INF/l10n/CVS/Repository b/org.eclipse.cdt.codan.core/OSGI-INF/l10n/CVS/Repository
new file mode 100644
index 0000000..dcc0604
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/OSGI-INF/l10n/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.core/OSGI-INF/l10n
diff --git a/org.eclipse.cdt.codan.core/OSGI-INF/l10n/CVS/Root b/org.eclipse.cdt.codan.core/OSGI-INF/l10n/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/OSGI-INF/l10n/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.core/OSGI-INF/l10n/CVS/Tag b/org.eclipse.cdt.codan.core/OSGI-INF/l10n/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/OSGI-INF/l10n/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/OSGI-INF/l10n/bundle.properties b/org.eclipse.cdt.codan.core/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 0000000..88acd6e
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,19 @@
+###############################################################################
+# 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
+###############################################################################
+#Properties file for org.eclipse.cdt.codan.core
+Bundle-Vendor = Eclipse CDT
+Bundle-Name = Code Analysis Core
+extension.name.Builder = Code Analysis Project Builder
+extension.name.Nature = Code Analysis Nature
+extension.name.Marker = Code Analysis Problem
+category.name.ProgrammingErrors = Potential programming problems
+category.name.CodeStyle = Coding Style
+extension-point.name.CodeAnalysis = Code Analysis Checkers
\ No newline at end of file
diff --git a/org.eclipse.cdt.codan.core/about.html b/org.eclipse.cdt.codan.core/about.html
new file mode 100644
index 0000000..d7c5118
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/about.html
@@ -0,0 +1,24 @@
+
+
+About
+
+
+
About This Content
+
+
June 22, 2007
+
License
+
+
The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at http://www.eclipse.org/legal/epl-v10.html.
+For purposes of the EPL, "Program" will mean the Content.
+
+
If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at http://www.eclipse.org.
+
+
\ No newline at end of file
diff --git a/org.eclipse.cdt.codan.core/build.properties b/org.eclipse.cdt.codan.core/build.properties
index 3595411..b599b4a 100644
--- a/org.eclipse.cdt.codan.core/build.properties
+++ b/org.eclipse.cdt.codan.core/build.properties
@@ -1,6 +1,19 @@
+###############################################################################
+# Copyright (c) 2009, 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
+###############################################################################
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
- schema/
+ schema/,\
+ OSGI-INF/l10n/bundle.properties,\
+ about.html
+src.includes = schema/
diff --git a/org.eclipse.cdt.codan.core/plugin.xml b/org.eclipse.cdt.codan.core/plugin.xml
index b7b10a0..1b051a3 100644
--- a/org.eclipse.cdt.codan.core/plugin.xml
+++ b/org.eclipse.cdt.codan.core/plugin.xml
@@ -1,11 +1,11 @@
-
+
@@ -16,7 +16,7 @@
+
+
+
+
+ type="org.eclipse.cdt.core.problem">
+
+
+
+
+
@@ -48,9 +59,12 @@
+
-
@@ -62,7 +76,7 @@
thread="main"
visible="true">
+ class="org.eclipse.cdt.codan.internal.core.CodanApplication">
diff --git a/org.eclipse.cdt.codan.core/schema/CVS/Entries b/org.eclipse.cdt.codan.core/schema/CVS/Entries
index 2905ba5..f6008c3 100644
--- a/org.eclipse.cdt.codan.core/schema/CVS/Entries
+++ b/org.eclipse.cdt.codan.core/schema/CVS/Entries
@@ -1,2 +1 @@
-/checkers.exsd/1.1/Thu Apr 9 12:46:50 2009//
-D
+/checkers.exsd/1.5/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/schema/CVS/Tag b/org.eclipse.cdt.codan.core/schema/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/schema/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/schema/checkers.exsd b/org.eclipse.cdt.codan.core/schema/checkers.exsd
index 71808a5..1990117 100644
--- a/org.eclipse.cdt.codan.core/schema/checkers.exsd
+++ b/org.eclipse.cdt.codan.core/schema/checkers.exsd
@@ -60,6 +60,7 @@
+
@@ -143,6 +144,43 @@
+
+
+
+ If problem is enabled in original profile. Default is true.
+
+
+
+
+
+
+ Default error message pattern. Use java pattern notation such as {0} to replace with first argument, and so on.
+
+
+
+
+
+
+
+
+
+ Short description of the problem
+
+
+
+
+
+
+
+
+
+ Marker type to use to generate problem, default is the generic codan marker
+
+
+
+
+
+
@@ -178,6 +216,21 @@
+
+
+
+
+
+ Reference to a problem
+
+
+
+
+
+
+
+
+
diff --git a/org.eclipse.cdt.codan.core/src/CVS/Tag b/org.eclipse.cdt.codan.core/src/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/src/org/CVS/Tag b/org.eclipse.cdt.codan.core/src/org/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/CVS/Tag b/org.eclipse.cdt.codan.core/src/org/eclipse/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/CVS/Tag b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/CVS/Entries b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/CVS/Entries
index 94f7274..d028aeb 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/CVS/Entries
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/CVS/Entries
@@ -1,2 +1,3 @@
D/core////
D/internal////
+D/provisional////
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/CVS/Tag b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CVS/Entries b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CVS/Entries
index d3c5192..3e108e0 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CVS/Entries
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CVS/Entries
@@ -1,6 +1,8 @@
-/CodanApplication.java/1.2/Sat Aug 22 21:16:48 2009//
-/CodanCorePlugin.java/1.3/Sat Aug 22 21:16:48 2009//
-/CodanRuntime.java/1.1/Sat Aug 22 21:16:48 2009//
-/PreferenceConstants.java/1.2/Sat Apr 18 04:01:43 2009//
+/CodanCorePlugin.java/1.5/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/CodanRuntime.java/1.6/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/Messages.java/1.3/Tue May 25 01:33:23 2010//TCDT_7_0_0
+/PreferenceConstants.java/1.6/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
D/builder////
+/messages.properties/1.4/Thu Jun 3 17:01:53 2010//TCDT_7_0_0
D/model////
+D/param////
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CVS/Tag b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanApplication.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanApplication.java
deleted file mode 100644
index e0287b1..0000000
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanApplication.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package org.eclipse.cdt.codan.core;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-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;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.equinox.app.IApplication;
-import org.eclipse.equinox.app.IApplicationContext;
-
-public class CodanApplication implements IApplication {
- private Collection projects = new ArrayList();
- private boolean verbose = false;
- private boolean all = false;
-
- public Object start(IApplicationContext context) throws Exception {
- String[] args = (String[]) context.getArguments().get(
- "application.args");
- if (args == null || args.length == 0) {
- help();
- return EXIT_OK;
- }
- extractArguments(args);
- CodanBuilder codanBuilder = new CodanBuilder();
- CodanRuntime runtime = CodanRuntime.getInstance();
- runtime.setProblemReporter(new CodanMarkerProblemReporter() {
- @Override
- public void reportProblem(String id, int severity, IFile file,
- int lineNumber, int startChar, int endChar, String message) {
- System.out.println(file.getLocation() + ":" + lineNumber + ": "
- + message);
- }
- });
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- if (all) {
- log("Launching analysis on workspace");
- root.accept(codanBuilder.new CodanResourceVisitor());
- } else {
- for (String project : projects) {
- log("Launching analysis on project " + project);
- IProject wProject = root.getProject(project);
- if (!wProject.exists()) {
- System.err.println("Error: project " + project
- + " does not exist");
- continue;
- }
- wProject.accept(codanBuilder.new CodanResourceVisitor());
- }
- }
- return EXIT_OK;
- }
-
- /**
- * @param string
- */
- private void log(String string) {
- if (verbose)
- System.err.println(string);
- }
-
- /**
- * @param args
- */
- private void extractArguments(String[] args) {
- for (int i = 0; i < args.length; i++) {
- String string = args[i];
- if (string.equals("-verbose")) {
- verbose = true;
- } else if (string.equals("-all")) {
- all = true;
- } else {
- projects.add(string);
- }
- }
- }
-
- /**
- *
- */
- private void help() {
- System.out.println("Usage: [options] ...");
- System.out.println("Options:");
- System.out.println(" -all - run on all projects in workspace");
- System.out.println(" -verbose - print extra build information");
- }
-
- public void stop() {
- // nothing
- }
-}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java
index d60262b..90e5d83 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 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.core;
import org.eclipse.cdt.codan.internal.core.CodeAnlysisNature;
@@ -13,7 +23,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 PLUGIN_ID = "org.eclipse.cdt.codan.core"; //$NON-NLS-1$
public static final String NATURE_ID = CodeAnlysisNature.NATURE_ID;
// The shared instance
private static CodanCorePlugin plugin;
@@ -34,6 +44,7 @@ public class CodanCorePlugin extends Plugin {
* @see
* org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
+ @Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
@@ -45,6 +56,7 @@ public class CodanCorePlugin extends Plugin {
* @see
* org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
+ @Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanRuntime.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanRuntime.java
index 16375cf..bc7b3d7 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanRuntime.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanRuntime.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -11,44 +11,102 @@
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.IProblemLocationFactory;
import org.eclipse.cdt.codan.core.model.IProblemReporter;
-import org.eclipse.cdt.codan.internal.core.CheckersRegisry;
+import org.eclipse.cdt.codan.internal.core.CheckersRegistry;
import org.eclipse.cdt.codan.internal.core.CodanBuilder;
import org.eclipse.cdt.codan.internal.core.model.CodanMarkerProblemReporter;
+import org.eclipse.cdt.codan.internal.core.model.ProblemLocationFactory;
/**
* Runtime singleton class to get access to Codan framework parts
*
+ * Clients may extend this class to override default framework parts.
+ *
+ *
+ * EXPERIMENTAL. This class or interface has been added as part
+ * of a work in progress. There is no guarantee that this API will work or that
+ * it will remain the same.
+ *
*/
public class CodanRuntime {
private static CodanRuntime instance = new CodanRuntime();
private IProblemReporter problemReporter = new CodanMarkerProblemReporter();
- private CodanBuilder builder = new CodanBuilder();
- private CheckersRegisry checkers = CheckersRegisry.getInstance();
+ private ICodanBuilder builder = new CodanBuilder();
+ private CheckersRegistry checkers = CheckersRegistry.getInstance();
+ private IProblemLocationFactory locFactory = new ProblemLocationFactory();
+
+ /**
+ * CodanRuntime - only can be called by subclasses to override default
+ * constructor
+ */
+ protected CodanRuntime() {
+ // nothing here
+ }
+ /**
+ * Get runtime problem reporter. Default reported generated problem markers.
+ *
+ * @return
+ */
public IProblemReporter getProblemReporter() {
return problemReporter;
}
+ /**
+ * Set different problem reporter.
+ *
+ * @param reporter
+ */
public void setProblemReporter(IProblemReporter reporter) {
problemReporter = reporter;
}
+ /**
+ * Get instance of of Codan Runtime
+ *
+ * @return
+ */
public static CodanRuntime getInstance() {
return instance;
}
+ /**
+ * Get builder. Builder can used to run code analysis on given resource
+ * using API.
+ *
+ * @return
+ */
public ICodanBuilder getBuilder() {
return builder;
}
- public ICodanAstReconciler getAstQuickBuilder() {
- return builder;
- }
-
+ /**
+ * Get checkers registry.
+ *
+ * @return
+ */
public ICheckersRegistry getChechersRegistry() {
return checkers;
}
+
+ /**
+ * Get problem location factory.
+ *
+ * @return
+ */
+ public IProblemLocationFactory getProblemLocationFactory() {
+ return locFactory;
+ }
+
+ /**
+ * Set another problem location factory - only need if default is not
+ * sufficient, i.e IProblemLocation is implemented differently
+ *
+ * @param factory
+ */
+ public void setProblemLocationFactory(IProblemLocationFactory factory) {
+ locFactory = factory;
+ }
}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/Messages.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/Messages.java
new file mode 100644
index 0000000..312c5c2
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/Messages.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2009,2010 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.osgi.util.NLS;
+
+/**
+ * Core Messages
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.codan.core.messages"; //$NON-NLS-1$
+ public static String CodanApplication_all_option;
+ public static String CodanApplication_Error_ProjectDoesNotExists;
+ public static String CodanApplication_LogRunProject;
+ public static String CodanApplication_LogRunWorkspace;
+ public static String CodanApplication_Options;
+ public static String CodanApplication_Usage;
+ public static String CodanApplication_verbose_option;
+ public static String CodanBuilder_Code_Analysis_On;
+ public static String FileScopeProblemPreference_Label;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/PreferenceConstants.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/PreferenceConstants.java
index a4a1374..c730e9e 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/PreferenceConstants.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/PreferenceConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -12,9 +12,15 @@ package org.eclipse.cdt.codan.core;
/**
* Constant definitions for plug-in preferences
+ *
+ * EXPERIMENTAL. This class or interface has been added as part
+ * of a work in progress. There is no guarantee that this API will work or that
+ * it will remain the same.
+ *
*/
public class PreferenceConstants {
- public static final String P_RUN_ON_BUILD = "booleanPreference";
- public static final String P_PROBLEMS = "problems";
- public static final String P_USE_PARENT = "useParentScope";
+ public static final String P_RUN_ON_BUILD = "onBuild"; //$NON-NLS-1$
+ public static final String P_RUN_IN_EDITOR = "inEditor"; //$NON-NLS-1$
+ public static final String P_PROBLEMS = "problems"; //$NON-NLS-1$
+ public static final String P_USE_PARENT = "useParentScope"; //$NON-NLS-1$
}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/messages.properties b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/messages.properties
new file mode 100644
index 0000000..d27aa29
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/messages.properties
@@ -0,0 +1,19 @@
+###############################################################################
+# 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
+###############################################################################
+CodanApplication_Error_ProjectDoesNotExists=Error: project {0} does not exist
+CodanApplication_LogRunProject=Running code analysis on project
+CodanApplication_LogRunWorkspace=Running code analysis on workspace
+CodanApplication_Usage=Usage: [options] ...
+CodanApplication_Options=Options:
+CodanApplication_all_option= -all - run on all projects in workspace
+CodanApplication_verbose_option= -verbose - print verbose build information
+CodanBuilder_Code_Analysis_On=Code analysis on
+FileScopeProblemPreference_Label=Exclusion and Inclusion
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java
index f1e5028..411ba67 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -11,12 +11,21 @@
package org.eclipse.cdt.codan.core.model;
import org.eclipse.cdt.codan.core.CodanRuntime;
+import org.eclipse.cdt.codan.internal.core.CheckersRegistry;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+/**
+ * Convenience implementation of IChecker interface. Has a default
+ * implementation for common methods.
+ *
+ */
public abstract class AbstractChecker implements IChecker {
protected String name;
+ /**
+ * Default constructor
+ */
public AbstractChecker() {
}
@@ -32,19 +41,38 @@ public abstract class AbstractChecker implements IChecker {
* Reports a simple problem for given file and line
*
* @param id
- * - problem id
+ * - problem id
* @param file
- * - 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)
+ * - line
+ * @param args
+ * - problem arguments, 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 arg) {
+ public void reportProblem(String id, IFile file, int lineNumber,
+ Object... args) {
getProblemReporter().reportProblem(id,
- new ProblemLocation(file, lineNumber), arg);
+ createProblemLocation(file, lineNumber), args);
+ }
+
+ /**
+ * Finds an instance of problem by given id, in user profile registered for
+ * specific file
+ *
+ * @param id
+ * - problem id
+ * @param file
+ * - file in scope
+ * @return problem instance
+ */
+ public IProblem getProblemById(String id, IResource file) {
+ IProblem problem = CheckersRegistry.getInstance()
+ .getResourceProfile(file).findProblem(id);
+ if (problem == null)
+ throw new IllegalArgumentException("Id is not registered"); //$NON-NLS-1$
+ return problem;
}
/**
@@ -52,15 +80,15 @@ public abstract class AbstractChecker implements IChecker {
* from problem definition
*
* @param id
- * - problem id
+ * - problem id
* @param file
- * - file
+ * - file
* @param lineNumber
- * - line
+ * - line
*/
public void reportProblem(String id, IFile file, int lineNumber) {
getProblemReporter().reportProblem(id,
- new ProblemLocation(file, lineNumber), new Object[] {});
+ createProblemLocation(file, lineNumber), new Object[] {});
}
/**
@@ -70,7 +98,64 @@ public abstract class AbstractChecker implements IChecker {
return CodanRuntime.getInstance().getProblemReporter();
}
+ /**
+ * Convenience method to return codan runtime
+ *
+ * @return
+ */
+ protected CodanRuntime getRuntime() {
+ return CodanRuntime.getInstance();
+ }
+
+ /**
+ * Convenience method to create and return instance of IProblemLocation
+ *
+ * @param file
+ * - file where problem is found
+ * @param line
+ * - line number 1-relative
+ * @return instance of IProblemLocation
+ */
+ protected IProblemLocation createProblemLocation(IFile file, int line) {
+ return getRuntime().getProblemLocationFactory().createProblemLocation(
+ file, line);
+ }
+
+ /**
+ * Convenience method to create and return instance of IProblemLocation
+ *
+ * @param file
+ * - file where problem is found
+ * @param startChar
+ * - start char of the problem in the file, is zero-relative
+ * @param endChar
+ * - end char of the problem in the file, is zero-relative and
+ * exclusive.
+ * @return instance of IProblemLocation
+ */
+ protected IProblemLocation createProblemLocation(IFile file, int startChar,
+ int endChar) {
+ return getRuntime().getProblemLocationFactory().createProblemLocation(
+ file, startChar, endChar);
+ }
+
+ /**
+ * Defines if checker should be run as user type in C editor. Override this
+ * method is checker is too heavy for that (runs too long)
+ */
public boolean runInEditor() {
- return false;
+ return this instanceof IRunnableInEditorChecker;
+ }
+
+ /**
+ * report a problem
+ *
+ * @param problemId - id of a problem
+ * @param loc - problem location
+ * @param args - extra problem arguments
+ */
+ public void reportProblem(String problemId, IProblemLocation loc,
+ Object... args) {
+ getProblemReporter().reportProblem(problemId, loc, args);
}
}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractCheckerWithProblemPreferences.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractCheckerWithProblemPreferences.java
new file mode 100644
index 0000000..b58156f
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractCheckerWithProblemPreferences.java
@@ -0,0 +1,223 @@
+/*******************************************************************************
+ * Copyright (c) 2009,2010 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.Collection;
+import java.util.Iterator;
+
+import org.eclipse.cdt.codan.core.param.AbstractProblemPreference;
+import org.eclipse.cdt.codan.core.param.BasicProblemPreference;
+import org.eclipse.cdt.codan.core.param.FileScopeProblemPreference;
+import org.eclipse.cdt.codan.core.param.IProblemPreference;
+import org.eclipse.cdt.codan.core.param.IProblemPreferenceDescriptor.PreferenceType;
+import org.eclipse.cdt.codan.core.param.ListProblemPreference;
+import org.eclipse.cdt.codan.core.param.MapProblemPreference;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * AbstarctChecker that has extra methods to simplify adding problem
+ * preferences.
+ * Checker can produce several problems, but preferences are per problem.
+ * Sharing preferences between problems is not supported now.
+ */
+public abstract class AbstractCheckerWithProblemPreferences extends
+ AbstractChecker implements ICheckerWithPreferences {
+ /**
+ * Checker that actually has parameter must override this
+ */
+ public void initPreferences(IProblemWorkingCopy problem) {
+ // by default add file scope preference
+ addPreference(problem, new FileScopeProblemPreference(), null);
+ }
+
+ /**
+ * Scope preference - special preference that all file checkers should have,
+ * it allows user to include/exclude files for this specific problem.
+ *
+ * @param problem - problem for which scope preference is need
+ * @return scope problem preference, null if not defined
+ */
+ public FileScopeProblemPreference getScopePreference(IProblem problem) {
+ FileScopeProblemPreference scope = (FileScopeProblemPreference) getTopLevelPreferenceMap(
+ problem).getChildDescriptor(FileScopeProblemPreference.KEY);
+ return scope;
+ }
+
+ /**
+ * User can scope out some resources for this checker. Checker can use this
+ * call to test if it should run on this resource at all or not. Test should
+ * be done within processResource method not in enabledInContext.
+ * This test uses user "scope" preference for the all problems that this
+ * checker can produce.
+ *
+ * @param res - resource to test on
+ * @return true if checker should report problems, fails otherwise.
+ */
+ public boolean shouldProduceProblems(IResource res) {
+ Collection refProblems = getRuntime().getChechersRegistry()
+ .getRefProblems(this);
+ for (Iterator iterator = refProblems.iterator(); iterator
+ .hasNext();) {
+ IProblem checkerProblem = iterator.next();
+ if (shouldProduceProblem(
+ getProblemById(checkerProblem.getId(), res),
+ res.getLocation()))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * User can scope out some resources for this checker. Checker can use this
+ * call to test if it should run on this resource at all or produce a
+ * specific problem on this resource. Test should
+ * be done within processResource method not in enabledInContext, or just
+ * before printing of a problem.
+ * This test uses user "scope" preference for the given problem. If scope is
+ * not defined preference it returns true.
+ *
+ * @param problem - problem to test for
+ * @param resource - resource to test on
+ *
+ * @return true if problem should be report for given resource, fails
+ * otherwise.
+ */
+ public boolean shouldProduceProblem(IProblem problem, IPath resource) {
+ FileScopeProblemPreference scope = getScopePreference(problem);
+ if (scope == null)
+ return true;
+ return scope.isInScope(resource);
+ }
+
+ @Override
+ public void reportProblem(String problemId, IProblemLocation loc,
+ Object... args) {
+ if (shouldProduceProblem(getProblemById(problemId, loc.getFile()), loc
+ .getFile().getLocation()))
+ super.reportProblem(problemId, loc, args);
+ }
+
+ /**
+ * Add a parameter
+ *
+ * @param problem
+ * - problem that has parameter
+ * @param key
+ * - parameter key
+ * @param label
+ * - parameter label - user visible
+ * @param defaultValue
+ * - parameter default value
+ * @return - parameter info object
+ */
+ public IProblemPreference addPreference(IProblemWorkingCopy problem,
+ String key, String label, Object defaultValue) {
+ MapProblemPreference map = getTopLevelPreferenceMap(problem);
+ BasicProblemPreference info = new BasicProblemPreference(key, label,
+ PreferenceType.typeOf(defaultValue));
+ map.addChildDescriptor(info);
+ setDefaultPreferenceValue(problem, key, defaultValue);
+ return info;
+ }
+
+ /**
+ * Add preference of type list of strings, list is empty by
+ * default
+ *
+ * @param problem
+ * - problem
+ * @param key
+ * - preference key
+ * @param label
+ * - preference label
+ * @param itemLabel
+ * @return preference instance of of the list, can be used to add default
+ * values or set different element type
+ *
+ */
+ public ListProblemPreference addListPreference(IProblemWorkingCopy problem,
+ String key, String label, String itemLabel) {
+ MapProblemPreference map = getTopLevelPreferenceMap(problem);
+ ListProblemPreference list = new ListProblemPreference(key, label);
+ list.setChildDescriptor(new BasicProblemPreference(
+ ListProblemPreference.COMMON_DESCRIPTOR_KEY, itemLabel,
+ PreferenceType.TYPE_STRING));
+ return (ListProblemPreference) map.addChildDescriptor(list);
+ }
+
+ /**
+ * Add preference for the given problem with default value
+ *
+ * @param problem
+ * @param pref - preference
+ * @param defaultValue - default value of the preference
+ * @return added preference
+ */
+ public IProblemPreference addPreference(IProblemWorkingCopy problem,
+ IProblemPreference pref, Object defaultValue) {
+ MapProblemPreference map = getTopLevelPreferenceMap(problem);
+ String key = pref.getKey();
+ pref = map.addChildDescriptor(pref);
+ setDefaultPreferenceValue(problem, key, defaultValue);
+ return pref;
+ }
+
+ /**
+ * Convenience method for setting default preference value for checker that
+ * uses "map" as top level problem preference.
+ *
+ * @param problem - problem for which to set default value for a prefence
+ * @param key - preference key
+ * @param defaultValue - value of preference to be set
+ */
+ protected void setDefaultPreferenceValue(IProblemWorkingCopy problem,
+ String key, Object defaultValue) {
+ MapProblemPreference map = getTopLevelPreferenceMap(problem);
+ if (map.getChildValue(key) == null)
+ map.setChildValue(key, defaultValue);
+ }
+
+ /**
+ * Return "map" problem preference for a give problem, if problem
+ * has preference different than a map, it will throw ClassCastException.
+ * If top level preference does not exist create a map preference with name
+ * "params"
+ * and return it.
+ *
+ * @param problem
+ * @return top level preference if it is a map
+ */
+ protected MapProblemPreference getTopLevelPreferenceMap(IProblem problem) {
+ MapProblemPreference map = (MapProblemPreference) problem
+ .getPreference();
+ if (map == null) {
+ map = new MapProblemPreference(AbstractProblemPreference.PARAM, ""); //$NON-NLS-1$
+ if (problem instanceof IProblemWorkingCopy) {
+ ((IProblemWorkingCopy) problem).setPreference(map);
+ }
+ }
+ return map;
+ }
+
+ /**
+ * Returns value of the preference for the key in the top level
+ * preference map for the given problem
+ *
+ * @param problem - problem for which to get the preference
+ * @param key - preference key
+ * @return value of the preference
+ */
+ public Object getPreference(IProblem problem, String key) {
+ return ((MapProblemPreference) problem.getPreference())
+ .getChildValue(key);
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractIndexAstChecker.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractIndexAstChecker.java
deleted file mode 100644
index d805f2f..0000000
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractIndexAstChecker.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * 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.cdt.codan.core.CodanCorePlugin;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.index.IIndex;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-/**
- * @author Alena
- *
- */
-public abstract class AbstractIndexAstChecker extends AbstractChecker implements
- ICAstChecker {
- private IFile file;
-
- protected IFile getFile() {
- return file;
- }
-
- void processFile(IFile file) throws CoreException, InterruptedException {
- // create translation unit and access index
- ICElement model = CoreModel.getDefault().create(file);
- if (!(model instanceof ITranslationUnit))
- return;
- ITranslationUnit tu = (ITranslationUnit) model;
- if (tu == null)
- return; // not a C/C++ file
- IIndex index = CCorePlugin.getIndexManager().getIndex(tu.getCProject());
- // lock the index for read access
- index.acquireReadLock();
- try {
- // create index based ast
- IASTTranslationUnit ast = tu.getAST(index,
- ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
- // traverse the ast using the visitor pattern.
- this.file = file;
- processAst(ast);
- } finally {
- this.file = null;
- index.releaseReadLock();
- }
- }
-
- public boolean processResource(IResource resource) {
- if (resource instanceof IFile) {
- IFile file = (IFile) resource;
- try {
- processFile(file);
- } catch (CoreException e) {
- CodanCorePlugin.log(e);
- } catch (InterruptedException e) {
- // ignore
- }
- return false;
- }
- return true;
- }
-
- public void reportProblem(String id, IASTNode astNode, String message) {
- IASTFileLocation astLocation = astNode.getFileLocation();
- IPath location = new Path(astLocation.getFileName());
- IFile astFile = ResourcesPlugin.getWorkspace().getRoot()
- .getFileForLocation(location);
- if (astFile == null) {
- astFile = file;
- }
- ProblemLocation loc;
- if (astLocation.getStartingLineNumber() == astLocation
- .getEndingLineNumber())
- loc = new ProblemLocation(astFile, astLocation.getNodeOffset(),
- astLocation.getNodeOffset() + astLocation.getNodeLength());
- else
- loc = new ProblemLocation(astFile, astLocation
- .getStartingLineNumber());
- getProblemReporter().reportProblem(id, loc, message);
- }
-
- @Override
- public boolean runInEditor() {
- return true;
- }
-}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractProblemLocation.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractProblemLocation.java
new file mode 100644
index 0000000..c2bcd2a
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractProblemLocation.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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;
+
+/**
+ * Abstract Implementation of IProblemLocation
+ *
+ * Clients may extend this class.
+ *
+ * EXPERIMENTAL. This class or interface has been added as
+ * part of a work in progress. There is no guarantee that this API will
+ * work or that it will remain the same.
+ *
+ */
+public abstract class AbstractProblemLocation implements IProblemLocation {
+ protected IFile file;
+ protected int line;
+ protected int posStart;
+ protected int posEnd;
+ protected Object extra;
+
+ protected AbstractProblemLocation(IFile file, int line) {
+ this.file = file;
+ this.line = line;
+ this.posStart = -1;
+ this.posEnd = -1;
+ }
+
+ protected AbstractProblemLocation(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;
+ }
+
+ /**
+ * Sets extra data for the problem location
+ *
+ * @param data
+ */
+ public void setData(Object data) {
+ this.extra = data;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.IProblemLocation#getFile()
+ */
+ public IFile getFile() {
+ return file;
+ }
+
+ /**
+ * Problem line number referenced in problem view in location field
+ */
+ public int getLineNumber() {
+ return getStartingLineNumber();
+ }
+
+ /**
+ * @return line number where problem starts
+ */
+ 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/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Entries b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Entries
index 8635b9d..4315bc4 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Entries
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Entries
@@ -1,16 +1,19 @@
-/AbstractChecker.java/1.4/Sat Aug 22 21:31:29 2009//
-/AbstractIndexAstChecker.java/1.6/Wed Dec 16 21:48:48 2009//
-/CodanSeverity.java/1.2/Wed Apr 22 01:26:56 2009//
-/ICAstChecker.java/1.1/Thu Apr 9 12:46:50 2009//
-/IChecker.java/1.3/Wed Dec 16 21:48:48 2009//
-/ICheckersRegistry.java/1.1/Sat Aug 22 21:16:48 2009//
-/ICodanAstReconciler.java/1.1/Sat Aug 22 21:16:48 2009//
-/ICodanBuilder.java/1.1/Sat Aug 22 21:16:48 2009//
-/IProblem.java/1.4/Wed Dec 16 21:48:48 2009//
-/IProblemCategory.java/1.3/Wed Dec 16 21:48:48 2009//
-/IProblemElement.java/1.2/Wed Dec 16 21:48:48 2009//
-/IProblemLocation.java/1.1/Sat Aug 22 21:16:48 2009//
-/IProblemProfile.java/1.4/Wed Dec 16 21:48:48 2009//
-/IProblemReporter.java/1.2/Wed Dec 16 21:48:48 2009//
-/ProblemLocation.java/1.1/Sat Aug 22 21:16:48 2009//
-D
+/AbstractChecker.java/1.13/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/AbstractCheckerWithProblemPreferences.java/1.5/Mon May 31 02:53:25 2010//TCDT_7_0_0
+/AbstractProblemLocation.java/1.3/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/CodanSeverity.java/1.6/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IChecker.java/1.8/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/ICheckerWithPreferences.java/1.3/Thu Jun 3 17:01:52 2010//TCDT_7_0_0
+/ICheckersRegistry.java/1.6/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/ICodanBuilder.java/1.4/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblem.java/1.13/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblemCategory.java/1.7/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblemElement.java/1.4/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblemLocation.java/1.4/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblemLocationFactory.java/1.5/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblemProfile.java/1.8/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblemReporter.java/1.6/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblemReporterPersistent.java/1.3/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblemWorkingCopy.java/1.9/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IRunnableInEditorChecker.java/1.3/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+D/cfg////
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Tag b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanSeverity.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanSeverity.java
index acfa4d1..fb85718 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanSeverity.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanSeverity.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -12,21 +12,40 @@ package org.eclipse.cdt.codan.core.model;
import org.eclipse.core.resources.IMarker;
+/**
+ *
+ * Represents Severity of the codan problem. It is directly mapped to markers
+ * severity.
+ *
+ */
public enum CodanSeverity {
- Info(IMarker.SEVERITY_INFO), Warning(IMarker.SEVERITY_WARNING), Error(
- IMarker.SEVERITY_ERROR);
+ /**
+ * Info severity
+ */
+ Info(IMarker.SEVERITY_INFO),
+ /**
+ * Warning severity
+ */
+ Warning(IMarker.SEVERITY_WARNING),
+ /**
+ * Error severity
+ */
+ Error(IMarker.SEVERITY_ERROR);
private int value;
private CodanSeverity(int value) {
this.value = value;
}
+ /**
+ * @return int value of the severity
+ */
public int intValue() {
return value;
}
/**
- * @return
+ * @return array of string value for all severities
*/
public static String[] stringValues() {
CodanSeverity[] values = values();
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICAstChecker.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICAstChecker.java
deleted file mode 100644
index 461c0fa..0000000
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICAstChecker.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * 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.cdt.core.dom.ast.IASTTranslationUnit;
-
-/**
- * @author Alena
- *
- */
-public interface ICAstChecker extends IChecker {
- void processAst(IASTTranslationUnit ast);
-}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IChecker.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IChecker.java
index 60f7cb2..f00fea0 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IChecker.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IChecker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -13,27 +13,48 @@ package org.eclipse.cdt.codan.core.model;
import org.eclipse.core.resources.IResource;
/**
- * Interface that checker must implement. CDT Checker must be able to process a resource.
+ * Interface that checker must implement (through extending directly or
+ * indirectly {@link AbstractChecker}.
+ *
+ *
+ * EXPERIMENTAL. This class or interface has been added as part
+ * of a work in progress. There is no guarantee that this API will work or that
+ * it will remain the same.
+ *
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * Extend {@link AbstractChecker} class instead.
*/
public interface IChecker {
/**
* Main method that checker should implement that actually detects errors
- * @param resource - resource to run on
- * @return true if need to traverse children
+ *
+ * @param resource
+ * - resource to run on
+ * @return true if framework should traverse children of the resource and
+ * run this checkers on them again
*/
boolean processResource(IResource resource);
/**
- * Implement this method to trim down type of resource you are interested in,
- * usually it will be c/c++ files only
+ * Implement this method to trim down type of resource you are interested
+ * in, usually it will be c/c++ files only. This method should be
+ * independent from current user preferences.
+ *
* @param resource
- * @return
+ * - resource to run on
+ * @return - true if checker should be run on this resource
*/
boolean enabledInContext(IResource resource);
/**
* Checker must implement this method to determine if it can run in editor
- * "as you type", checker must be really light weight to run in this mode
+ * "as you type". Checker must be really light weight to run in this mode.
+ * If it returns true, checker must also implement
+ * {@link IRunnableInEditorChecker}.
+ * Checker should return false if check is non-trivial and takes a long
+ * time.
*
* @return true if need to be run in editor as user types, and false
* otherwise
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckerWithPreferences.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckerWithPreferences.java
new file mode 100644
index 0000000..56619cb
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckerWithPreferences.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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;
+
+/**
+ * Interface for checker with parameters, if checker implements this interface
+ * method would be called on initialization so checker has a chance to set
+ * default values for its parameters. It is recommended to use
+ * {@link AbstractCheckerWithProblemPreferences} insted of implementing it
+ * directly.
+ * EXPERIMENTAL. This class or interface has been added as part
+ * of a work in progress. There is no guarantee that this API will work or that
+ * it will remain the same.
+ *
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface ICheckerWithPreferences {
+ /**
+ * Implement this method to set default parameters for checkers with
+ * parameters.
+ *
+ * @param problem
+ * - instance of problem working copy
+ */
+ void initPreferences(IProblemWorkingCopy problem);
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java
index 052d868..04189ae 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -10,57 +10,125 @@
*******************************************************************************/
package org.eclipse.cdt.codan.core.model;
+import java.util.Collection;
import java.util.Iterator;
import org.eclipse.core.resources.IResource;
/**
- * @author Alena
+ * This interface an API to add/remove checker and problems programmatically,
+ * get problem profiles and change problem default settings
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
*
*/
-public interface ICheckersRegistry {
- public abstract Iterator iterator();
+public interface ICheckersRegistry extends Iterable {
+ /**
+ * Iterator for registered checkers
+ *
+ * @return iterator for registered checkers
+ */
+ public Iterator iterator();
+
+ /**
+ * Add a checker
+ *
+ * @param checker instance
+ */
+ public void addChecker(IChecker checker);
- public abstract void addChecker(IChecker checker);
+ /**
+ * Add problem p into a category defined by a category id into default
+ * profile, category must exists in default profile
+ *
+ * @param p
+ * - problem
+ * @param categoryId
+ * - category id
+ */
+ public void addProblem(IProblem p, String categoryId);
- public abstract void addProblem(IProblem p, String category);
+ /**
+ * Add subcategory category into parent category with the id of
+ * parentCategoryId, if parent does not exist in the default profile or it
+ * is a null - it will be added to the root
+ *
+ * @param category
+ * - new category
+ * @param parentCategoryId
+ * - parent category id
+ */
+ public abstract void addCategory(IProblemCategory category,
+ String parentCategoryId);
- public abstract void addCategory(IProblemCategory p, String category);
+ /**
+ * Add problem reference to a checker, i.e. claim that checker can produce
+ * this problem. If checker does not claim any problems it cannot be
+ * enabled.
+ *
+ * @param c
+ * - checker
+ * @param p
+ * - problem
+ */
+ public void addRefProblem(IChecker c, IProblem p);
- public abstract void addRefProblem(IChecker c, IProblem p);
+ /**
+ * Return collection of problem that this checker can produce
+ *
+ * @param checker
+ * @return collection of problems
+ */
+ public Collection getRefProblems(IChecker checker);
/**
- * @return
+ * Default profile is kind of "Installation Default".
+ * Always the same, comes from defaults in checker extensions or APIs added
+ *
+ * @return default profile
*/
- public abstract IProblemProfile getDefaultProfile();
+ public IProblemProfile getDefaultProfile();
/**
- * @return
+ * Get workspace profile. User can change setting for workspace profile.
+ *
+ * @return workspace profile
*/
- public abstract IProblemProfile getWorkspaceProfile();
+ public IProblemProfile getWorkspaceProfile();
/**
+ * Get resource profile. For example given project can have different
+ * profile than a workspace.
+ *
* @param element
- * @return
+ * - resource
+ * @return resource profile
*/
- public abstract IProblemProfile getResourceProfile(IResource element);
+ public IProblemProfile getResourceProfile(IResource element);
/**
+ * Returns profile working copy for given resource element. (If profile is
+ * not specified for given element it will search for parent resource and so
+ * on). If you planning on editing it this method should be used instead of
+ * getResourceProfile. You have to save your changes after updating a
+ * working copy, using {@link #updateProfile(IResource, IProblemProfile)}
+ * method.
+ *
+ * @noreference This method is not intended to be referenced by clients.
* @param element
- * @return
+ * @return resource profile
*/
- public abstract IProblemProfile getResourceProfileWorkingCopy(
- IResource element);
+ public IProblemProfile getResourceProfileWorkingCopy(IResource element);
/**
- * Set profile for resource. This method is called by UI, and should not be
- * called by clients directly
+ * Set profile for resource.
*
+ * @noreference This method is not intended to be referenced by clients.
* @param resource
- * - resource
+ * - resource
* @param profile
- * - problems profile
+ * - problems profile
*/
- public abstract void updateProfile(IResource resource,
- IProblemProfile profile);
+ public void updateProfile(IResource resource, IProblemProfile profile);
}
\ No newline at end of file
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanAstReconciler.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanAstReconciler.java
deleted file mode 100644
index 17bc8f7..0000000
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanAstReconciler.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * 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.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * @author Alena
- *
- */
-public interface ICodanAstReconciler {
- public void reconcileAst(IASTTranslationUnit ast, IProgressMonitor monitor);
-}
\ No newline at end of file
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanBuilder.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanBuilder.java
index ce1f668..dcbe4c3 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanBuilder.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanBuilder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -14,9 +14,20 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
/**
- * @author Alena
+ * Interface for "Codan Builder". Clients can call processResource method to
+ * traverse the resource tree. It will be calling all the checkers (this
+ * interface allows to call framework without using UI). You can obtain instance
+ * of this class as CodanRuntime.getInstance().getBuilder()
*
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICodanBuilder {
+ /**
+ * Run code analysis on given resource
+ *
+ * @param resource - resource to process
+ * @param monitor - progress monitor
+ */
public void processResource(IResource resource, IProgressMonitor monitor);
}
\ No newline at end of file
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java
index bbab313..d12806d 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -10,56 +10,82 @@
*******************************************************************************/
package org.eclipse.cdt.codan.core.model;
-import java.util.Collection;
+import org.eclipse.cdt.codan.core.param.IProblemPreference;
/**
- * Interface representing code analysis problem
- *
+ * Interface representing code analysis problem type. For example
+ * "Null Pointer Dereference" is a problem. It has user visible Name and Message
+ * (translatable), as well as some other parameters, changeable by user such as
+ * enablement, severity and so on. Same problem cannot have two severities
+ * determined by runtime. If it is the case - two Problems should be created
+ * (i.e. one for error and one for warning). All of problem attributes are
+ * defined in a checker extension point.
+ *
+ *
+ * EXPERIMENTAL. This class or interface has been added as part
+ * of a work in progress. There is no guarantee that this API will work or that
+ * it will remain the same.
+ *
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
*/
public interface IProblem extends IProblemElement {
/**
* Name of the problem - user visible "title", not the message
+ *
+ * @return title of the problem
*/
String getName();
/**
- * Unique problem id. Should be qualified by plugin name to maintain uniqueness.
- * @return
+ * Unique problem id. Should be qualified by plugin name to maintain
+ * uniqueness.
+ *
+ * @return unique problem id
*/
String getId();
/**
* Is enabled in current context (usually within profile)
+ *
* @return true if enabled
*/
boolean isEnabled();
/**
* Get current severity
+ *
* @return severity
*/
CodanSeverity getSeverity();
/**
* Message pattern, java patter like 'Variable {0} is never used here'
- * @return pattern
+ *
+ * @return pattern
*/
String getMessagePattern();
- void setSeverity(CodanSeverity sev);
-
- void setEnabled(boolean checked);
-
- void setMessagePattern(String message);
-
- public void setProperty(Object key, Object value);
+ /**
+ * Get root preference descriptor or null if not defined (used by ui to
+ * generate user controls for changing parameters)
+ *
+ * @return root preference or null
+ */
+ public IProblemPreference getPreference();
/**
- * Get custom property
- * @param property name
- * @return property object
+ * Get short description of a problem
+ *
+ * @return description
*/
- public Object getProperty(Object key);
+ public String getDescription();
- public Collection
+ *
+ * @param array
+ * the given array
+ * @param prefix
+ * the given prefix
+ * @return the result of the comparison
+ * @exception NullPointerException
+ * if either array or prefix is null
+ */
+ public static final int compareWith(char[] array, char[] prefix) {
+ int arrayLength = array.length;
+ int prefixLength = prefix.length;
+ int min = Math.min(arrayLength, prefixLength);
+ int i = 0;
+ while (min-- != 0) {
+ char c1 = array[i];
+ char c2 = prefix[i++];
+ if (c1 != c2)
+ return c1 - c2;
+ }
+ if (prefixLength == i)
+ return 0;
+ return 1;
+ }
+
+ /**
+ * Answers the concatenation of the two arrays. It answers null if the two
+ * arrays are null.
+ * If the first array is null, then the second array is returned.
+ * If the second array is null, then the first array is returned.
+ *
+ *
+ * For example:
+ *
+ *
+ * first = null
+ * second = { 'a' }
+ * => result = { ' a' }
+ *
+ *
+ *
+ * first = { ' a' }
+ * second = null
+ * => result = { ' a' }
+ *
+ *
+ *
+ * first = { ' a' }
+ * second = { ' b' }
+ * => result = { ' a' , ' b' }
+ *
+ *
+ *
+ *
+ * @param first
+ * the first array to concatenate
+ * @param second
+ * the second array to concatenate
+ * @return the concatenation of the two arrays, or null if the two arrays
+ * are null.
+ */
+ public static final char[] concat(char[] first, char[] second) {
+ if (first == null)
+ return second;
+ if (second == null)
+ return first;
+ int length1 = first.length;
+ int length2 = second.length;
+ char[] result = new char[length1 + length2];
+ System.arraycopy(first, 0, result, 0, length1);
+ System.arraycopy(second, 0, result, length1, length2);
+ return result;
+ }
+
+ /**
+ * Answers the concatenation of the three arrays. It answers null if the
+ * three arrays are null.
+ * If first is null, it answers the concatenation of second and third.
+ * If second is null, it answers the concatenation of first and third.
+ * If third is null, it answers the concatenation of first and second.
+ *
+ *
+ * For example:
+ *
+ *
+ * first = null
+ * second = { 'a' }
+ * third = { 'b' }
+ * => result = { ' a', 'b' }
+ *
+ *
+ *
+ * first = { 'a' }
+ * second = null
+ * third = { 'b' }
+ * => result = { ' a', 'b' }
+ *
+ *
+ *
+ * first = { 'a' }
+ * second = { 'b' }
+ * third = null
+ * => result = { ' a', 'b' }
+ *
+ *
+ *
+ * first = null
+ * second = null
+ * third = null
+ * => result = null
+ *
+ *
+ *
+ * first = { 'a' }
+ * second = { 'b' }
+ * third = { 'c' }
+ * => result = { 'a', 'b', 'c' }
+ *
+ *
+ *
+ *
+ * @param first
+ * the first array to concatenate
+ * @param second
+ * the second array to concatenate
+ * @param third
+ * the third array to concatenate
+ *
+ * @return the concatenation of the three arrays, or null if the three
+ * arrays are null.
+ */
+ public static final char[] concat(char[] first, char[] second, char[] third) {
+ if (first == null)
+ return concat(second, third);
+ if (second == null)
+ return concat(first, third);
+ if (third == null)
+ return concat(first, second);
+ int length1 = first.length;
+ int length2 = second.length;
+ int length3 = third.length;
+ char[] result = new char[length1 + length2 + length3];
+ System.arraycopy(first, 0, result, 0, length1);
+ System.arraycopy(second, 0, result, length1, length2);
+ System.arraycopy(third, 0, result, length1 + length2, length3);
+ return result;
+ }
+
+ /**
+ * Answers the concatenation of the two arrays inserting the separator
+ * character between the two arrays.
+ * It answers null if the two arrays are null.
+ * If the first array is null, then the second array is returned.
+ * If the second array is null, then the first array is returned.
+ *
+ *
+ * For example:
+ *
+ *
+ * first = null
+ * second = { 'a' }
+ * separator = '/'
+ * => result = { ' a' }
+ *
+ *
+ *
+ * first = { ' a' }
+ * second = null
+ * separator = '/'
+ * => result = { ' a' }
+ *
+ *
+ *
+ * first = { ' a' }
+ * second = { ' b' }
+ * separator = '/'
+ * => result = { ' a' , '/', 'b' }
+ *
+ *
+ *
+ *
+ * @param first
+ * the first array to concatenate
+ * @param second
+ * the second array to concatenate
+ * @param separator
+ * the character to insert
+ * @return the concatenation of the two arrays inserting the separator
+ * character
+ * between the two arrays , or null if the two arrays are null.
+ */
+ public static final char[] concat(char[] first, char[] second,
+ char separator) {
+ if (first == null)
+ return second;
+ if (second == null)
+ return first;
+ int length1 = first.length;
+ if (length1 == 0)
+ return second;
+ int length2 = second.length;
+ if (length2 == 0)
+ return first;
+ char[] result = new char[length1 + length2 + 1];
+ System.arraycopy(first, 0, result, 0, length1);
+ result[length1] = separator;
+ System.arraycopy(second, 0, result, length1 + 1, length2);
+ return result;
+ }
+
+ /**
+ * Answers the concatenation of the three arrays inserting the sep1
+ * character between the
+ * two arrays and sep2 between the last two.
+ * It answers null if the three arrays are null.
+ * If the first array is null, then it answers the concatenation of second
+ * and third inserting
+ * the sep2 character between them.
+ * If the second array is null, then it answers the concatenation of first
+ * and third inserting
+ * the sep1 character between them.
+ * If the third array is null, then it answers the concatenation of first
+ * and second inserting
+ * the sep1 character between them.
+ *
+ *
+ * For example:
+ *
+ *
+ * first = null
+ * sep1 = '/'
+ * second = { 'a' }
+ * sep2 = ':'
+ * third = { 'b' }
+ * => result = { ' a' , ':', 'b' }
+ *
+ *
+ *
+ * first = { 'a' }
+ * sep1 = '/'
+ * second = null
+ * sep2 = ':'
+ * third = { 'b' }
+ * => result = { ' a' , '/', 'b' }
+ *
+ *
+ *
+ * first = { 'a' }
+ * sep1 = '/'
+ * second = { 'b' }
+ * sep2 = ':'
+ * third = null
+ * => result = { ' a' , '/', 'b' }
+ *
+ *
+ *
+ * first = { 'a' }
+ * sep1 = '/'
+ * second = { 'b' }
+ * sep2 = ':'
+ * third = { 'c' }
+ * => result = { ' a' , '/', 'b' , ':', 'c' }
+ *
+ *
+ *
+ *
+ * @param first
+ * the first array to concatenate
+ * @param sep1
+ * the character to insert
+ * @param second
+ * the second array to concatenate
+ * @param sep2
+ * the character to insert
+ * @param third
+ * the second array to concatenate
+ * @return the concatenation of the three arrays inserting the sep1
+ * character between the
+ * two arrays and sep2 between the last two.
+ */
+ public static final char[] concat(char[] first, char sep1, char[] second,
+ char sep2, char[] third) {
+ if (first == null)
+ return concat(second, third, sep2);
+ if (second == null)
+ return concat(first, third, sep1);
+ if (third == null)
+ return concat(first, second, sep1);
+ int length1 = first.length;
+ int length2 = second.length;
+ int length3 = third.length;
+ char[] result = new char[length1 + length2 + length3 + 2];
+ System.arraycopy(first, 0, result, 0, length1);
+ result[length1] = sep1;
+ System.arraycopy(second, 0, result, length1 + 1, length2);
+ result[length1 + length2 + 1] = sep2;
+ System.arraycopy(third, 0, result, length1 + length2 + 2, length3);
+ return result;
+ }
+
+ /**
+ * Answers a new array with prepending the prefix character and appending
+ * the suffix
+ * character at the end of the array. If array is null, it answers a new
+ * array containing the
+ * prefix and the suffix characters.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param prefix
+ * the prefix character
+ * @param array
+ * the array that is concanated with the prefix and suffix
+ * characters
+ * @param suffix
+ * the suffix character
+ * @return the new array
+ */
+ public static final char[] concat(char prefix, char[] array, char suffix) {
+ if (array == null)
+ return new char[] { prefix, suffix };
+ int length = array.length;
+ char[] result = new char[length + 2];
+ result[0] = prefix;
+ System.arraycopy(array, 0, result, 1, length);
+ result[length + 1] = suffix;
+ return result;
+ }
+
+ /**
+ * Answers the concatenation of the given array parts using the given
+ * separator between each
+ * part and appending the given name at the end.
+ *
+ *
+ * For example:
+ *
+ *
+ * name = { ' c' }
+ * array = null
+ * separator = '.'
+ * => result = { 'c' }
+ *
+ *
+ *
+ * @param name
+ * the given name
+ * @param array
+ * the given array
+ * @param separator
+ * the given separator
+ * @return the concatenation of the given array parts using the given
+ * separator between each
+ * part and appending the given name at the end
+ */
+ public static final char[] concatWith(char[] name, char[][] array,
+ char separator) {
+ int nameLength = name == null ? 0 : name.length;
+ if (nameLength == 0)
+ return concatWith(array, separator);
+ if (array == null)
+ return name;
+ final int length = array.length;
+ if (length == 0)
+ return name;
+ int size = nameLength;
+ int index = length;
+ while (--index >= 0)
+ if (array[index].length > 0)
+ size += array[index].length + 1;
+ char[] result = new char[size];
+ index = size;
+ for (int i = length - 1; i >= 0; i--) {
+ int subLength = array[i].length;
+ if (subLength > 0) {
+ index -= subLength;
+ System.arraycopy(array[i], 0, result, index, subLength);
+ result[--index] = separator;
+ }
+ }
+ System.arraycopy(name, 0, result, 0, nameLength);
+ return result;
+ }
+
+ /**
+ * Answers the concatenation of the given array parts using the given
+ * separator between each
+ * part and appending the given name at the end.
+ *
+ *
+ * For example:
+ *
+ *
+ * name = { ' c' }
+ * array = null
+ * separator = '.'
+ * => result = { 'c' }
+ *
+ *
+ *
+ * @param array
+ * the given array
+ * @param name
+ * the given name
+ * @param separator
+ * the given separator
+ * @return the concatenation of the given array parts using the given
+ * separator between each
+ * part and appending the given name at the end
+ */
+ public static final char[] concatWith(char[][] array, char[] name,
+ char separator) {
+ int nameLength = name == null ? 0 : name.length;
+ if (nameLength == 0)
+ return concatWith(array, separator);
+ if (array == null)
+ return name;
+ final int length = array.length;
+ if (length == 0)
+ return name;
+ int size = nameLength;
+ int index = length;
+ while (--index >= 0)
+ if (array[index].length > 0)
+ size += array[index].length + 1;
+ char[] result = new char[size];
+ index = 0;
+ for (int i = 0; i < length; i++) {
+ int subLength = array[i].length;
+ if (subLength > 0) {
+ System.arraycopy(array[i], 0, result, index, subLength);
+ index += subLength;
+ result[index++] = separator;
+ }
+ }
+ System.arraycopy(name, 0, result, index, nameLength);
+ return result;
+ }
+
+ /**
+ * Answers the concatenation of the given array parts using the given
+ * separator between each part.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param array
+ * the given array
+ * @param separator
+ * the given separator
+ * @return the concatenation of the given array parts using the given
+ * separator between each part
+ */
+ public static final char[] concatWith(char[][] array, char separator) {
+ if (array == null)
+ return CharOperation.NO_CHAR;
+ int length = array.length;
+ if (length == 0)
+ return CharOperation.NO_CHAR;
+ int size = length - 1;
+ int index = length;
+ while (--index >= 0) {
+ if (array[index].length == 0)
+ size--;
+ else
+ size += array[index].length;
+ }
+ if (size <= 0)
+ return CharOperation.NO_CHAR;
+ char[] result = new char[size];
+ index = length;
+ while (--index >= 0) {
+ length = array[index].length;
+ if (length > 0) {
+ System.arraycopy(array[index], 0, result, (size -= length),
+ length);
+ if (--size >= 0)
+ result[size] = separator;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Answers true if the array contains an occurrence of character, false
+ * otherwise.
+ *
+ *
+ *
+ * For example:
+ *
+ *
+ * character = 'c'
+ * array = { { ' a' }, { ' b' } }
+ * result => false
+ *
+ *
+ *
+ * character = 'a'
+ * array = { { ' a' }, { ' b' } }
+ * result => true
+ *
+ *
+ *
+ *
+ * @param character
+ * the character to search
+ * @param array
+ * the array in which the search is done
+ * @return true if the array contains an occurrence of character, false
+ * otherwise.
+ * @exception NullPointerException
+ * if array is null.
+ */
+ public static final boolean contains(char character, char[][] array) {
+ for (int i = array.length; --i >= 0;) {
+ char[] subarray = array[i];
+ for (int j = subarray.length; --j >= 0;)
+ if (subarray[j] == character)
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Answers true if the array contains an occurrence of character, false
+ * otherwise.
+ *
+ *
+ *
+ * For example:
+ *
+ *
+ * character = 'c'
+ * array = { ' b' }
+ * result => false
+ *
+ *
+ *
+ * character = 'a'
+ * array = { ' a' , ' b' }
+ * result => true
+ *
+ *
+ *
+ *
+ * @param character
+ * the character to search
+ * @param array
+ * the array in which the search is done
+ * @return true if the array contains an occurrence of character, false
+ * otherwise.
+ * @exception NullPointerException
+ * if array is null.
+ */
+ public static final boolean contains(char character, char[] array) {
+ for (int i = array.length; --i >= 0;)
+ if (array[i] == character)
+ return true;
+ return false;
+ }
+
+ /**
+ * Answers a deep copy of the toCopy array.
+ *
+ * @param toCopy
+ * the array to copy
+ * @return a deep copy of the toCopy array.
+ */
+ public static final char[][] deepCopy(char[][] toCopy) {
+ int toCopyLength = toCopy.length;
+ char[][] result = new char[toCopyLength][];
+ for (int i = 0; i < toCopyLength; i++) {
+ char[] toElement = toCopy[i];
+ int toElementLength = toElement.length;
+ char[] resultElement = new char[toElementLength];
+ System.arraycopy(toElement, 0, resultElement, 0, toElementLength);
+ result[i] = resultElement;
+ }
+ return result;
+ }
+
+ /**
+ * Return true if array ends with the sequence of characters contained in
+ * toBeFound,
+ * otherwise false.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param array
+ * the array to check
+ * @param toBeFound
+ * the array to find
+ * @return true if array ends with the sequence of characters contained in
+ * toBeFound,
+ * otherwise false.
+ * @exception NullPointerException
+ * if array is null or toBeFound is null
+ */
+ public static final boolean endsWith(char[] array, char[] toBeFound) {
+ int i = toBeFound.length;
+ int j = array.length - i;
+ if (j < 0)
+ return false;
+ while (--i >= 0)
+ if (toBeFound[i] != array[i + j])
+ return false;
+ return true;
+ }
+
+ /**
+ * Answers true if the two arrays are identical character by character,
+ * otherwise false.
+ * The equality is case sensitive.
+ *
+ *
+ * For example:
+ *
+ *
+ * first = null
+ * second = null
+ * result => true
+ *
+ *
+ *
+ * first = { { } }
+ * second = null
+ * result => false
+ *
+ *
+ *
+ * first = { { 'a' } }
+ * second = { { 'a' } }
+ * result => true
+ *
+ *
+ *
+ * first = { { 'A' } }
+ * second = { { 'a' } }
+ * result => false
+ *
+ *
+ *
+ *
+ * @param first
+ * the first array
+ * @param second
+ * the second array
+ * @return true if the two arrays are identical character by character,
+ * otherwise false
+ */
+ public static final boolean equals(char[][] first, char[][] second) {
+ if (first == second)
+ return true;
+ if (first == null || second == null)
+ return false;
+ if (first.length != second.length)
+ return false;
+ for (int i = first.length; --i >= 0;)
+ if (!equals(first[i], second[i]))
+ return false;
+ return true;
+ }
+
+ /**
+ * If isCaseSensite is true, answers true if the two arrays are identical
+ * character
+ * by character, otherwise false.
+ * If it is false, answers true if the two arrays are identical character by
+ * character without checking the case, otherwise false.
+ *
+ *
+ * For example:
+ *
+ *
+ * first = null
+ * second = null
+ * isCaseSensitive = true
+ * result => true
+ *
+ *
+ *
+ * first = { { } }
+ * second = null
+ * isCaseSensitive = true
+ * result => false
+ *
+ *
+ *
+ * first = { { 'A' } }
+ * second = { { 'a' } }
+ * isCaseSensitive = true
+ * result => false
+ *
+ *
+ *
+ * first = { { 'A' } }
+ * second = { { 'a' } }
+ * isCaseSensitive = false
+ * result => true
+ *
+ *
+ *
+ *
+ * @param first
+ * the first array
+ * @param second
+ * the second array
+ * @param isCaseSensitive
+ * check whether or not the equality should be case sensitive
+ * @return true if the two arrays are identical character by character
+ * according to the value
+ * of isCaseSensitive, otherwise false
+ */
+ public static final boolean equals(char[][] first, char[][] second,
+ boolean isCaseSensitive) {
+ if (isCaseSensitive) {
+ return equals(first, second);
+ }
+ if (first == second)
+ return true;
+ if (first == null || second == null)
+ return false;
+ if (first.length != second.length)
+ return false;
+ for (int i = first.length; --i >= 0;)
+ if (!equals(first[i], second[i], false))
+ return false;
+ return true;
+ }
+
+ /**
+ * Answers true if the two arrays are identical character by character,
+ * otherwise false.
+ * The equality is case sensitive.
+ *
+ *
+ * For example:
+ *
+ *
+ * first = null
+ * second = null
+ * result => true
+ *
+ *
+ *
+ * first = { }
+ * second = null
+ * result => false
+ *
+ *
+ *
+ * first = { 'a' }
+ * second = { 'a' }
+ * result => true
+ *
+ *
+ *
+ * first = { 'a' }
+ * second = { 'A' }
+ * result => false
+ *
+ *
+ *
+ *
+ * @param first
+ * the first array
+ * @param second
+ * the second array
+ * @return true if the two arrays are identical character by character,
+ * otherwise false
+ */
+ public static final boolean equals(char[] first, char[] second) {
+ if (first == second)
+ return true;
+ if (first == null || second == null)
+ return false;
+ if (first.length != second.length)
+ return false;
+ for (int i = first.length; --i >= 0;)
+ if (first[i] != second[i])
+ return false;
+ return true;
+ }
+
+ /**
+ * If isCaseSensite is true, answers true if the two arrays are identical
+ * character
+ * by character, otherwise false.
+ * If it is false, answers true if the two arrays are identical character by
+ * character without checking the case, otherwise false.
+ *
+ *
+ * For example:
+ *
+ *
+ * first = null
+ * second = null
+ * isCaseSensitive = true
+ * result => true
+ *
+ *
+ *
+ * first = { }
+ * second = null
+ * isCaseSensitive = true
+ * result => false
+ *
+ *
+ *
+ * first = { 'A' }
+ * second = { 'a' }
+ * isCaseSensitive = true
+ * result => false
+ *
+ *
+ *
+ * first = { 'A' }
+ * second = { 'a' }
+ * isCaseSensitive = false
+ * result => true
+ *
+ *
+ *
+ *
+ * @param first
+ * the first array
+ * @param second
+ * the second array
+ * @param isCaseSensitive
+ * check whether or not the equality should be case sensitive
+ * @return true if the two arrays are identical character by character
+ * according to the value
+ * of isCaseSensitive, otherwise false
+ */
+ public static final boolean equals(char[] first, char[] second,
+ boolean isCaseSensitive) {
+ if (isCaseSensitive) {
+ return equals(first, second);
+ }
+ if (first == second)
+ return true;
+ if (first == null || second == null)
+ return false;
+ if (first.length != second.length)
+ return false;
+ for (int i = first.length; --i >= 0;)
+ if (Character.toLowerCase(first[i]) != Character
+ .toLowerCase(second[i]))
+ return false;
+ return true;
+ }
+
+ /**
+ * If isCaseSensite is true, the equality is case sensitive, otherwise it is
+ * case insensitive.
+ *
+ * Answers true if the name contains the fragment at the starting index
+ * startIndex, otherwise false.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param fragment
+ * the fragment to check
+ * @param name
+ * the array to check
+ * @param startIndex
+ * the starting index
+ * @param isCaseSensitive
+ * check whether or not the equality should be case sensitive
+ * @return true if the name contains the fragment at the starting index
+ * startIndex according to the
+ * value of isCaseSensitive, otherwise false.
+ * @exception NullPointerException
+ * if fragment or name is null.
+ */
+ public static final boolean fragmentEquals(char[] fragment, char[] name,
+ int startIndex, boolean isCaseSensitive) {
+ int max = fragment.length;
+ if (name.length < max + startIndex)
+ return false;
+ if (isCaseSensitive) {
+ for (int i = max; --i >= 0;)
+ // assumes the prefix is not larger than the name
+ if (fragment[i] != name[i + startIndex])
+ return false;
+ return true;
+ }
+ for (int i = max; --i >= 0;)
+ // assumes the prefix is not larger than the name
+ if (Character.toLowerCase(fragment[i]) != Character
+ .toLowerCase(name[i + startIndex]))
+ return false;
+ return true;
+ }
+
+ /**
+ * Answers a hashcode for the array
+ *
+ * @param array
+ * the array for which a hashcode is required
+ * @return the hashcode
+ * @exception NullPointerException
+ * if array is null
+ */
+ public static final int hashCode(char[] array) {
+ int hash = 0;
+ int offset = 0;
+ int length = array.length;
+ if (length < 16) {
+ for (int i = length; i > 0; i--)
+ hash = (hash * 37) + array[offset++];
+ } else {
+ // only sample some characters
+ int skip = length / 8;
+ for (int i = length; i > 0; i -= skip, offset += skip)
+ hash = (hash * 39) + array[offset];
+ }
+ return hash & 0x7FFFFFFF;
+ }
+
+ /**
+ * Answers true if c is a whitespace according to the JLS (\u000a,
+ * \u000c, \u000d, \u0009), otherwise false.
+ *
+ *
+ * For example:
+ *
+ *
+ * c = ' '
+ * result => true
+ *
+ *
+ *
+ * c = '\u3000'
+ * result => false
+ *
+ *
+ *
+ *
+ * @param c
+ * the character to check
+ * @return true if c is a whitespace according to the JLS, otherwise false.
+ */
+ public static boolean isWhitespace(char c) {
+ switch (c) {
+ case 10: /* \ u000a: LINE FEED */
+ case 12: /* \ u000c: FORM FEED */
+ case 13: /* \ u000d: CARRIAGE RETURN */
+ case 32: /* \ u0020: SPACE */
+ case 9: /* \ u0009: HORIZONTAL TABULATION */
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ /**
+ * Answers the first index in the array for which the corresponding
+ * character is
+ * equal to toBeFound. Answers -1 if no occurrence of this character is
+ * found.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param toBeFound
+ * the character to search
+ * @param array
+ * the array to be searched
+ * @return the first index in the array for which the corresponding
+ * character is
+ * equal to toBeFound, -1 otherwise
+ * @exception NullPointerException
+ * if array is null
+ */
+ public static final int indexOf(char toBeFound, char[] array) {
+ for (int i = 0; i < array.length; i++)
+ if (toBeFound == array[i])
+ return i;
+ return -1;
+ }
+
+ /**
+ * Answers the first index in the array for which the corresponding
+ * character is
+ * equal to toBeFound starting the search at index start.
+ * Answers -1 if no occurrence of this character is found.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param toBeFound
+ * the character to search
+ * @param array
+ * the array to be searched
+ * @param start
+ * the starting index
+ * @return the first index in the array for which the corresponding
+ * character is
+ * equal to toBeFound, -1 otherwise
+ * @exception NullPointerException
+ * if array is null
+ * @exception ArrayIndexOutOfBoundsException
+ * if start is lower than 0
+ */
+ public static final int indexOf(char toBeFound, char[] array, int start) {
+ for (int i = start; i < array.length; i++)
+ if (toBeFound == array[i])
+ return i;
+ return -1;
+ }
+
+ /**
+ * Answers the last index in the array for which the corresponding character
+ * is
+ * equal to toBeFound starting from the end of the array.
+ * Answers -1 if no occurrence of this character is found.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param toBeFound
+ * the character to search
+ * @param array
+ * the array to be searched
+ * @return the last index in the array for which the corresponding character
+ * is
+ * equal to toBeFound starting from the end of the array, -1
+ * otherwise
+ * @exception NullPointerException
+ * if array is null
+ */
+ public static final int lastIndexOf(char toBeFound, char[] array) {
+ for (int i = array.length; --i >= 0;)
+ if (toBeFound == array[i])
+ return i;
+ return -1;
+ }
+
+ /**
+ * Answers the last index in the array for which the corresponding character
+ * is
+ * equal to toBeFound stopping at the index startIndex.
+ * Answers -1 if no occurrence of this character is found.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param toBeFound
+ * the character to search
+ * @param array
+ * the array to be searched
+ * @param startIndex
+ * the stopping index
+ * @return the last index in the array for which the corresponding character
+ * is
+ * equal to toBeFound stopping at the index startIndex, -1 otherwise
+ * @exception NullPointerException
+ * if array is null
+ * @exception ArrayIndexOutOfBoundsException
+ * if startIndex is lower than 0
+ */
+ public static final int lastIndexOf(char toBeFound, char[] array,
+ int startIndex) {
+ for (int i = array.length; --i >= startIndex;)
+ if (toBeFound == array[i])
+ return i;
+ return -1;
+ }
+
+ /**
+ * Answers the last index in the array for which the corresponding character
+ * is
+ * equal to toBeFound starting from endIndex to startIndex.
+ * Answers -1 if no occurrence of this character is found.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param toBeFound
+ * the character to search
+ * @param array
+ * the array to be searched
+ * @param startIndex
+ * the stopping index
+ * @param endIndex
+ * the starting index
+ * @return the last index in the array for which the corresponding character
+ * is
+ * equal to toBeFound starting from endIndex to startIndex, -1
+ * otherwise
+ * @exception NullPointerException
+ * if array is null
+ * @exception ArrayIndexOutOfBoundsException
+ * if endIndex is greater or equals to array length or
+ * starting is lower than 0
+ */
+ public static final int lastIndexOf(char toBeFound, char[] array,
+ int startIndex, int endIndex) {
+ for (int i = endIndex; --i >= startIndex;)
+ if (toBeFound == array[i])
+ return i;
+ return -1;
+ }
+
+ /**
+ * Answers the last portion of a name given a separator.
+ *
+ *
+ * For example,
+ *
+ *
+ * @param array
+ * the array
+ * @param separator
+ * the given separator
+ * @return the last portion of a name given a separator
+ * @exception NullPointerException
+ * if array is null
+ */
+ final static public char[] lastSegment(char[] array, char separator) {
+ int pos = lastIndexOf(separator, array);
+ if (pos < 0)
+ return array;
+ return subarray(array, pos + 1, array.length);
+ }
+
+ /**
+ * Answers true if the pattern matches the given name, false otherwise. This
+ * char[] pattern matching
+ * accepts wild-cards '*' and '?'.
+ *
+ * When not case sensitive, the pattern is assumed to already be lowercased,
+ * the
+ * name will be lowercased character per character as comparing.
+ * If name is null, the answer is false.
+ * If pattern is null, the answer is true if name is not null.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param pattern
+ * the given pattern
+ * @param name
+ * the given name
+ * @param isCaseSensitive
+ * flag to know whether or not the matching should be case
+ * sensitive
+ * @return true if the pattern matches the given name, false otherwise
+ */
+ public static final boolean match(char[] pattern, char[] name,
+ boolean isCaseSensitive) {
+ if (name == null)
+ return false; // null name cannot match
+ if (pattern == null)
+ return true; // null pattern is equivalent to '*'
+ return match(pattern, 0, pattern.length, name, 0, name.length,
+ isCaseSensitive, true);
+ }
+
+ /**
+ * Answers true if the a sub-pattern matches the subpart of the given name,
+ * false otherwise.
+ * char[] pattern matching, accepting wild-cards '*' and '?'. Can match only
+ * subset of name/pattern.
+ * end positions are non-inclusive.
+ * The subpattern is defined by the patternStart and pattternEnd positions.
+ * When not case sensitive, the pattern is assumed to already be lowercased,
+ * the
+ * name will be lowercased character per character as comparing.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param toBeFound
+ * the given character
+ * @param array
+ * the given array
+ * @return the number of occurrences of the given character in the given
+ * array, 0 if any
+ * @exception NullPointerException
+ * if array is null
+ */
+ public static final int occurencesOf(char toBeFound, char[] array) {
+ int count = 0;
+ for (char element : array)
+ if (toBeFound == element)
+ count++;
+ return count;
+ }
+
+ /**
+ * Answers the number of occurrences of the given character in the given
+ * array starting
+ * at the given index, 0 if any.
+ *
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param toBeFound
+ * the given character
+ * @param array
+ * the given array
+ * @return the number of occurrences of the given character in the given
+ * array, 0 if any
+ * @exception NullPointerException
+ * if array is null
+ * @exception ArrayIndexOutOfBoundsException
+ * if start is lower than 0
+ */
+ public static final int occurencesOf(char toBeFound, char[] array, int start) {
+ int count = 0;
+ for (int i = start; i < array.length; i++)
+ if (toBeFound == array[i])
+ count++;
+ return count;
+ }
+
+ /**
+ * Answers true if the given name starts with the given prefix, false
+ * otherwise.
+ * The comparison is case sensitive.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param prefix
+ * the given prefix
+ * @param name
+ * the given name
+ * @return true if the given name starts with the given prefix, false
+ * otherwise
+ * @exception NullPointerException
+ * if the given name is null or if the given prefix is null
+ */
+ public static final boolean prefixEquals(char[] prefix, char[] name) {
+ int max = prefix.length;
+ if (name.length < max)
+ return false;
+ for (int i = max; --i >= 0;)
+ // assumes the prefix is not larger than the name
+ if (prefix[i] != name[i])
+ return false;
+ return true;
+ }
+
+ /**
+ * Answers true if the given name starts with the given prefix, false
+ * otherwise.
+ * isCaseSensitive is used to find out whether or not the comparison should
+ * be case sensitive.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param prefix
+ * the given prefix
+ * @param name
+ * the given name
+ * @param isCaseSensitive
+ * to find out whether or not the comparison should be case
+ * sensitive
+ * @return true if the given name starts with the given prefix, false
+ * otherwise
+ * @exception NullPointerException
+ * if the given name is null or if the given prefix is null
+ */
+ public static final boolean prefixEquals(char[] prefix, char[] name,
+ boolean isCaseSensitive) {
+ int max = prefix.length;
+ if (name.length < max)
+ return false;
+ if (isCaseSensitive) {
+ for (int i = max; --i >= 0;)
+ // assumes the prefix is not larger than the name
+ if (prefix[i] != name[i])
+ return false;
+ return true;
+ }
+ for (int i = max; --i >= 0;)
+ // assumes the prefix is not larger than the name
+ if (Character.toLowerCase(prefix[i]) != Character
+ .toLowerCase(name[i]))
+ return false;
+ return true;
+ }
+
+ /**
+ * Replace all occurrence of the character to be replaced with the
+ * remplacement character in the
+ * given array.
+ *
+ *
+ * For example:
+ *
+ *
+ * array = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * toBeReplaced = 'b'
+ * replacementChar = 'a'
+ * result => No returned value, but array is now equals to { 'a' , 'a', 'a',
+ * 'a', 'a', 'a' }
+ *
+ *
+ *
+ * array = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * toBeReplaced = 'c'
+ * replacementChar = 'a'
+ * result => No returned value, but array is now equals to { 'a' , 'b', 'b',
+ * 'a', 'b', 'a' }
+ *
+ *
+ *
+ *
+ * @param array
+ * the given array
+ * @param toBeReplaced
+ * the character to be replaced
+ * @param replacementChar
+ * the replacement character
+ * @exception NullPointerException
+ * if the given array is null
+ */
+ public static final void replace(char[] array, char toBeReplaced,
+ char replacementChar) {
+ if (toBeReplaced != replacementChar) {
+ for (int i = 0, max = array.length; i < max; i++) {
+ if (array[i] == toBeReplaced)
+ array[i] = replacementChar;
+ }
+ }
+ }
+
+ /**
+ * Answers a new array of characters with substitutions. No side-effect is
+ * operated on the original
+ * array, in case no substitution happened, then the result is the same as
+ * the
+ * original one.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param divider
+ * the given divider
+ * @param array
+ * the given array
+ * @return a new array which is the split of the given array using the given
+ * divider and triming each subarray to remove
+ * whitespaces equals to ' '
+ */
+ public static final char[][] splitAndTrimOn(char divider, char[] array) {
+ if (array == null)
+ return NO_CHAR_CHAR;
+ final int length = array.length;
+ if (length == 0)
+ return NO_CHAR_CHAR;
+ int wordCount = 1;
+ for (int i = 0; i < length; i++)
+ if (array[i] == divider)
+ wordCount++;
+ char[][] split = new char[wordCount][];
+ int last = 0, currentWord = 0;
+ for (int i = 0; i < length; i++) {
+ if (array[i] == divider) {
+ int start = last, end = i - 1;
+ while (start < i && array[start] == ' ')
+ start++;
+ while (end > start && array[end] == ' ')
+ end--;
+ split[currentWord] = new char[end - start + 1];
+ System.arraycopy(array, start, split[currentWord++], 0, end
+ - start + 1);
+ last = i + 1;
+ }
+ }
+ int start = last, end = length - 1;
+ while (start < length && array[start] == ' ')
+ start++;
+ while (end > start && array[end] == ' ')
+ end--;
+ split[currentWord] = new char[end - start + 1];
+ System.arraycopy(array, start, split[currentWord++], 0, end - start + 1);
+ return split;
+ }
+
+ /**
+ * Return a new array which is the split of the given array using the given
+ * divider.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param divider
+ * the given divider
+ * @param array
+ * the given array
+ * @return a new array which is the split of the given array using the given
+ * divider
+ */
+ public static final char[][] splitOn(char divider, char[] array) {
+ if (array == null)
+ return NO_CHAR_CHAR;
+ final int length = array.length;
+ if (length == 0)
+ return NO_CHAR_CHAR;
+ int wordCount = 1;
+ for (int i = 0; i < length; i++)
+ if (array[i] == divider)
+ wordCount++;
+ char[][] split = new char[wordCount][];
+ int last = 0, currentWord = 0;
+ for (int i = 0; i < length; i++) {
+ if (array[i] == divider) {
+ split[currentWord] = new char[i - last];
+ System.arraycopy(array, last, split[currentWord++], 0, i - last);
+ last = i + 1;
+ }
+ }
+ split[currentWord] = new char[length - last];
+ System.arraycopy(array, last, split[currentWord], 0, length - last);
+ return split;
+ }
+
+ /**
+ * Return a new array which is the split of the given array using the given
+ * divider. The given end
+ * is exclusive and the given start is inclusive.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param divider
+ * the given divider
+ * @param array
+ * the given array
+ * @param start
+ * the given starting index
+ * @param end
+ * the given ending index
+ * @return a new array which is the split of the given array using the given
+ * divider
+ * @exception ArrayIndexOutOfBoundsException
+ * if start is lower than 0 or end is greater than the array
+ * length
+ */
+ public static final char[][] splitOn(char divider, char[] array, int start,
+ int end) {
+ if (array == null)
+ return NO_CHAR_CHAR;
+ final int length = array.length;
+ if (length == 0 || start > end)
+ return NO_CHAR_CHAR;
+ int wordCount = 1;
+ for (int i = start; i < end; i++)
+ if (array[i] == divider)
+ wordCount++;
+ char[][] split = new char[wordCount][];
+ int last = start, currentWord = 0;
+ for (int i = start; i < end; i++) {
+ if (array[i] == divider) {
+ split[currentWord] = new char[i - last];
+ System.arraycopy(array, last, split[currentWord++], 0, i - last);
+ last = i + 1;
+ }
+ }
+ split[currentWord] = new char[end - last];
+ System.arraycopy(array, last, split[currentWord], 0, end - last);
+ return split;
+ }
+
+ /**
+ * Answers a new array which is a copy of the given array starting at the
+ * given start and
+ * ending at the given end. The given start is inclusive and the given end
+ * is exclusive.
+ * Answers null if start is greater than end, if start is lower than 0 or if
+ * end is greater
+ * than the length of the given array. If end equals -1, it is converted to
+ * the array length.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param array
+ * the given array
+ * @param start
+ * the given starting index
+ * @param end
+ * the given ending index
+ * @return a new array which is a copy of the given array starting at the
+ * given start and
+ * ending at the given end
+ * @exception NullPointerException
+ * if the given array is null
+ */
+ public static final char[][] subarray(char[][] array, int start, int end) {
+ if (end == -1)
+ end = array.length;
+ if (start > end)
+ return null;
+ if (start < 0)
+ return null;
+ if (end > array.length)
+ return null;
+ char[][] result = new char[end - start][];
+ System.arraycopy(array, start, result, 0, end - start);
+ return result;
+ }
+
+ /**
+ * Answers a new array which is a copy of the given array starting at the
+ * given start and
+ * ending at the given end. The given start is inclusive and the given end
+ * is exclusive.
+ * Answers null if start is greater than end, if start is lower than 0 or if
+ * end is greater
+ * than the length of the given array. If end equals -1, it is converted to
+ * the array length.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param array
+ * the given array
+ * @param start
+ * the given starting index
+ * @param end
+ * the given ending index
+ * @return a new array which is a copy of the given array starting at the
+ * given start and
+ * ending at the given end
+ * @exception NullPointerException
+ * if the given array is null
+ */
+ public static final char[] subarray(char[] array, int start, int end) {
+ if (end == -1)
+ end = array.length;
+ if (start > end)
+ return null;
+ if (start < 0)
+ return null;
+ if (end > array.length)
+ return null;
+ char[] result = new char[end - start];
+ System.arraycopy(array, start, result, 0, end - start);
+ return result;
+ }
+
+ /**
+ * Answers the result of a char[] conversion to lowercase. Answers null if
+ * the given chars array is null.
+ *
+ * NOTE: If no conversion was necessary, then answers back the argument one.
+ *
+ *
+ * For example:
+ *
+ *
+ *
+ *
+ * @param array
+ * the given array
+ * @return a string which is the concatenation of the given array using the
+ * '.' as a separator
+ */
+ final static public String toString(char[][] array) {
+ char[] result = concatWith(array, '.');
+ return new String(result);
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegisry.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegisry.java
deleted file mode 100644
index 5661622..0000000
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegisry.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/*******************************************************************************
- * 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.internal.core;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.cdt.codan.core.CodanCorePlugin;
-import org.eclipse.cdt.codan.core.PreferenceConstants;
-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.internal.core.model.CodanProblem;
-import org.eclipse.cdt.codan.internal.core.model.CodanProblemCategory;
-import org.eclipse.cdt.codan.internal.core.model.ProblemProfile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-
-public class CheckersRegisry implements Iterable, ICheckersRegistry {
- private static final String EXTENSION_POINT_NAME = "checkers";
- private static final String CHECKER_ELEMENT = "checker";
- private static final String PROBLEM_ELEMENT = "problem";
- private static final String CATEGORY_ELEMENT = "category";
- private static final Object DEFAULT = "DEFAULT";
- private Collection checkers = new ArrayList();
- private static CheckersRegisry instance;
- private HashMap profiles = new HashMap();
- private HashMap> problemList = new HashMap>();
-
- private CheckersRegisry() {
- instance = this;
- profiles.put(DEFAULT, new ProblemProfile());
- readCheckersRegistry();
- }
-
- private void readCheckersRegistry() {
- IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(
- CodanCorePlugin.PLUGIN_ID, EXTENSION_POINT_NAME);
- if (ep == null)
- return;
- IConfigurationElement[] elements = ep.getConfigurationElements();
- // process categories
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement configurationElement = elements[i];
- processCategories(configurationElement);
- }
- // process shared problems
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement configurationElement = elements[i];
- processProblem(configurationElement);
- }
- // process checkers
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement configurationElement = elements[i];
- processChecker(configurationElement);
- }
- }
-
- /**
- * @param configurationElement
- */
- private void processCategories(IConfigurationElement configurationElement) {
- if (configurationElement.getName().equals(CATEGORY_ELEMENT)) {
- String id = getAtt(configurationElement, "id");
- if (id == null)
- return;
- String name = getAtt(configurationElement, "name");
- if (name == null)
- return;
- CodanProblemCategory cat = new CodanProblemCategory(id, name);
- String category = getAtt(configurationElement, "parentCategory",
- false);
- addCategory(cat, category);
- }
- }
-
- /**
- * @param configurationElement
- */
- private void processChecker(IConfigurationElement configurationElement) {
- try {
- if (configurationElement.getName().equals(CHECKER_ELEMENT)) {
- String id = getAtt(configurationElement, "id");
- if (id == null)
- return;
- String name = getAtt(configurationElement, "name", false);
- if (name == null)
- name = id;
- IChecker checkerObj = null;
- try {
- Object checker = configurationElement
- .createExecutableExtension("class");
- checkerObj = (IChecker) checker;
- addChecker(checkerObj);
- } catch (CoreException e) {
- CodanCorePlugin.log(e);
- return;
- }
- IConfigurationElement[] children1 = configurationElement
- .getChildren("problemRef");
- boolean hasRef = false;
- IConfigurationElement[] children2 = configurationElement
- .getChildren(PROBLEM_ELEMENT);
- if (children2 != null) {
- for (IConfigurationElement ref : children2) {
- IProblem p = processProblem(ref);
- addRefProblem(checkerObj, p);
- hasRef = true;
- }
- }
- if (children1 != null) {
- for (IConfigurationElement ref : children1) {
- hasRef = true;
- IProblem p = getDefaultProfile().findProblem(
- ref.getAttribute("refId"));
- addRefProblem(checkerObj, p);
- }
- }
- if (!hasRef) {
- CodanProblem p = new CodanProblem(id, name);
- addProblem(p, null);
- addRefProblem(checkerObj, p);
- }
- }
- } catch (Exception e) {
- CodanCorePlugin.log(e);
- }
- }
-
- /**
- * @param configurationElement
- * @return
- */
- private CodanProblem processProblem(
- IConfigurationElement configurationElement) {
- if (configurationElement.getName().equals(PROBLEM_ELEMENT)) {
- String id = getAtt(configurationElement, "id");
- if (id == null)
- return null;
- String name = getAtt(configurationElement, "name");
- if (name == null)
- name = id;
- CodanProblem p = new CodanProblem(id, name);
- String category = getAtt(configurationElement, "category", false);
- if (category == null)
- category = "org.eclipse.cdt.codan.core.categories.ProgrammingProblems";
- addProblem(p, category);
- return p;
- }
- return null;
- }
-
- private static String getAtt(IConfigurationElement configurationElement,
- String name) {
- return getAtt(configurationElement, name, true);
- }
-
- private static String getAtt(IConfigurationElement configurationElement,
- String name, boolean req) {
- String elementValue = configurationElement.getAttribute(name);
- if (elementValue == null && req)
- CodanCorePlugin.log("Extension "
- + configurationElement.getDeclaringExtension()
- .getUniqueIdentifier()
- + " missing required attribute: "
- + configurationElement.getName() + "." + name);
- return elementValue;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#iterator()
- */
- public Iterator iterator() {
- return checkers.iterator();
- }
-
- public static CheckersRegisry getInstance() {
- if (instance == null)
- new CheckersRegisry();
- 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)
- cat = getDefaultProfile().getRoot();
- ((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)
- cat = getDefaultProfile().getRoot();
- ((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) {
- Collection plist = problemList.get(c);
- if (plist == null) {
- plist = new ArrayList();
- problemList.put(c, plist);
- }
- plist.add(p);
- }
-
- /**
- * Returns list of problems registered for given checker
- * @return collection of problems or null
- */
- public Collection getRefProblems(IChecker checker) {
- return problemList.get(checker);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.cdt.codan.core.model.ICheckersRegistry#getDefaultProfile()
- */
- public IProblemProfile getDefaultProfile() {
- return profiles.get(DEFAULT);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.cdt.codan.core.model.ICheckersRegistry#getWorkspaceProfile()
- */
- public IProblemProfile getWorkspaceProfile() {
- IProblemProfile wp = profiles.get(ResourcesPlugin.getWorkspace());
- if (wp == null) {
- try {
- wp = (IProblemProfile) getDefaultProfile().clone();
- // load default values
- CodanPreferencesLoader loader = new CodanPreferencesLoader(wp);
- loader.load(CodanCorePlugin.getDefault().getStorePreferences());
- } catch (CloneNotSupportedException e) {
- wp = getDefaultProfile();
- }
- }
- return wp;
- }
-
- public void updateProfile(IResource element, IProblemProfile profile) {
- if (profile == null)
- profiles.remove(element);
- else
- profiles.put(element, profile);
- }
-
- /*
- * (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);
- if (prof == null) {
- if (element instanceof IProject) {
- try {
- prof = (IProblemProfile) getWorkspaceProfile().clone();
- // load default values
- CodanPreferencesLoader loader = new CodanPreferencesLoader(
- prof);
- IEclipsePreferences node = new ProjectScope(
- (IProject) element)
- .getNode(CodanCorePlugin.PLUGIN_ID);
- boolean useWorkspace = node.getBoolean(
- PreferenceConstants.P_USE_PARENT, false);
- if (!useWorkspace) {
- loader.load(node);
- }
- updateProfile(element, prof);
- } catch (CloneNotSupportedException e) {
- // cant
- }
- } else if (element.getParent() != null) {
- prof = getResourceProfile(element.getParent());
- } else {
- prof = getResourceProfile(element.getProject());
- }
- } else {
- }
- return prof;
- }
-
- /*
- * (non-Javadoc)
- *
- * @seeorg.eclipse.cdt.codan.core.model.ICheckersRegistry#
- * getResourceProfileWorkingCopy(org.eclipse.core.resources.IResource)
- */
- public IProblemProfile getResourceProfileWorkingCopy(IResource element) {
- if (element instanceof IProject) {
- try {
- IProblemProfile prof = (IProblemProfile) getWorkspaceProfile()
- .clone();
- // load default values
- CodanPreferencesLoader loader = new CodanPreferencesLoader(prof);
- IEclipsePreferences node = new ProjectScope((IProject) element)
- .getNode(CodanCorePlugin.PLUGIN_ID);
- loader.load(node);
- return prof;
- } catch (CloneNotSupportedException e) {
- // cant
- }
- }
- return null;
- }
-}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegistry.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegistry.java
new file mode 100644
index 0000000..9a9dadc
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegistry.java
@@ -0,0 +1,442 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.core;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.cdt.codan.core.CodanCorePlugin;
+import org.eclipse.cdt.codan.core.PreferenceConstants;
+import org.eclipse.cdt.codan.core.model.CodanSeverity;
+import org.eclipse.cdt.codan.core.model.IChecker;
+import org.eclipse.cdt.codan.core.model.ICheckerWithPreferences;
+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.IProblemWorkingCopy;
+import org.eclipse.cdt.codan.internal.core.model.CodanProblem;
+import org.eclipse.cdt.codan.internal.core.model.CodanProblemCategory;
+import org.eclipse.cdt.codan.internal.core.model.ProblemProfile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.osgi.service.prefs.Preferences;
+
+/**
+ * Implementation of checker registry interface
+ */
+public class CheckersRegistry implements Iterable, ICheckersRegistry {
+ private static final String NAME_ATTR = "name"; //$NON-NLS-1$
+ private static final String ID_ATTR = "id"; //$NON-NLS-1$
+ private static final String EXTENSION_POINT_NAME = "checkers"; //$NON-NLS-1$
+ private static final String CHECKER_ELEMENT = "checker"; //$NON-NLS-1$
+ private static final String PROBLEM_ELEMENT = "problem"; //$NON-NLS-1$
+ private static final String CATEGORY_ELEMENT = "category"; //$NON-NLS-1$
+ private static final Object DEFAULT = "DEFAULT"; //$NON-NLS-1$
+ private Collection checkers = new ArrayList();
+ private static CheckersRegistry instance;
+ private HashMap profiles = new HashMap();
+ private HashMap> problemList = new HashMap>();
+
+ private CheckersRegistry() {
+ instance = this;
+ profiles.put(DEFAULT, new ProblemProfile());
+ readCheckersRegistry();
+ }
+
+ private void readCheckersRegistry() {
+ IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(
+ CodanCorePlugin.PLUGIN_ID, EXTENSION_POINT_NAME);
+ if (ep == null)
+ return;
+ IConfigurationElement[] elements = ep.getConfigurationElements();
+ // process categories
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement configurationElement = elements[i];
+ processCategories(configurationElement);
+ }
+ // process shared problems
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement configurationElement = elements[i];
+ processProblem(configurationElement);
+ }
+ // process checkers
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement configurationElement = elements[i];
+ processChecker(configurationElement);
+ }
+ // init parameters for checkers with parameters
+ for (Iterator iterator = problemList.keySet().iterator(); iterator
+ .hasNext();) {
+ IChecker c = iterator.next();
+ if (c instanceof ICheckerWithPreferences) {
+ Collection list = problemList.get(c);
+ for (Iterator iterator2 = list.iterator(); iterator2
+ .hasNext();) {
+ IProblem p = iterator2.next();
+ if (p instanceof IProblemWorkingCopy) {
+ try {
+ ((ICheckerWithPreferences) c)
+ .initPreferences((IProblemWorkingCopy) p);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ CodanCorePlugin.log(t);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * @param configurationElement
+ */
+ private void processCategories(IConfigurationElement configurationElement) {
+ if (configurationElement.getName().equals(CATEGORY_ELEMENT)) {
+ String id = getAtt(configurationElement, ID_ATTR);
+ if (id == null)
+ return;
+ String name = getAtt(configurationElement, NAME_ATTR);
+ if (name == null)
+ return;
+ CodanProblemCategory cat = new CodanProblemCategory(id, name);
+ String category = getAtt(configurationElement,
+ "parentCategory", false); //$NON-NLS-1$
+ addCategory(cat, category);
+ }
+ }
+
+ /**
+ * @param configurationElement
+ */
+ private void processChecker(IConfigurationElement configurationElement) {
+ try {
+ if (configurationElement.getName().equals(CHECKER_ELEMENT)) {
+ String id = getAtt(configurationElement, ID_ATTR);
+ if (id == null)
+ return;
+ String name = getAtt(configurationElement, NAME_ATTR, false);
+ if (name == null)
+ name = id;
+ IChecker checkerObj = null;
+ try {
+ Object checker = configurationElement
+ .createExecutableExtension("class"); //$NON-NLS-1$
+ checkerObj = (IChecker) checker;
+ addChecker(checkerObj);
+ } catch (CoreException e) {
+ CodanCorePlugin.log(e);
+ return;
+ }
+ IConfigurationElement[] children1 = configurationElement
+ .getChildren("problemRef"); //$NON-NLS-1$
+ boolean hasRef = false;
+ IConfigurationElement[] children2 = configurationElement
+ .getChildren(PROBLEM_ELEMENT);
+ if (children2 != null) {
+ for (IConfigurationElement ref : children2) {
+ IProblem p = processProblem(ref);
+ addRefProblem(checkerObj, p);
+ hasRef = true;
+ }
+ }
+ if (children1 != null) {
+ for (IConfigurationElement ref : children1) {
+ hasRef = true;
+ IProblem p = getDefaultProfile().findProblem(
+ ref.getAttribute("refId")); //$NON-NLS-1$
+ addRefProblem(checkerObj, p);
+ }
+ }
+ if (!hasRef) {
+ CodanProblem p = new CodanProblem(id, name);
+ addProblem(p, null);
+ addRefProblem(checkerObj, p);
+ }
+ }
+ } catch (Throwable e) {
+ CodanCorePlugin.log(e);
+ }
+ }
+
+ /**
+ * @param configurationElement
+ * @return
+ */
+ private CodanProblem processProblem(
+ IConfigurationElement configurationElement) {
+ if (configurationElement.getName().equals(PROBLEM_ELEMENT)) {
+ String id = getAtt(configurationElement, ID_ATTR);
+ if (id == null)
+ return null;
+ String name = getAtt(configurationElement, NAME_ATTR);
+ if (name == null)
+ name = id;
+ CodanProblem p = new CodanProblem(id, name);
+ String category = getAtt(configurationElement, "category", false); //$NON-NLS-1$
+ if (category == null)
+ category = "org.eclipse.cdt.codan.core.categories.ProgrammingProblems"; //$NON-NLS-1$
+ String enab = getAtt(configurationElement, "defaultEnabled", false); //$NON-NLS-1$
+ String sev = getAtt(configurationElement, "defaultSeverity", false); //$NON-NLS-1$
+ String patt = getAtt(configurationElement, "messagePattern", false); //$NON-NLS-1$
+ String desc = getAtt(configurationElement, "description", false); //$NON-NLS-1$
+ String markerType = getAtt(configurationElement,
+ "markerType", false); //$NON-NLS-1$
+ if (enab != null) {
+ p.setEnabled(Boolean.valueOf(enab));
+ }
+ if (sev != null) {
+ CodanSeverity cSev = CodanSeverity.valueOf(sev);
+ if (cSev != null)
+ p.setSeverity(cSev);
+ }
+ if (patt != null) {
+ p.setMessagePattern(patt);
+ }
+ if (markerType != null) {
+ p.setMarkerType(markerType);
+ }
+ p.setDescription(desc);
+ addProblem(p, category);
+ return p;
+ }
+ return null;
+ }
+
+ private static String getAtt(IConfigurationElement configurationElement,
+ String name) {
+ return getAtt(configurationElement, name, true);
+ }
+
+ private static String getAtt(IConfigurationElement configurationElement,
+ String name, boolean req) {
+ String elementValue = configurationElement.getAttribute(name);
+ if (elementValue == null && req)
+ CodanCorePlugin
+ .log("Extension " + configurationElement.getDeclaringExtension().getUniqueIdentifier() //$NON-NLS-1$
+ + " missing required attribute: " + configurationElement.getName() + "." + name); //$NON-NLS-1$ //$NON-NLS-2$
+ return elementValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#iterator()
+ */
+ public Iterator iterator() {
+ return checkers.iterator();
+ }
+
+ public static CheckersRegistry getInstance() {
+ if (instance == null)
+ return new CheckersRegistry();
+ 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)
+ cat = getDefaultProfile().getRoot();
+ ((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)
+ cat = getDefaultProfile().getRoot();
+ ((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) {
+ Collection plist = problemList.get(c);
+ if (plist == null) {
+ plist = new ArrayList();
+ problemList.put(c, plist);
+ }
+ plist.add(p);
+ }
+
+ /**
+ * Returns list of problems registered for given checker
+ *
+ * @return collection of problems or null
+ */
+ public Collection getRefProblems(IChecker checker) {
+ return problemList.get(checker);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.cdt.codan.core.model.ICheckersRegistry#getDefaultProfile()
+ */
+ public IProblemProfile getDefaultProfile() {
+ return profiles.get(DEFAULT);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.cdt.codan.core.model.ICheckersRegistry#getWorkspaceProfile()
+ */
+ public IProblemProfile getWorkspaceProfile() {
+ IProblemProfile wp = profiles.get(ResourcesPlugin.getWorkspace());
+ if (wp == null) {
+ try {
+ wp = (IProblemProfile) getDefaultProfile().clone();
+ // load default values
+ CodanPreferencesLoader loader = new CodanPreferencesLoader(wp);
+ loader.load(CodanPreferencesLoader.getWorkspaceNode());
+ } catch (CloneNotSupportedException e) {
+ wp = getDefaultProfile();
+ }
+ profiles.put(ResourcesPlugin.getWorkspace(), wp);
+ }
+ return wp;
+ }
+
+ public void updateProfile(IResource element, IProblemProfile profile) {
+ // updating profile can invalidate all cached profiles
+ IProblemProfile defaultProfile = getDefaultProfile();
+ profiles.clear();
+ profiles.put(DEFAULT, defaultProfile);
+ if (profile != null && element != null)
+ profiles.put(element, profile);
+ }
+
+ /*
+ * (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);
+ if (prof == null) {
+ if (element instanceof IProject) {
+ try {
+ prof = (IProblemProfile) getWorkspaceProfile().clone();
+ // load default values
+ CodanPreferencesLoader loader = new CodanPreferencesLoader(
+ prof);
+ Preferences projectNode = CodanPreferencesLoader
+ .getProjectNode((IProject) element);
+ boolean useWorkspace = projectNode.getBoolean(
+ PreferenceConstants.P_USE_PARENT, false);
+ if (!useWorkspace) {
+ loader.load(projectNode);
+ }
+ profiles.put(element, prof);
+ } catch (CloneNotSupportedException e) {
+ // cant
+ }
+ } else if (element.getParent() != null) {
+ prof = getResourceProfile(element.getParent());
+ } else {
+ prof = getResourceProfile(element.getProject());
+ }
+ } else {
+ }
+ return prof;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.cdt.codan.core.model.ICheckersRegistry#
+ * getResourceProfileWorkingCopy(org.eclipse.core.resources.IResource)
+ */
+ public IProblemProfile getResourceProfileWorkingCopy(IResource element) {
+ try {
+ IProblemProfile prof = (IProblemProfile) getResourceProfile(element)
+ .clone();
+ return prof;
+ } catch (CloneNotSupportedException e) {
+ // cant
+ return null;
+ }
+ }
+
+ /**
+ * Test if checker is enabled (needs to be run) or not. Checker is enabled
+ * if at least one problem it prints is enabled.
+ *
+ * @param checker
+ * @param resource
+ * @return
+ */
+ public boolean isCheckerEnabled(IChecker checker, IResource resource) {
+ IProblemProfile resourceProfile = getResourceProfile(resource);
+ Collection refProblems = getRefProblems(checker);
+ for (Iterator iterator = refProblems.iterator(); iterator
+ .hasNext();) {
+ IProblem p = iterator.next();
+ // we need to check problem enablement in particular profile
+ IProblem problem = resourceProfile.findProblem(p.getId());
+ if (problem == null)
+ throw new IllegalArgumentException("Id is not registered"); //$NON-NLS-1$
+ if (problem.isEnabled())
+ return true;
+ }
+ // no problem is enabled for this checker, skip the checker
+ return false;
+ }
+
+ /**
+ * @return
+ */
+ public int getCheckersSize() {
+ return checkers.size();
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanApplication.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanApplication.java
new file mode 100644
index 0000000..188be3c
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanApplication.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * 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.internal.core;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.cdt.codan.core.CodanRuntime;
+import org.eclipse.cdt.codan.core.Messages;
+import org.eclipse.cdt.codan.internal.core.model.CodanMarkerProblemReporter;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Application to support headless build
+ *
+ * @noextend This class is not intended to be extended by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public class CodanApplication implements IApplication {
+ private Collection projects = new ArrayList();
+ private boolean verbose = false;
+ private boolean all = false;
+
+ public Object start(IApplicationContext context) throws Exception {
+ String[] args = (String[]) context.getArguments().get(
+ "application.args"); //$NON-NLS-1$
+ if (args == null || args.length == 0) {
+ help();
+ return EXIT_OK;
+ }
+ extractArguments(args);
+ CodanBuilder codanBuilder = new CodanBuilder();
+ CodanRuntime runtime = CodanRuntime.getInstance();
+ runtime.setProblemReporter(new CodanMarkerProblemReporter() {
+ @Override
+ public void reportProblem(String id, String markerType,
+ int severity, IResource file, int lineNumber,
+ int startChar, int endChar, String message) {
+ System.out.println(file.getLocation() + ":" + lineNumber + ": " //$NON-NLS-1$ //$NON-NLS-2$
+ + message);
+ }
+ });
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ if (all) {
+ log(Messages.CodanApplication_LogRunWorkspace);
+ codanBuilder.processResource(root, new NullProgressMonitor());
+ } else {
+ for (String project : projects) {
+ log(Messages.CodanApplication_LogRunProject + project);
+ IProject wProject = root.getProject(project);
+ if (!wProject.exists()) {
+ System.err
+ .println( //
+ NLS.bind(
+ Messages.CodanApplication_Error_ProjectDoesNotExists,
+ project));
+ continue;
+ }
+ codanBuilder.processResource(wProject,
+ new NullProgressMonitor());
+ }
+ }
+ return EXIT_OK;
+ }
+
+ /**
+ * @param string
+ */
+ private void log(String string) {
+ if (verbose)
+ System.err.println(string);
+ }
+
+ /**
+ * @param args
+ */
+ private void extractArguments(String[] args) {
+ for (int i = 0; i < args.length; i++) {
+ String string = args[i];
+ if (string.equals("-verbose")) { //$NON-NLS-1$
+ verbose = true;
+ } else if (string.equals("-all")) { //$NON-NLS-1$
+ all = true;
+ } else {
+ projects.add(string);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private void help() {
+ System.out.println(Messages.CodanApplication_Usage);
+ System.out.println(Messages.CodanApplication_Options);
+ System.out.println(Messages.CodanApplication_all_option);
+ System.out.println(Messages.CodanApplication_verbose_option);
+ }
+
+ public void stop() {
+ // nothing
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanBuilder.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanBuilder.java
index 56916b8..6685b98 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanBuilder.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanBuilder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -10,91 +10,74 @@
*******************************************************************************/
package org.eclipse.cdt.codan.internal.core;
-import java.io.File;
-import java.net.URI;
-import java.util.Collection;
-import java.util.Iterator;
import java.util.Map;
import org.eclipse.cdt.codan.core.CodanCorePlugin;
import org.eclipse.cdt.codan.core.CodanRuntime;
-import org.eclipse.cdt.codan.core.model.ICAstChecker;
+import org.eclipse.cdt.codan.core.Messages;
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.IProblem;
-import org.eclipse.cdt.codan.core.model.IProblemProfile;
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.cdt.codan.core.model.IProblemReporterPersistent;
+import org.eclipse.cdt.codan.core.model.IRunnableInEditorChecker;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
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;
+import org.eclipse.core.runtime.SubProgressMonitor;
+/**
+ * Implementation of {@link ICodanBuilder}
+ */
public class CodanBuilder extends IncrementalProjectBuilder implements
- ICodanBuilder, ICodanAstReconciler {
- public static final String BUILDER_ID = "org.eclipse.cdt.codan.core.codanBuilder";
+ ICodanBuilder {
+ /**
+ * codan builder id
+ */
+ public static final String BUILDER_ID = "org.eclipse.cdt.codan.core.codanBuilder"; //$NON-NLS-1$
- public class CodanDeltaVisitor implements IResourceDeltaVisitor {
- /*
- * (non-Javadoc)
- *
- * @see
- * 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)
+ private class CodanDeltaVisitor implements IResourceDeltaVisitor {
+ private IProgressMonitor monitor;
+
+ /**
+ * @param monitor
*/
+ public CodanDeltaVisitor(IProgressMonitor monitor) {
+ this.monitor = monitor;
+ }
+
public boolean visit(IResourceDelta delta) throws CoreException {
IResource resource = delta.getResource();
switch (delta.getKind()) {
- case IResourceDelta.ADDED:
- // handle added resource
- processResource(resource, new NullProgressMonitor());
- break;
- case IResourceDelta.REMOVED:
- // handle removed resource
- break;
- case IResourceDelta.CHANGED:
- // handle changed resource
- processResource(resource, new NullProgressMonitor());
- break;
+ case IResourceDelta.ADDED:
+ // handle added resource
+ processResource(resource, monitor);
+ break;
+ case IResourceDelta.REMOVED:
+ // handle removed resource
+ break;
+ case IResourceDelta.CHANGED:
+ // handle changed resource
+ processResource(resource, monitor);
+ break;
}
// return true to continue visiting children.
return true;
}
}
- public class CodanResourceVisitor implements IResourceVisitor {
- public boolean visit(IResource resource) {
- if (!(resource instanceof IProject))
- processResource(resource, new NullProgressMonitor());
- // return true to continue visiting children.
- return true;
- }
- }
-
/*
* (non-Javadoc)
*
* @see org.eclipse.core.internal.events.InternalBuilder#build(int,
* java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
*/
+ @SuppressWarnings("rawtypes")
+ @Override
protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
throws CoreException {
if (kind == FULL_BUILD) {
@@ -111,119 +94,101 @@ public class CodanBuilder extends IncrementalProjectBuilder implements
}
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
- IProblemReporter problemReporter = CodanRuntime.getInstance()
- .getProblemReporter();
- if (problemReporter instanceof CodanMarkerProblemReporter) {
- ((CodanMarkerProblemReporter) problemReporter)
- .deleteMarkers(resource);
- }
- for (IChecker checker : CheckersRegisry.getInstance()) {
- try {
- boolean run = false;
- if (checker.enabledInContext(resource))
- run = true;
- if (areProblemsForCheckerEnabled(checker, resource))
- run = true;
- if (run)
- checker.processResource(resource);
- } catch (Throwable e) {
- CodanCorePlugin.log(e);
- }
- }
- if (resource instanceof IProject) {
+ processResource(resource, monitor, null, false);
+ }
+
+ protected void processResource(IResource resource,
+ IProgressMonitor monitor, Object model, boolean inEditor) {
+ CheckersRegistry chegistry = CheckersRegistry.getInstance();
+ int checkers = chegistry.getCheckersSize();
+ int memsize = 0;
+ if (resource instanceof IContainer) {
try {
- resource.accept(getResourceVisitor());
+ IResource[] members = ((IContainer) resource).members();
+ memsize = members.length;
} 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();
- IFile[] resources;
- URI uri = new File(filePath).toURI();
- resources = root.findFilesForLocationURI(uri);
- if (resources != null && resources.length > 0) {
- IFile resource = resources[0];
+ int tick = 1000;
+ // System.err.println("processing " + resource);
+ monitor.beginTask(Messages.CodanBuilder_Code_Analysis_On + resource,
+ checkers + memsize * tick);
+ try {
IProblemReporter problemReporter = CodanRuntime.getInstance()
.getProblemReporter();
- // TODO: this is wrong - should not delete all markers -
- // only those that contributed by the checker that we run now
- if (problemReporter instanceof CodanMarkerProblemReporter) {
- ((CodanMarkerProblemReporter) problemReporter)
- .deleteMarkers(resource);
- }
- for (IChecker checker : CheckersRegisry.getInstance()) {
+ for (IChecker checker : chegistry) {
try {
- boolean run = false;
- if (checker.enabledInContext(resource))
- run = true;
- if (areProblemsForCheckerEnabled(checker, resource)) {
- run = true;
+ if (monitor.isCanceled())
+ return;
+ if (checker.enabledInContext(resource)) {
+ // delete markers if checker can possibly run on this
+ // resource
+ // this way if checker is not enabled markers would be
+ // deleted too
+ if (problemReporter instanceof IProblemReporterPersistent) {
+ // delete general markers
+ ((IProblemReporterPersistent) problemReporter)
+ .deleteProblems(resource, checker);
+ }
+ if (chegistry.isCheckerEnabled(checker, resource)) {
+ if (inEditor) {
+ if (checker.runInEditor()
+ && checker instanceof IRunnableInEditorChecker) {
+ ((IRunnableInEditorChecker) checker)
+ .processModel(model);
+ }
+ } else {
+ checker.processResource(resource);
+ }
+ }
}
- if (run && checker instanceof ICAstChecker
- && checker.runInEditor())
- ((ICAstChecker) checker).processAst(ast);
+ monitor.worked(1);
} catch (Throwable e) {
CodanCorePlugin.log(e);
}
}
+ if (resource instanceof IContainer) {
+ try {
+ IResource[] members = ((IContainer) resource).members();
+ for (int i = 0; i < members.length; i++) {
+ if (monitor.isCanceled())
+ return;
+ IResource member = members[i];
+ processResource(member, new SubProgressMonitor(monitor,
+ tick));
+ }
+ } catch (CoreException e) {
+ CodanCorePlugin.log(e);
+ }
+ }
+ } finally {
+ monitor.done();
}
}
- /**
- * @param checker
- * @param resource
- * @return
- */
- private boolean areProblemsForCheckerEnabled(IChecker checker,
- IResource resource) {
- IProblemProfile resourceProfile = CheckersRegisry.getInstance()
- .getResourceProfile(resource);
- Collection refProblems = CheckersRegisry.getInstance()
- .getRefProblems(checker);
- for (Iterator iterator = refProblems.iterator(); iterator.hasNext();) {
- IProblem p = (IProblem) iterator.next();
- // we need to check problem enablement in particular profile
- IProblem problem = resourceProfile.findProblem(p.getId());
- if (problem == null)
- throw new IllegalArgumentException("Id is not registered");
- if (problem.isEnabled())
- return true;
- }
- // no problem is enabled for this checker, skip the checker
- return false;
- }
-
protected void fullBuild(final IProgressMonitor monitor)
throws CoreException {
- try {
- getProject().accept(new CodanResourceVisitor());
- } catch (CoreException e) {
- }
+ processResource(getProject(), monitor);
}
protected void incrementalBuild(IResourceDelta delta,
IProgressMonitor monitor) throws CoreException {
// the visitor does the work.
- delta.accept(new CodanDeltaVisitor());
+ delta.accept(new CodanDeltaVisitor(monitor));
}
- /*
- * (non-Javadoc)
+ /**
+ * Run all checkers that support "check as you type" mode
*
- * @see org.eclipse.cdt.codan.core.model.ICodanBuilder#getResourceVisitor()
+ * @param model - model of given resource such as ast
+ * @param resource - resource to process
+ * @param monitor - progress monitor
*/
- public CodanResourceVisitor getResourceVisitor() {
- return new CodanResourceVisitor();
+ public void runInEditor(Object model, IResource resource,
+ IProgressMonitor monitor) {
+ if (model == null)
+ return;
+ processResource(resource, monitor, model, true);
}
}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanPreferencesLoader.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanPreferencesLoader.java
index bafff9a..38af027 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanPreferencesLoader.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanPreferencesLoader.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -10,38 +10,50 @@
*******************************************************************************/
package org.eclipse.cdt.codan.internal.core;
+import org.eclipse.cdt.codan.core.CodanCorePlugin;
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;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
+import org.eclipse.cdt.codan.core.param.IProblemPreference;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.osgi.service.prefs.Preferences;
/**
- * @author Alena
+ * Helper class to load/save problem profile settings in persistent storage
*
*/
public class CodanPreferencesLoader {
private IProblemProfile baseModel;
/**
- * @param workspaceProfile
+ * Constructor
+ *
+ * @param profile - problem profile to work with
*/
public CodanPreferencesLoader(IProblemProfile profile) {
setInput(profile);
}
/**
- *
+ * Default constructor
*/
public CodanPreferencesLoader() {
}
- public void setInput(Object model) {
- baseModel = (IProblemProfile) model;
+ /**
+ * Sets the profile for this class
+ *
+ * @param profile
+ */
+ public void setInput(IProblemProfile profile) {
+ baseModel = profile;
}
/**
- * @return
+ * @return problems array from the profile
*/
public IProblem[] getProblems() {
IProblem[] problems = baseModel.getProblems();
@@ -54,66 +66,144 @@ public class CodanPreferencesLoader {
*/
public void setProperty(String id, String s) {
IProblem prob = baseModel.findProblem(id);
- if (!(prob instanceof CodanProblem))
+ if (!(prob instanceof IProblemWorkingCopy))
return;
String sevs = s;
boolean enabled = true;
- if (sevs.startsWith("-")) {
+ if (sevs.startsWith("-")) { //$NON-NLS-1$
sevs = sevs.substring(1);
enabled = false;
}
- ((CodanProblem) prob).setEnabled(enabled);
+ ((IProblemWorkingCopy) prob).setEnabled(enabled);
CodanSeverity sev;
try {
sev = CodanSeverity.valueOf(sevs);
} catch (RuntimeException e) {
sev = CodanSeverity.Warning;
}
- ((CodanProblem) prob).setSeverity(sev);
+ ((IProblemWorkingCopy) prob).setSeverity(sev);
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
return getInput().toString();
}
/**
- * @return
+ * @return problem profile set for this class
*/
public IProblemProfile getInput() {
return baseModel;
}
/**
- * @param id
- * @return
+ * @param id - property id, which is the same as problem id
+ * @return get text representation of a "property" value for the given id,
+ * which is severity name, with "-" in front of it it problem is
+ * disabled.
*/
public String getProperty(String id) {
IProblem prob = baseModel.findProblem(id);
- if (!(prob instanceof CodanProblem))
- return null;
- String enabled = prob.isEnabled() ? "" : "-";
+ String enabled = prob.isEnabled() ? "" : "-"; //$NON-NLS-1$ //$NON-NLS-2$
String severity = prob.getSeverity().toString();
String res = enabled + severity;
return res;
}
/**
+ * Takes string values from storePreferences and applies them to the problem
+ * profile
+ *
* @param storePreferences
*/
- public void load(IEclipsePreferences storePreferences) {
+ public void load(Preferences storePreferences) {
IProblem[] probs = getProblems();
for (int i = 0; i < probs.length; i++) {
String id = probs[i].getId();
String s = storePreferences.get(id, null);
if (s != null) {
setProperty(id, s);
+ setProblemPreferenceValues(id, storePreferences);
}
}
}
+
+ /**
+ * Takes string values of the problem preferences from storePreferences
+ * and applies them to the problem profile
+ *
+ * @param problemId
+ * @param storePreferences
+ */
+ private void setProblemPreferenceValues(String problemId,
+ Preferences storePreferences) {
+ IProblem prob = baseModel.findProblem(problemId);
+ String prefKey = getPreferencesKey(problemId);
+ if (prefKey == null)
+ return;
+ String exported = storePreferences.get(prefKey, null);
+ if (exported != null) {
+ //System.err.println(prefKey + " import " + exported);
+ prob.getPreference().importValue(exported);
+ }
+ }
+
+ /**
+ * Return preference node (osgi preferences) for the project
+ *
+ * @param project
+ * @return project preferences node
+ */
+ public static Preferences getProjectNode(IProject project) {
+ if (!project.exists())
+ return null;
+ Preferences prefNode = new ProjectScope(project)
+ .getNode(CodanCorePlugin.PLUGIN_ID);
+ if (prefNode == null)
+ return null;
+ return prefNode;
+ }
+
+ /**
+ * Return preference node (osgi preferences) for the workspace
+ *
+ * @return project preferences node
+ */
+ public static Preferences getWorkspaceNode() {
+ Preferences prefNode = new InstanceScope()
+ .getNode(CodanCorePlugin.PLUGIN_ID);
+ if (prefNode == null)
+ return null;
+ return prefNode;
+ }
+
+ /**
+ * Name of the preference key for the root problem preference in the osgi
+ * preferences
+ *
+ * @param id - problem id
+ * @return top level preference id
+ */
+ public String getPreferencesKey(String id) {
+ IProblem prob = baseModel.findProblem(id);
+ IProblemPreference pref = prob.getPreference();
+ if (pref == null)
+ return null;
+ return id + "." + pref.getKey(); //$NON-NLS-1$
+ }
+
+ /**
+ * @param id - problem id
+ * @return - export value of root problem preference (to be saved in eclipse
+ * preferences)
+ */
+ public String getPreferencesString(String id) {
+ IProblem prob = baseModel.findProblem(id);
+ IProblemPreference pref = prob.getPreference();
+ if (pref == null)
+ return null;
+ String str = pref.exportValue();
+ //System.err.println(id + " set " + str);
+ return str;
+ }
}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodeAnlysisNature.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodeAnlysisNature.java
index 5157e16..f73ee61 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodeAnlysisNature.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodeAnlysisNature.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -16,18 +16,16 @@ import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
+/**
+ * Code Analysis Nature for builder
+ */
public class CodeAnlysisNature implements IProjectNature {
/**
* ID of this project nature
*/
- public static final String NATURE_ID = "org.eclipse.cdt.codan.core.codanNature";
+ public static final String NATURE_ID = "org.eclipse.cdt.codan.core.codanNature"; //$NON-NLS-1$
private IProject project;
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.resources.IProjectNature#configure()
- */
public void configure() throws CoreException {
IProjectDescription desc = project.getDescription();
ICommand[] commands = desc.getBuildSpec();
@@ -45,11 +43,6 @@ public class CodeAnlysisNature implements IProjectNature {
project.setDescription(desc, null);
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.resources.IProjectNature#deconfigure()
- */
public void deconfigure() throws CoreException {
IProjectDescription description = getProject().getDescription();
ICommand[] commands = description.getBuildSpec();
@@ -66,22 +59,10 @@ public class CodeAnlysisNature implements IProjectNature {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.resources.IProjectNature#getProject()
- */
public IProject getProject() {
return project;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core
- * .resources.IProject)
- */
public void setProject(IProject project) {
this.project = project;
}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractBasicBlock.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractBasicBlock.java
new file mode 100644
index 0000000..15a191a
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractBasicBlock.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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.internal.core.cfg;
+
+import org.eclipse.cdt.codan.core.model.cfg.IBasicBlock;
+import org.eclipse.cdt.codan.core.model.cfg.ICfgData;
+
+/**
+ * Abstract Basic Block for control flow graph.
+ */
+public abstract class AbstractBasicBlock implements IBasicBlock, ICfgData {
+ /**
+ * Empty array of basic blocks
+ */
+ public final static IBasicBlock[] EMPTY_LIST = new IBasicBlock[0];
+ private Object data;
+
+ public Object getData() {
+ return data;
+ }
+
+ public void setData(Object data) {
+ this.data = data;
+ }
+
+ /**
+ * Add a node to list of outgoing nodes of this node
+ *
+ * @param node - node to add
+ */
+ public abstract void addOutgoing(IBasicBlock node);
+
+ /**
+ * Add a node to list of incoming nodes of this node
+ *
+ * @param node - node to add
+ */
+ public abstract void addIncoming(IBasicBlock node);
+
+ /**
+ * @return toString for data object
+ */
+ public String toStringData() {
+ if (getData() == null)
+ return "0x" + Integer.toHexString(System.identityHashCode(this)); //$NON-NLS-1$
+ return getData().toString();
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + ": " + toStringData(); //$NON-NLS-1$
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleIncomingNode.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleIncomingNode.java
new file mode 100644
index 0000000..9054f2a
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleIncomingNode.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.internal.core.cfg;
+
+import org.eclipse.cdt.codan.core.model.cfg.IBasicBlock;
+import org.eclipse.cdt.codan.core.model.cfg.ISingleIncoming;
+
+/**
+ * Abstract node with one incoming arc (node)
+ *
+ */
+public abstract class AbstractSingleIncomingNode extends AbstractBasicBlock
+ implements ISingleIncoming {
+ private IBasicBlock prev;
+
+ /**
+ * Default constructor
+ */
+ public AbstractSingleIncomingNode() {
+ super();
+ }
+
+ public IBasicBlock[] getIncomingNodes() {
+ return new IBasicBlock[] { prev };
+ }
+
+ public int getIncomingSize() {
+ return 1;
+ }
+
+ public IBasicBlock getIncoming() {
+ return prev;
+ }
+
+ /**
+ * Sets the incoming node
+ *
+ * @param prev
+ */
+ public void setIncoming(IBasicBlock prev) {
+ this.prev = prev;
+ }
+
+ @Override
+ public void addIncoming(IBasicBlock node) {
+ setIncoming(node);
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleOutgoingNode.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleOutgoingNode.java
new file mode 100644
index 0000000..e4f7fcf
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleOutgoingNode.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.internal.core.cfg;
+
+import org.eclipse.cdt.codan.core.model.cfg.IBasicBlock;
+import org.eclipse.cdt.codan.core.model.cfg.ISingleOutgoing;
+
+/**
+ * Abstract implementation of basic block with single outgoing arc (node)
+ *
+ */
+public abstract class AbstractSingleOutgoingNode extends AbstractBasicBlock
+ implements ISingleOutgoing {
+ private IBasicBlock next;
+
+ /**
+ * Default constructor
+ */
+ public AbstractSingleOutgoingNode() {
+ super();
+ }
+
+ public IBasicBlock[] getOutgoingNodes() {
+ return new IBasicBlock[] { next };
+ }
+
+ public int getOutgoingSize() {
+ return 1;
+ }
+
+ public IBasicBlock getOutgoing() {
+ return next;
+ }
+
+ /**
+ * Sets outgoing node
+ *
+ * @param node
+ */
+ public void setOutgoing(IBasicBlock node) {
+ this.next = node;
+ }
+
+ @Override
+ public void addOutgoing(IBasicBlock node) {
+ setOutgoing(node);
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/BranchNode.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/BranchNode.java
new file mode 100644
index 0000000..ecd99e1
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/BranchNode.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.core.cfg;
+
+import org.eclipse.cdt.codan.core.model.cfg.IBranchNode;
+
+/**
+ * Branch node is a node with on incoming arc, one outgoing arc and a "string"
+ * label. Can be used to represent branches of if, switch and labelled
+ * statements.
+ */
+public class BranchNode extends PlainNode implements IBranchNode {
+ protected String label;
+
+ protected BranchNode(String label) {
+ super();
+ this.label = label;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ @Override
+ public String toStringData() {
+ return label;
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/CVS/Entries b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/CVS/Entries
new file mode 100644
index 0000000..bd763ef
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/CVS/Entries
@@ -0,0 +1,12 @@
+/AbstractBasicBlock.java/1.10/Thu Jun 3 17:01:52 2010//TCDT_7_0_0
+/AbstractSingleIncomingNode.java/1.6/Thu Jun 3 17:01:52 2010//TCDT_7_0_0
+/AbstractSingleOutgoingNode.java/1.6/Thu Jun 3 17:01:52 2010//TCDT_7_0_0
+/BranchNode.java/1.5/Thu Jun 3 17:01:52 2010//TCDT_7_0_0
+/ConnectorNode.java/1.7/Thu Jun 3 17:01:52 2010//TCDT_7_0_0
+/ControlFlowGraph.java/1.11/Thu Jun 3 17:01:52 2010//TCDT_7_0_0
+/DecisionNode.java/1.9/Thu Jun 3 17:01:52 2010//TCDT_7_0_0
+/ExitNode.java/1.6/Thu Jun 3 17:01:52 2010//TCDT_7_0_0
+/JumpNode.java/1.9/Thu Jun 3 17:01:52 2010//TCDT_7_0_0
+/NodeFactory.java/1.2/Thu Jun 3 17:01:52 2010//TCDT_7_0_0
+/PlainNode.java/1.8/Thu Jun 3 17:01:52 2010//TCDT_7_0_0
+/StartNode.java/1.8/Thu Jun 3 17:01:52 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/CVS/Repository b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/CVS/Repository
new file mode 100644
index 0000000..34bede2
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/CVS/Root b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/CVS/Tag b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ConnectorNode.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ConnectorNode.java
new file mode 100644
index 0000000..7c91818
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ConnectorNode.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.core.cfg;
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.codan.core.model.cfg.IBasicBlock;
+import org.eclipse.cdt.codan.core.model.cfg.IConnectorNode;
+import org.eclipse.cdt.codan.core.model.cfg.IJumpNode;
+
+/**
+ * TODO: add description
+ */
+public class ConnectorNode extends AbstractSingleOutgoingNode implements
+ IConnectorNode {
+ protected ArrayList incoming = new ArrayList(2);
+
+ protected ConnectorNode() {
+ super();
+ }
+
+ @Override
+ public void addIncoming(IBasicBlock node) {
+ incoming.add(node);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.cdt.codan.provisional.core.model.cfg.IBasicBlock#
+ * getIncomingIterator()
+ */
+ public IBasicBlock[] getIncomingNodes() {
+ return incoming.toArray(new IBasicBlock[incoming.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.cfg.IBasicBlock#getIncomingSize ()
+ */
+ public int getIncomingSize() {
+ return incoming.size();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.cdt.codan.provisional.core.model.cfg.IConnectorNode#
+ * hasBackwardIncoming()
+ */
+ public boolean hasBackwardIncoming() {
+ for (IBasicBlock node : incoming) {
+ if (node instanceof IJumpNode) {
+ if (((IJumpNode) node).isBackwardArc())
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ControlFlowGraph.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ControlFlowGraph.java
new file mode 100644
index 0000000..8133e8c
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ControlFlowGraph.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.core.cfg;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+
+import org.eclipse.cdt.codan.core.model.cfg.IBasicBlock;
+import org.eclipse.cdt.codan.core.model.cfg.IBranchNode;
+import org.eclipse.cdt.codan.core.model.cfg.IConnectorNode;
+import org.eclipse.cdt.codan.core.model.cfg.IControlFlowGraph;
+import org.eclipse.cdt.codan.core.model.cfg.IDecisionNode;
+import org.eclipse.cdt.codan.core.model.cfg.IExitNode;
+import org.eclipse.cdt.codan.core.model.cfg.ISingleOutgoing;
+import org.eclipse.cdt.codan.core.model.cfg.IStartNode;
+
+/**
+ * Implementation of control flow graph
+ */
+public class ControlFlowGraph implements IControlFlowGraph {
+ private List exitNodes;
+ private List deadNodes = new ArrayList();
+ private IStartNode start;
+
+ public ControlFlowGraph(IStartNode start, Collection exitNodes) {
+ setExitNodes(exitNodes);
+ this.start = start;
+ }
+
+ public Iterator getExitNodeIterator() {
+ return exitNodes.iterator();
+ }
+
+ public int getExitNodeSize() {
+ return exitNodes.size();
+ }
+
+ public void setExitNodes(Collection exitNodes) {
+ if (this.exitNodes != null)
+ throw new IllegalArgumentException(
+ "Cannot modify already exiting connector"); //$NON-NLS-1$
+ this.exitNodes = Collections.unmodifiableList(new ArrayList(
+ exitNodes));
+ }
+
+ public void setUnconnectedNodes(Collection nodes) {
+ this.deadNodes = Collections
+ .unmodifiableList(new ArrayList(nodes));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.cdt.codan.provisional.core.model.cfg.IControlFlowGraph#
+ * getStartNode()
+ */
+ public IStartNode getStartNode() {
+ return start;
+ }
+
+ void setStartNode(IStartNode start) {
+ this.start = start;
+ }
+
+ public void print(IBasicBlock node) {
+ System.out.println(node.getClass().getSimpleName() + ": " //$NON-NLS-1$
+ + ((AbstractBasicBlock) node).toStringData());
+ if (node instanceof IDecisionNode) {
+ // todo
+ IBasicBlock[] branches = ((IDecisionNode) node).getOutgoingNodes();
+ for (int i = 0; i < branches.length; i++) {
+ IBasicBlock brNode = branches[i];
+ System.out.println("{"); //$NON-NLS-1$
+ print(brNode);
+ System.out.println("}"); //$NON-NLS-1$
+ }
+ print(((IDecisionNode) node).getMergeNode());
+ } else if (node instanceof ISingleOutgoing) {
+ IBasicBlock next = ((ISingleOutgoing) node).getOutgoing();
+ if (!(next instanceof IConnectorNode && !(next instanceof IBranchNode)))
+ print(next);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.cdt.codan.provisional.core.model.cfg.IControlFlowGraph#
+ * getUnconnectedNodeIterator()
+ */
+ public Iterator getUnconnectedNodeIterator() {
+ return deadNodes.iterator();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.cdt.codan.provisional.core.model.cfg.IControlFlowGraph#
+ * getUnconnectedNodeSize()
+ */
+ public int getUnconnectedNodeSize() {
+ return deadNodes.size();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.cfg.IControlFlowGraph#getNodes ()
+ */
+ public Collection getNodes() {
+ Collection result = new LinkedHashSet();
+ getNodes(getStartNode(), result);
+ for (Iterator iterator = deadNodes.iterator(); iterator
+ .hasNext();) {
+ IBasicBlock d = iterator.next();
+ getNodes(d, result);
+ }
+ return result;
+ }
+
+ /**
+ * @param d
+ * @param result
+ */
+ private void getNodes(IBasicBlock start, Collection result) {
+ if (result.contains(start))
+ return;
+ result.add(start);
+ IBasicBlock[] outgoingNodes = start.getOutgoingNodes();
+ for (int i = 0; i < outgoingNodes.length; i++) {
+ IBasicBlock b = outgoingNodes[i];
+ getNodes(b, result);
+ }
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/DecisionNode.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/DecisionNode.java
new file mode 100644
index 0000000..df0da9c
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/DecisionNode.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.core.cfg;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.codan.core.model.cfg.IBasicBlock;
+import org.eclipse.cdt.codan.core.model.cfg.IBranchNode;
+import org.eclipse.cdt.codan.core.model.cfg.IConnectorNode;
+import org.eclipse.cdt.codan.core.model.cfg.IDecisionNode;
+
+/**
+ * @see {@link IDecisionNode}
+ */
+public class DecisionNode extends AbstractSingleIncomingNode implements
+ IDecisionNode {
+ private List next = new ArrayList(2);
+ private IConnectorNode conn;
+
+ /**
+ * @param prev
+ */
+ protected DecisionNode() {
+ super();
+ }
+
+ @Override
+ public void addOutgoing(IBasicBlock node) {
+ IBranchNode cnode = (IBranchNode) node; // cast to throw CCE
+ next.add(cnode);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.cdt.codan.provisional.core.model.cfg.IBasicBlock#
+ * getOutgoingIterator()
+ */
+ public IBasicBlock[] getOutgoingNodes() {
+ return next.toArray(new IBasicBlock[next.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.cfg.IBasicBlock#getOutgoingSize ()
+ */
+ public int getOutgoingSize() {
+ return next.size();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.cdt.codan.provisional.core.model.cfg.IDecisionNode#
+ * getConnectionNode()
+ */
+ public IConnectorNode getMergeNode() {
+ return conn;
+ }
+
+ public void setMergeNode(IConnectorNode conn) {
+ this.conn = conn;
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ExitNode.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ExitNode.java
new file mode 100644
index 0000000..7bd9848
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ExitNode.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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.internal.core.cfg;
+
+import org.eclipse.cdt.codan.core.model.cfg.IBasicBlock;
+import org.eclipse.cdt.codan.core.model.cfg.IExitNode;
+import org.eclipse.cdt.codan.core.model.cfg.IStartNode;
+
+/**
+ * Plain node has one prev one jump
+ *
+ */
+public class ExitNode extends AbstractSingleIncomingNode implements IExitNode {
+ private IStartNode start;
+
+ protected ExitNode() {
+ super();
+ }
+
+ public IBasicBlock[] getOutgoingNodes() {
+ return EMPTY_LIST;
+ }
+
+ public int getOutgoingSize() {
+ return 0;
+ }
+
+ public IStartNode getStartNode() {
+ return start;
+ }
+
+ public void setStartNode(IStartNode start) {
+ this.start = start;
+ }
+
+ @Override
+ public void addOutgoing(IBasicBlock node) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/JumpNode.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/JumpNode.java
new file mode 100644
index 0000000..b5198d0
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/JumpNode.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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.internal.core.cfg;
+
+import org.eclipse.cdt.codan.core.model.cfg.IBasicBlock;
+import org.eclipse.cdt.codan.core.model.cfg.IConnectorNode;
+import org.eclipse.cdt.codan.core.model.cfg.IJumpNode;
+
+/**
+ * Jump node is node that connects unusual control pass, such as goto, break and
+ * continue
+ *
+ */
+public class JumpNode extends AbstractSingleIncomingNode implements IJumpNode {
+ private IConnectorNode jump;
+ private boolean backward;
+
+ protected JumpNode() {
+ super();
+ }
+
+ public IBasicBlock[] getOutgoingNodes() {
+ return new IBasicBlock[] { jump };
+ }
+
+ public int getOutgoingSize() {
+ return 1;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.cfg.IJumpNode#getJumpNode()
+ */
+ public IConnectorNode getJumpNode() {
+ return jump;
+ }
+
+ public IBasicBlock getOutgoing() {
+ return jump;
+ }
+
+ public boolean isBackwardArc() {
+ return backward;
+ }
+
+ public void setJump(IConnectorNode jump, boolean backward) {
+ if (this.jump != null && this.jump != jump)
+ throw new IllegalArgumentException(
+ "Cannot modify exiting connector"); //$NON-NLS-1$
+ this.jump = jump;
+ this.backward = backward;
+ }
+
+ public void setBackward(boolean backward) {
+ this.backward = backward;
+ }
+
+ @Override
+ public void addOutgoing(IBasicBlock node) {
+ setJump((IConnectorNode) node, backward);
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/NodeFactory.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/NodeFactory.java
new file mode 100644
index 0000000..0de0734
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/NodeFactory.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.core.cfg;
+
+import org.eclipse.cdt.codan.core.model.cfg.IBranchNode;
+import org.eclipse.cdt.codan.core.model.cfg.IConnectorNode;
+import org.eclipse.cdt.codan.core.model.cfg.IControlFlowGraph;
+import org.eclipse.cdt.codan.core.model.cfg.IDecisionNode;
+import org.eclipse.cdt.codan.core.model.cfg.IExitNode;
+import org.eclipse.cdt.codan.core.model.cfg.IJumpNode;
+import org.eclipse.cdt.codan.core.model.cfg.INodeFactory;
+import org.eclipse.cdt.codan.core.model.cfg.IPlainNode;
+import org.eclipse.cdt.codan.core.model.cfg.IStartNode;
+
+/**
+ * Factory that creates cfg nodes
+ */
+public class NodeFactory implements INodeFactory {
+ IControlFlowGraph graph;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.cdt.codan.provisional.core.model.cfg.INodeFactory#
+ * getControlFlowGraph()
+ */
+ public IControlFlowGraph getControlFlowGraph() {
+ return graph;
+ }
+
+ public NodeFactory() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.cfg.INodeFactory#createPlainNode ()
+ */
+ public IPlainNode createPlainNode() {
+ return new PlainNode();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.cfg.INodeFactory#createJumpNode ()
+ */
+ public IJumpNode createJumpNode() {
+ return new JumpNode();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.cdt.codan.provisional.core.model.cfg.INodeFactory#
+ * createDecisionNode()
+ */
+ public IDecisionNode createDecisionNode() {
+ return new DecisionNode();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.cdt.codan.provisional.core.model.cfg.INodeFactory#
+ * createConnectiorNode()
+ */
+ public IConnectorNode createConnectorNode() {
+ return new ConnectorNode();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.cfg.INodeFactory#createStartNode ()
+ */
+ public IStartNode createStartNode() {
+ return new StartNode();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.cfg.INodeFactory#createExitNode ()
+ */
+ public IExitNode createExitNode() {
+ return new ExitNode();
+ }
+
+ public IBranchNode createBranchNode(String label) {
+ return new BranchNode(label);
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/PlainNode.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/PlainNode.java
new file mode 100644
index 0000000..d382fb4
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/PlainNode.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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.internal.core.cfg;
+
+import org.eclipse.cdt.codan.core.model.cfg.IBasicBlock;
+import org.eclipse.cdt.codan.core.model.cfg.IPlainNode;
+
+/**
+ * Plain node has one incoming arc and one outgoing arc
+ *
+ */
+public class PlainNode extends AbstractSingleIncomingNode implements IPlainNode {
+ protected IBasicBlock next;
+
+ protected PlainNode() {
+ super();
+ }
+
+ public IBasicBlock[] getOutgoingNodes() {
+ return new IBasicBlock[] { next };
+ }
+
+ public int getOutgoingSize() {
+ return 1;
+ }
+
+ public IBasicBlock getOutgoing() {
+ return next;
+ }
+
+ public void setOutgoing(IBasicBlock exit) {
+ this.next = exit;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.cdt.codan.internal.core.cfg.AbstractBasicBlock#addOutgoing
+ * (org.eclipse.cdt.codan.core.model.cfg.IBasicBlock)
+ */
+ @Override
+ public void addOutgoing(IBasicBlock node) {
+ setOutgoing(node);
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/StartNode.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/StartNode.java
new file mode 100644
index 0000000..4d64bad
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/StartNode.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.internal.core.cfg;
+
+import org.eclipse.cdt.codan.core.model.cfg.IBasicBlock;
+import org.eclipse.cdt.codan.core.model.cfg.IStartNode;
+
+/**
+ * Start node has no incoming, one outgoing and it is connect to function exits
+ *
+ */
+public class StartNode extends AbstractSingleOutgoingNode implements IStartNode {
+ protected StartNode() {
+ super();
+ }
+
+ public IBasicBlock[] getIncomingNodes() {
+ return EMPTY_LIST;
+ }
+
+ public int getIncomingSize() {
+ return 0;
+ }
+
+ @Override
+ public void addOutgoing(IBasicBlock node) {
+ setOutgoing(node);
+ }
+
+ @Override
+ public void addIncoming(IBasicBlock node) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CVS/Entries b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CVS/Entries
index 5f7a029..182ee54 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CVS/Entries
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CVS/Entries
@@ -1,5 +1,6 @@
-/CodanMarkerProblemReporter.java/1.2/Wed Dec 16 21:48:48 2009//
-/CodanProblem.java/1.1/Sat Aug 22 21:16:48 2009//
-/CodanProblemCategory.java/1.2/Wed Dec 16 21:48:48 2009//
-/ProblemProfile.java/1.1/Wed Sep 23 23:29:36 2009//
-D
+/CodanMarkerProblemReporter.java/1.15/Sun Jun 27 01:30:42 2010//TCDT_7_0_0
+/CodanProblem.java/1.9/Sun Jun 27 01:30:42 2010//TCDT_7_0_0
+/CodanProblemCategory.java/1.4/Sun Jun 27 01:30:42 2010//TCDT_7_0_0
+/CodanProblemLocation.java/1.4/Sun Jun 27 01:30:42 2010//TCDT_7_0_0
+/ProblemLocationFactory.java/1.3/Sun Jun 27 01:30:42 2010//TCDT_7_0_0
+/ProblemProfile.java/1.3/Sun Jun 27 01:30:42 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CVS/Tag b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanMarkerProblemReporter.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanMarkerProblemReporter.java
index a4599c5..51a4794 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanMarkerProblemReporter.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanMarkerProblemReporter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -11,39 +11,40 @@
package org.eclipse.cdt.codan.internal.core.model;
import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.Iterator;
+import org.eclipse.cdt.codan.core.CodanCorePlugin;
+import org.eclipse.cdt.codan.core.CodanRuntime;
+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.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.cdt.codan.core.model.IProblemReporterPersistent;
+import org.eclipse.cdt.codan.internal.core.CheckersRegistry;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
-public class CodanMarkerProblemReporter implements IProblemReporter {
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.cdt.codan.core.model.IProblemReporter#reportProblem(java.
- * lang.String, org.eclipse.cdt.codan.core.model.IProblemLocation,
- * java.lang.Object[])
- */
+/**
+ * Problem reported that created eclipse markers
+ */
+public class CodanMarkerProblemReporter implements IProblemReporterPersistent {
public void reportProblem(String id, IProblemLocation loc, Object... args) {
- IFile file = loc.getFile();
+ IResource file = loc.getFile();
int lineNumber = loc.getLineNumber();
if (file == null)
- throw new NullPointerException("file");
+ throw new NullPointerException("file"); //$NON-NLS-1$
if (id == null)
- throw new NullPointerException("id");
- IProblem problem = CheckersRegisry.getInstance().getResourceProfile(
- file).findProblem(id);
+ throw new NullPointerException("id"); //$NON-NLS-1$
+ IProblem problem = CheckersRegistry.getInstance()
+ .getResourceProfile(file).findProblem(id);
if (problem == null)
- throw new IllegalArgumentException("Id is not registered");
+ throw new IllegalArgumentException("Id is not registered:" + id); //$NON-NLS-1$
if (problem.isEnabled() == false)
return; // skip
int severity = problem.getSeverity().intValue();
@@ -53,25 +54,31 @@ public class CodanMarkerProblemReporter implements IProblemReporter {
if (args != null && args.length > 0 && args[0] instanceof String)
message = (String) args[0];
} else {
- MessageFormat.format(messagePattern, args);
+ message = MessageFormat.format(messagePattern, args);
}
- reportProblem(id, severity, file, lineNumber, loc.getStartingChar(),
- loc.getEndingChar(), message);
+ reportProblem(id, problem.getMarkerType(), 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)
+ /**
+ * @param id - problem id
+ * @param markerType - marker id
+ * @param severity - marker severity
+ * @param file - resource
+ * @param lineNumber - line number for error
+ * @param startChar - start char (offset in charts from the begging of the
+ * document)
+ * @param endChar - end char (offset in charts from the begging of the
+ * document, exclusive)
+ * @param message - marker message
*/
- public void reportProblem(String id, int severity, IFile file,
- int lineNumber, int startChar, int endChar, String message) {
+ public void reportProblem(String id, String markerType, int severity,
+ IResource file, int lineNumber, int startChar, int endChar,
+ String message) {
try {
// Do not put in duplicates
- IMarker[] cur = file.findMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE,
- false, IResource.DEPTH_ZERO);
+ IMarker[] cur = file.findMarkers(markerType, false,
+ IResource.DEPTH_ZERO);
if (cur != null) {
for (IMarker element : cur) {
int line = ((Integer) element
@@ -86,37 +93,72 @@ public class CodanMarkerProblemReporter implements IProblemReporter {
}
}
}
- IMarker marker = file
- .createMarker(GENERIC_CODE_ANALYSIS_MARKER_TYPE);
+ IMarker marker = file.createMarker(markerType);
marker.setAttribute(IMarker.MESSAGE, message);
marker.setAttribute(IMarker.SEVERITY, severity);
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
marker.setAttribute(IMarker.PROBLEM, id);
marker.setAttribute(IMarker.CHAR_END, endChar);
marker.setAttribute(IMarker.CHAR_START, startChar);
+ marker.setAttribute("org.eclipse.cdt.core.problem", 42); //$NON-NLS-1$
} catch (CoreException e) {
e.printStackTrace();
}
}
- public void deleteMarkers(IResource file) {
+ public void deleteProblems(IResource file) {
try {
- file.deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, false,
+ file.deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, true,
IResource.DEPTH_ZERO);
} catch (CoreException ce) {
ce.printStackTrace();
}
}
- public void deleteAllMarkers() {
+ public void deleteAllProblems() {
try {
- // TODO delete contributed markers too
- ResourcesPlugin.getWorkspace().getRoot().deleteMarkers(
- GENERIC_CODE_ANALYSIS_MARKER_TYPE, false,
- IResource.DEPTH_INFINITE);
+ ResourcesPlugin
+ .getWorkspace()
+ .getRoot()
+ .deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, true,
+ IResource.DEPTH_INFINITE);
} catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ CodanCorePlugin.log(e);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.cdt.codan.core.model.IProblemReporterPersistent#deleteProblems
+ * (org.eclipse.core.resources.IResource,
+ * org.eclipse.cdt.codan.core.model.IChecker)
+ */
+ public void deleteProblems(final IResource file, final IChecker checker) {
+ try {
+ ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ IMarker[] markers = file.findMarkers(
+ GENERIC_CODE_ANALYSIS_MARKER_TYPE, true,
+ IResource.DEPTH_INFINITE);
+ ICheckersRegistry reg = CodanRuntime.getInstance()
+ .getChechersRegistry();
+ for (int i = 0; i < markers.length; i++) {
+ IMarker m = markers[i];
+ String id = m.getAttribute(IMarker.PROBLEM, ""); //$NON-NLS-1$
+ Collection problems = reg.getRefProblems(checker);
+ for (Iterator iterator = problems.iterator(); iterator
+ .hasNext();) {
+ IProblem iProblem = iterator.next();
+ if (iProblem.getId().equals(id))
+ m.delete();
+ }
+ }
+ }
+ }, null, IWorkspace.AVOID_UPDATE, null);
+ } catch (CoreException e) {
+ CodanCorePlugin.log(e);
}
}
}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblem.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblem.java
index a094cc1..56b43c5 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblem.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -10,20 +10,21 @@
*******************************************************************************/
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;
+import org.eclipse.cdt.codan.core.model.IProblemReporter;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
+import org.eclipse.cdt.codan.core.param.IProblemPreference;
-public class CodanProblem implements IProblem {
+public class CodanProblem implements IProblemWorkingCopy {
private String id;
private String name;
private String message;
private CodanSeverity severity = CodanSeverity.Warning;
private boolean enabled = true;
- private HashMap properties = new HashMap(0);
+ private IProblemPreference preference;
+ private boolean frozen;
+ private String description;
+ private String markerType = IProblemReporter.GENERIC_CODE_ANALYSIS_MARKER_TYPE;
public CodanSeverity getSeverity() {
return severity;
@@ -32,6 +33,7 @@ public class CodanProblem implements IProblem {
public CodanProblem(String problemId, String name) {
this.id = problemId;
this.name = name;
+ this.frozen = false;
}
public String getName() {
@@ -42,11 +44,6 @@ public class CodanProblem implements IProblem {
return id;
}
- public IProblemCategory getCategory() {
- // TODO Auto-generated method stub
- return null;
- }
-
@Override
public String toString() {
return name;
@@ -73,19 +70,19 @@ public class CodanProblem implements IProblem {
*/
@Override
public Object clone() throws CloneNotSupportedException {
- return super.clone();
+ CodanProblem prob = (CodanProblem) super.clone();
+ if (preference != null) {
+ prob.preference = (IProblemPreference) preference.clone();
+ }
+ return prob;
}
- public void setProperty(Object key, Object value) {
- properties.put(key, value);
+ public void setPreference(IProblemPreference value) {
+ preference = value;
}
- public Object getProperty(Object key) {
- return properties.get(key);
- };
-
- public Collection getPropertyKeys() {
- return properties.keySet();
+ public IProblemPreference getPreference() {
+ return preference;
}
/*
@@ -97,10 +94,54 @@ public class CodanProblem implements IProblem {
return message;
}
+ protected void freeze() {
+ frozen = true;
+ }
+
/**
- * @param message the message to set
+ * @param message
+ * the message to set
*/
public void setMessagePattern(String message) {
+ checkSet();
this.message = message;
}
+
+ protected void checkSet() {
+ if (frozen)
+ throw new IllegalStateException("Object is unmodifieble"); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.IProblem#getDescription()
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.cdt.codan.core.model.IProblemWorkingCopy#setDescription(java
+ * .lang.String)
+ */
+ public void setDescription(String desc) {
+ this.description = desc;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.core.model.IProblem#getMarkerType()
+ */
+ public String getMarkerType() {
+ return markerType;
+ }
+
+ public void setMarkerType(String type) {
+ markerType = type;
+ }
}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemCategory.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemCategory.java
index fc63480..0156211 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemCategory.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemCategory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -41,40 +41,36 @@ public class CodanProblemCategory implements IProblemCategory, Cloneable {
}
public IProblemElement[] getChildren() {
- return (IProblemElement[]) list.toArray(new IProblemElement[list.size()]);
+ return list.toArray(new IProblemElement[list.size()]);
}
public void addChild(IProblemElement p) {
list.add(p);
}
- public IProblem findProblem(String id) {
- Object[] children = this.getChildren();
+ public static IProblem findProblem(IProblemCategory c, String id) {
+ Object[] children = c.getChildren();
for (Object object : children) {
if (object instanceof IProblemCategory) {
IProblemCategory cat = (IProblemCategory) object;
- IProblem found = cat.findProblem(id);
- if (found != null)
- return found;
+ IProblem found = findProblem(cat, id);
+ if (found != null) return found;
} else if (object instanceof IProblem) {
IProblem p = (IProblem) object;
- if (p.getId().equals(id))
- return p;
+ if (p.getId().equals(id)) return p;
}
}
return null;
}
- public IProblemCategory findCategory(String id) {
- if (getId().equals(id))
- return this;
- Object[] children = getChildren();
+ public static IProblemCategory findCategory(IProblemCategory cat, String id) {
+ if (cat.getId().equals(id)) return cat;
+ Object[] children = cat.getChildren();
for (Object object : children) {
if (object instanceof IProblemCategory) {
- IProblemCategory cat = (IProblemCategory) object;
- IProblemCategory found = cat.findCategory(id);
- if (found != null)
- return found;
+ IProblemCategory cat2 = (IProblemCategory) object;
+ IProblemCategory found = findCategory(cat2, id);
+ if (found != null) return found;
}
}
return null;
@@ -90,8 +86,7 @@ public class CodanProblemCategory implements IProblemCategory, Cloneable {
try {
CodanProblemCategory clone = (CodanProblemCategory) super.clone();
clone.list = new ArrayList();
- for (Iterator iterator = this.list.iterator(); iterator
- .hasNext();) {
+ for (Iterator iterator = this.list.iterator(); iterator.hasNext();) {
IProblemElement child = iterator.next();
clone.list.add((IProblemElement) child.clone());
}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemLocation.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemLocation.java
new file mode 100644
index 0000000..ca6bd02
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemLocation.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.core.model;
+
+import org.eclipse.cdt.codan.core.model.AbstractProblemLocation;
+import org.eclipse.core.resources.IFile;
+
+/**
+ * Codan Problem Location, so far same as abstract class
+ *
+ */
+public class CodanProblemLocation extends AbstractProblemLocation {
+ public CodanProblemLocation(IFile file, int startChar, int endChar) {
+ super(file, startChar, endChar);
+ }
+
+ public CodanProblemLocation(IFile file, int startChar, int endChar, int line) {
+ super(file, startChar, endChar);
+ this.line = line;
+ }
+
+ protected CodanProblemLocation(IFile file, int line) {
+ super(file, line);
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemLocationFactory.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemLocationFactory.java
new file mode 100644
index 0000000..835f6bf
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemLocationFactory.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.core.model;
+
+import org.eclipse.cdt.codan.core.model.IProblemLocation;
+import org.eclipse.cdt.codan.core.model.IProblemLocationFactory;
+import org.eclipse.core.resources.IFile;
+
+/**
+ * Factory class that allows to create problem locations
+ *
+ */
+public class ProblemLocationFactory implements IProblemLocationFactory {
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.cdt.codan.core.model.IProblemLocationFactory#
+ * createProblemLocation(org.eclipse.core.resources.IFile, int)
+ */
+ public IProblemLocation createProblemLocation(IFile file, int line) {
+ return new CodanProblemLocation(file, line);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.cdt.codan.core.model.IProblemLocationFactory#
+ * createProblemLocation(org.eclipse.core.resources.IFile, int, int)
+ */
+ public IProblemLocation createProblemLocation(IFile file, int startChar,
+ int endChar) {
+ return new CodanProblemLocation(file, startChar, endChar);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.cdt.codan.core.model.IProblemLocationFactory#
+ * createProblemLocation(org.eclipse.core.resources.IFile, int, int, int)
+ */
+ public IProblemLocation createProblemLocation(IFile file, int startChar,
+ int endChar, int line) {
+ return new CodanProblemLocation(file, startChar, endChar, line);
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemProfile.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemProfile.java
index d2330f1..1eb045b 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemProfile.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemProfile.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -22,8 +22,7 @@ import org.eclipse.cdt.codan.core.model.IProblemProfile;
*
*/
public class ProblemProfile implements IProblemProfile, Cloneable {
- private IProblemCategory rootCategory = new CodanProblemCategory("root",
- "root");
+ private IProblemCategory rootCategory = new CodanProblemCategory("root", "root"); //$NON-NLS-1$ //$NON-NLS-2$
/*
* (non-Javadoc)
@@ -33,7 +32,7 @@ public class ProblemProfile implements IProblemProfile, Cloneable {
* .String)
*/
public IProblem findProblem(String id) {
- return getRoot().findProblem(id);
+ return CodanProblemCategory.findProblem(getRoot(), id);
}
/*
@@ -51,8 +50,7 @@ public class ProblemProfile implements IProblemProfile, Cloneable {
* @param root
* @param problems
*/
- protected void collectProblems(IProblemCategory parent,
- Collection problems) {
+ protected void collectProblems(IProblemCategory parent, Collection problems) {
Object[] children = parent.getChildren();
for (Object object : children) {
if (object instanceof IProblemCategory) {
@@ -69,13 +67,12 @@ public class ProblemProfile implements IProblemProfile, Cloneable {
}
public void addProblem(IProblem p, IProblemCategory cat) {
- if (cat == null)
- cat = getRoot();
+ if (cat == null) cat = getRoot();
((CodanProblemCategory) cat).addChild(p);
}
public IProblemCategory findCategory(String id) {
- return getRoot().findCategory(id);
+ return CodanProblemCategory.findCategory(getRoot(), id);
}
/*
@@ -87,8 +84,7 @@ public class ProblemProfile implements IProblemProfile, Cloneable {
public Object clone() {
try {
ProblemProfile clone = (ProblemProfile) super.clone();
- clone.rootCategory = (IProblemCategory) ((CodanProblemCategory) this.rootCategory)
- .clone();
+ clone.rootCategory = (IProblemCategory) ((CodanProblemCategory) this.rootCategory).clone();
return clone;
} catch (CloneNotSupportedException e) {
return this;
diff --git a/org.eclipse.cdt.codan.extension/META-INF/MANIFEST.MF b/org.eclipse.cdt.codan.extension/META-INF/MANIFEST.MF
index fde603b..4304067 100644
--- a/org.eclipse.cdt.codan.extension/META-INF/MANIFEST.MF
+++ b/org.eclipse.cdt.codan.extension/META-INF/MANIFEST.MF
@@ -6,6 +6,7 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: Eclipse
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.eclipse.cdt.codan.core,
+ org.eclipse.cdt.codan.core.cxx.model,
org.eclipse.cdt.codan.core.model,
org.eclipse.cdt.core.dom,
org.eclipse.cdt.core.dom.ast,
@@ -15,3 +16,5 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.5.0",
org.eclipse.ui;bundle-version="3.5.0",
org.eclipse.core.resources;bundle-version="3.5.0"
Bundle-Activator: org.eclipse.cdt.codan.extension.Activator
+Export-Package: org.eclipse.cdt.codan.extension,
+ org.eclipse.cdt.codan.extension.checkers
diff --git a/org.eclipse.cdt.codan.extension/src/org/eclipse/cdt/codan/extension/checkers/AbstractPropSimChecker.java b/org.eclipse.cdt.codan.extension/src/org/eclipse/cdt/codan/extension/checkers/AbstractPropSimChecker.java
index de8d818..d066392 100644
--- a/org.eclipse.cdt.codan.extension/src/org/eclipse/cdt/codan/extension/checkers/AbstractPropSimChecker.java
+++ b/org.eclipse.cdt.codan.extension/src/org/eclipse/cdt/codan/extension/checkers/AbstractPropSimChecker.java
@@ -13,7 +13,7 @@ package org.eclipse.cdt.codan.extension.checkers;
import java.io.File;
import java.net.URI;
-import org.eclipse.cdt.codan.core.model.AbstractIndexAstChecker;
+import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
import org.eclipse.cdt.codan.extension.ExecutionState;
import org.eclipse.cdt.codan.extension.IPropertyFSM;
import org.eclipse.cdt.codan.extension.PropertySimulator;
diff --git a/org.eclipse.cdt.codan.ui/.project b/org.eclipse.cdt.codan.ui/.project
index 1a97756..f51fbc8 100644
--- a/org.eclipse.cdt.codan.ui/.project
+++ b/org.eclipse.cdt.codan.ui/.project
@@ -20,9 +20,15 @@
+
+ org.eclipse.pde.api.tools.apiAnalysisBuilder
+
+
+ org.eclipse.pde.PluginNatureorg.eclipse.jdt.core.javanature
+ org.eclipse.pde.api.tools.apiAnalysisNature
diff --git a/org.eclipse.cdt.codan.ui/.settings/.api_filters b/org.eclipse.cdt.codan.ui/.settings/.api_filters
new file mode 100644
index 0000000..2d910f4
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/.settings/.api_filters
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/org.eclipse.cdt.codan.ui/.settings/CVS/Entries b/org.eclipse.cdt.codan.ui/.settings/CVS/Entries
index e7a8ed5..f5857d6 100644
--- a/org.eclipse.cdt.codan.ui/.settings/CVS/Entries
+++ b/org.eclipse.cdt.codan.ui/.settings/CVS/Entries
@@ -1 +1,3 @@
-/org.eclipse.jdt.core.prefs/1.1/Thu Apr 9 12:47:54 2009//
+/.api_filters/1.1/Mon Mar 8 19:51:30 2010//TCDT_7_0_0
+/org.eclipse.jdt.core.prefs/1.2/Wed Mar 24 03:31:59 2010//TCDT_7_0_0
+/org.eclipse.jdt.ui.prefs/1.1/Sun May 16 02:17:54 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/.settings/CVS/Tag b/org.eclipse.cdt.codan.ui/.settings/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/.settings/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.cdt.codan.ui/.settings/org.eclipse.jdt.core.prefs
index 57703d3..f7e128a 100644
--- a/org.eclipse.cdt.codan.ui/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.cdt.codan.ui/.settings/org.eclipse.jdt.core.prefs
@@ -1,8 +1,71 @@
-#Fri Apr 03 21:34:42 EDT 2009
+#Thu Mar 18 10:02:29 EDT 2010
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=enabled
+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=warning
+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=warning
+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.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=ignore
+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=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+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.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/org.eclipse.cdt.codan.ui/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.cdt.codan.ui/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..62d3d7e
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,55 @@
+#Sat May 15 20:01:30 EDT 2010
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=false
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=false
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=true
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/org.eclipse.cdt.codan.ui/CVS/Entries b/org.eclipse.cdt.codan.ui/CVS/Entries
index f361049..af40da4 100644
--- a/org.eclipse.cdt.codan.ui/CVS/Entries
+++ b/org.eclipse.cdt.codan.ui/CVS/Entries
@@ -1,7 +1,11 @@
-/.classpath/1.1/Thu Apr 9 12:47:54 2009//
-/.project/1.1/Thu Apr 9 12:47:54 2009//
+/.classpath/1.1/Thu Apr 9 12:47:54 2009//TCDT_7_0_0
+/.project/1.2/Wed Mar 24 03:31:59 2010//TCDT_7_0_0
D/.settings////
D/META-INF////
-/build.properties/1.1/Thu Apr 9 12:47:54 2009//
-/plugin.xml/1.2/Fri Apr 24 12:49:45 2009//
+D/OSGI-INF////
+/about.html/1.1/Mon Jun 14 18:35:43 2010//TCDT_7_0_0
+/build.properties/1.7/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
+D/icons////
+/plugin.xml/1.14/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
+D/schema////
D/src////
diff --git a/org.eclipse.cdt.codan.ui/CVS/Tag b/org.eclipse.cdt.codan.ui/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/META-INF/CVS/Entries b/org.eclipse.cdt.codan.ui/META-INF/CVS/Entries
index a9833bb..0f1fcea 100644
--- a/org.eclipse.cdt.codan.ui/META-INF/CVS/Entries
+++ b/org.eclipse.cdt.codan.ui/META-INF/CVS/Entries
@@ -1 +1 @@
-/MANIFEST.MF/1.2/Fri Apr 24 12:49:44 2009//
+/MANIFEST.MF/1.12/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/META-INF/CVS/Tag b/org.eclipse.cdt.codan.ui/META-INF/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/META-INF/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF b/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF
index 9d5357d..7192ca6 100644
--- a/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF
@@ -1,18 +1,28 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: Code Analyzers Framework
+Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.cdt.codan.ui; singleton:=true
-Bundle-Version: 1.0.0
-Bundle-Activator: org.eclipse.cdt.codan.ui.Activator
-Bundle-Vendor: Eclipse
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.cdt.codan.internal.ui.CodanUIActivator
+Bundle-Vendor: %Bundle-Vendor
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources,
- org.eclipse.cdt.core;bundle-version="5.1.0",
- org.eclipse.cdt.codan.core;bundle-version="1.0.0",
- org.eclipse.cdt.ui;bundle-version="5.1.0",
- org.eclipse.ui.workbench.texteditor;bundle-version="3.5.0",
- org.eclipse.ui.editors;bundle-version="3.5.0"
+ org.eclipse.ui.workbench.texteditor,
+ org.eclipse.ui.editors,
+ org.eclipse.cdt.codan.core,
+ org.eclipse.jface.text,
+ org.eclipse.ui.ide,
+ org.eclipse.cdt.ui,
+ org.eclipse.cdt.core
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.cdt.codan.internal.ui;x-friends:="org.eclipse.cdt.codan.ui.cxx",
+ org.eclipse.cdt.codan.internal.ui.actions;x-friends:="org.eclipse.cdt.codan.ui.cxx",
+ org.eclipse.cdt.codan.internal.ui.dialogs;x-friends:="org.eclipse.cdt.codan.ui.cxx",
+ org.eclipse.cdt.codan.internal.ui.preferences;x-friends:="org.eclipse.cdt.codan.ui.cxx",
+ org.eclipse.cdt.codan.internal.ui.views;x-internal:=true,
+ org.eclipse.cdt.codan.internal.ui.widgets;x-internal:=true,
+ org.eclipse.cdt.codan.ui,
+ org.eclipse.cdt.codan.ui.handlers
diff --git a/org.eclipse.cdt.codan.ui/OSGI-INF/CVS/Entries b/org.eclipse.cdt.codan.ui/OSGI-INF/CVS/Entries
new file mode 100644
index 0000000..2928641
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/OSGI-INF/CVS/Entries
@@ -0,0 +1 @@
+D/l10n////
diff --git a/org.eclipse.cdt.codan.ui/OSGI-INF/CVS/Repository b/org.eclipse.cdt.codan.ui/OSGI-INF/CVS/Repository
new file mode 100644
index 0000000..4afee4d
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/OSGI-INF/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/OSGI-INF
diff --git a/org.eclipse.cdt.codan.ui/OSGI-INF/CVS/Root b/org.eclipse.cdt.codan.ui/OSGI-INF/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/OSGI-INF/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.ui/OSGI-INF/CVS/Tag b/org.eclipse.cdt.codan.ui/OSGI-INF/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/OSGI-INF/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/OSGI-INF/CVS/Template b/org.eclipse.cdt.codan.ui/OSGI-INF/CVS/Template
new file mode 100644
index 0000000..e69de29
diff --git a/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/CVS/Entries b/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/CVS/Entries
new file mode 100644
index 0000000..81f8f25
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/CVS/Entries
@@ -0,0 +1 @@
+/bundle.properties/1.7/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/CVS/Repository b/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/CVS/Repository
new file mode 100644
index 0000000..31447ef
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/OSGI-INF/l10n
diff --git a/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/CVS/Root b/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/CVS/Tag b/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/CVS/Template b/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/CVS/Template
new file mode 100644
index 0000000..e69de29
diff --git a/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/bundle.properties b/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 0000000..4b8f443
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,22 @@
+###############################################################################
+# 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
+###############################################################################
+#Properties file for org.eclipse.cdt.codan.ui
+Bundle-Vendor = Eclipse CDT
+Bundle-Name = Code Analysis UI
+CodeAnalysisAction.label = Run Code Analysis
+CodeAnalysisProperties.name = Code Analysis
+CodeAnalysisPreferences.name = Code Analysis
+CodeAnalysisPreferencesBuild.name = Launching
+category.name = Code Analysis
+command.name = Run Code Analysis
+view.name = Problem Details
+extension-point.name = Codan Problem Details
+extension-point.name.codamMarkerResolution = Codan Marker Resolution
\ No newline at end of file
diff --git a/org.eclipse.cdt.codan.ui/about.html b/org.eclipse.cdt.codan.ui/about.html
new file mode 100644
index 0000000..d7c5118
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/about.html
@@ -0,0 +1,24 @@
+
+
+About
+
+
+
About This Content
+
+
June 22, 2007
+
License
+
+
The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at http://www.eclipse.org/legal/epl-v10.html.
+For purposes of the EPL, "Program" will mean the Content.
+
+
If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at http://www.eclipse.org.
+
+
\ No newline at end of file
diff --git a/org.eclipse.cdt.codan.ui/build.properties b/org.eclipse.cdt.codan.ui/build.properties
index 2b0d95b..07b5ba9 100644
--- a/org.eclipse.cdt.codan.ui/build.properties
+++ b/org.eclipse.cdt.codan.ui/build.properties
@@ -1,5 +1,19 @@
+###############################################################################
+# Copyright (c) 2009, 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
+###############################################################################
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
- .
+ .,\
+ OSGI-INF/l10n/bundle.properties,\
+ schema/,\
+ icons/,\
+ about.html
diff --git a/org.eclipse.cdt.codan.ui/icons/CVS/Entries b/org.eclipse.cdt.codan.ui/icons/CVS/Entries
new file mode 100644
index 0000000..4b4fbf7
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/icons/CVS/Entries
@@ -0,0 +1 @@
+/problemDetails.gif/1.2/Thu Apr 29 01:49:24 2010/-kb/TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/icons/CVS/Repository b/org.eclipse.cdt.codan.ui/icons/CVS/Repository
new file mode 100644
index 0000000..0176656
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/icons/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/icons
diff --git a/org.eclipse.cdt.codan.ui/icons/CVS/Root b/org.eclipse.cdt.codan.ui/icons/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/icons/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.ui/icons/CVS/Tag b/org.eclipse.cdt.codan.ui/icons/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/icons/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/icons/problemDetails.gif b/org.eclipse.cdt.codan.ui/icons/problemDetails.gif
new file mode 100644
index 0000000..22f1318
Binary files /dev/null and b/org.eclipse.cdt.codan.ui/icons/problemDetails.gif differ
diff --git a/org.eclipse.cdt.codan.ui/plugin.xml b/org.eclipse.cdt.codan.ui/plugin.xml
index eff5ea6..c1284b7 100644
--- a/org.eclipse.cdt.codan.ui/plugin.xml
+++ b/org.eclipse.cdt.codan.ui/plugin.xml
@@ -3,54 +3,45 @@
-
-
-
-
-
+
+
+
+
-
+ name="%CodeAnalysisProperties.name">
+ id="org.eclipse.cdt.codan.ui.properties.codanProblemsPropertyPage"
+ name="%CodeAnalysisPreferences.name">
-
-
+
+
+
+ name="%CodeAnalysisPreferencesBuild.name">
-
-
+
+
+
@@ -62,9 +53,61 @@
class="org.eclipse.cdt.codan.internal.ui.preferences.PreferenceInitializer">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ point="org.eclipse.ui.ide.markerResolution">
+
+
diff --git a/org.eclipse.cdt.codan.ui/schema/CVS/Entries b/org.eclipse.cdt.codan.ui/schema/CVS/Entries
new file mode 100644
index 0000000..2d2de75
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/schema/CVS/Entries
@@ -0,0 +1,2 @@
+/codanMarkerResolution.exsd/1.1/Sun May 2 01:47:10 2010//TCDT_7_0_0
+/codanProblemDetails.exsd/1.2/Thu Apr 29 16:34:18 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/schema/CVS/Repository b/org.eclipse.cdt.codan.ui/schema/CVS/Repository
new file mode 100644
index 0000000..aae173a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/schema/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/schema
diff --git a/org.eclipse.cdt.codan.ui/schema/CVS/Root b/org.eclipse.cdt.codan.ui/schema/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/schema/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.ui/schema/CVS/Tag b/org.eclipse.cdt.codan.ui/schema/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/schema/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/schema/codanMarkerResolution.exsd b/org.eclipse.cdt.codan.ui/schema/codanMarkerResolution.exsd
new file mode 100644
index 0000000..4cdbf23
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/schema/codanMarkerResolution.exsd
@@ -0,0 +1,132 @@
+
+
+
+
+
+
+
+
+ Extension point to plugin quick fix for codan markers
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Contribute codan marker resolution
+
+
+
+
+
+
+ Class that implement IMarkerResolution that provides a fix for the given problem
+
+
+
+
+
+
+
+
+
+ Problem id of the problem for which quick fix is defined
+
+
+
+
+
+
+
+
+
+ If problem id is not enought to identity the fix messagePattern can be used to apply fix for given message
+
+
+
+
+
+
+
+
+
+
+
+ since 1.0
+
+
+
+
+
+
+
+
+ <extension
+ point="org.eclipse.cdt.codan.checkers.ui.codanMarkerResolution">
+ <resolution
+ class="org.eclipse.cdt.codan.internal.checkers.ui.quickfix.CatchByReferenceQuickFix"
+ problemId="org.eclipse.cdt.codan.internal.checkers.CatchByReference">
+ </resolution>
+ </extension>
+
+
+
+
+
+
+
+
+ Programmatically resolution can be added using CatchByReferenceQuickFix.addResolution method.
+It is not API yet.
+
+
+
+
+
+
+
+
+ see CatchByReferenceQuickFix
+
+
+
+
+
diff --git a/org.eclipse.cdt.codan.ui/schema/codanProblemDetails.exsd b/org.eclipse.cdt.codan.ui/schema/codanProblemDetails.exsd
new file mode 100644
index 0000000..87f6b94
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/schema/codanProblemDetails.exsd
@@ -0,0 +1,127 @@
+
+
+
+
+
+
+
+
+ This extension point provides a mechanism to add extra details for a problem, which would
+be displayed in Problem Details view. It can include extra locations, associated problems,
+help link or extenal link.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ root element for extension.
+
+
+
+
+
+
+ Problem id for which extra details available.
+If ommitted provider would be called for all problem kinds.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+ <extension
+ point="org.eclipse.cdt.codan.ui.codanProblemDetails">
+ <problemDetails
+ class="org.eclipse.cdt.codan.examples.uicontrib.FlexlintHelpLink"
+ >
+ </problemDetails>
+ </extension>
+
+
+
+
+
+
+
+
+ [Enter API information here.]
+
+
+
+
+
+
+
+
+ See
+org.eclipse.cdt.codan.examples.uicontrib.FlexlintHelpLink
+
+
+
+
+
diff --git a/org.eclipse.cdt.codan.ui/src/CVS/Tag b/org.eclipse.cdt.codan.ui/src/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/CVS/Tag b/org.eclipse.cdt.codan.ui/src/org/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/CVS/Tag b/org.eclipse.cdt.codan.ui/src/org/eclipse/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/CVS/Tag b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/CVS/Tag b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/CVS/Tag b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/CVS/Tag
new file mode 100644
index 0000000..3cd1ca4
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/CVS/Tag
@@ -0,0 +1 @@
+TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CVS/Entries b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CVS/Entries
index f769284..089fc52 100644
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CVS/Entries
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CVS/Entries
@@ -1 +1,9 @@
+/CodanProblemMarkerResolutionGenerator.java/1.3/Thu Jun 3 17:01:39 2010//TCDT_7_0_0
+/CodanUIActivator.java/1.4/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
+/CodanUIMessages.java/1.5/Mon May 24 15:05:36 2010//TCDT_7_0_0
+D/actions////
+D/dialogs////
+/messages.properties/1.8/Thu Jun 3 17:01:39 2010//TCDT_7_0_0
D/preferences////
+D/views////
+D/widgets////
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CVS/Tag b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanProblemMarkerResolutionGenerator.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanProblemMarkerResolutionGenerator.java
new file mode 100644
index 0000000..690f87b
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanProblemMarkerResolutionGenerator.java
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Andrew Gvozdev
+ * 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:
+ * Andrew Gvozdev - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.codan.internal.ui;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import org.eclipse.cdt.codan.ui.AbstarctCodanCMarkerResolution;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.ui.IMarkerResolution;
+import org.eclipse.ui.IMarkerResolutionGenerator;
+
+public class CodanProblemMarkerResolutionGenerator implements
+ IMarkerResolutionGenerator {
+ private static final String EXTENSION_POINT_NAME = "codanMarkerResolution"; //$NON-NLS-1$
+ private static Map> resolutions = new HashMap>();
+ private static boolean resolutionsLoaded = false;
+
+ static class ConditionalResolution {
+ IMarkerResolution res;
+ String messagePattern;
+
+ public ConditionalResolution(IMarkerResolution res2,
+ String messagePattern2) {
+ res = res2;
+ messagePattern = messagePattern2;
+ }
+ }
+
+ public IMarkerResolution[] getResolutions(IMarker marker) {
+ if (resolutionsLoaded == false) {
+ readExtensions();
+ }
+ String id = marker.getAttribute(IMarker.PROBLEM, null);
+ if (id == null)
+ return new IMarkerResolution[0];
+ String message = marker.getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$
+ Collection collection = resolutions.get(id);
+ if (collection != null) {
+ ArrayList list = new ArrayList();
+ for (Iterator iterator = collection
+ .iterator(); iterator.hasNext();) {
+ ConditionalResolution res = iterator.next();
+ if (res.messagePattern != null) {
+ if (!message.matches(res.messagePattern))
+ continue;
+ }
+ if (res.res instanceof AbstarctCodanCMarkerResolution) {
+ if (!((AbstarctCodanCMarkerResolution)res.res).isApplicable(marker))
+ continue;
+ }
+ list.add(res.res);
+ }
+ if (list.size() > 0)
+ return list.toArray(new IMarkerResolution[list.size()]);
+ }
+ return new IMarkerResolution[0];
+ }
+
+ private static synchronized void readExtensions() {
+ IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(
+ CodanUIActivator.PLUGIN_ID, EXTENSION_POINT_NAME);
+ if (ep == null)
+ return;
+ try {
+ IConfigurationElement[] elements = ep.getConfigurationElements();
+ // process categories
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement configurationElement = elements[i];
+ processResolution(configurationElement);
+ }
+ } finally {
+ resolutionsLoaded = true;
+ }
+ }
+
+ /**
+ * @param configurationElement
+ */
+ private static void processResolution(
+ IConfigurationElement configurationElement) {
+ if (configurationElement.getName().equals("resolution")) { //$NON-NLS-1$
+ String id = configurationElement.getAttribute("problemId"); //$NON-NLS-1$
+ if (id == null) {
+ CodanUIActivator.log("Extension for " + EXTENSION_POINT_NAME //$NON-NLS-1$
+ + " problemId is not defined"); //$NON-NLS-1$
+ return;
+ }
+ IMarkerResolution res;
+ try {
+ res = (IMarkerResolution) configurationElement
+ .createExecutableExtension("class");//$NON-NLS-1$
+ } catch (CoreException e) {
+ CodanUIActivator.log(e);
+ return;
+ }
+ String messagePattern = configurationElement
+ .getAttribute("messagePattern"); //$NON-NLS-1$
+ if (messagePattern != null) {
+ try {
+ Pattern.compile(messagePattern);
+ } catch (Exception e) {
+ // bad pattern log and ignore
+ CodanUIActivator.log("Extension for " //$NON-NLS-1$
+ + EXTENSION_POINT_NAME
+ + " messagePattern is invalid: " + e.getMessage()); //$NON-NLS-1$
+ return;
+ }
+ }
+ ConditionalResolution co = new ConditionalResolution(res,
+ messagePattern);
+ addResolution(id, co);
+ }
+ }
+
+ public static void addResolution(String id, IMarkerResolution res,
+ String messagePattern) {
+ addResolution(id, new ConditionalResolution(res, messagePattern));
+ }
+
+ private static void addResolution(String id, ConditionalResolution res) {
+ Collection collection = resolutions.get(id);
+ if (collection == null) {
+ collection = new ArrayList();
+ resolutions.put(id, collection);
+ }
+ collection.add(res);
+ }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIActivator.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIActivator.java
new file mode 100644
index 0000000..e530269
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIActivator.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.internal.ui;
+
+import org.eclipse.cdt.codan.core.CodanCorePlugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class CodanUIActivator extends AbstractUIPlugin {
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.cdt.codan.ui"; //$NON-NLS-1$
+ // The shared instance
+ private static CodanUIActivator plugin;
+ private IPreferenceStore preferenceCoreStore;
+
+ /**
+ * The constructor
+ */
+ public CodanUIActivator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
+ * )
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
+ * )
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static CodanUIActivator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given plug-in
+ * relative path
+ *
+ * @param path
+ * the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
+ /**
+ * Logs the specified status with this plug-in's log.
+ *
+ * @param status
+ * status to log
+ */
+ public static void log(IStatus status) {
+ getDefault().getLog().log(status);
+ }
+
+ /**
+ * Logs an internal error with the specified throwable
+ *
+ * @param e
+ * the exception to be logged
+ */
+ public static void log(Throwable e) {
+ log(new Status(IStatus.ERROR, PLUGIN_ID, 1, "Internal Error", e)); //$NON-NLS-1$
+ }
+
+ /**
+ * Logs an internal error with the specified message.
+ *
+ * @param message
+ * the error message to log
+ */
+ public static void log(String message) {
+ log(new Status(IStatus.ERROR, PLUGIN_ID, 1, message, null));
+ }
+
+ /**
+ * @return
+ */
+ public IPreferenceStore getCorePreferenceStore() {
+ if (preferenceCoreStore == null) {
+ preferenceCoreStore = new ScopedPreferenceStore(
+ new InstanceScope(), CodanCorePlugin.PLUGIN_ID);
+ }
+ return preferenceCoreStore;
+ }
+
+ public IPreferenceStore getPreferenceStore(IProject project) {
+ ProjectScope ps = new ProjectScope(project);
+ ScopedPreferenceStore scoped = new ScopedPreferenceStore(ps, PLUGIN_ID);
+ scoped.setSearchContexts(new IScopeContext[] { ps, new InstanceScope() });
+ return scoped;
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.java
new file mode 100644
index 0000000..5b3134e
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2009,2010 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.internal.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Externalized messages
+ */
+public class CodanUIMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.codan.internal.ui.messages"; //$NON-NLS-1$
+ public static String BuildPropertyPage_RunAsYouType;
+ public static String BuildPropertyPage_RunWithBuild;
+ public static String CheckedTreeEditor_SelectionCannotBeEmpty;
+ public static String CodanPreferencePage_Customize;
+ public static String CodanPreferencePage_Description;
+ public static String CodanPreferencePage_HasPreferences;
+ public static String CodanPreferencePage_Info;
+ public static String CodanPreferencePage_MessageLabel;
+ public static String CodanPreferencePage_NoInfo;
+ public static String CodanPreferencePage_Parameters;
+ public static String ProblemsTreeEditor_NameColumn;
+ public static String ProblemsTreeEditor_Problems;
+ public static String ProblemsTreeEditor_SeverityColumn;
+ public static String OverlayPage_Use_Workspace_Settings;
+ public static String OverlayPage_Use_Project_Settings;
+ public static String OverlayPage_Configure_Workspace_Settings;
+ public static String PropertyStore_Cannot_write_resource_property;
+ public static String CustomizeProblemComposite_TabParameters;
+ public static String CustomizeProblemComposite_TabScope;
+ public static String CustomizeProblemDialog_Message;
+ public static String CustomizeProblemDialog_Title;
+ public static String Job_TitleRunningAnalysis;
+ public static String ParametersComposite_NewValue;
+ public static String ParametersComposite_None;
+ //
+ public static String ExclusionInclusionDialog_title;
+ public static String ExclusionInclusionDialog_description;
+ public static String ExclusionInclusionDialog_description2;
+ public static String ExclusionInclusionDialog_exclusion_pattern_label;
+ public static String ExclusionInclusionDialog_inclusion_pattern_label;
+ public static String ExclusionInclusionDialog_inclusion_pattern_add;
+ public static String ExclusionInclusionDialog_inclusion_pattern_add_multiple;
+ public static String ExclusionInclusionDialog_inclusion_pattern_remove;
+ public static String ExclusionInclusionDialog_inclusion_pattern_edit;
+ public static String ExclusionInclusionDialog_exclusion_pattern_add;
+ public static String ExclusionInclusionDialog_exclusion_pattern_add_multiple;
+ public static String ExclusionInclusionDialog_exclusion_pattern_remove;
+ public static String ExclusionInclusionDialog_exclusion_pattern_edit;
+ public static String ExclusionInclusionDialog_ChooseExclusionPattern_title;
+ public static String ExclusionInclusionDialog_ChooseExclusionPattern_description;
+ public static String ExclusionInclusionDialog_ChooseInclusionPattern_title;
+ public static String ExclusionInclusionDialog_ChooseInclusionPattern_description;
+ public static String ExclusionInclusionEntryDialog_exclude_add_title;
+ public static String ExclusionInclusionEntryDialog_exclude_edit_title;
+ public static String ExclusionInclusionEntryDialog_exclude_description;
+ public static String ExclusionInclusionEntryDialog_exclude_pattern_label;
+ public static String ExclusionInclusionEntryDialog_include_add_title;
+ public static String ExclusionInclusionEntryDialog_include_edit_title;
+ public static String ExclusionInclusionEntryDialog_include_description;
+ public static String ExclusionInclusionEntryDialog_include_pattern_label;
+ public static String ExclusionInclusionEntryDialog_pattern_button;
+ public static String ExclusionInclusionEntryDialog_error_empty;
+ public static String ExclusionInclusionEntryDialog_error_notrelative;
+ public static String ExclusionInclusionEntryDialog_error_exists;
+ public static String ExclusionInclusionEntryDialog_ChooseExclusionPattern_title;
+ public static String ExclusionInclusionEntryDialog_ChooseExclusionPattern_description;
+ public static String ExclusionInclusionEntryDialog_ChooseInclusionPattern_title;
+ public static String ExclusionInclusionEntryDialog_ChooseInclusionPattern_description;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, CodanUIMessages.class);
+ }
+
+ private CodanUIMessages() {
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/CVS/Entries b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/CVS/Entries
new file mode 100644
index 0000000..a8f550a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/CVS/Entries
@@ -0,0 +1,2 @@
+/RunCodeAnalysis.java/1.4/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
+/ToggleNatureAction.java/1.2/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/CVS/Repository b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/CVS/Repository
new file mode 100644
index 0000000..6f71b9e
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/CVS/Root b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/CVS/Tag b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/CVS/Template b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/CVS/Template
new file mode 100644
index 0000000..e69de29
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/RunCodeAnalysis.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/RunCodeAnalysis.java
new file mode 100644
index 0000000..3d1198b
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/RunCodeAnalysis.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.ui.actions;
+
+import java.util.Iterator;
+
+import org.eclipse.cdt.codan.core.CodanRuntime;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
+import org.eclipse.core.resources.IResource;
+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;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class RunCodeAnalysis implements IObjectActionDelegate {
+ private ISelection sel;
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ // nothing
+ }
+
+ public void run(IAction action) {
+ Job job = new Job(CodanUIMessages.Job_TitleRunningAnalysis) {
+ @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) {
+ this.sel = selection;
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/ToggleNatureAction.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/ToggleNatureAction.java
new file mode 100644
index 0000000..94c51f0
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/ToggleNatureAction.java
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * 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.internal.ui.actions;
+
+import java.util.Iterator;
+
+import org.eclipse.cdt.codan.core.CodanCorePlugin;
+import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class ToggleNatureAction implements IObjectActionDelegate {
+ private ISelection selection;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ if (selection instanceof IStructuredSelection) {
+ for (Iterator it = ((IStructuredSelection) selection).iterator(); it
+ .hasNext();) {
+ Object element = it.next();
+ IProject project = null;
+ if (element instanceof IProject) {
+ project = (IProject) element;
+ } else if (element instanceof IAdaptable) {
+ project = (IProject) ((IAdaptable) element)
+ .getAdapter(IProject.class);
+ }
+ if (project != null) {
+ toggleNature(project, !hasCodanNature(project));
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action
+ * .IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ this.selection = selection;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.
+ * action.IAction, org.eclipse.ui.IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
+
+ public boolean hasCodanNature(IProject project) {
+ IProjectDescription description;
+ try {
+ description = project.getDescription();
+ String[] natures = description.getNatureIds();
+ for (int i = 0; i < natures.length; ++i) {
+ if (CodanCorePlugin.NATURE_ID.equals(natures[i])) {
+ return true;
+ }
+ }
+ } catch (CoreException e) {
+ CodanUIActivator.log(e);
+ }
+ return false;
+ }
+
+ /**
+ * Toggles codan nature on a project
+ *
+ * @param project
+ * to have codan nature added or removed
+ */
+ public void toggleNature(IProject project, boolean add) {
+ try {
+ IProjectDescription description = project.getDescription();
+ String[] natures = description.getNatureIds();
+ for (int i = 0; i < natures.length; ++i) {
+ if (CodanCorePlugin.NATURE_ID.equals(natures[i])) {
+ if (add == false) {
+ // Remove the nature
+ String[] newNatures = new String[natures.length - 1];
+ System.arraycopy(natures, 0, newNatures, 0, i);
+ System.arraycopy(natures, i + 1, newNatures, i,
+ natures.length - i - 1);
+ description.setNatureIds(newNatures);
+ project.setDescription(description, null);
+ return;
+ }
+ // already there no need to add
+ add = false;
+ break;
+ }
+ }
+ if (add) {
+ // Add the nature
+ String[] newNatures = new String[natures.length + 1];
+ System.arraycopy(natures, 0, newNatures, 0, natures.length);
+ newNatures[natures.length] = CodanCorePlugin.NATURE_ID;
+ description.setNatureIds(newNatures);
+ project.setDescription(description, null);
+ }
+ } catch (CoreException e) {
+ CodanUIActivator.log(e);
+ }
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CVS/Entries b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CVS/Entries
new file mode 100644
index 0000000..87cd5d6
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CVS/Entries
@@ -0,0 +1,2 @@
+/CustomizeProblemDialog.java/1.5/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
+/ExclusionInclusionEntryDialog.java/1.2/Thu Jun 3 17:01:39 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CVS/Repository b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CVS/Repository
new file mode 100644
index 0000000..a829e01
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CVS/Root b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CVS/Tag b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CVS/Template b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CVS/Template
new file mode 100644
index 0000000..e69de29
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CustomizeProblemDialog.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CustomizeProblemDialog.java
new file mode 100644
index 0000000..8b35f1d
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CustomizeProblemDialog.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.ui.dialogs;
+
+import org.eclipse.cdt.codan.core.model.IProblem;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
+import org.eclipse.cdt.codan.internal.ui.widgets.CustomizeProblemComposite;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Dialog that allows to customise problems
+ *
+ */
+public class CustomizeProblemDialog extends TitleAreaDialog {
+ private CustomizeProblemComposite comp;
+ private IProblem problem;
+ private IResource resource;
+
+ /**
+ * @param parentShell
+ * @param selectedProblem
+ * @param iResource
+ */
+ public CustomizeProblemDialog(Shell parentShell, IProblem selectedProblem,
+ IResource resource) {
+ super(parentShell);
+ this.problem = selectedProblem;
+ this.resource = resource;
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ }
+
+ /**
+ * Stores edit values into problem working copy
+ *
+ * @param problem
+ * - problem working copy
+ */
+ public void save(IProblemWorkingCopy problem) {
+ comp.save(problem);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse
+ * .swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ getShell().setText(CodanUIMessages.CustomizeProblemDialog_Title);
+ setTitle(problem.getName());
+ setMessage(CodanUIMessages.CustomizeProblemDialog_Message);
+ Composite area = (Composite) super.createDialogArea(parent);
+ comp = new CustomizeProblemComposite(area, problem, resource);
+ GridData ld = new GridData(GridData.FILL_BOTH);
+ ld.minimumHeight = 300;
+ comp.setLayoutData(ld);
+ return area;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ save((IProblemWorkingCopy) problem);
+ super.okPressed();
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/ExclusionInclusionEntryDialog.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/ExclusionInclusionEntryDialog.java
new file mode 100644
index 0000000..5367e8b
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/ExclusionInclusionEntryDialog.java
@@ -0,0 +1,284 @@
+/*******************************************************************************
+ * 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.internal.ui.dialogs;
+
+import java.text.MessageFormat;
+import java.util.List;
+
+import org.eclipse.cdt.codan.core.param.FileScopeProblemPreference;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
+import org.eclipse.cdt.codan.internal.ui.widgets.BasicElementLabels;
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.dialogs.TypedElementSelectionValidator;
+import org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+public class ExclusionInclusionEntryDialog extends StatusDialog {
+ private StringButtonDialogField fExclusionPatternDialog;
+ private StatusInfo fExclusionPatternStatus;
+ private IContainer fCurrSourceFolder;
+ private String fExclusionPattern;
+ private List fExistingPatterns;
+ private boolean fIsExclusion;
+
+ public ExclusionInclusionEntryDialog(Shell parent, boolean isExclusion,
+ String patternToEdit, List existingPatterns,
+ FileScopeProblemPreference entryToEdit) {
+ super(parent);
+ fIsExclusion = isExclusion;
+ fExistingPatterns = existingPatterns;
+ String title, message;
+ if (isExclusion) {
+ if (patternToEdit == null) {
+ title = CodanUIMessages.ExclusionInclusionEntryDialog_exclude_add_title;
+ } else {
+ title = CodanUIMessages.ExclusionInclusionEntryDialog_exclude_edit_title;
+ }
+ message = MessageFormat
+ .format(CodanUIMessages.ExclusionInclusionEntryDialog_exclude_pattern_label,
+ BasicElementLabels.getPathLabel(
+ entryToEdit.getPath(), false));
+ } else {
+ if (patternToEdit == null) {
+ title = CodanUIMessages.ExclusionInclusionEntryDialog_include_add_title;
+ } else {
+ title = CodanUIMessages.ExclusionInclusionEntryDialog_include_edit_title;
+ }
+ message = MessageFormat
+ .format(CodanUIMessages.ExclusionInclusionEntryDialog_include_pattern_label,
+ BasicElementLabels.getPathLabel(
+ entryToEdit.getPath(), false));
+ }
+ setTitle(title);
+ if (patternToEdit != null) {
+ fExistingPatterns.remove(patternToEdit);
+ }
+ IProject currProject = entryToEdit.getProject();
+ IWorkspaceRoot root = currProject != null ? currProject.getWorkspace()
+ .getRoot() : ResourcesPlugin.getWorkspace().getRoot();
+ IResource res = root.findMember(entryToEdit.getPath());
+ if (res instanceof IContainer) {
+ fCurrSourceFolder = (IContainer) res;
+ }
+ fExclusionPatternStatus = new StatusInfo();
+ ExclusionPatternAdapter adapter = new ExclusionPatternAdapter();
+ fExclusionPatternDialog = new StringButtonDialogField(adapter);
+ fExclusionPatternDialog.setLabelText(message);
+ fExclusionPatternDialog
+ .setButtonLabel(CodanUIMessages.ExclusionInclusionEntryDialog_pattern_button);
+ fExclusionPatternDialog.setDialogFieldListener(adapter);
+ fExclusionPatternDialog.enableButton(fCurrSourceFolder != null);
+ if (patternToEdit == null) {
+ fExclusionPatternDialog.setText(""); //$NON-NLS-1$
+ } else {
+ fExclusionPatternDialog.setText(patternToEdit.toString());
+ }
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ int widthHint = convertWidthInCharsToPixels(60);
+ Composite inner = new Composite(composite, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 2;
+ inner.setLayout(layout);
+ Label description = new Label(inner, SWT.WRAP);
+ if (fIsExclusion) {
+ description
+ .setText(CodanUIMessages.ExclusionInclusionEntryDialog_exclude_description);
+ } else {
+ description
+ .setText(CodanUIMessages.ExclusionInclusionEntryDialog_include_description);
+ }
+ GridData gd = new GridData();
+ gd.horizontalSpan = 2;
+ gd.widthHint = convertWidthInCharsToPixels(80);
+ description.setLayoutData(gd);
+ fExclusionPatternDialog.doFillIntoGrid(inner, 3);
+ LayoutUtil.setWidthHint(fExclusionPatternDialog.getLabelControl(null),
+ widthHint);
+ LayoutUtil.setHorizontalSpan(
+ fExclusionPatternDialog.getLabelControl(null), 2);
+ LayoutUtil.setWidthHint(fExclusionPatternDialog.getTextControl(null),
+ widthHint);
+ LayoutUtil.setHorizontalGrabbing(fExclusionPatternDialog
+ .getTextControl(null));
+ fExclusionPatternDialog.postSetFocusOnDialogField(parent.getDisplay());
+ applyDialogFont(composite);
+ return composite;
+ }
+
+ // -------- ExclusionPatternAdapter --------
+ private class ExclusionPatternAdapter implements IDialogFieldListener,
+ IStringButtonAdapter {
+ // -------- IDialogFieldListener
+ public void dialogFieldChanged(DialogField field) {
+ doStatusLineUpdate();
+ }
+
+ public void changeControlPressed(DialogField field) {
+ doChangeControlPressed();
+ }
+ }
+
+ protected void doChangeControlPressed() {
+ IPath pattern = chooseExclusionPattern();
+ if (pattern != null) {
+ fExclusionPatternDialog.setText(pattern.toString());
+ }
+ }
+
+ protected void doStatusLineUpdate() {
+ checkIfPatternValid();
+ updateStatus(fExclusionPatternStatus);
+ }
+
+ protected void checkIfPatternValid() {
+ String pattern = fExclusionPatternDialog.getText().trim();
+ if (pattern.length() == 0) {
+ fExclusionPatternStatus
+ .setError(CodanUIMessages.ExclusionInclusionEntryDialog_error_empty);
+ return;
+ }
+ IPath path = new Path(pattern);
+ if (path.isAbsolute() || path.getDevice() != null) {
+ fExclusionPatternStatus
+ .setError(CodanUIMessages.ExclusionInclusionEntryDialog_error_notrelative);
+ return;
+ }
+ if (fExistingPatterns.contains(pattern)) {
+ fExclusionPatternStatus
+ .setError(CodanUIMessages.ExclusionInclusionEntryDialog_error_exists);
+ return;
+ }
+ fExclusionPattern = pattern;
+ fExclusionPatternStatus.setOK();
+ }
+
+ public String getExclusionPattern() {
+ return fExclusionPattern;
+ }
+
+ /*
+ * @see org.eclipse.jface.window.Window#configureShell(Shell)
+ */
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ }
+
+ // ---------- util method ------------
+ private IPath chooseExclusionPattern() {
+ String title, message;
+ if (fIsExclusion) {
+ title = CodanUIMessages.ExclusionInclusionEntryDialog_ChooseExclusionPattern_title;
+ message = CodanUIMessages.ExclusionInclusionEntryDialog_ChooseExclusionPattern_description;
+ } else {
+ title = CodanUIMessages.ExclusionInclusionEntryDialog_ChooseInclusionPattern_title;
+ message = CodanUIMessages.ExclusionInclusionEntryDialog_ChooseInclusionPattern_description;
+ }
+ IPath initialPath = new Path(fExclusionPatternDialog.getText());
+ IPath[] res = chooseExclusionPattern(getShell(), fCurrSourceFolder,
+ title, message, initialPath, false);
+ if (res == null) {
+ return null;
+ }
+ return res[0];
+ }
+
+ public static IPath[] chooseExclusionPattern(Shell shell,
+ IContainer currentSourceFolder, String title, String message,
+ IPath initialPath, boolean multiSelection) {
+ Class[] acceptedClasses = new Class[] { IFolder.class, IFile.class,
+ IProject.class };
+ ISelectionStatusValidator validator = new TypedElementSelectionValidator(
+ acceptedClasses, multiSelection);
+ ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
+ ILabelProvider lp = new WorkbenchLabelProvider();
+ ITreeContentProvider cp = new WorkbenchContentProvider();
+ IResource initialElement = null;
+ if (initialPath != null) {
+ IContainer curr = currentSourceFolder;
+ int nSegments = initialPath.segmentCount();
+ for (int i = 0; i < nSegments; i++) {
+ IResource elem = curr.findMember(initialPath.segment(i));
+ if (elem != null) {
+ initialElement = elem;
+ }
+ if (elem instanceof IContainer) {
+ curr = (IContainer) elem;
+ } else {
+ break;
+ }
+ }
+ }
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
+ shell, lp, cp);
+ dialog.setTitle(title);
+ dialog.setValidator(validator);
+ dialog.setMessage(message);
+ dialog.addFilter(filter);
+ dialog.setInput(currentSourceFolder);
+ dialog.setInitialSelection(initialElement);
+ dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
+ dialog.setHelpAvailable(false);
+ if (dialog.open() == Window.OK) {
+ Object[] objects = dialog.getResult();
+ int existingSegments = currentSourceFolder.getFullPath()
+ .segmentCount();
+ IPath[] resArr = new IPath[objects.length];
+ for (int i = 0; i < objects.length; i++) {
+ IResource currRes = (IResource) objects[i];
+ IPath path = currRes.getFullPath()
+ .removeFirstSegments(existingSegments).makeRelative();
+ if (currRes instanceof IContainer) {
+ path = path.addTrailingSeparator();
+ }
+ resArr[i] = path;
+ }
+ return resArr;
+ }
+ return null;
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/messages.properties b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/messages.properties
new file mode 100644
index 0000000..ff8fe4c
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/messages.properties
@@ -0,0 +1,85 @@
+###############################################################################
+# 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
+###############################################################################
+BuildPropertyPage_RunAsYouType=Run as you &type (selected checkers)
+BuildPropertyPage_RunWithBuild=&Run with build
+CheckedTreeEditor_SelectionCannotBeEmpty=Selection cannot be empty
+CodanPreferencePage_Customize=Customize...
+CodanPreferencePage_Description=Description:
+CodanPreferencePage_HasPreferences=This problem has extra preferences
+CodanPreferencePage_Info=Info
+CodanPreferencePage_MessageLabel=Message:
+CodanPreferencePage_NoInfo=Not defined
+CodanPreferencePage_Parameters=Parameters:
+CustomizeProblemComposite_TabParameters=Preferences
+CustomizeProblemComposite_TabScope=Scope
+CustomizeProblemDialog_Message=Edit problem preferences, scope and launch options
+CustomizeProblemDialog_Title=Customize Problem...
+Job_TitleRunningAnalysis=Running Code Analysis
+ParametersComposite_NewValue=New Value
+ParametersComposite_None=No extra preferences
+ProblemsTreeEditor_NameColumn=Name
+ProblemsTreeEditor_Problems=Problems
+ProblemsTreeEditor_SeverityColumn=Severity
+OverlayPage_Use_Workspace_Settings=Use &workspace settings
+OverlayPage_Use_Project_Settings=Use pr&oject settings
+OverlayPage_Configure_Workspace_Settings=&Configure Workspace Settings...
+PropertyStore_Cannot_write_resource_property=Cannot write resource property
+
+# ------- ExclusionInclusionDialog -------
+
+ExclusionInclusionDialog_title=Inclusion and Exclusion Patterns
+ExclusionInclusionDialog_description=Included and excluded resources for ''{0}''.
+ExclusionInclusionDialog_description2=Add or remove inclusion and exclusion patterns to resources for which problem is reported
+
+ExclusionInclusionDialog_exclusion_pattern_label=E&xclusion patterns:
+ExclusionInclusionDialog_inclusion_pattern_label=I&nclusion patterns:
+
+ExclusionInclusionDialog_inclusion_pattern_add=A&dd...
+ExclusionInclusionDialog_inclusion_pattern_add_multiple=Add &Multiple...
+ExclusionInclusionDialog_inclusion_pattern_remove=&Remove
+ExclusionInclusionDialog_inclusion_pattern_edit=&Edit...
+
+ExclusionInclusionDialog_exclusion_pattern_add=&Add...
+ExclusionInclusionDialog_exclusion_pattern_add_multiple=Add M&ultiple...
+ExclusionInclusionDialog_exclusion_pattern_remove=Rem&ove
+ExclusionInclusionDialog_exclusion_pattern_edit=Edi&t...
+
+ExclusionInclusionDialog_ChooseExclusionPattern_title=Exclusion Pattern Selection
+ExclusionInclusionDialog_ChooseExclusionPattern_description=&Choose folders or files to exclude:
+
+ExclusionInclusionDialog_ChooseInclusionPattern_title=Inclusion Pattern Selection
+ExclusionInclusionDialog_ChooseInclusionPattern_description=&Choose folders or files to include:
+
+# ------- ExclusionInclusionEntryDialog -------
+
+ExclusionInclusionEntryDialog_exclude_add_title=Add Exclusion Pattern
+ExclusionInclusionEntryDialog_exclude_edit_title=Edit Exclusion Pattern
+ExclusionInclusionEntryDialog_exclude_description=Enter a pattern for excluding files from the source folder. Allowed wildcards are '*', '?' and '**'. Examples: 'src/util/a*.c', 'src/util/', '**/Test*'.
+
+ExclusionInclusionEntryDialog_exclude_pattern_label=E&xclusion pattern (Path relative to ''{0}''):
+
+ExclusionInclusionEntryDialog_include_add_title=Add Inclusion Pattern
+ExclusionInclusionEntryDialog_include_edit_title=Edit Inclusion Pattern
+ExclusionInclusionEntryDialog_include_description=Enter a pattern for including files to the source folder. Allowed wildcards are '*', '?' and '**'. Examples: 'src/util/a*.c', 'src/util/', '**/Test*'.
+
+ExclusionInclusionEntryDialog_include_pattern_label=I&nclusion pattern (Path relative to ''{0}''):
+
+ExclusionInclusionEntryDialog_pattern_button=Bro&wse...
+
+ExclusionInclusionEntryDialog_error_empty=Enter a pattern.
+ExclusionInclusionEntryDialog_error_notrelative=Pattern must be a relative path.
+ExclusionInclusionEntryDialog_error_exists=Pattern already exists.
+
+ExclusionInclusionEntryDialog_ChooseExclusionPattern_title=Exclusion Pattern Selection
+ExclusionInclusionEntryDialog_ChooseExclusionPattern_description=&Choose a folder or file to exclude:
+
+ExclusionInclusionEntryDialog_ChooseInclusionPattern_title=Inclusion Pattern Selection
+ExclusionInclusionEntryDialog_ChooseInclusionPattern_description=&Choose a folder or file to include:
\ No newline at end of file
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java
index 95f7ff6..4155cce 100644
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java
@@ -1,17 +1,25 @@
+/*******************************************************************************
+ * 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.internal.ui.preferences;
-import org.eclipse.cdt.codan.core.CodanCorePlugin;
import org.eclipse.cdt.codan.core.PreferenceConstants;
-import org.eclipse.cdt.codan.ui.actions.ToggleNatureAction;
+import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
+import org.eclipse.cdt.codan.internal.ui.actions.ToggleNatureAction;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.IWorkbenchPropertyPage;
-import org.eclipse.ui.preferences.ScopedPreferenceStore;
public class BuildPropertyPage extends FieldEditorPreferencePage implements
IWorkbenchPropertyPage {
@@ -21,8 +29,7 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements
*
*/
public BuildPropertyPage() {
- setPreferenceStore(org.eclipse.cdt.codan.ui.Activator.getDefault()
- .getPreferenceStore());
+ setPreferenceStore(CodanUIActivator.getDefault().getPreferenceStore());
}
/*
@@ -35,7 +42,9 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements
@Override
protected void createFieldEditors() {
addField(new BooleanFieldEditor(PreferenceConstants.P_RUN_ON_BUILD,
- "&Run with Build", getFieldEditorParent()));
+ CodanUIMessages.BuildPropertyPage_RunWithBuild, getFieldEditorParent()));
+ addField(new BooleanFieldEditor(PreferenceConstants.P_RUN_IN_EDITOR,
+ CodanUIMessages.BuildPropertyPage_RunAsYouType, getFieldEditorParent()));
}
@Override
@@ -70,7 +79,9 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements
* @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
*/
public IAdaptable getElement() {
- return element;
+ if (element.getAdapter(IProject.class) != null)
+ return (IProject) element.getAdapter(IProject.class);
+ return null;
}
/*
@@ -82,16 +93,14 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements
*/
public void setElement(IAdaptable element) {
this.element = element;
- ProjectScope ps = new ProjectScope((IProject) getElement());
- ScopedPreferenceStore scoped = new ScopedPreferenceStore(ps,
- CodanCorePlugin.PLUGIN_ID);
- scoped
- .setSearchContexts(new IScopeContext[] { ps,
- new InstanceScope() });
- setPreferenceStore(scoped);
+ if (getElement() != null) {
+ IPreferenceStore scoped = CodanUIActivator.getDefault()
+ .getPreferenceStore(((IProject) getElement()));
+ setPreferenceStore(scoped);
+ }
}
protected String getPageId() {
- return "org.eclipse.cdt.codan.internal.ui.preferences.CodanPreferencePage";
+ return "org.eclipse.cdt.codan.internal.ui.preferences.CodanPreferencePage"; //$NON-NLS-1$
}
}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Entries b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Entries
index 980f899..f152569 100644
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Entries
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Entries
@@ -1,8 +1,7 @@
-/BuildPropertyPage.java/1.4/Sat Aug 22 21:16:50 2009//
-/CheckedTreeEditor.java/1.4/Wed Apr 22 01:26:58 2009//
-/CodanPreferencePage.java/1.4/Sat Aug 22 21:16:50 2009//
-/FieldEditorOverlayPage.java/1.3/Sat Apr 18 04:01:44 2009//
-/Messages.java/1.1/Thu Apr 9 12:47:54 2009//
-/Messages.properties/1.1/Thu Apr 9 12:47:54 2009//
-/PreferenceInitializer.java/1.2/Thu Apr 16 01:46:56 2009//
-/ProblemsTreeEditor.java/1.8/Wed Dec 16 21:48:50 2009//
+/BuildPropertyPage.java/1.10/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
+/CheckedTreeEditor.java/1.7/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
+/CodanPreferencePage.java/1.16/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
+/FieldEditorOverlayPage.java/1.7/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
+/FileScopePreferencePage.java/1.2/Thu Jun 3 17:01:39 2010//TCDT_7_0_0
+/PreferenceInitializer.java/1.6/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
+/ProblemsTreeEditor.java/1.17/Sun Jun 27 01:30:36 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Tag b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CheckedTreeEditor.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CheckedTreeEditor.java
index 7c98ef4..ce55a32 100644
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CheckedTreeEditor.java
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CheckedTreeEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation 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
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.codan.internal.ui.preferences;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
@@ -312,7 +313,7 @@ public abstract class CheckedTreeEditor extends FieldEditor implements
if (!emptySelectionAllowed) {
Object[] checkedElements = getTreeViewer().getCheckedElements();
if (checkedElements.length == 0) {
- showErrorMessage("Selection cannot be empty");
+ showErrorMessage(CodanUIMessages.CheckedTreeEditor_SelectionCannotBeEmpty);
return false;
}
}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java
index 35b9a8f..825e8cd 100644
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -10,12 +10,37 @@
*******************************************************************************/
package org.eclipse.cdt.codan.internal.ui.preferences;
+import java.text.MessageFormat;
+
import org.eclipse.cdt.codan.core.CodanCorePlugin;
import org.eclipse.cdt.codan.core.CodanRuntime;
import org.eclipse.cdt.codan.core.model.ICheckersRegistry;
+import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.model.IProblemProfile;
+import org.eclipse.cdt.codan.core.param.IProblemPreference;
+import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
+import org.eclipse.cdt.codan.internal.ui.dialogs.CustomizeProblemDialog;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
@@ -33,16 +58,39 @@ import org.eclipse.ui.preferences.ScopedPreferenceStore;
public class CodanPreferencePage extends FieldEditorOverlayPage implements
IWorkbenchPreferencePage {
private IProblemProfile profile;
+ private ISelectionChangedListener problemSelectionListener;
+ private IProblem selectedProblem;
+ private Group info;
+ private Label infoDesc;
+ private Label infoMessage;
+ private Label infoParams;
+ private Button infoButton;
+ private ProblemsTreeEditor checkedTreeEditor;
public CodanPreferencePage() {
super(GRID);
setPreferenceStore(new ScopedPreferenceStore(new InstanceScope(),
CodanCorePlugin.PLUGIN_ID));
- setDescription("Code Analyzers Preference Page");
+ // setDescription("Code Analysis Preference Page");
+ problemSelectionListener = new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ if (info != null) {
+ if (event.getSelection() instanceof ITreeSelection) {
+ ITreeSelection s = (ITreeSelection) event
+ .getSelection();
+ if (s.getFirstElement() instanceof IProblem)
+ setSelectedProblem((IProblem) s.getFirstElement());
+ else
+ setSelectedProblem(null);
+ }
+ }
+ }
+ };
}
+ @Override
protected String getPageId() {
- return "org.eclipse.cdt.codan.internal.ui.preferences.CodanPreferencePage";
+ return "org.eclipse.cdt.codan.internal.ui.preferences.CodanPreferencePage"; //$NON-NLS-1$
}
/**
@@ -50,13 +98,93 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements
* GUI blocks needed to manipulate various types of preferences. Each field
* editor knows how to save and restore itself.
*/
+ @Override
public void createFieldEditors() {
profile = isPropertyPage() ? getRegistry()
.getResourceProfileWorkingCopy((IResource) getElement())
: getRegistry().getWorkspaceProfile();
- CheckedTreeEditor checkedTreeEditor = new ProblemsTreeEditor(
- getFieldEditorParent(), profile);
+ checkedTreeEditor = new ProblemsTreeEditor(getFieldEditorParent(),
+ profile);
addField(checkedTreeEditor);
+ checkedTreeEditor.getTreeViewer().addSelectionChangedListener(
+ problemSelectionListener);
+ checkedTreeEditor.getTreeViewer().addDoubleClickListener(
+ new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ openCustomizeDialog();
+ }
+ });
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.cdt.codan.internal.ui.preferences.FieldEditorOverlayPage#
+ * createContents(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createContents(Composite parent) {
+ Composite comp = (Composite) super.createContents(parent);
+ createInfoControl(comp);
+ return comp;
+ }
+
+ /**
+ * @param comp
+ */
+ private void createInfoControl(Composite comp) {
+ info = new Group(comp, SWT.NONE);
+ info.setLayoutData(new GridData(GridData.FILL_BOTH));
+ info.setLayout(new GridLayout(3, false));
+ info.setText(CodanUIMessages.CodanPreferencePage_Info);
+ GridDataFactory gdLab = GridDataFactory.swtDefaults()
+ .align(SWT.BEGINNING, SWT.BEGINNING).grab(false, false);
+ GridDataFactory gdFact = GridDataFactory.swtDefaults()
+ .align(SWT.BEGINNING, SWT.BEGINNING).grab(true, true);
+ // message
+ Label labelMessage = new Label(info, SWT.NONE);
+ labelMessage.setText(CodanUIMessages.CodanPreferencePage_MessageLabel);
+ labelMessage.setLayoutData(gdLab.create());
+ infoMessage = new Label(info, SWT.WRAP);
+ infoMessage.setLayoutData(gdFact.copy().span(2, 1).create());
+ // description
+ Label labelDesc = new Label(info, SWT.NONE);
+ labelDesc.setText(CodanUIMessages.CodanPreferencePage_Description);
+ labelDesc.setLayoutData(gdLab.create());
+ infoDesc = new Label(info, SWT.WRAP);
+ PixelConverter pixelConverter = new PixelConverter(comp);
+ infoDesc.setLayoutData(gdFact
+ .copy()
+ .span(2, 1)
+ .hint(pixelConverter.convertWidthInCharsToPixels(60),
+ pixelConverter.convertHeightInCharsToPixels(3))
+ .create());
+ // params
+ Label labelParams = new Label(info, SWT.NONE);
+ labelParams.setText(CodanUIMessages.CodanPreferencePage_Parameters);
+ labelParams.setLayoutData(gdLab.create());
+ infoParams = new Label(info, SWT.NONE);
+ infoParams.setLayoutData(gdFact.create());
+ infoButton = new Button(info, SWT.PUSH);
+ infoButton.setLayoutData(GridDataFactory.swtDefaults()
+ .align(SWT.END, SWT.BEGINNING).create());
+ infoButton.setText(CodanUIMessages.CodanPreferencePage_Customize);
+ infoButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ openCustomizeDialog();
+ }
+ });
+ restoreWidgetValues();
+ }
+
+ /**
+ * @param selection
+ */
+ protected void setSelectedProblem(IProblem problem) {
+ this.selectedProblem = problem;
+ updateProblemInfo();
}
/**
@@ -73,11 +201,70 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements
*/
@Override
public boolean performOk() {
- if (isPropertyPage())
- getRegistry().updateProfile((IResource) getElement(), null);
+ saveWidgetValues();
+ // if (isPropertyPage())
+ getRegistry().updateProfile((IResource) getElement(), null);
return super.performOk();
}
+ /**
+ *
+ */
+ private void saveWidgetValues() {
+ CodanUIActivator
+ .getDefault()
+ .getDialogSettings()
+ .put(getWidgetId(),
+ selectedProblem == null ? "" : selectedProblem.getId()); //$NON-NLS-1$
+ }
+
+ private void restoreWidgetValues() {
+ String id = CodanUIActivator.getDefault().getDialogSettings()
+ .get(getWidgetId());
+ if (id != null && id.length() > 0) {
+ checkedTreeEditor.getTreeViewer().setSelection(
+ new StructuredSelection(profile.findProblem(id)), true);
+ } else {
+ setSelectedProblem(null);
+ }
+ }
+
+ /**
+ * @return
+ */
+ protected String getWidgetId() {
+ return getPageId() + ".selection"; //$NON-NLS-1$
+ }
+
+ /**
+ *
+ */
+ private void updateProblemInfo() {
+ if (selectedProblem == null) {
+ infoMessage.setText(""); //$NON-NLS-1$
+ infoDesc.setText(""); //$NON-NLS-1$
+ infoParams.setText(""); //$NON-NLS-1$
+ infoButton.setEnabled(false);
+ } else {
+ IProblemPreference pref = selectedProblem.getPreference();
+ String description = selectedProblem.getDescription();
+ if (description == null)
+ description = CodanUIMessages.CodanPreferencePage_NoInfo;
+ String messagePattern = selectedProblem.getMessagePattern();
+ String message = CodanUIMessages.CodanPreferencePage_NoInfo;
+ if (messagePattern != null) {
+ message = MessageFormat.format(messagePattern, "X", "Y", "Z"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ infoMessage.setText(message);
+ infoDesc.setText(description);
+ infoParams
+ .setText(pref == null ? CodanUIMessages.CodanPreferencePage_NoInfo
+ : CodanUIMessages.CodanPreferencePage_HasPreferences);
+ infoButton.setEnabled(true);
+ }
+ info.layout(true);
+ }
+
/*
* (non-Javadoc)
*
@@ -86,4 +273,13 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements
*/
public void init(IWorkbench workbench) {
}
+
+ /**
+ *
+ */
+ protected void openCustomizeDialog() {
+ CustomizeProblemDialog d = new CustomizeProblemDialog(getShell(),
+ selectedProblem, (IResource) getElement());
+ d.open();
+ }
}
\ No newline at end of file
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FieldEditorOverlayPage.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FieldEditorOverlayPage.java
index e617a75..714d841 100644
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FieldEditorOverlayPage.java
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FieldEditorOverlayPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003 Berthold Daum.
+ * Copyright (c) 2003, 2010 Berthold Daum.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,6 +16,7 @@ import java.util.List;
import org.eclipse.cdt.codan.core.CodanCorePlugin;
import org.eclipse.cdt.codan.core.PreferenceConstants;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.IAdaptable;
@@ -121,6 +122,10 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage
* @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
*/
public IAdaptable getElement() {
+ if (element == null)
+ return element;
+ if (!(element instanceof IProject))
+ return (IAdaptable) element.getAdapter(IProject.class);
return element;
}
@@ -157,12 +162,15 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage
// Cache the page id
pageId = getPageId();
// Create an overlay preference store and fill it with properties
- ProjectScope ps = new ProjectScope((IProject) getElement());
- ScopedPreferenceStore scoped = new ScopedPreferenceStore(ps,
- CodanCorePlugin.PLUGIN_ID);
- scoped.setSearchContexts(new IScopeContext[] { ps,
- new InstanceScope() });
- overlayStore = scoped;
+ IAdaptable e = getElement();
+ if (e != null) {
+ ProjectScope ps = new ProjectScope((IProject) e);
+ ScopedPreferenceStore scoped = new ScopedPreferenceStore(ps,
+ CodanCorePlugin.PLUGIN_ID);
+ scoped.setSearchContexts(new IScopeContext[] { ps,
+ new InstanceScope() });
+ overlayStore = scoped;
+ }
// Set overlay store as current preference store
}
super.createControl(parent);
@@ -200,13 +208,12 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage
Composite radioGroup = new Composite(comp, SWT.NONE);
radioGroup.setLayout(new GridLayout());
radioGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- useWorkspaceSettingsButton = createRadioButton(radioGroup, Messages
- .getString("OverlayPage.Use_Workspace_Settings")); //$NON-NLS-1$
- useProjectSettingsButton = createRadioButton(radioGroup, Messages
- .getString("OverlayPage.Use_Project_Settings")); //$NON-NLS-1$
+ useWorkspaceSettingsButton = createRadioButton(radioGroup,
+ CodanUIMessages.OverlayPage_Use_Workspace_Settings);
+ useProjectSettingsButton = createRadioButton(radioGroup,
+ CodanUIMessages.OverlayPage_Use_Project_Settings);
configureButton = new Button(comp, SWT.PUSH);
- configureButton.setText(Messages
- .getString("OverlayPage.Configure_Workspace_Settings")); //$NON-NLS-1$
+ configureButton.setText(CodanUIMessages.OverlayPage_Use_Workspace_Settings);
configureButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
configureWorkspaceSettings();
@@ -322,6 +329,7 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage
/**
* Creates a new preferences page and opens it
*/
+ @SuppressWarnings("cast")
protected void configureWorkspaceSettings() {
try {
// create a new instance of the current class
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FileScopePreferencePage.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FileScopePreferencePage.java
new file mode 100644
index 0000000..149dee9
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FileScopePreferencePage.java
@@ -0,0 +1,312 @@
+/*******************************************************************************
+ * 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.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.cdt.codan.core.param.FileScopeProblemPreference;
+import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
+import org.eclipse.cdt.codan.internal.ui.dialogs.ExclusionInclusionEntryDialog;
+import org.eclipse.cdt.codan.internal.ui.widgets.BasicElementLabels;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+public class FileScopePreferencePage extends PreferencePage {
+ private ListDialogField fInclusionPatternList;
+ private ListDialogField fExclusionPatternList;
+ private FileScopeProblemPreference fCurrElement;
+ private IProject fCurrProject;
+ private IContainer fCurrSourceFolder;
+ private static final int IDX_ADD = 0;
+ private static final int IDX_ADD_MULTIPLE = 1;
+ private static final int IDX_EDIT = 2;
+ private static final int IDX_REMOVE = 4;
+
+ public FileScopePreferencePage(FileScopeProblemPreference entryToEdit) {
+ setTitle(CodanUIMessages.ExclusionInclusionDialog_title);
+ setDescription(CodanUIMessages.ExclusionInclusionDialog_description2);
+ fCurrElement = entryToEdit;
+ fCurrProject = entryToEdit.getProject();
+ IWorkspaceRoot root = fCurrProject != null ? fCurrProject
+ .getWorkspace().getRoot() : ResourcesPlugin.getWorkspace()
+ .getRoot();
+ IResource res = root.findMember(entryToEdit.getPath());
+ if (res instanceof IContainer) {
+ fCurrSourceFolder = (IContainer) res;
+ }
+ if (res == null)
+ fCurrSourceFolder = root;
+ String excLabel = CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_label;
+ ImageDescriptor excDescriptor = null; //JavaPluginImages.DESC_OBJS_EXCLUSION_FILTER_ATTRIB;
+ String[] excButtonLabels = new String[] {
+ CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_add,
+ CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_add_multiple,
+ CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_edit,
+ null,
+ CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_remove };
+ String incLabel = CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_label;
+ ImageDescriptor incDescriptor = null; //JavaPluginImages.DESC_OBJS_INCLUSION_FILTER_ATTRIB;
+ String[] incButtonLabels = new String[] {
+ CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_add,
+ CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_add_multiple,
+ CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_edit,
+ null,
+ CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_remove };
+ fExclusionPatternList = createListContents(entryToEdit,
+ FileScopeProblemPreference.EXCLUSION, excLabel, null,
+ excButtonLabels);
+ fInclusionPatternList = createListContents(entryToEdit,
+ FileScopeProblemPreference.INCLUSION, incLabel, null,
+ incButtonLabels);
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Composite inner = new Composite(parent, SWT.NONE);
+ inner.setFont(parent.getFont());
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 2;
+ inner.setLayout(layout);
+ inner.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fInclusionPatternList.doFillIntoGrid(inner, 3);
+ LayoutUtil.setHorizontalSpan(
+ fInclusionPatternList.getLabelControl(null), 2);
+ LayoutUtil.setHorizontalGrabbing(fInclusionPatternList
+ .getListControl(null));
+ fExclusionPatternList.doFillIntoGrid(inner, 3);
+ LayoutUtil.setHorizontalSpan(
+ fExclusionPatternList.getLabelControl(null), 2);
+ LayoutUtil.setHorizontalGrabbing(fExclusionPatternList
+ .getListControl(null));
+ setControl(inner);
+ Dialog.applyDialogFont(inner);
+ return inner;
+ }
+
+ private static class ExclusionInclusionLabelProvider extends LabelProvider {
+ private Image fElementImage;
+
+ public ExclusionInclusionLabelProvider(String descriptorPath) {
+ if (descriptorPath != null) {
+ ImageDescriptor d = CodanUIActivator
+ .getImageDescriptor(descriptorPath);
+ }
+ fElementImage = null; // XXX
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ return fElementImage;
+ }
+
+ @Override
+ public String getText(Object element) {
+ return BasicElementLabels.getFilePattern((String) element);
+ }
+ }
+
+ private ListDialogField createListContents(
+ FileScopeProblemPreference entryToEdit, String key, String label,
+ String descriptor, String[] buttonLabels) {
+ ExclusionPatternAdapter adapter = new ExclusionPatternAdapter();
+ ListDialogField patternList = new ListDialogField(adapter,
+ buttonLabels, new ExclusionInclusionLabelProvider(descriptor));
+ patternList.setDialogFieldListener(adapter);
+ patternList.setLabelText(label);
+ patternList.enableButton(IDX_EDIT, false);
+ IPath[] pattern = entryToEdit.getAttribute(key);
+ ArrayList elements = new ArrayList(pattern.length);
+ for (int i = 0; i < pattern.length; i++) {
+ String patternName = pattern[i].toString();
+ if (patternName.length() > 0)
+ elements.add(patternName);
+ }
+ patternList.setElements(elements);
+ patternList.selectFirstElement();
+ patternList.enableButton(IDX_ADD_MULTIPLE, fCurrSourceFolder != null);
+ patternList.setViewerComparator(new ViewerComparator());
+ return patternList;
+ }
+
+ protected void doCustomButtonPressed(ListDialogField field, int index) {
+ if (index == IDX_ADD) {
+ addEntry(field);
+ } else if (index == IDX_EDIT) {
+ editEntry(field);
+ } else if (index == IDX_ADD_MULTIPLE) {
+ addMultipleEntries(field);
+ } else if (index == IDX_REMOVE) {
+ field.removeElements(field.getSelectedElements());
+ }
+ updateStatus();
+ }
+
+ private void updateStatus() {
+ fCurrElement.setAttribute(FileScopeProblemPreference.INCLUSION,
+ getInclusionPattern());
+ fCurrElement.setAttribute(FileScopeProblemPreference.EXCLUSION,
+ getExclusionPattern());
+ }
+
+ protected void doDoubleClicked(ListDialogField field) {
+ editEntry(field);
+ updateStatus();
+ }
+
+ protected void doSelectionChanged(ListDialogField field) {
+ List selected = field.getSelectedElements();
+ field.enableButton(IDX_EDIT, canEdit(selected));
+ }
+
+ private boolean canEdit(List selected) {
+ return selected.size() == 1;
+ }
+
+ private void editEntry(ListDialogField field) {
+ List selElements = field.getSelectedElements();
+ if (selElements.size() != 1) {
+ return;
+ }
+ List existing = field.getElements();
+ String entry = (String) selElements.get(0);
+ ExclusionInclusionEntryDialog dialog = new ExclusionInclusionEntryDialog(
+ getShell(), isExclusion(field), entry, existing, fCurrElement);
+ if (dialog.open() == Window.OK) {
+ field.replaceElement(entry, dialog.getExclusionPattern());
+ }
+ }
+
+ private boolean isExclusion(ListDialogField field) {
+ return field == fExclusionPatternList;
+ }
+
+ private void addEntry(ListDialogField field) {
+ List existing = field.getElements();
+ ExclusionInclusionEntryDialog dialog = new ExclusionInclusionEntryDialog(
+ getShell(), isExclusion(field), null, existing, fCurrElement);
+ if (dialog.open() == Window.OK) {
+ field.addElement(dialog.getExclusionPattern());
+ }
+ }
+
+ // -------- ExclusionPatternAdapter --------
+ private class ExclusionPatternAdapter implements IListAdapter,
+ IDialogFieldListener {
+ /**
+ * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#customButtonPressed(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField,
+ * int)
+ */
+ public void customButtonPressed(ListDialogField field, int index) {
+ doCustomButtonPressed(field, index);
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#selectionChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField)
+ */
+ public void selectionChanged(ListDialogField field) {
+ doSelectionChanged(field);
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#doubleClicked(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField)
+ */
+ public void doubleClicked(ListDialogField field) {
+ doDoubleClicked(field);
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField)
+ */
+ public void dialogFieldChanged(DialogField field) {
+ }
+ }
+
+ protected void doStatusLineUpdate() {
+ }
+
+ protected void checkIfPatternValid() {
+ }
+
+ private IPath[] getPattern(ListDialogField field) {
+ Object[] arr = field.getElements().toArray();
+ Arrays.sort(arr);
+ IPath[] res = new IPath[arr.length];
+ for (int i = 0; i < res.length; i++) {
+ res[i] = new Path((String) arr[i]);
+ }
+ return res;
+ }
+
+ public IPath[] getExclusionPattern() {
+ return getPattern(fExclusionPatternList);
+ }
+
+ public IPath[] getInclusionPattern() {
+ return getPattern(fInclusionPatternList);
+ }
+
+ /*
+ * @see org.eclipse.jface.window.Window#configureShell(Shell)
+ */
+ protected void configureShell(Shell newShell) {
+ }
+
+ private void addMultipleEntries(ListDialogField field) {
+ String title, message;
+ if (isExclusion(field)) {
+ title = CodanUIMessages.ExclusionInclusionDialog_ChooseExclusionPattern_title;
+ message = CodanUIMessages.ExclusionInclusionDialog_ChooseExclusionPattern_description;
+ } else {
+ title = CodanUIMessages.ExclusionInclusionDialog_ChooseInclusionPattern_title;
+ message = CodanUIMessages.ExclusionInclusionDialog_ChooseInclusionPattern_description;
+ }
+ IPath[] res = ExclusionInclusionEntryDialog.chooseExclusionPattern(
+ getShell(), fCurrSourceFolder, title, message, null, true);
+ if (res != null) {
+ for (int i = 0; i < res.length; i++) {
+ field.addElement(res[i].toString());
+ }
+ }
+ }
+
+ @Override
+ public void noDefaultAndApplyButton() {
+ super.noDefaultAndApplyButton();
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/Messages.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/Messages.java
deleted file mode 100644
index 4ef5f89..0000000
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/Messages.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 Berthold Daum.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Berthold Daum
- *******************************************************************************/
-
-package org.eclipse.cdt.codan.internal.ui.preferences;
-
-import java.util.ResourceBundle;
-
-
-public class Messages {
-
- private final static String RESOURCE_BUNDLE = "org.eclipse.cdt.codan.internal.ui.preferences.Messages";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle = null;
-
- private static boolean notRead = true;
-
- public Messages() {
- }
- public static ResourceBundle getResourceBundle() {
- if (notRead) {
- notRead = false;
- try {
- fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
- }
- catch (Exception e) {
- }
- }
-
- return fgResourceBundle;
- }
- public static String getString(String key) {
- try {
- return getResourceBundle().getString(key);
- } catch (Exception e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-}
-
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/Messages.properties b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/Messages.properties
deleted file mode 100644
index 689b7ee..0000000
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/Messages.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-OverlayPage.Use_Workspace_Settings=Use &workspace settings
-OverlayPage.Use_Project_Settings=Use pr&oject settings
-OverlayPage.Configure_Workspace_Settings=&Configure Workspace Settings ...
-PropertyStore.Cannot_write_resource_property=Cannot write resource property
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/PreferenceInitializer.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/PreferenceInitializer.java
index 4362098..645a892 100644
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/PreferenceInitializer.java
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/PreferenceInitializer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -11,6 +11,7 @@
package org.eclipse.cdt.codan.internal.ui.preferences;
import org.eclipse.cdt.codan.core.PreferenceConstants;
+import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -18,16 +19,16 @@ import org.eclipse.jface.preference.IPreferenceStore;
* Class used to initialize default preference values.
*/
public class PreferenceInitializer extends AbstractPreferenceInitializer {
-
/*
* (non-Javadoc)
*
- * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#
+ * initializeDefaultPreferences()
*/
public void initializeDefaultPreferences() {
- IPreferenceStore store = org.eclipse.cdt.codan.ui.Activator
- .getDefault().getPreferenceStore();
+ IPreferenceStore store = CodanUIActivator.getDefault()
+ .getPreferenceStore();
store.setDefault(PreferenceConstants.P_RUN_ON_BUILD, false);
+ store.setDefault(PreferenceConstants.P_RUN_IN_EDITOR, true);
}
-
}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java
index 26e433e..4547028 100644
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -14,24 +14,27 @@ import org.eclipse.cdt.codan.core.PreferenceConstants;
import org.eclipse.cdt.codan.core.model.CodanSeverity;
import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.model.IProblemCategory;
+import org.eclipse.cdt.codan.core.model.IProblemElement;
import org.eclipse.cdt.codan.core.model.IProblemProfile;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
import org.eclipse.cdt.codan.internal.core.CodanPreferencesLoader;
-import org.eclipse.jface.viewers.BaseLabelProvider;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ComboBoxCellEditor;
import org.eclipse.jface.viewers.EditingSupport;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.ICheckStateProvider;
import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
public class ProblemsTreeEditor extends CheckedTreeEditor {
private CodanPreferencesLoader codanPreferencesLoader = new CodanPreferencesLoader();
@@ -136,39 +139,26 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
}
}
+ @Override
public void checkStateChanged(CheckStateChangedEvent event) {
Object element = event.getElement();
- if (element instanceof IProblem) {
- ((IProblem) element).setEnabled(event.getChecked());
- }
- }
-
- class ProblemsLabelProvider extends BaseLabelProvider implements
- IBaseLabelProvider, ITableLabelProvider {
- public Image getColumnImage(Object element, int columnIndex) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- if (element instanceof IProblem) {
- IProblem p = (IProblem) element;
- if (columnIndex == 0)
- return p.getName();
- if (columnIndex == 1)
- return p.getSeverity().toString();
- }
- if (element instanceof IProblemCategory) {
- IProblemCategory p = (IProblemCategory) element;
- if (columnIndex == 0)
- return p.getName();
+ if (element instanceof IProblemWorkingCopy) {
+ ((IProblemWorkingCopy) element).setEnabled(event.getChecked());
+ } else if (element instanceof IProblemCategory) {
+ IProblemCategory cat = (IProblemCategory) element;
+ IProblemElement[] children = cat.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ IProblemElement pe = children[i];
+ checkStateChanged(new CheckStateChangedEvent(getTreeViewer(),
+ pe, event.getChecked()));
}
- return null;
}
+ getTreeViewer().refresh();
}
public ProblemsTreeEditor(Composite parent, IProblemProfile profile) {
- super(PreferenceConstants.P_PROBLEMS, "Problems", parent);
+ super(PreferenceConstants.P_PROBLEMS,
+ CodanUIMessages.ProblemsTreeEditor_Problems, parent);
setEmptySelectionAllowed(true);
getTreeViewer().getTree().setHeaderVisible(true);
// getTreeViewer().getTree().
@@ -178,8 +168,10 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
TreeViewerColumn column1 = new TreeViewerColumn(getTreeViewer(),
SWT.NONE);
column1.getColumn().setWidth(300);
- column1.getColumn().setText("Name");
+ column1.getColumn().setText(
+ CodanUIMessages.ProblemsTreeEditor_NameColumn);
column1.setLabelProvider(new ColumnLabelProvider() {
+ @Override
public String getText(Object element) {
if (element instanceof IProblem) {
IProblem p = (IProblem) element;
@@ -196,8 +188,31 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
TreeViewerColumn column2 = new TreeViewerColumn(getTreeViewer(),
SWT.NONE);
column2.getColumn().setWidth(100);
- column2.getColumn().setText("Severity");
+ column2.getColumn().setText(
+ CodanUIMessages.ProblemsTreeEditor_SeverityColumn);
column2.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public Image getImage(Object element) {
+ final ISharedImages images = PlatformUI.getWorkbench()
+ .getSharedImages();
+ if (element instanceof IProblem) {
+ IProblem p = (IProblem) element;
+ switch (p.getSeverity().intValue()) {
+ case IMarker.SEVERITY_INFO:
+ return images
+ .getImage(ISharedImages.IMG_OBJS_INFO_TSK);
+ case IMarker.SEVERITY_WARNING:
+ return images
+ .getImage(ISharedImages.IMG_OBJS_WARN_TSK);
+ case IMarker.SEVERITY_ERROR:
+ return images
+ .getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+ }
+ }
+ return null;
+ }
+
+ @Override
public String getText(Object element) {
if (element instanceof IProblem) {
IProblem p = (IProblem) element;
@@ -207,23 +222,27 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
}
});
column2.setEditingSupport(new EditingSupport(getTreeViewer()) {
+ @Override
protected boolean canEdit(Object element) {
return element instanceof IProblem;
}
+ @Override
protected CellEditor getCellEditor(Object element) {
return new ComboBoxCellEditor(getTreeViewer().getTree(),
CodanSeverity.stringValues());
}
+ @Override
protected Object getValue(Object element) {
return ((IProblem) element).getSeverity().intValue();
}
+ @Override
protected void setValue(Object element, Object value) {
int index = ((Integer) value).intValue();
CodanSeverity val = CodanSeverity.values()[index];
- ((IProblem) element).setSeverity(val);
+ ((IProblemWorkingCopy) element).setSeverity(val);
getTreeViewer().update(element, null);
}
});
@@ -245,6 +264,9 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
for (int i = 0; i < probs.length; i++) {
String id = probs[i].getId();
String s = getPreferenceStore().getString(id);
+ if (s == null || s.length() == 0) {
+ s = codanPreferencesLoader.getProperty(id);
+ }
codanPreferencesLoader.setProperty(id, s);
}
getViewer().setInput(codanPreferencesLoader.getInput());
@@ -258,6 +280,9 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
for (int i = 0; i < probs.length; i++) {
String id = probs[i].getId();
String s = getPreferenceStore().getDefaultString(id);
+ if (s == null || s.length() == 0) {
+ s = codanPreferencesLoader.getProperty(id);
+ }
codanPreferencesLoader.setProperty(id, s);
}
getViewer().setInput(codanPreferencesLoader.getInput());
@@ -272,12 +297,17 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
*/
@Override
protected void doStore() {
- codanPreferencesLoader.setInput(getViewer().getInput());
+ codanPreferencesLoader.setInput((IProblemProfile) getViewer()
+ .getInput());
IProblem[] probs = codanPreferencesLoader.getProblems();
for (int i = 0; i < probs.length; i++) {
String id = probs[i].getId();
String s = codanPreferencesLoader.getProperty(id);
getPreferenceStore().setValue(id, s);
+ String params = codanPreferencesLoader.getPreferencesString(id);
+ if (params != null)
+ getPreferenceStore().setValue(
+ codanPreferencesLoader.getPreferencesKey(id), params);
}
}
@@ -301,6 +331,6 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
*/
@Override
protected String modelToString(Object model) {
- return "";
+ return ""; //$NON-NLS-1$
}
}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/CVS/Entries b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/CVS/Entries
new file mode 100644
index 0000000..58fdd77
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/CVS/Entries
@@ -0,0 +1,3 @@
+/GenericCodanProblemDetailsProvider.java/1.2/Sat May 1 00:41:55 2010//TCDT_7_0_0
+/ProblemDetails.java/1.5/Wed May 5 20:48:28 2010//TCDT_7_0_0
+/ProblemDetailsExtensions.java/1.2/Sat May 1 00:41:55 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/CVS/Repository b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/CVS/Repository
new file mode 100644
index 0000000..b01fe09
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/CVS/Root b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/CVS/Tag b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/GenericCodanProblemDetailsProvider.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/GenericCodanProblemDetailsProvider.java
new file mode 100644
index 0000000..0afb53c
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/GenericCodanProblemDetailsProvider.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.internal.ui.views;
+
+import org.eclipse.cdt.codan.ui.AbstractCodanProblemDetailsProvider;
+
+/**
+ * This provides details for errors that do not have own details provider
+ */
+public class GenericCodanProblemDetailsProvider extends AbstractCodanProblemDetailsProvider {
+ @Override
+ public boolean isApplicable(String id) {
+ return true;
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetails.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetails.java
new file mode 100644
index 0000000..3f164af
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetails.java
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.internal.ui.views;
+
+import java.util.Collection;
+
+import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
+import org.eclipse.cdt.codan.ui.AbstractCodanProblemDetailsProvider;
+import org.eclipse.cdt.codan.ui.CodanEditorUtility;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * Problems Details view show details for selected problem marker.
+ * Other plugins can contribute to override default behaviour using
+ * codanProblemDetails extension point.
+ */
+public class ProblemDetails extends ViewPart {
+ /**
+ * The ID of the view as specified by the extension.
+ */
+ public static final String ID = "org.eclipse.cdt.codan.internal.ui.views.ProblemDetails"; //$NON-NLS-1$
+ private Composite area;
+ /**
+ * Control for problem message, which can include location
+ */
+ private Link message;
+ /**
+ * Control for problem description which can include links to help or web-sites with extra info
+ */
+ private Link description;
+ private GenericCodanProblemDetailsProvider genProvider = new GenericCodanProblemDetailsProvider();
+ private AbstractCodanProblemDetailsProvider curProvider = genProvider;
+
+ /**
+ * The constructor.
+ */
+ public ProblemDetails() {
+ }
+
+ /**
+ * This is a callback that will allow us
+ * to create the area and initialize it.
+ */
+ public void createPartControl(Composite parent) {
+ final String problemsViewId = "org.eclipse.ui.views.ProblemView"; //$NON-NLS-1$
+ area = new Composite(parent, SWT.NONE);
+ area.setLayout(new GridLayout());
+ SelectionAdapter linkSelAdapter = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ String link = e.text;
+ if (link == null)
+ return;
+ if (link.startsWith("http")) { //$NON-NLS-1$
+ org.eclipse.swt.program.Program.launch(e.text);
+ return;
+ }
+ // link file format example "file:/tmp/file.c#42", 42 is the line number
+ if (link.startsWith("file:")) { //$NON-NLS-1$
+ try {
+ CodanEditorUtility.openInEditor(link, curProvider.getMarker().getResource());
+ } catch (PartInitException e1) {
+ CodanUIActivator.log(e1);
+ }
+ return;
+ }
+ if (link.startsWith("help:")) { //$NON-NLS-1$
+ // open in eclipse help TODO
+ return;
+ }
+ }
+ };
+ message = new Link(area, SWT.WRAP);
+ message.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ message.addSelectionListener(linkSelAdapter);
+ description = new Link(area, SWT.WRAP);
+ description.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ description.addSelectionListener(linkSelAdapter);
+ ISelectionService ser = (ISelectionService) getSite().getService(ISelectionService.class);
+ ser.addSelectionListener(new ISelectionListener() {
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if (part.getSite().getId().equals(problemsViewId)) {
+ processSelection(selection);
+ }
+ }
+ });
+ ISelection selection = ser.getSelection(problemsViewId);
+ processSelection(selection);
+ }
+
+ protected void processSelection(ISelection selection) {
+ if (selection == null || selection.isEmpty())
+ return;
+ if (selection instanceof IStructuredSelection) {
+ Object firstElement = ((IStructuredSelection) selection).getFirstElement();
+ IMarker marker = null;
+ if (firstElement instanceof IAdaptable) {
+ marker = (IMarker) ((IAdaptable) firstElement).getAdapter(IMarker.class);
+ } else if (firstElement instanceof IMarker) {
+ marker = (IMarker) firstElement;
+ }
+ if (marker != null) {
+ queryProviders(marker);
+ area.layout();
+ }
+ }
+ }
+
+ private void queryProviders(IMarker marker) {
+ String id = marker.getAttribute(IMarker.PROBLEM, "id"); //$NON-NLS-1$
+ Collection providers = ProblemDetailsExtensions.getProviders(id);
+ for (AbstractCodanProblemDetailsProvider provider : providers) {
+ synchronized (provider) {
+ provider.setMarker(marker);
+ if (provider.isApplicable(id)) {
+ applyProvider(provider);
+ return;
+ }
+ }
+ }
+ genProvider.setMarker(marker);
+ applyProvider(genProvider);
+ }
+
+ private void applyProvider(AbstractCodanProblemDetailsProvider provider) {
+ curProvider = provider;
+ setTextSafe(message, provider, provider.getStyledProblemMessage());
+ setTextSafe(description, provider, provider.getStyledProblemDescription());
+ }
+
+ protected void setTextSafe(Link control, AbstractCodanProblemDetailsProvider provider, String text) {
+ try {
+ control.setText(text);
+ } catch (Exception e) {
+ // this is debug message
+ control.setText("failed to set text: " + provider.getClass() + " " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * Passing the focus request to the area's control.
+ */
+ public void setFocus() {
+ message.setFocus();
+ }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetailsExtensions.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetailsExtensions.java
new file mode 100644
index 0000000..689d9d8
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetailsExtensions.java
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.internal.ui.views;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
+import org.eclipse.cdt.codan.ui.AbstractCodanProblemDetailsProvider;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * Class that can load extension for problemDetails
+ */
+public class ProblemDetailsExtensions {
+ public static final String ALL = "*";//$NON-NLS-1$
+ private static final String EXTENSION_POINT_NAME = "codanProblemDetails"; //$NON-NLS-1$
+ private static boolean extensionsLoaded;
+ private static HashMap> map = new HashMap>();
+
+ private static synchronized void readExtensions() {
+ if (extensionsLoaded) return;
+ IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(CodanUIActivator.PLUGIN_ID, EXTENSION_POINT_NAME);
+ if (ep == null)
+ return;
+ try {
+ IConfigurationElement[] elements = ep.getConfigurationElements();
+ // process categories
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement configurationElement = elements[i];
+ processDetails(configurationElement);
+ }
+ } finally {
+ extensionsLoaded = true;
+ }
+ }
+
+ /**
+ * @param configurationElement
+ */
+ private static void processDetails(IConfigurationElement configurationElement) {
+ if (configurationElement.getName().equals("problemDetails")) { //$NON-NLS-1$
+ String id = configurationElement.getAttribute("problemId"); //$NON-NLS-1$
+ if (id == null) {
+ id = ALL;
+ }
+ addExtension(id, configurationElement);
+ }
+ }
+
+ public static AbstractCodanProblemDetailsProvider resolveClass(IConfigurationElement configurationElement) {
+ AbstractCodanProblemDetailsProvider res;
+ try {
+ res = (AbstractCodanProblemDetailsProvider) configurationElement.createExecutableExtension("class");//$NON-NLS-1$
+ } catch (CoreException e) {
+ CodanUIActivator.log(e);
+ return null;
+ }
+ return res;
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private static void addExtension(String id, IConfigurationElement configurationElement) {
+ Collection collection = getCollection(id);
+ collection.add(configurationElement);
+ }
+
+ /**
+ * Remove provider from the list
+ * @param id - codan problem id or ALL
+ * @param el - details provider (class extending AbstractCodanProblemDetailsProvider) or ElementConfiguration (user internally)
+ */
+ @SuppressWarnings("rawtypes")
+ public static void removeExtension(String id, Object el) {
+ Collection collection = getCollection(id);
+ collection.remove(el);
+ }
+
+ @SuppressWarnings("rawtypes")
+ private static Collection getCollection(String id) {
+ Collection collection = map.get(id);
+ if (collection == null) {
+ collection = new ArrayList();
+ map.put(id, collection);
+ }
+ return collection;
+ }
+
+ public static Collection getProviders(String id) {
+ readExtensions();
+ Collection providers = new ArrayList();
+ Collection> collection1 = getCollection(id);
+ Collection> collection2 = getCollection(ALL);
+ providers.addAll(resolveProviders(collection1));
+ providers.addAll(resolveProviders(collection2));
+ return providers;
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public static Collection resolveProviders(Collection collection) {
+ Collection res = new ArrayList(collection);
+ for (Iterator iterator = res.iterator(); iterator.hasNext();) {
+ Object object = iterator.next();
+ if (object instanceof IConfigurationElement) {
+ // resolve
+ collection.remove(object);
+ AbstractCodanProblemDetailsProvider provider = resolveClass((IConfigurationElement) object);
+ if (provider!=null)
+ collection.add(provider);
+ }
+ }
+ return collection;
+ }
+
+ /**
+ * Add extension (details provider) using API
+ * @param id - codan problem id or ALL
+ * @param provider - class extending AbstractCodanProblemDetailsProvider
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public static void addExtension(String id, AbstractCodanProblemDetailsProvider provider) {
+ Collection collection = getCollection(id);
+ collection.add(provider);
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/BasicElementLabels.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/BasicElementLabels.java
new file mode 100644
index 0000000..cc2f966
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/BasicElementLabels.java
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * 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.internal.ui.widgets;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.osgi.util.TextProcessor;
+import org.eclipse.ui.IWorkingSet;
+
+/**
+ * A label provider for basic elements like paths. The label provider will make
+ * sure that the labels are correctly
+ * shown in RTL environments.
+ *
+ * @since 3.4
+ */
+public class BasicElementLabels {
+ // TextProcessor delimiters
+ private static final String CODE_DELIMITERS = TextProcessor
+ .getDefaultDelimiters() + "<>()?,{}+-*!%=^|&;[]~"; //$NON-NLS-1$
+ private static final String FILE_PATTERN_DELIMITERS = TextProcessor
+ .getDefaultDelimiters() + "*.?"; //$NON-NLS-1$
+ private static final String URL_DELIMITERS = TextProcessor
+ .getDefaultDelimiters() + ":@?-"; //$NON-NLS-1$
+
+ /**
+ * Returns the label of a path.
+ *
+ * @param path
+ * the path
+ * @param isOSPath
+ * if true, the path represents an OS path, if
+ * false it is a workspace path.
+ * @return the label of the path to be used in the UI.
+ */
+ public static String getPathLabel(IPath path, boolean isOSPath) {
+ String label;
+ if (isOSPath) {
+ label = path.toOSString();
+ } else {
+ label = path.makeRelative().toString();
+ }
+ return markLTR(label);
+ }
+
+ /**
+ * Returns the label of the path of a file.
+ *
+ * @param file
+ * the file
+ * @return the label of the file path to be used in the UI.
+ */
+ public static String getPathLabel(File file) {
+ return markLTR(file.getAbsolutePath());
+ }
+
+ /**
+ * Returns the label for a file pattern like '*.java'
+ *
+ * @param name
+ * the pattern
+ * @return the label of the pattern.
+ */
+ public static String getFilePattern(String name) {
+ return markLTR(name, FILE_PATTERN_DELIMITERS);
+ }
+
+ /**
+ * Returns the label for a URL, URI or URL part. Example is
+ * 'http://www.x.xom/s.html#1'
+ *
+ * @param name
+ * the URL string
+ * @return the label of the URL.
+ */
+ public static String getURLPart(String name) {
+ return markLTR(name, URL_DELIMITERS);
+ }
+
+ /**
+ * Returns a label for a resource name.
+ *
+ * @param resource
+ * the resource
+ * @return the label of the resource name.
+ */
+ public static String getResourceName(IResource resource) {
+ return markLTR(resource.getName());
+ }
+
+ /**
+ * Returns a label for a resource name.
+ *
+ * @param resourceName
+ * the resource name
+ * @return the label of the resource name.
+ */
+ public static String getResourceName(String resourceName) {
+ return markLTR(resourceName);
+ }
+
+ /**
+ * Returns a label for Java code snippet used in a label. Example is 'Test
+ * test= new Test extends List>() { ...}'.
+ *
+ * @param string
+ * the Java code snippet
+ * @return the label for the Java code snippet
+ */
+ public static String getJavaCodeString(String string) {
+ return markLTR(string, CODE_DELIMITERS);
+ }
+
+ /**
+ * Returns a label for a version name. Example is '1.4.1'
+ *
+ * @param name
+ * the version string
+ * @return the version label
+ */
+ public static String getVersionName(String name) {
+ return markLTR(name);
+ }
+
+ /**
+ * Returns a label for a working set
+ *
+ * @param set
+ * the working set
+ * @return the label of the working set
+ */
+ public static String getWorkingSetLabel(IWorkingSet set) {
+ return markLTR(set.getLabel());
+ }
+
+ /**
+ * It does not do anything now, but just in case we need to do the same as
+ * JDT does (see String.markLTR in JDT)
+ */
+ private static String markLTR(String label) {
+ return label;
+ }
+
+ private static String markLTR(String label, String delim) {
+ return label;
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Entries b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Entries
new file mode 100644
index 0000000..6bad80f
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Entries
@@ -0,0 +1,4 @@
+/BasicElementLabels.java/1.2/Thu Jun 3 17:01:40 2010//TCDT_7_0_0
+/CustomizeProblemComposite.java/1.2/Thu Jun 3 17:01:40 2010//TCDT_7_0_0
+/FileScopeComposite.java/1.2/Thu Jun 3 17:01:40 2010//TCDT_7_0_0
+/ParametersComposite.java/1.2/Thu Jun 3 17:01:40 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Repository b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Repository
new file mode 100644
index 0000000..905430a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Root b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Tag b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CustomizeProblemComposite.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CustomizeProblemComposite.java
new file mode 100644
index 0000000..32ba550
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CustomizeProblemComposite.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.ui.widgets;
+
+import org.eclipse.cdt.codan.core.model.IProblem;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+
+/**
+ * Composite for problem customisable parameters
+ *
+ */
+public class CustomizeProblemComposite extends Composite {
+ private Composite parametersTab;
+ private IProblem problem;
+ private ParametersComposite problemsComposite;
+ private FileScopeComposite scopeComposite;
+ private IResource resource;
+
+ /**
+ * @param parent
+ * @param selectedProblem
+ * @param resource
+ * @param style
+ */
+ public CustomizeProblemComposite(Composite parent,
+ IProblem selectedProblem, IResource resource) {
+ super(parent, SWT.NONE);
+ this.setLayout(new GridLayout(1, false));
+ this.problem = selectedProblem;
+ this.resource = resource;
+ final TabFolder tabFolder = new TabFolder(this, SWT.TOP);
+ tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
+ // createMainTab(tabFolder);
+ createParamtersTab(tabFolder);
+ createScopeTab(tabFolder);
+ }
+
+ public void save(IProblemWorkingCopy problem) {
+ problemsComposite.save(problem);
+ scopeComposite.save(problem);
+ }
+
+ /**
+ * @param tabFolder
+ */
+ private void createParamtersTab(TabFolder tabFolder) {
+ TabItem tabItem1 = new TabItem(tabFolder, SWT.NULL);
+ tabItem1.setText(CodanUIMessages.CustomizeProblemComposite_TabParameters);
+ parametersTab = new Composite(tabFolder, SWT.NONE);
+ tabItem1.setControl(parametersTab);
+ parametersTab.setLayout(new GridLayout());
+ problemsComposite = new ParametersComposite(parametersTab, problem);
+ problemsComposite.setLayoutData(new GridData(SWT.BEGINNING,
+ SWT.BEGINNING, true, false));
+ }
+
+ /**
+ * @param tabFolder
+ */
+ private void createScopeTab(TabFolder tabFolder) {
+ TabItem tabItem1 = new TabItem(tabFolder, SWT.NULL);
+ tabItem1.setText(CodanUIMessages.CustomizeProblemComposite_TabScope);
+ Composite comp = new Composite(tabFolder, SWT.NONE);
+ tabItem1.setControl(comp);
+ comp.setLayout(new GridLayout());
+ scopeComposite = new FileScopeComposite(comp, problem, resource);
+ scopeComposite.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING,
+ true, false));
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/FileScopeComposite.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/FileScopeComposite.java
new file mode 100644
index 0000000..1a8536c
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/FileScopeComposite.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.ui.widgets;
+
+import org.eclipse.cdt.codan.core.model.IProblem;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
+import org.eclipse.cdt.codan.core.param.FileScopeProblemPreference;
+import org.eclipse.cdt.codan.core.param.IProblemPreference;
+import org.eclipse.cdt.codan.core.param.MapProblemPreference;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
+import org.eclipse.cdt.codan.internal.ui.preferences.FileScopePreferencePage;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.preference.PreferenceStore;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * Composite to show problem scope
+ *
+ */
+public class FileScopeComposite extends Composite {
+ private FileScopePreferencePage page;
+ private IProblem problem;
+ private PreferenceStore prefStore;
+ private FileScopeProblemPreference scope;
+
+ /**
+ * @param parent
+ * @param problem
+ * @param resource
+ * @param style
+ */
+ public FileScopeComposite(Composite parent, final IProblem problem,
+ IResource resource) {
+ super(parent, SWT.NONE);
+ if (problem == null)
+ throw new NullPointerException();
+ this.setLayout(new GridLayout(2, false));
+ this.problem = problem;
+ this.prefStore = new PreferenceStore();
+ IProblemPreference info = problem.getPreference();
+ FileScopeProblemPreference scopeIn = null;
+ if (info == null
+ || (!(info instanceof MapProblemPreference))
+ || ((scopeIn = (FileScopeProblemPreference) ((MapProblemPreference) info)
+ .getChildDescriptor(FileScopeProblemPreference.KEY)) == null)) {
+ Label label = new Label(this, 0);
+ label.setText(CodanUIMessages.ParametersComposite_None);
+ return;
+ }
+ scope = (FileScopeProblemPreference) scopeIn.clone();
+ scope.setResource(resource);
+ initPrefStore();
+ page = new FileScopePreferencePage(scope);
+ page.setPreferenceStore(prefStore);
+ page.noDefaultAndApplyButton();
+ page.createControl(parent);
+ page.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
+ }
+
+ public void save(IProblemWorkingCopy problem) {
+ if (page != null)
+ page.performOk();
+ savePrefStore();
+ }
+
+ private void savePrefStore() {
+ if (scope == null)
+ return;
+ String key = scope.getQualifiedKey();
+ ((MapProblemPreference) problem.getPreference()).setChildValue(
+ FileScopeProblemPreference.KEY, scope);
+ prefStore.setValue(key, scope.exportValue());
+ }
+
+ private void initPrefStore() {
+ if (scope == null)
+ return;
+ String key = scope.getQualifiedKey();
+ prefStore.setValue(key, scope.exportValue());
+ }
+
+ /**
+ * @return the problem
+ */
+ public IProblem getProblem() {
+ return problem;
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java
new file mode 100644
index 0000000..26e58fc
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java
@@ -0,0 +1,261 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.internal.ui.widgets;
+
+import java.io.File;
+
+import org.eclipse.cdt.codan.core.model.IProblem;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
+import org.eclipse.cdt.codan.core.param.FileScopeProblemPreference;
+import org.eclipse.cdt.codan.core.param.IProblemPreference;
+import org.eclipse.cdt.codan.core.param.IProblemPreferenceCompositeDescriptor;
+import org.eclipse.cdt.codan.core.param.ListProblemPreference;
+import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.FileFieldEditor;
+import org.eclipse.jface.preference.ListEditor;
+import org.eclipse.jface.preference.PreferenceStore;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * Composite to show problem preferences
+ *
+ */
+public class ParametersComposite extends Composite {
+ private FieldEditorPreferencePage page;
+ private IProblem problem;
+ private PreferenceStore prefStore;
+
+ /**
+ * @param parent
+ * @param problem
+ * @param style
+ */
+ public ParametersComposite(Composite parent, final IProblem problem) {
+ super(parent, SWT.NONE);
+ if (problem == null)
+ throw new NullPointerException();
+ this.setLayout(new GridLayout(2, false));
+ this.problem = problem;
+ this.prefStore = new PreferenceStore();
+ page = new FieldEditorPreferencePage() {
+ @Override
+ protected void createFieldEditors() {
+ noDefaultAndApplyButton();
+ IProblemPreference pref = problem.getPreference();
+ createFieldEditorsForParameters(pref);
+ }
+
+ /**
+ * @param info
+ */
+ private void createFieldEditorsForParameters(
+ final IProblemPreference info) {
+ if (info == null)
+ return;
+ if (info.getKey() == FileScopeProblemPreference.KEY)
+ return; // skip the scope
+ switch (info.getType()) {
+ case TYPE_STRING: {
+ StringFieldEditor fe = new StringFieldEditor(
+ info.getQualifiedKey(), info.getLabel(),
+ getFieldEditorParent());
+ addField(fe);
+ break;
+ }
+ case TYPE_BOOLEAN: {
+ BooleanFieldEditor fe = new BooleanFieldEditor(
+ info.getQualifiedKey(), info.getLabel(),
+ getFieldEditorParent());
+ addField(fe);
+ break;
+ }
+ case TYPE_LIST:
+ ListEditor le = new ListEditor(info.getQualifiedKey(),
+ info.getLabel(), getFieldEditorParent()) {
+ @Override
+ protected String[] parseString(String stringList) {
+ ListProblemPreference list = (ListProblemPreference) info;
+ IProblemPreference[] childDescriptors = list
+ .getChildDescriptors();
+ if (childDescriptors.length == 0)
+ return new String[0];
+ String res[] = new String[childDescriptors.length];
+ for (int i = 0; i < childDescriptors.length; i++) {
+ IProblemPreference item = childDescriptors[i];
+ res[i] = String.valueOf(item.getValue());
+ }
+ return res;
+ }
+
+ @Override
+ protected String getNewInputObject() {
+ ListProblemPreference list = (ListProblemPreference) info;
+ String label = list.getChildDescriptor()
+ .getLabel();
+ InputDialog dialog = new InputDialog(
+ getShell(),
+ CodanUIMessages.ParametersComposite_NewValue,
+ label, "", null); //$NON-NLS-1$
+ if (dialog.open() == Window.OK) {
+ return dialog.getValue();
+ }
+ return null;
+ }
+
+ @Override
+ protected String createList(String[] items) {
+ ListProblemPreference list = (ListProblemPreference) info
+ .clone();
+ list.clear();
+ for (int i = 0; i < items.length; i++) {
+ String val = items[i];
+ list.addChildValue(val);
+ }
+ return list.exportValue();
+ }
+ };
+ addField(le);
+ break;
+ case TYPE_MAP:
+ IProblemPreference[] childrenDescriptor = ((IProblemPreferenceCompositeDescriptor) info)
+ .getChildDescriptors();
+ for (int i = 0; i < childrenDescriptor.length; i++) {
+ IProblemPreference desc = childrenDescriptor[i];
+ createFieldEditorsForParameters(desc);
+ }
+ break;
+ case TYPE_CUSTOM: {
+ StringFieldEditor fe = new StringFieldEditor(
+ info.getQualifiedKey(), info.getLabel(),
+ getFieldEditorParent());
+ addField(fe);
+ break;
+ }
+ case TYPE_FILE: {
+ FileFieldEditor fe = new FileFieldEditor(
+ info.getQualifiedKey(), info.getLabel(),
+ getFieldEditorParent());
+ addField(fe);
+ break;
+ }
+ default:
+ throw new UnsupportedOperationException(info.getType()
+ .toString());
+ }
+ }
+ };
+ IProblemPreference info = problem.getPreference();
+ if (info == null) {
+ Label label = new Label(this, 0);
+ label.setText(CodanUIMessages.ParametersComposite_None);
+ } else {
+ initPrefStore(info);
+ }
+ page.setPreferenceStore(prefStore);
+ page.createControl(parent);
+ page.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
+ }
+
+ public void save(IProblemWorkingCopy problem) {
+ page.performOk();
+ savePrefStore(problem.getPreference());
+ }
+
+ private void savePrefStore(IProblemPreference desc) {
+ if (desc == null)
+ return;
+ String key = desc.getQualifiedKey();
+ switch (desc.getType()) {
+ case TYPE_STRING:
+ desc.setValue(prefStore.getString(key));
+ break;
+ case TYPE_BOOLEAN:
+ desc.setValue(prefStore.getBoolean(key));
+ break;
+ case TYPE_INTEGER:
+ desc.setValue(prefStore.getInt(key));
+ break;
+ case TYPE_FILE:
+ desc.setValue(new File(prefStore.getString(key)));
+ break;
+ case TYPE_LIST:
+ desc.importValue(prefStore.getString(key));
+ break;
+ case TYPE_CUSTOM:
+ desc.importValue(prefStore.getString(key));
+ break;
+ case TYPE_MAP:
+ IProblemPreference[] childrenDescriptor = ((IProblemPreferenceCompositeDescriptor) desc)
+ .getChildDescriptors();
+ for (int i = 0; i < childrenDescriptor.length; i++) {
+ IProblemPreference chi = childrenDescriptor[i];
+ savePrefStore(chi);
+ }
+ break;
+ default:
+ throw new UnsupportedOperationException(desc.getType()
+ .toString());
+ }
+ }
+
+ private void initPrefStore(IProblemPreference desc) {
+ if (desc == null)
+ return;
+ String key = desc.getQualifiedKey();
+ switch (desc.getType()) {
+ case TYPE_STRING:
+ prefStore.setValue(key, (String) desc.getValue());
+ break;
+ case TYPE_BOOLEAN:
+ prefStore.setValue(key, (Boolean) desc.getValue());
+ break;
+ case TYPE_INTEGER:
+ prefStore.setValue(key, (Integer) desc.getValue());
+ break;
+ case TYPE_FILE:
+ prefStore.setValue(key, ((File) desc.getValue()).getPath());
+ break;
+ case TYPE_LIST:
+ prefStore.setValue(key, desc.exportValue());
+ break;
+ case TYPE_CUSTOM:
+ prefStore.setValue(key, desc.exportValue());
+ break;
+ case TYPE_MAP:
+ IProblemPreference[] childrenDescriptor = ((IProblemPreferenceCompositeDescriptor) desc)
+ .getChildDescriptors();
+ for (int i = 0; i < childrenDescriptor.length; i++) {
+ IProblemPreference chi = childrenDescriptor[i];
+ initPrefStore(chi);
+ }
+ break;
+ default:
+ throw new UnsupportedOperationException(desc.getType()
+ .toString());
+ }
+ }
+
+ /**
+ * @return the problem
+ */
+ public IProblem getProblem() {
+ return problem;
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstarctCodanCMarkerResolution.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstarctCodanCMarkerResolution.java
new file mode 100644
index 0000000..6a36763
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstarctCodanCMarkerResolution.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.ui;
+
+import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IMarkerResolution;
+import org.eclipse.ui.IMarkerResolution2;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * Generic class for codan marker resolution (for quick fix). Use as a base
+ * class for codanMarkerResolution extension. To add specific icon and
+ * description client class should additionally implement
+ * {@link IMarkerResolution2}
+ */
+public abstract class AbstarctCodanCMarkerResolution implements IMarkerResolution {
+ /**
+ * Get position offset from marker. If CHAR_START attribute is not set for
+ * marker, line and document would be used.
+ *
+ * @param marker
+ * @param doc
+ * @return
+ */
+ public int getOffset(IMarker marker, IDocument doc) {
+ int charStart = marker.getAttribute(IMarker.CHAR_START, -1);
+ int position;
+ if (charStart > 0) {
+ position = charStart;
+ } else {
+ int line = marker.getAttribute(IMarker.LINE_NUMBER, -1) - 1;
+ try {
+ position = doc.getLineOffset(line);
+ } catch (BadLocationException e) {
+ return -1;
+ }
+ }
+ return position;
+ }
+
+ /**
+ * Runs this resolution.
+ *
+ * @param marker
+ * the marker to resolve
+ */
+ public void run(IMarker marker) {
+ IEditorPart editorPart;
+ try {
+ editorPart = CodanEditorUtility.openInEditor(marker);
+ } catch (PartInitException e) {
+ CodanUIActivator.log(e);
+ return;
+ }
+ if (editorPart instanceof ITextEditor) {
+ ITextEditor editor = (ITextEditor) editorPart;
+ IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
+ apply(marker, doc);
+ }
+ }
+
+ /**
+ * Apply marker resolution for given marker in given open document.
+ *
+ * @param marker
+ * @param document
+ */
+ public abstract void apply(IMarker marker, IDocument document);
+
+ /**
+ * Override is extra checks is required to determine appicablity of marker resolution
+ * @param marker
+ * @return
+ */
+ public boolean isApplicable(IMarker marker) {
+ return true;
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanProblemDetailsProvider.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanProblemDetailsProvider.java
new file mode 100644
index 0000000..4fff924
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanProblemDetailsProvider.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.ui;
+
+import org.eclipse.cdt.codan.core.CodanRuntime;
+import org.eclipse.cdt.codan.core.model.IProblem;
+import org.eclipse.core.resources.IMarker;
+
+/**
+ * Abstract class that provides stubs for problems details.
+ * This class intended to be extended by the users of codanProblemDetails extension point.
+ * One instance of this class would exists at runtime. To query for results, framework
+ * would synchronize on this class object, set setMarker then call other getStyled* methods
+ * to obtain data.
+ */
+public abstract class AbstractCodanProblemDetailsProvider {
+ protected IMarker marker;
+
+ public AbstractCodanProblemDetailsProvider() {
+ }
+
+ /**
+ * sets the marker, called from framework to initialize provider
+ */
+ public void setMarker(IMarker marker) {
+ this.marker = marker;
+ }
+
+ /**
+ * Get marker associated with this provider
+ * @return
+ */
+ public IMarker getMarker() {
+ return marker;
+ }
+
+ /**
+ * Convenience method to return marker message
+ * @return
+ */
+ protected String getProblemMessage() {
+ String message = marker.getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$
+ return message;
+ }
+
+ /**
+ * Convenience method to return codan problem id
+ * @return
+ */
+ protected String getProblemId() {
+ String id = marker.getAttribute(IMarker.PROBLEM, (String) null);
+ return id;
+ }
+
+ /**
+ * return true if provider can provide details for given marker (previously set by setMarker)
+ * @param id - id of the problem
+ * @return true if details are available for given marker
+ */
+ public abstract boolean isApplicable(String id);
+
+ /**
+ * Return styled problem message. This text would be used in Link widget.
+ * String can include tags to which would be
+ * visible as hyperlinks and newline characters (\n). Default message if
+ * marker message plus location. Ampersand (&) should be escape because
+ * it is interpreted as mnemonic for control navigation (can use espaceForLink method).
+ * This method intended to be overriden by the client.
+ */
+ public String getStyledProblemMessage() {
+ String message = escapeForLink(getProblemMessage());
+ String href = getLocationHRef();
+ String link = href.replaceFirst("^file:", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ link = link.replaceFirst("#(\\d+)$", ":$1"); //$NON-NLS-1$//$NON-NLS-2$
+ return "" + link + " \n" + message; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ }
+ protected String getLocationHRef() {
+ return CodanEditorUtility.getLocationHRef(marker);
+ }
+ /**
+ * Return styled problem description. This text would be used in Link widget.
+ * String can include tags to which would be
+ * visible as hyperlinks and newline characters (\n).
+ * Ampersand (&) should be escape because
+ * it is interpreted as mnemonic for control navigation (can use espaceForLink method).
+ *
+ * Default implementation return desciption of codan problem.
+ * This method intended to be overriden by the client.
+ *
+ */
+ public String getStyledProblemDescription() {
+ String id = getProblemId();
+ if (id == null)
+ return ""; //$NON-NLS-1$
+ IProblem problem = CodanRuntime.getInstance().getChechersRegistry().getDefaultProfile().findProblem(id);
+ return escapeForLink(problem.getDescription());
+ }
+
+ /**
+ * Method to escape characters which are interpreted by Link swt control,
+ * such as & (mnemonic)
+ */
+ protected String escapeForLink(String text) {
+ return text.replaceAll("&", "&&"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/Activator.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/Activator.java
deleted file mode 100644
index 849993a..0000000
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/Activator.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.eclipse.cdt.codan.ui;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.cdt.codan.ui";
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
- * )
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
- * )
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
- /**
- * Returns an image descriptor for the image file at the given plug-in
- * relative path
- *
- * @param path
- * the path
- * @return the image descriptor
- */
- public static ImageDescriptor getImageDescriptor(String path) {
- return imageDescriptorFromPlugin(PLUGIN_ID, path);
- }
-
- /**
- * Logs the specified status with this plug-in's log.
- *
- * @param status
- * status to log
- */
- public static void log(IStatus status) {
- getDefault().getLog().log(status);
- }
-
- /**
- * Logs an internal error with the specified throwable
- *
- * @param e
- * the exception to be logged
- */
- public static void log(Throwable e) {
- log(new Status(IStatus.ERROR, PLUGIN_ID, 1, "Internal Error", e)); //$NON-NLS-1$
- }
-
- /**
- * Logs an internal error with the specified message.
- *
- * @param message
- * the error message to log
- */
- public static void log(String message) {
- log(new Status(IStatus.ERROR, PLUGIN_ID, 1, message, null));
- }
-}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CVS/Entries b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CVS/Entries
index 4387fb2..e02c292 100644
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CVS/Entries
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CVS/Entries
@@ -1,4 +1,6 @@
-/Activator.java/1.2/Fri Apr 24 12:49:44 2009//
-/CodanCReconciler.java/1.3/Sat Aug 22 21:16:50 2009//
-/Startup.java/1.1/Fri Apr 24 12:49:44 2009//
+/AbstarctCodanCMarkerResolution.java/1.4/Thu Jun 3 17:01:40 2010//TCDT_7_0_0
+/AbstractCodanProblemDetailsProvider.java/1.7/Sat May 8 01:19:46 2010//TCDT_7_0_0
+/CodanEditorUtility.java/1.1/Wed May 5 19:59:17 2010//TCDT_7_0_0
D/actions////
+D/handlers////
+D/views////
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CVS/Tag b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CVS/Template b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CVS/Template
deleted file mode 100644
index e69de29..0000000
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanCReconciler.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanCReconciler.java
deleted file mode 100644
index 5bec1c1..0000000
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanCReconciler.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * 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.ui;
-
-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;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-/**
- * @author Alena
- *
- */
-public class CodanCReconciler implements ICReconcilingListener {
- void install(ITextEditor editor) {
- if (editor instanceof CEditor) {
- initialize();
- ((CEditor) editor).addReconcileListener(this);
- }
- }
-
- void uninstall(ITextEditor editor) {
- if (editor instanceof CEditor) {
- initialize();
- ((CEditor) editor).removeReconcileListener(this);
- }
- }
-
- /**
- *
- */
- private void initialize() {
- // TODO Auto-generated method stub
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.cdt.internal.ui.text.ICReconcilingListener#aboutToBeReconciled
- * ()
- */
- public void aboutToBeReconciled() {
- // TODO Auto-generated method stub
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(org
- * .eclipse.cdt.core.dom.ast.IASTTranslationUnit, boolean,
- * org.eclipse.core.runtime.IProgressMonitor)
- */
- public void reconciled(IASTTranslationUnit ast, boolean force,
- IProgressMonitor progressMonitor) {
- CodanRuntime.getInstance().getAstQuickBuilder().reconcileAst(ast,
- progressMonitor);
- // System.err.println("ast reconsiled");
- }
-}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanEditorUtility.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanEditorUtility.java
new file mode 100644
index 0000000..1cdc5ef
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanEditorUtility.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * $QNXLicenseC:
+ * Copyright 2008, QNX Software Systems. All Rights Reserved.
+ *
+ * You must obtain a written license from and pay applicable license fees to QNX
+ * Software Systems before you may reproduce, modify or distribute this software,
+ * or any work that includes all or part of this software. Free development
+ * licenses are available for evaluation and non-commercial purposes. For more
+ * information visit http://licensing.qnx.com or email licensing@qnx.com.
+ *
+ * This file may contain contributions from others. Please review this entire
+ * file for other proprietary rights or license notices, as well as the QNX
+ * Development Suite License Guide at http://licensing.qnx.com/license-guide/
+ * for other information.
+ * $
+ *******************************************************************************/
+/*
+ * Created by: Elena Laskavaia
+ * Created on: 2010-05-05
+ * Last modified by: $Author: elaskavaia $
+ */
+package org.eclipse.cdt.codan.ui;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * Utility tools to open editor and highlight the line
+ */
+public class CodanEditorUtility {
+ /**
+ * @param fileUrl - file "url", like file:/tmp/a.c#22
+ * @throws PartInitException
+ * @throws BadLocationException
+ */
+ public static void openFileURL(String fileUrl, IResource markerResource) throws PartInitException, BadLocationException {
+ String file = getFileFromURL(fileUrl);
+
+ IEditorPart part = openInEditor(file, markerResource);
+ int line = getLineFromURL(fileUrl);
+ revealLine(part, line);
+ }
+
+ /**
+ * Line is the part the follows # in this URL
+ * @return -1 if not line found in URL, and line number if there is
+ */
+ public static int getLineFromURL(String fileUrl) {
+ String sline = fileUrl.replaceAll(".*#(\\d+)$", "$1"); //$NON-NLS-1$ //$NON-NLS-2$
+ int line = -1;
+ try {
+ line = Integer.parseInt(sline);
+ } catch (NumberFormatException e2) {
+ // no line
+ }
+ return line;
+ }
+
+ public static String getFileFromURL(String link) {
+ String file = link.replaceFirst("^file:", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ file = file.replaceAll("#\\d+$", ""); //$NON-NLS-1$//$NON-NLS-2$
+ return file;
+ }
+
+ public static void revealLine(IEditorPart part, int line) throws BadLocationException {
+ if (line > 0) {
+ if (part instanceof ITextEditor) {
+ ITextEditor textEditor = (ITextEditor) part;
+ IDocument document = textEditor.getDocumentProvider().getDocument(part.getEditorInput());
+ textEditor.selectAndReveal(document.getLineOffset(line - 1), 0);
+ }
+ }
+ }
+
+ @SuppressWarnings("restriction")
+ public static IEditorPart openInEditor(String file, IResource markerResource) throws PartInitException {
+ IPath pfile = new Path(file);
+ ICElement element = null;
+ if (markerResource != null)
+ CoreModel.getDefault().create(markerResource);
+ IEditorPart part = EditorUtility.openInEditor(pfile, element);
+ return part;
+ }
+
+ public static IEditorPart openInEditor(IMarker marker) throws PartInitException {
+ String href = getLocationHRef(marker);
+ String file = getFileFromURL(href);
+ return openInEditor(file, marker.getResource());
+ }
+
+ public static String getLocationHRef(IMarker marker) {
+ String loc = marker.getResource().getLocationURI().toString();
+ String loc2 = marker.getAttribute(IMarker.LOCATION, ""); //$NON-NLS-1$
+ int line = marker.getAttribute(IMarker.LINE_NUMBER, 0);
+ if (loc2.length() > 0) {
+ loc = "file:" + loc2.replaceAll("[^:]*: ", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ String href = loc + "#" + line; //$NON-NLS-1$
+ return href;
+ }
+}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/Startup.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/Startup.java
deleted file mode 100644
index 41fbf89..0000000
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/Startup.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * 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.ui;
-
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.IStartup;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-/**
- * @author Alena
- *
- */
-public class Startup implements IStartup {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IStartup#earlyStartup()
- */
- public void earlyStartup() {
- registerListeners();
- }
-
- /**
- * Register part listener for editor to install c ast reconcile listener
- */
- private void registerListeners() {
- final IWorkbench workbench = PlatformUI.getWorkbench();
- workbench.getDisplay().asyncExec(new Runnable() {
- public void run() {
- IWorkbenchWindow active = workbench.getActiveWorkbenchWindow();
- final IWorkbenchPage page = active.getActivePage();
- IPartListener2 partListener = new IPartListener2() {
- CodanCReconciler reconsiler = new CodanCReconciler();
-
- public void partActivated(IWorkbenchPartReference partRef) {
- }
-
- public void partDeactivated(IWorkbenchPartReference partRef) {
- }
-
- public void partOpened(IWorkbenchPartReference partRef) {
- IWorkbenchPart editor = partRef.getPart(false);
- if (editor instanceof ITextEditor) {
- reconsiler.install((ITextEditor) editor);
- }
- }
-
- public void partHidden(IWorkbenchPartReference partRef) {
- }
-
- public void partVisible(IWorkbenchPartReference partRef) {
- }
-
- public void partClosed(IWorkbenchPartReference partRef) {
- IWorkbenchPart part = partRef.getPart(false);
- if (part instanceof ITextEditor) {
- reconsiler.uninstall((ITextEditor) part);
- }
- }
-
- public void partBroughtToTop(IWorkbenchPartReference partRef) {
- }
-
- public void partInputChanged(IWorkbenchPartReference partRef) {
- }
- };
- page.addPartListener(partListener);
- // check current open editors
- IEditorReference[] editorReferences = page
- .getEditorReferences();
- for (int i = 0; i < editorReferences.length; i++) {
- IEditorReference ref = editorReferences[i];
- partListener.partOpened(ref);
- }
- }
- });
- }
-}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/CVS/Entries b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/CVS/Entries
deleted file mode 100644
index 30cf7ec..0000000
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/CVS/Entries
+++ /dev/null
@@ -1,2 +0,0 @@
-/RunCodeAnalysis.java/1.3/Sat Aug 22 21:16:50 2009//
-/ToggleNatureAction.java/1.2/Sat Aug 22 21:16:50 2009//
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/CVS/Repository b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/CVS/Repository
deleted file mode 100644
index 09c1aeb..0000000
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/CVS/Root b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/CVS/Root
deleted file mode 100644
index 04efa23..0000000
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/CVS/Template b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/CVS/Template
deleted file mode 100644
index e69de29..0000000
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/RunCodeAnalysis.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/RunCodeAnalysis.java
deleted file mode 100644
index 01d7c25..0000000
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/RunCodeAnalysis.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * 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.ui.actions;
-
-import java.util.Iterator;
-
-import org.eclipse.cdt.codan.core.CodanRuntime;
-import org.eclipse.core.resources.IResource;
-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;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-
-public class RunCodeAnalysis implements IObjectActionDelegate {
- private ISelection sel;
-
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- // nothing
- }
-
- public void run(IAction action) {
- 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) {
- this.sel = selection;
- }
-}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/ToggleNatureAction.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/ToggleNatureAction.java
deleted file mode 100644
index 3993621..0000000
--- a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/ToggleNatureAction.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * 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.ui.actions;
-
-import java.util.Iterator;
-
-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;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-
-public class ToggleNatureAction implements IObjectActionDelegate {
- private ISelection selection;
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run(IAction action) {
- if (selection instanceof IStructuredSelection) {
- for (Iterator it = ((IStructuredSelection) selection).iterator(); it
- .hasNext();) {
- Object element = it.next();
- IProject project = null;
- if (element instanceof IProject) {
- project = (IProject) element;
- } else if (element instanceof IAdaptable) {
- project = (IProject) ((IAdaptable) element)
- .getAdapter(IProject.class);
- }
- if (project != null) {
- toggleNature(project, !hasCodanNature(project));
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action
- * .IAction, org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- this.selection = selection;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.
- * action.IAction, org.eclipse.ui.IWorkbenchPart)
- */
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- }
-
- public boolean hasCodanNature(IProject project) {
- IProjectDescription description;
- try {
- description = project.getDescription();
- String[] natures = description.getNatureIds();
- for (int i = 0; i < natures.length; ++i) {
- if (CodanCorePlugin.NATURE_ID.equals(natures[i])) {
- return true;
- }
- }
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return false;
- }
-
- /**
- * Toggles sample nature on a project
- *
- * @param project
- * to have sample nature added or removed
- */
- public void toggleNature(IProject project, boolean add) {
- try {
- IProjectDescription description = project.getDescription();
- String[] natures = description.getNatureIds();
- for (int i = 0; i < natures.length; ++i) {
- if (CodanCorePlugin.NATURE_ID.equals(natures[i])) {
- if (add == false) {
- // Remove the nature
- String[] newNatures = new String[natures.length - 1];
- System.arraycopy(natures, 0, newNatures, 0, i);
- System.arraycopy(natures, i + 1, newNatures, i,
- natures.length - i - 1);
- description.setNatureIds(newNatures);
- project.setDescription(description, null);
- return;
- } else {
- // already there no need to add
- add = false;
- break;
- }
- }
- }
- if (add) {
- // Add the nature
- String[] newNatures = new String[natures.length + 1];
- System.arraycopy(natures, 0, newNatures, 0, natures.length);
- newNatures[natures.length] = CodanCorePlugin.NATURE_ID;
- description.setNatureIds(newNatures);
- project.setDescription(description, null);
- }
- } catch (CoreException e) {
- }
- }
-}
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/CVS/Entries b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/CVS/Entries
new file mode 100644
index 0000000..8a29f40
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/CVS/Entries
@@ -0,0 +1 @@
+/RunCodanCommand.java/1.3/Thu Jun 3 17:01:40 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/CVS/Repository b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/CVS/Repository
new file mode 100644
index 0000000..c8ef8af
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/CVS/Root b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/CVS/Tag b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/RunCodanCommand.java b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/RunCodanCommand.java
new file mode 100644
index 0000000..d0999a8
--- /dev/null
+++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/RunCodanCommand.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.ui.handlers;
+
+import org.eclipse.cdt.codan.internal.ui.actions.RunCodeAnalysis;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Command to run code analysis on selected resources
+ * @see org.eclipse.core.commands.IHandler
+ * @see org.eclipse.core.commands.AbstractHandler
+ */
+public class RunCodanCommand extends AbstractHandler {
+
+ public RunCodanCommand() {
+ }
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
+ RunCodeAnalysis action = new RunCodeAnalysis();
+ action.selectionChanged(null, currentSelection);
+ action.run(null);
+ return null;
+ }
+}
--
cgit