Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 200547 Details for
Bug 350144
[checker] suppressing the "No break at the end of case" problem with regexp
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
example fix
clipboard.txt (text/plain), 2.56 KB, created by
Tomasz Wesolowski
on 2011-07-28 13:42:33 EDT
(
hide
)
Description:
example fix
Filename:
MIME Type:
Creator:
Tomasz Wesolowski
Created:
2011-07-28 13:42:33 EDT
Size:
2.56 KB
patch
obsolete
>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 a56b943..d6ac137 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 >@@ -11,6 +11,8 @@ > *******************************************************************************/ > package org.eclipse.cdt.codan.internal.checkers; > >+import java.util.regex.Pattern; >+ > import org.eclipse.cdt.codan.core.cxx.CxxAstUtils; > import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker; > import org.eclipse.cdt.codan.core.model.ICheckerWithPreferences; >@@ -40,7 +42,8 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke > 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 >+ private Pattern _noBreakRegex; >+ private static final int NO_BREAK_REGEX_FLAGS = Pattern.CASE_INSENSITIVE; > > /** > * This visitor looks for "switch" statements and invokes "SwitchVisitor" on >@@ -110,8 +113,9 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke > } > if (comment != null) { > String str = getTrimmedComment(comment); >- if (str.equalsIgnoreCase(_noBreakComment)) >+ if (_noBreakRegex.matcher(str).find()) { > continue; >+ } > } > reportProblem(ER_ID, prevCase, (Object) null); > } >@@ -213,7 +217,8 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke > 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); >+ String noBreakRegexStr = (String) getPreference(getProblemById(ER_ID, getFile()), PARAM_NO_BREAK_COMMENT); >+ _noBreakRegex = Pattern.compile(noBreakRegexStr, NO_BREAK_REGEX_FLAGS); > SwitchFindingVisitor visitor = new SwitchFindingVisitor(); > ast.accept(visitor); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 350144
: 200547