From af92b8417ae76946c7d10772d8848abbe1126209 Mon Sep 17 00:00:00 2001 From: Elliott Baron Date: Wed, 16 Dec 2009 16:51:53 -0500 Subject: Update codan plugins to HEAD. * org.eclipse.cdt.codan.checkers.ui: Updated. * org.eclipse.cdt.codan.checkers: Updated. * org.eclipse.cdt.codan.core: Updated. * org.eclipse.cdt.codan.ui: Updated. --- .../codan/core/model/AbstractIndexAstChecker.java | 14 ++- .../org/eclipse/cdt/codan/core/model/CVS/Entries | 15 ++- .../org/eclipse/cdt/codan/core/model/CVS/Template | 0 .../org/eclipse/cdt/codan/core/model/IChecker.java | 16 +++- .../org/eclipse/cdt/codan/core/model/IProblem.java | 28 ++++++ .../cdt/codan/core/model/IProblemCategory.java | 19 +++- .../cdt/codan/core/model/IProblemElement.java | 2 +- .../cdt/codan/core/model/IProblemProfile.java | 6 +- .../cdt/codan/core/model/IProblemReporter.java | 1 + .../cdt/codan/core/model/ProblemProfile.java | 103 --------------------- 10 files changed, 84 insertions(+), 120 deletions(-) create mode 100644 org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Template delete mode 100644 org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.java (limited to 'org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model') 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 index 2c87b07..d805f2f 100644 --- 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 @@ -85,12 +85,18 @@ public abstract class AbstractIndexAstChecker extends AbstractChecker implements if (astFile == null) { astFile = file; } - getProblemReporter().reportProblem( - id, - new ProblemLocation(astFile, astLocation - .getStartingLineNumber()), message); + 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/CVS/Entries b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Entries index 736d312..8635b9d 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,17 +1,16 @@ /AbstractChecker.java/1.4/Sat Aug 22 21:31:29 2009// -/AbstractIndexAstChecker.java/1.5/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.2/Sat Aug 22 21:31:29 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.3/Sat Aug 22 21:16:48 2009// -/IProblemCategory.java/1.2/Thu Apr 16 01:46:57 2009// -/IProblemElement.java/1.1/Thu Apr 16 01:46:57 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.3/Sat May 9 01:54:38 2009// -/IProblemReporter.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// -/ProblemProfile.java/1.4/Sat Aug 22 21:16:48 2009// D diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Template b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Template new file mode 100644 index 0000000..e69de29 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 4f995db..60f7cb2 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 @@ -12,9 +12,23 @@ 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. + */ public interface IChecker { - public boolean processResource(IResource resource); + /** + * Main method that checker should implement that actually detects errors + * @param resource - resource to run on + * @return true if need to traverse children + */ + 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 + * @param resource + * @return + */ boolean enabledInContext(IResource resource); /** 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 52cfff2..bbab313 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 @@ -12,15 +12,38 @@ package org.eclipse.cdt.codan.core.model; import java.util.Collection; +/** + * Interface representing code analysis problem + * + */ public interface IProblem extends IProblemElement { + /** + * Name of the problem - user visible "title", not the message + */ String getName(); + /** + * Unique problem id. Should be qualified by plugin name to maintain uniqueness. + * @return + */ 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 + */ String getMessagePattern(); void setSeverity(CodanSeverity sev); @@ -31,6 +54,11 @@ public interface IProblem extends IProblemElement { public void setProperty(Object key, Object value); + /** + * Get custom property + * @param property name + * @return property object + */ public Object getProperty(Object key); public Collection getPropertyKeys(); diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemCategory.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemCategory.java index 45a62a0..cd3de3a 100644 --- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemCategory.java +++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemCategory.java @@ -10,20 +10,37 @@ *******************************************************************************/ package org.eclipse.cdt.codan.core.model; +/** + * Problem category + * + */ public interface IProblemCategory extends IProblemElement { + /** + * Category name + */ String getName(); + /** + * Unique category id + * @return id + */ String getId(); - Object[] getChildren(); + /** + * Category children (other categories or problems) + * @return + */ + IProblemElement[] getChildren(); /** + * Find problem by id within children recursively * @param id * @return */ IProblem findProblem(String id); /** + * Find category by id within children recursively * @param id * @return */ diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java index b9f7fb8..318f304 100644 --- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java +++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java @@ -11,7 +11,7 @@ package org.eclipse.cdt.codan.core.model; /** - * @author Alena + * Problem category or problem * */ public interface IProblemElement extends Cloneable { diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java index 9dc465e..896eb10 100644 --- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java +++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java @@ -11,8 +11,10 @@ package org.eclipse.cdt.codan.core.model; /** - * Problem Profile contains tree of categories and problems. Profiles can have - * different categories and different problems set, problems with the same id + * Problem Profile contains tree of categories and problems. For user profile is quick way + * to switch between problems sets depends on task he is doing (i.e. find real bugs, vs doing code style report) + * User can set different profiles in different projects. + * Profiles can have different categories and different problems set, problems with the same id * can have different severities/enablement in different profiles. To obtain * profile use class {@link CheckersRegisry#getResourceProfile, * CheckersRegisry#getDefaultProfile() or CheckersRegisry#getWorkspaceProfile()} diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java index 814cc40..059f155 100644 --- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java +++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java @@ -16,6 +16,7 @@ package org.eclipse.cdt.codan.core.model; * */ public interface IProblemReporter { + public static final String GENERIC_CODE_ANALYSIS_MARKER_TYPE = "org.eclipse.cdt.codan.core.codanProblem"; /** * Report a problem with "problemId" id on location determined by "loc", * using problem specific error message customised by args. diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.java deleted file mode 100644 index ae90e76..0000000 --- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.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 java.util.ArrayList; -import java.util.Collection; - -import org.eclipse.cdt.codan.internal.core.model.CodanProblemCategory; - -/** - * @author Alena - * - */ -public class ProblemProfile implements IProblemProfile, Cloneable { - private IProblemCategory rootCategory = new CodanProblemCategory("root", - "root"); - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.cdt.codan.core.model.IProblemProfile#getProblem(java.lang - * .String) - */ - public IProblem findProblem(String id) { - return getRoot().findProblem(id); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.codan.core.model.IProblemProfile#getProblems() - */ - public IProblem[] getProblems() { - Collection problems = new ArrayList(); - collectProblems(getRoot(), problems); - return problems.toArray(new IProblem[problems.size()]); - } - - /** - * @param root - * @param problems - */ - protected void collectProblems(IProblemCategory parent, - Collection problems) { - Object[] children = parent.getChildren(); - for (Object object : children) { - if (object instanceof IProblemCategory) { - IProblemCategory cat = (IProblemCategory) object; - collectProblems(cat, problems); - } else if (object instanceof IProblem) { - problems.add((IProblem) object); - } - } - } - - public IProblemCategory getRoot() { - return rootCategory; - } - - public void addProblem(IProblem p, IProblemCategory cat) { - if (cat == null) - cat = getRoot(); - ((CodanProblemCategory) cat).addChild(p); - } - - public IProblemCategory findCategory(String id) { - return getRoot().findCategory(id); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#clone() - */ - @Override - public Object clone() { - try { - ProblemProfile clone = (ProblemProfile) super.clone(); - clone.rootCategory = (IProblemCategory) ((CodanProblemCategory) this.rootCategory) - .clone(); - return clone; - } catch (CloneNotSupportedException e) { - return this; - } - } - - /** - * @param p - * @param cat - */ - public void addCategory(IProblemCategory category, IProblemCategory parent) { - ((CodanProblemCategory) parent).addChild(category); - } -} -- cgit