Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2012-02-10 20:34:15 -0500
committerSergey Prigogin2012-02-10 20:47:39 -0500
commitda28cc19fcfc124dfdfac6ed590b8fa0e7fe2d83 (patch)
treebb82ed042dab8fc2ec56f7545b2cfdea3aa7e642 /codan/org.eclipse.cdt.codan.checkers
parent6322c0691d6bd114586312e84baafd760f263d33 (diff)
downloadorg.eclipse.cdt-da28cc19fcfc124dfdfac6ed590b8fa0e7fe2d83.tar.gz
org.eclipse.cdt-da28cc19fcfc124dfdfac6ed590b8fa0e7fe2d83.tar.xz
org.eclipse.cdt-da28cc19fcfc124dfdfac6ed590b8fa0e7fe2d83.zip
Java 1.5-style loops, etc.
Diffstat (limited to 'codan/org.eclipse.cdt.codan.checkers')
-rw-r--r--codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CaseBreakChecker.java23
1 files changed, 10 insertions, 13 deletions
diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CaseBreakChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CaseBreakChecker.java
index dc39e19c27..b6b001ae71 100644
--- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CaseBreakChecker.java
+++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CaseBreakChecker.java
@@ -43,12 +43,9 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
public static final String PARAM_EMPTY_CASE = "empty_case_param"; //$NON-NLS-1$
public static final String PARAM_NO_BREAK_COMMENT = "no_break_comment"; //$NON-NLS-1$
public static final String DEFAULT_NO_BREAK_COMMENT = "no break"; //$NON-NLS-1$
- private Boolean _checkLastCase; // Should we check the last case in the switch?
- private Boolean _checkEmptyCase; // Should we check an empty case (a case without any statements within it)
- private String _noBreakComment; // The comment suppressing this warning
-
- public CaseBreakChecker() {
- }
+ private boolean fCheckLastCase; // Should we check the last case in the switch?
+ private boolean fCheckEmptyCase; // Should we check an empty case (a case without any statements within it)
+ private String fNoBreakComment; // The comment suppressing this warning
/**
* This visitor looks for "switch" statements and invokes "SwitchVisitor" on them.
@@ -99,10 +96,10 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
// Next is case or end of switch - means this one is the last
if (prevCase != null && (isCaseStatement(next) || next == null)) {
// Check that current statement end with break or any other exit statement
- if (!_checkEmptyCase && isCaseStatement(curr) && next != null) {
+ if (!fCheckEmptyCase && isCaseStatement(curr) && next != null) {
continue; // Empty case and we don't care
}
- if (!_checkLastCase && next == null) {
+ if (!fCheckLastCase && next == null) {
continue; // Last case and we don't care
}
if (!isProducedByMacroExpansion(prevCase) && isFallThroughStamement(curr)) {
@@ -116,7 +113,7 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
}
if (comment != null) {
String str = getTrimmedComment(comment);
- if (str.toLowerCase().contains(_noBreakComment.toLowerCase()))
+ if (str.toLowerCase().contains(fNoBreakComment.toLowerCase()))
continue;
}
reportProblem(curr, prevCase);
@@ -162,7 +159,7 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
}
}
- public void reportProblem(IASTStatement curr, IASTStatement prevCase) {
+ private void reportProblem(IASTStatement curr, IASTStatement prevCase) {
reportProblem(ER_ID, getProblemLocationAtEndOfNode(curr));
}
@@ -227,9 +224,9 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
@Override
public void processAst(IASTTranslationUnit ast) {
- _checkLastCase = (Boolean) getPreference(getProblemById(ER_ID, getFile()), PARAM_LAST_CASE);
- _checkEmptyCase = (Boolean) getPreference(getProblemById(ER_ID, getFile()), PARAM_EMPTY_CASE);
- _noBreakComment = (String) getPreference(getProblemById(ER_ID, getFile()), PARAM_NO_BREAK_COMMENT);
+ fCheckLastCase = (Boolean) getPreference(getProblemById(ER_ID, getFile()), PARAM_LAST_CASE);
+ fCheckEmptyCase = (Boolean) getPreference(getProblemById(ER_ID, getFile()), PARAM_EMPTY_CASE);
+ fNoBreakComment = (String) getPreference(getProblemById(ER_ID, getFile()), PARAM_NO_BREAK_COMMENT);
SwitchFindingVisitor visitor = new SwitchFindingVisitor();
ast.accept(visitor);
}

Back to the top