diff options
77 files changed, 516 insertions, 59 deletions
diff --git a/org.eclipse.cdt.codan.checkers.ui/.classpath b/org.eclipse.cdt.codan.checkers.ui/.classpath index 1fa3e68..64c5e31 100644 --- a/org.eclipse.cdt.codan.checkers.ui/.classpath +++ b/org.eclipse.cdt.codan.checkers.ui/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/org.eclipse.cdt.codan.checkers.ui/.settings/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/.settings/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/.settings/CVS/Template diff --git a/org.eclipse.cdt.codan.checkers.ui/CVS/Entries b/org.eclipse.cdt.codan.checkers.ui/CVS/Entries index 47e41bc..1583ce7 100644 --- a/org.eclipse.cdt.codan.checkers.ui/CVS/Entries +++ b/org.eclipse.cdt.codan.checkers.ui/CVS/Entries @@ -1,4 +1,4 @@ -/.classpath/1.1/Sat Apr 18 02:11:07 2009// +/.classpath/1.2/Wed Dec 16 21:48:51 2009// /.project/1.1/Sat Apr 18 02:11:07 2009// D/.settings//// D/META-INF//// diff --git a/org.eclipse.cdt.codan.checkers.ui/META-INF/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/META-INF/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/META-INF/CVS/Template diff --git a/org.eclipse.cdt.codan.checkers.ui/src/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/src/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/CVS/Template diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/src/org/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/CVS/Template diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/CVS/Template diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/CVS/Template diff --git a/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Template b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/CVS/Template 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 new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/CVS/Template 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 new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CVS/Template 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 new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/quickfix/CVS/Template diff --git a/org.eclipse.cdt.codan.checkers/.classpath b/org.eclipse.cdt.codan.checkers/.classpath index 1fa3e68..64c5e31 100644 --- a/org.eclipse.cdt.codan.checkers/.classpath +++ b/org.eclipse.cdt.codan.checkers/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/org.eclipse.cdt.codan.checkers/.settings/CVS/Template b/org.eclipse.cdt.codan.checkers/.settings/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers/.settings/CVS/Template diff --git a/org.eclipse.cdt.codan.checkers/CVS/Entries b/org.eclipse.cdt.codan.checkers/CVS/Entries index 79d42fe..f0bd9f5 100644 --- a/org.eclipse.cdt.codan.checkers/CVS/Entries +++ b/org.eclipse.cdt.codan.checkers/CVS/Entries @@ -1,7 +1,7 @@ -/.classpath/1.2/Fri Apr 17 20:50:15 2009// +/.classpath/1.3/Wed Dec 16 21:48:51 2009// /.project/1.1/Thu Apr 9 12:48:43 2009// D/.settings//// D/META-INF//// /build.properties/1.1/Thu Apr 9 12:48:44 2009// -/plugin.xml/1.5/Sat May 9 01:16:26 2009// +/plugin.xml/1.7/Wed Dec 16 21:48:51 2009// D/src//// diff --git a/org.eclipse.cdt.codan.checkers/META-INF/CVS/Template b/org.eclipse.cdt.codan.checkers/META-INF/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers/META-INF/CVS/Template diff --git a/org.eclipse.cdt.codan.checkers/plugin.xml b/org.eclipse.cdt.codan.checkers/plugin.xml index e2dac3e..63b999e 100644 --- a/org.eclipse.cdt.codan.checkers/plugin.xml +++ b/org.eclipse.cdt.codan.checkers/plugin.xml @@ -40,5 +40,28 @@ name="Class has a virtual method and non-virtual destructor"> </problem> </checker> + + <checker + class="org.eclipse.cdt.codan.checkers.sample.CatchUsesReference" + id="org.eclipse.cdt.codan.checkers.sample.CatchUsesReference" + name="CatchUsesReferenceChecker"> + <problem + category="org.eclipse.cdt.codan.core.categories.ProgrammingProblems" + defaultSeverity="Warning" + id="org.eclipse.cdt.codan.checkers.sample.CatchUsesReference" + name="Catch uses reference to exception"> + </problem> + </checker> + <checker + class="org.eclipse.cdt.codan.checkers.sample.SuggestedParenthesisChecker" + id="org.eclipse.cdt.codan.checkers.sample.SuggestedParenthesisChecker" + name="SuggestedParenthesisChecker"> + <problem + category="org.eclipse.cdt.codan.core.categories.ProgrammingProblems" + defaultSeverity="Warning" + id="org.eclipse.cdt.codan.checkers.sample.SuggestedParenthesisProblem" + name="Suggested parenthesis around expression"> + </problem> + </checker> </extension> </plugin> diff --git a/org.eclipse.cdt.codan.checkers/src/CVS/Template b/org.eclipse.cdt.codan.checkers/src/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers/src/CVS/Template diff --git a/org.eclipse.cdt.codan.checkers/src/org/CVS/Template b/org.eclipse.cdt.codan.checkers/src/org/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers/src/org/CVS/Template diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/CVS/Template b/org.eclipse.cdt.codan.checkers/src/org/eclipse/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/CVS/Template diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/CVS/Template b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/CVS/Template diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/CVS/Template b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/CVS/Template diff --git a/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/CVS/Template b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/CVS/Template 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 index 7071b8d..705d9ab 100644 --- 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 @@ -1,3 +1,5 @@ /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/Template b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/CVS/Template 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 new file mode 100644 index 0000000..b3556cc --- /dev/null +++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/CatchUsesReference.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * 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/SuggestedParenthesisChecker.java b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/SuggestedParenthesisChecker.java new file mode 100644 index 0000000..27712b4 --- /dev/null +++ b/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/checkers/sample/SuggestedParenthesisChecker.java @@ -0,0 +1,143 @@ +/******************************************************************************* + * 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.core/.classpath b/org.eclipse.cdt.codan.core/.classpath index 16d067f..5e4c1fe 100644 --- a/org.eclipse.cdt.codan.core/.classpath +++ b/org.eclipse.cdt.codan.core/.classpath @@ -2,6 +2,6 @@ <classpath> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/org.eclipse.cdt.codan.core/.settings/CVS/Entries b/org.eclipse.cdt.codan.core/.settings/CVS/Entries index b6cae13..eb6c3d6 100644 --- a/org.eclipse.cdt.codan.core/.settings/CVS/Entries +++ b/org.eclipse.cdt.codan.core/.settings/CVS/Entries @@ -1,2 +1,3 @@ /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 diff --git a/org.eclipse.cdt.codan.core/.settings/CVS/Template b/org.eclipse.cdt.codan.core/.settings/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.core/.settings/CVS/Template 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 new file mode 100644 index 0000000..2117213 --- /dev/null +++ b/org.eclipse.cdt.codan.core/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,54 @@ +#Fri Nov 20 13:57:56 EST 2009 +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_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=true +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.core/CVS/Entries b/org.eclipse.cdt.codan.core/CVS/Entries index 2fa8e25..cb575f0 100644 --- a/org.eclipse.cdt.codan.core/CVS/Entries +++ b/org.eclipse.cdt.codan.core/CVS/Entries @@ -1,4 +1,4 @@ -/.classpath/1.2/Fri Apr 17 20:50:15 2009// +/.classpath/1.3/Wed Dec 16 21:48:48 2009// /.project/1.1/Thu Apr 9 12:46:50 2009// D/.settings//// D/META-INF//// diff --git a/org.eclipse.cdt.codan.core/META-INF/CVS/Entries b/org.eclipse.cdt.codan.core/META-INF/CVS/Entries index 86baf3a..222d593 100644 --- a/org.eclipse.cdt.codan.core/META-INF/CVS/Entries +++ b/org.eclipse.cdt.codan.core/META-INF/CVS/Entries @@ -1,2 +1,2 @@ -/MANIFEST.MF/1.4/Sat Aug 22 21:16:49 2009// +/MANIFEST.MF/1.5/Wed Dec 16 21:48:48 2009// D diff --git a/org.eclipse.cdt.codan.core/META-INF/CVS/Template b/org.eclipse.cdt.codan.core/META-INF/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.core/META-INF/CVS/Template diff --git a/org.eclipse.cdt.codan.core/META-INF/MANIFEST.MF b/org.eclipse.cdt.codan.core/META-INF/MANIFEST.MF index b77eb2c..b6eba46 100644 --- a/org.eclipse.cdt.codan.core/META-INF/MANIFEST.MF +++ b/org.eclipse.cdt.codan.core/META-INF/MANIFEST.MF @@ -11,4 +11,5 @@ Require-Bundle: org.eclipse.core.runtime, Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Package: org.eclipse.cdt.codan.core, - org.eclipse.cdt.codan.core.model + 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" diff --git a/org.eclipse.cdt.codan.core/schema/CVS/Template b/org.eclipse.cdt.codan.core/schema/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.core/schema/CVS/Template diff --git a/org.eclipse.cdt.codan.core/src/CVS/Template b/org.eclipse.cdt.codan.core/src/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.core/src/CVS/Template diff --git a/org.eclipse.cdt.codan.core/src/org/CVS/Template b/org.eclipse.cdt.codan.core/src/org/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.core/src/org/CVS/Template diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/CVS/Template b/org.eclipse.cdt.codan.core/src/org/eclipse/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.core/src/org/eclipse/CVS/Template diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/CVS/Template b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/CVS/Template diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/CVS/Template b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/CVS/Template 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 fec4197..d3c5192 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,5 @@ /CodanApplication.java/1.2/Sat Aug 22 21:16:48 2009// /CodanCorePlugin.java/1.3/Sat Aug 22 21:16:48 2009// -/CodanPreferencesLoader.java/1.1/Sat Aug 22 21:16:49 2009// /CodanRuntime.java/1.1/Sat Aug 22 21:16:48 2009// /PreferenceConstants.java/1.2/Sat Apr 18 04:01:43 2009// D/builder//// diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CVS/Template b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CVS/Template 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 --- /dev/null +++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Template 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<Object> 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/internal/CVS/Template b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/CVS/Template diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CVS/Entries b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CVS/Entries index 74cd7a6..49bf43c 100644 --- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CVS/Entries +++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CVS/Entries @@ -1,4 +1,5 @@ -/CheckersRegisry.java/1.1/Sat Aug 22 21:16:49 2009// -/CodanBuilder.java/1.2/Sat Aug 22 21:31:29 2009// +/CheckersRegisry.java/1.3/Wed Dec 16 21:48:48 2009// +/CodanBuilder.java/1.3/Wed Dec 16 21:48:48 2009// +/CodanPreferencesLoader.java/1.1/Wed Sep 23 23:29:36 2009// /CodeAnlysisNature.java/1.1/Sat Aug 22 21:16:49 2009// D/model//// diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CVS/Template b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CVS/Template 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 index 82ace80..5661622 100644 --- 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 @@ -16,16 +16,15 @@ import java.util.HashMap; import java.util.Iterator; import org.eclipse.cdt.codan.core.CodanCorePlugin; -import org.eclipse.cdt.codan.core.CodanPreferencesLoader; import org.eclipse.cdt.codan.core.PreferenceConstants; import org.eclipse.cdt.codan.core.model.IChecker; import org.eclipse.cdt.codan.core.model.ICheckersRegistry; import org.eclipse.cdt.codan.core.model.IProblem; import org.eclipse.cdt.codan.core.model.IProblemCategory; import org.eclipse.cdt.codan.core.model.IProblemProfile; -import org.eclipse.cdt.codan.core.model.ProblemProfile; import org.eclipse.cdt.codan.internal.core.model.CodanProblem; import org.eclipse.cdt.codan.internal.core.model.CodanProblemCategory; +import org.eclipse.cdt.codan.internal.core.model.ProblemProfile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ProjectScope; @@ -45,6 +44,7 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry { private Collection<IChecker> checkers = new ArrayList<IChecker>(); private static CheckersRegisry instance; private HashMap<Object, IProblemProfile> profiles = new HashMap<Object, IProblemProfile>(); + private HashMap<IChecker, Collection<IProblem>> problemList = new HashMap<IChecker, Collection<IProblem>>(); private CheckersRegisry() { instance = this; @@ -136,7 +136,9 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry { } } if (!hasRef) { - addProblem(new CodanProblem(id, name), null); + CodanProblem p = new CodanProblem(id, name); + addProblem(p, null); + addRefProblem(checkerObj, p); } } } catch (Exception e) { @@ -184,7 +186,9 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry { return elementValue; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#iterator() */ public Iterator<IChecker> iterator() { @@ -197,15 +201,23 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry { return instance; } - /* (non-Javadoc) - * @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#addChecker(org.eclipse.cdt.codan.core.model.IChecker) + /* + * (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) + /* + * (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); @@ -214,8 +226,12 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry { ((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) + /* + * (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); @@ -224,21 +240,46 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry { ((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) + /* + * (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<IProblem> plist = problemList.get(c); + if (plist == null) { + plist = new ArrayList<IProblem>(); + problemList.put(c, plist); + } + plist.add(p); + } + + /** + * Returns list of problems registered for given checker + * @return collection of problems or null + */ + public Collection<IProblem> getRefProblems(IChecker checker) { + return problemList.get(checker); } - /* (non-Javadoc) - * @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#getDefaultProfile() + /* + * (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() + /* + * (non-Javadoc) + * + * @see + * org.eclipse.cdt.codan.core.model.ICheckersRegistry#getWorkspaceProfile() */ public IProblemProfile getWorkspaceProfile() { IProblemProfile wp = profiles.get(ResourcesPlugin.getWorkspace()); @@ -262,8 +303,12 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry { profiles.put(element, profile); } - /* (non-Javadoc) - * @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#getResourceProfile(org.eclipse.core.resources.IResource) + /* + * (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); @@ -296,8 +341,11 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry { return prof; } - /* (non-Javadoc) - * @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#getResourceProfileWorkingCopy(org.eclipse.core.resources.IResource) + /* + * (non-Javadoc) + * + * @seeorg.eclipse.cdt.codan.core.model.ICheckersRegistry# + * getResourceProfileWorkingCopy(org.eclipse.core.resources.IResource) */ public IProblemProfile getResourceProfileWorkingCopy(IResource element) { if (element instanceof IProject) { 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 7d58351..56916b8 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 @@ -12,6 +12,8 @@ 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; @@ -20,6 +22,8 @@ import org.eclipse.cdt.codan.core.model.ICAstChecker; import org.eclipse.cdt.codan.core.model.IChecker; import org.eclipse.cdt.codan.core.model.ICodanAstReconciler; import org.eclipse.cdt.codan.core.model.ICodanBuilder; +import org.eclipse.cdt.codan.core.model.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; @@ -122,6 +126,8 @@ public class CodanBuilder extends IncrementalProjectBuilder implements boolean run = false; if (checker.enabledInContext(resource)) run = true; + if (areProblemsForCheckerEnabled(checker, resource)) + run = true; if (run) checker.processResource(resource); } catch (Throwable e) { @@ -161,6 +167,9 @@ public class CodanBuilder extends IncrementalProjectBuilder implements boolean run = false; if (checker.enabledInContext(resource)) run = true; + if (areProblemsForCheckerEnabled(checker, resource)) { + run = true; + } if (run && checker instanceof ICAstChecker && checker.runInEditor()) ((ICAstChecker) checker).processAst(ast); @@ -171,6 +180,30 @@ public class CodanBuilder extends IncrementalProjectBuilder implements } } + /** + * @param checker + * @param resource + * @return + */ + private boolean areProblemsForCheckerEnabled(IChecker checker, + IResource resource) { + IProblemProfile resourceProfile = CheckersRegisry.getInstance() + .getResourceProfile(resource); + Collection<IProblem> 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 { diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanPreferencesLoader.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanPreferencesLoader.java index 6fd6318..bafff9a 100644 --- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanPreferencesLoader.java +++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanPreferencesLoader.java @@ -8,7 +8,7 @@ * Contributors: * Alena Laskavaia - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.codan.core; +package org.eclipse.cdt.codan.internal.core; import org.eclipse.cdt.codan.core.model.CodanSeverity; import org.eclipse.cdt.codan.core.model.IProblem; 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 cf1f6cc..5f7a029 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,4 +1,5 @@ -/CodanMarkerProblemReporter.java/1.1/Sat Aug 22 21:16:48 2009// +/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.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 diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CVS/Template b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CVS/Template 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 ebf00c9..a4599c5 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 @@ -23,7 +23,7 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; public class CodanMarkerProblemReporter implements IProblemReporter { - public static final String GENERIC_CODE_ANALYSIS_MARKER_TYPE = "org.eclipse.cdt.codan.core.codanProblem"; + /* * (non-Javadoc) 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 289e0fd..fc63480 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 @@ -40,8 +40,8 @@ public class CodanProblemCategory implements IProblemCategory, Cloneable { return name; } - public Object[] getChildren() { - return list.toArray(); + public IProblemElement[] getChildren() { + return (IProblemElement[]) list.toArray(new IProblemElement[list.size()]); } public void addChild(IProblemElement p) { 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/internal/core/model/ProblemProfile.java index ae90e76..d2330f1 100644 --- 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/internal/core/model/ProblemProfile.java @@ -8,12 +8,14 @@ * Contributors: * Alena Laskavaia - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.codan.core.model; +package org.eclipse.cdt.codan.internal.core.model; import java.util.ArrayList; import java.util.Collection; -import org.eclipse.cdt.codan.internal.core.model.CodanProblemCategory; +import org.eclipse.cdt.codan.core.model.IProblem; +import org.eclipse.cdt.codan.core.model.IProblemCategory; +import org.eclipse.cdt.codan.core.model.IProblemProfile; /** * @author Alena diff --git a/org.eclipse.cdt.codan.ui/.settings/CVS/Template b/org.eclipse.cdt.codan.ui/.settings/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.ui/.settings/CVS/Template diff --git a/org.eclipse.cdt.codan.ui/META-INF/CVS/Template b/org.eclipse.cdt.codan.ui/META-INF/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.ui/META-INF/CVS/Template diff --git a/org.eclipse.cdt.codan.ui/src/CVS/Template b/org.eclipse.cdt.codan.ui/src/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.ui/src/CVS/Template diff --git a/org.eclipse.cdt.codan.ui/src/org/CVS/Template b/org.eclipse.cdt.codan.ui/src/org/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.ui/src/org/CVS/Template diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/CVS/Template b/org.eclipse.cdt.codan.ui/src/org/eclipse/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/CVS/Template diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/CVS/Template b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/CVS/Template diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/CVS/Template b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/CVS/Template diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/CVS/Template b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/CVS/Template diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CVS/Template b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CVS/Template 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 fb8ead1..980f899 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 @@ -5,4 +5,4 @@ /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.7/Sat Aug 22 21:16:50 2009// +/ProblemsTreeEditor.java/1.8/Wed Dec 16 21:48:50 2009// diff --git a/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Template b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CVS/Template 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 6ba82c6..26e433e 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 @@ -10,12 +10,12 @@ *******************************************************************************/ package org.eclipse.cdt.codan.internal.ui.preferences; -import org.eclipse.cdt.codan.core.CodanPreferencesLoader; import org.eclipse.cdt.codan.core.PreferenceConstants; import org.eclipse.cdt.codan.core.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.IProblemProfile; +import org.eclipse.cdt.codan.internal.core.CodanPreferencesLoader; import org.eclipse.jface.viewers.BaseLabelProvider; import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.CheckStateChangedEvent; 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 new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CVS/Template 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 new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/actions/CVS/Template |