1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Externalized strings

This commit is contained in:
Alena Laskavaia 2010-05-13 02:07:25 +00:00
parent 94cb067beb
commit 53845ca38e
6 changed files with 19 additions and 27 deletions

View file

@ -13,6 +13,7 @@
defaultSeverity="Warning"
description="Finds statements like 'if (a=b)'"
id="org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem"
messagePattern="Possible assignment in condition"
name="Assignment in condition">
</problem>
@ -39,6 +40,7 @@
category="org.eclipse.cdt.codan.core.categories.ProgrammingProblems"
defaultSeverity="Warning"
id="org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem"
messagePattern="Class &apos;&apos;{0}&apos;&apos; has virtual method &apos;&apos;{1}&apos;&apos; but non-virtual destructor &apos;&apos;{2}&apos;&apos;"
name="Class has a virtual method and non-virtual destructor">
</problem>
</checker>
@ -63,8 +65,8 @@
<problem
category="org.eclipse.cdt.codan.core.categories.ProgrammingProblems"
defaultSeverity="Warning"
description="This checker finds a problems that caused by lack of understanding operator precedence in C. Example (! x&gt;0 &amp;&amp; x&lt;10). Parenthesis should be used to clarify programmer's intent."
id="org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem"
messagePattern="Suggested parenthesis around expression"
name="Suggested parenthesis around expression">
</problem>
</checker>

View file

@ -10,7 +10,7 @@ import org.osgi.framework.BundleContext;
*/
public class CodanCheckersActivator extends Plugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.cdt.codan.checkers";
public static final String PLUGIN_ID = "org.eclipse.cdt.codan.checkers"; //$NON-NLS-1$
// The shared instance
private static CodanCheckersActivator plugin;

View file

@ -20,7 +20,7 @@ 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";
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.
@ -35,7 +35,7 @@ public class AssignmentInConditionChecker extends AbstractIndexAstChecker {
public int visit(IASTExpression expression) {
if (isAssignmentExpression(expression)
&& isUsedAsCondition(expression)) {
reportProblem(ER_ID, expression, "Possible assignment in condition");
reportProblem(ER_ID, expression);
}
return PROCESS_CONTINUE;
}

View file

@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers;
import java.text.MessageFormat;
import org.eclipse.cdt.codan.checkers.CodanCheckersActivator;
import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
@ -33,7 +31,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
*
*/
public class NonVirtualDestructor extends AbstractIndexAstChecker {
private static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem";
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.
@ -43,7 +41,7 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker {
class OnEachClass extends ASTVisitor {
private IASTName className;
private IBinding virMethodName;
private IBinding destName;
private IBinding destructorName;
OnEachClass() {
// shouldVisitDeclarations = true;
@ -55,22 +53,17 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker {
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;
if (destructorName != null) {
if (destructorName instanceof ICPPInternalBinding) {
ICPPInternalBinding bin = (ICPPInternalBinding) destructorName;
IASTNode[] decls = bin.getDeclarations();
if (decls!=null && decls.length>0)
ast = decls[0];
}
mess = MessageFormat
.format(
"Class ''{0}'' has virtual method ''{1}'' but non-virtual destructor ''{2}''",
clazz, method, destName.getName());
reportProblem(ER_ID, ast, mess);
reportProblem(ER_ID, ast, clazz, method, destructorName.getName());
}
}
} catch (DOMException e) {
@ -98,7 +91,7 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker {
if (binding instanceof ICPPClassType) {
ICPPClassType type = (ICPPClassType) binding;
virMethodName = null;
destName = 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
@ -118,7 +111,7 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker {
hasDestructor = true;
if (!icppMethod.isVirtual()) {
hasOwnNonVirDestructor = true;
destName = icppMethod;
destructorName = icppMethod;
}
}
}
@ -147,8 +140,8 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker {
if (icppMethod.isVirtual()) {
hasVirDestructor = true;
} else {
if (destName == null)
destName = icppMethod;
if (destructorName == null)
destructorName = icppMethod;
}
}
}

View file

@ -91,7 +91,6 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
* @param func
* @return
*/
@SuppressWarnings("restriction")
protected boolean endsWithNoExitNode(IASTFunctionDefinition func) {
IControlFlowGraph graph = CxxModelsCache.getInstance()
.getControlFlowGraph(func);

View file

@ -30,7 +30,7 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
*
*/
public class SuggestedParenthesisChecker extends AbstractIndexAstChecker {
private static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem";
private static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem"; //$NON-NLS-1$
public void processAst(IASTTranslationUnit ast) {
// traverse the ast using the visitor pattern.
@ -51,16 +51,14 @@ public class SuggestedParenthesisChecker extends AbstractIndexAstChecker {
return PROCESS_CONTINUE;
if (precedence == 2) { // unary not
if (isUsedAsOperand(expression)) {
reportProblem(ER_ID, expression,
"Suggested parenthesis around expression");
reportProblem(ER_ID, expression);
return PROCESS_SKIP;
}
} else if (precedence >= 0) {
int pp = getPrecedence(parentExpr);
if (pp == -1 || pp == precedence)
return PROCESS_CONTINUE;
reportProblem(ER_ID, expression,
"Suggested parenthesis around expression");
reportProblem(ER_ID, expression);
}
}
return PROCESS_CONTINUE;