Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #3675: Replace Scope with AccessModifier in ParameterNameCheck …
…to avoid wrong scopes comparison
- Loading branch information
Showing
15 changed files
with
264 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/AccessModifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code for adherence to a set of rules. | ||
// Copyright (C) 2001-2016 the original author or authors. | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
package com.puppycrawl.tools.checkstyle.checks.naming; | ||
|
||
import java.util.Locale; | ||
|
||
/** | ||
* This enum represents access modifiers. | ||
* Access modifiers names are taken from JLS: | ||
* https://docs.oracle.com/javase/specs/jls/se8/html/jls-6.html#jls-6.6 | ||
* | ||
* @author Andrei Selkin | ||
*/ | ||
public enum AccessModifier { | ||
/** Public access modifier. */ | ||
PUBLIC, | ||
/** Protected access modifier. */ | ||
PROTECTED, | ||
/** Package access modifier. */ | ||
PACKAGE, | ||
/** Private access modifier. */ | ||
PRIVATE; | ||
|
||
@Override | ||
public String toString() { | ||
return getName(); | ||
} | ||
|
||
public String getName() { | ||
return name().toLowerCase(Locale.ENGLISH); | ||
} | ||
|
||
/** | ||
* Factory method which returns an AccessModifier instance that corresponds to the | ||
* given access modifier name represented as a {@link String}. | ||
* The access modifier name can be formatted both as lower case or upper case string. | ||
* For example, passing PACKAGE or package as a modifier name | ||
* will return {@link AccessModifier#PACKAGE}. | ||
* | ||
* @param modifierName access modifier name represented as a {@link String}. | ||
* @return the AccessModifier associated with given access modifier name. | ||
*/ | ||
public static AccessModifier getInstance(String modifierName) { | ||
return valueOf(AccessModifier.class, modifierName.trim().toUpperCase(Locale.ENGLISH)); | ||
} | ||
} |
Oops, something went wrong.
f91b1af
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. This change doesn't work in Eclipse.
f91b1af
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In eclipse, you use eclipse-cs project, that use old version of checkstyle.
if you use latest http://eclipse-cs.sourceforge.net/#!/ so you need to make config for checkstyle 7.3 .
It is better to use built-in builder of configuration at eclipse-cs to be safe.
f91b1af
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the quick answer, unfortunately I am not sure I understand. I have installed net.sf.eclipsecs-updatesite_7.3.0.201612142232 from eclipse-cs and I would like to use google_checks.xml. What do you suggest?
f91b1af
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you run into the same problem as at #3761 , you need to use build-in google_checks.xml of checkstyle or download from repository xml of proper version. In your case - https://github.com/checkstyle/checkstyle/blob/checkstyle-7.3/src/main/resources/google_checks.xml
f91b1af
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!