Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CommentSuppressor |
|
| 1.5;1.5 |
1 | //////////////////////////////////////////////////////////////////////////////// | |
2 | // checkstyle: Checks Java source code for adherence to a set of rules. | |
3 | // Copyright (C) 2001-2014 Oliver Burn | |
4 | // | |
5 | // This library is free software; you can redistribute it and/or | |
6 | // modify it under the terms of the GNU Lesser General Public | |
7 | // License as published by the Free Software Foundation; either | |
8 | // version 2.1 of the License, or (at your option) any later version. | |
9 | // | |
10 | // This library is distributed in the hope that it will be useful, | |
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | // Lesser General Public License for more details. | |
14 | // | |
15 | // You should have received a copy of the GNU Lesser General Public | |
16 | // License along with this library; if not, write to the Free Software | |
17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | //////////////////////////////////////////////////////////////////////////////// | |
19 | package com.puppycrawl.tools.checkstyle.checks.regexp; | |
20 | ||
21 | import com.puppycrawl.tools.checkstyle.api.FileContents; | |
22 | ||
23 | /** | |
24 | * Implementation of a {@link MatchSuppressor} that suppresses based on | |
25 | * whether in a comment. | |
26 | * @author Oliver Burn | |
27 | */ | |
28 | 18 | class CommentSuppressor implements MatchSuppressor |
29 | { | |
30 | /** File contents to check for comments. */ | |
31 | private FileContents mCurrentContents; | |
32 | ||
33 | /** {@inheritDoc} */ | |
34 | public boolean shouldSuppress(int aStartLineNo, int aStartColNo, | |
35 | int aEndLineNo, int aEndColNo) | |
36 | { | |
37 | 9 | return (null != mCurrentContents) |
38 | && mCurrentContents.hasIntersectionWithComment(aStartLineNo, | |
39 | aStartColNo, aEndLineNo, aEndColNo); | |
40 | } | |
41 | ||
42 | /** | |
43 | * Set the current file contents. | |
44 | * @param aCurrentContents the new contents. | |
45 | */ | |
46 | public void setCurrentContents(FileContents aCurrentContents) | |
47 | { | |
48 | 18 | mCurrentContents = aCurrentContents; |
49 | 18 | } |
50 | } |