From c2ffb7f1812ab005915c110d1016137e1d2a6fb1 Mon Sep 17 00:00:00 2001
From: Gaurab Dasgupta
- * To not enforce an element style a {@code ElementStyle.IGNORE} type is provided. + * To not enforce an element style a {@code ElementStyleOption.IGNORE} type is provided. * The desired style can be set through the {@code elementStyle} property. *
*- * Using the {@code ElementStyle.EXPANDED} style is more verbose. + * Using the {@code ElementStyleOption.EXPANDED} style is more verbose. * The expanded version is sometimes referred to as "named parameters" in other languages. *
*- * Using the {@code ElementStyle.COMPACT} style is less verbose. + * Using the {@code ElementStyleOption.COMPACT} style is less verbose. * This style can only be used when there is an element called 'value' which is either * the sole element or all other elements have default values. *
*- * Using the {@code ElementStyle.COMPACT_NO_ARRAY} style is less verbose. - * It is similar to the {@code ElementStyle.COMPACT} style but single value arrays are flagged. + * Using the {@code ElementStyleOption.COMPACT_NO_ARRAY} style is less verbose. + * It is similar to the {@code ElementStyleOption.COMPACT} style but single value arrays are + * flagged. * With annotations a single value array does not need to be placed in an array initializer. *
** The ending parenthesis are optional when using annotations with no elements. - * To always require ending parenthesis use the {@code ClosingParens.ALWAYS} type. - * To never have ending parenthesis use the {@code ClosingParens.NEVER} type. - * To not enforce a closing parenthesis preference a {@code ClosingParens.IGNORE} type is provided. + * To always require ending parenthesis use the {@code ClosingParensOption.ALWAYS} type. + * To never have ending parenthesis use the {@code ClosingParensOption.NEVER} type. + * To not enforce a closing parenthesis preference a {@code ClosingParensOption.IGNORE} type is + * provided. * Set this through the {@code closingParens} property. *
** Annotations also allow you to specify arrays of elements in a standard format. * As with normal arrays, a trailing comma is optional. - * To always require a trailing comma use the {@code TrailingArrayComma.ALWAYS} type. - * To never have a trailing comma use the {@code TrailingArrayComma.NEVER} type. - * To not enforce a trailing array comma preference a {@code TrailingArrayComma.IGNORE} type + * To always require a trailing comma use the {@code TrailingArrayCommaOption.ALWAYS} type. + * To never have a trailing comma use the {@code TrailingArrayCommaOption.NEVER} type. + * To not enforce a trailing array comma preference a {@code TrailingArrayCommaOption.IGNORE} type * is provided. Set this through the {@code trailingArrayComma} property. *
*- * By default the {@code ElementStyle} is set to {@code COMPACT_NO_ARRAY}, - * the {@code TrailingArrayComma} is set to {@code NEVER}, - * and the {@code ClosingParens} is set to {@code NEVER}. + * By default the {@code ElementStyleOption} is set to {@code COMPACT_NO_ARRAY}, + * the {@code TrailingArrayCommaOption} is set to {@code NEVER}, + * and the {@code ClosingParensOption} is set to {@code NEVER}. *
** According to the JLS, it is legal to include a trailing comma @@ -136,7 +138,7 @@ public final class AnnotationUseStyleCheck extends AbstractCheck { /** * Defines the styles for defining elements in an annotation. */ - public enum ElementStyle { + public enum ElementStyleOption { /** * Expanded example @@ -173,7 +175,7 @@ public enum ElementStyle { * elements in an annotation. * */ - public enum TrailingArrayComma { + public enum TrailingArrayCommaOption { /** * With comma example @@ -201,7 +203,7 @@ public enum TrailingArrayComma { * elements in an annotation. * */ - public enum ClosingParens { + public enum ClosingParensOption { /** * With parens example @@ -269,18 +271,18 @@ public enum ClosingParens { /** * Define the annotation element styles. */ - private ElementStyle elementStyle = ElementStyle.COMPACT_NO_ARRAY; + private ElementStyleOption elementStyle = ElementStyleOption.COMPACT_NO_ARRAY; // defaulting to NEVER because of the strange compiler behavior /** * Define the policy for trailing comma in arrays. */ - private TrailingArrayComma trailingArrayComma = TrailingArrayComma.NEVER; + private TrailingArrayCommaOption trailingArrayComma = TrailingArrayCommaOption.NEVER; /** * Define the policy for ending parenthesis. */ - private ClosingParens closingParens = ClosingParens.NEVER; + private ClosingParensOption closingParens = ClosingParensOption.NEVER; /** * Setter to define the annotation element styles. @@ -288,7 +290,7 @@ public enum ClosingParens { * @param style string representation */ public void setElementStyle(final String style) { - elementStyle = getOption(ElementStyle.class, style); + elementStyle = getOption(ElementStyleOption.class, style); } /** @@ -297,7 +299,7 @@ public void setElementStyle(final String style) { * @param comma string representation */ public void setTrailingArrayComma(final String comma) { - trailingArrayComma = getOption(TrailingArrayComma.class, comma); + trailingArrayComma = getOption(TrailingArrayCommaOption.class, comma); } /** @@ -306,7 +308,7 @@ public void setTrailingArrayComma(final String comma) { * @param parens string representation */ public void setClosingParens(final String parens) { - closingParens = getOption(ClosingParens.class, parens); + closingParens = getOption(ClosingParensOption.class, parens); } /** @@ -348,13 +350,13 @@ public int[] getAcceptableTokens() { @Override public void visitToken(final DetailAST ast) { checkStyleType(ast); - checkCheckClosingParens(ast); + checkCheckClosingParensOption(ast); checkTrailingComma(ast); } /** * Checks to see if the - * {@link ElementStyle AnnotationElementStyle} + * {@link ElementStyleOption AnnotationElementStyleOption} * is correct. * * @param annotation the annotation token @@ -386,7 +388,7 @@ private void checkExpandedStyle(final DetailAST annotation) { annotation.getChildCount(TokenTypes.ANNOTATION_MEMBER_VALUE_PAIR); if (valuePairCount == 0 && hasArguments(annotation)) { - log(annotation, MSG_KEY_ANNOTATION_INCORRECT_STYLE, ElementStyle.EXPANDED); + log(annotation, MSG_KEY_ANNOTATION_INCORRECT_STYLE, ElementStyleOption.EXPANDED); } } @@ -419,7 +421,7 @@ private void checkCompactStyle(final DetailAST annotation) { && ANNOTATION_ELEMENT_SINGLE_NAME.equals( valuePair.getFirstChild().getText())) { log(annotation, MSG_KEY_ANNOTATION_INCORRECT_STYLE, - ElementStyle.COMPACT); + ElementStyleOption.COMPACT); } } @@ -436,7 +438,7 @@ private void checkCompactNoArrayStyle(final DetailAST annotation) { if (arrayInit != null && arrayInit.getChildCount(TokenTypes.EXPR) == 1) { log(annotation, MSG_KEY_ANNOTATION_INCORRECT_STYLE, - ElementStyle.COMPACT_NO_ARRAY); + ElementStyleOption.COMPACT_NO_ARRAY); } // in expanded style with pairs else { @@ -447,7 +449,7 @@ private void checkCompactNoArrayStyle(final DetailAST annotation) { if (nestedArrayInit != null && nestedArrayInit.getChildCount(TokenTypes.EXPR) == 1) { log(annotation, MSG_KEY_ANNOTATION_INCORRECT_STYLE, - ElementStyle.COMPACT_NO_ARRAY); + ElementStyleOption.COMPACT_NO_ARRAY); } ast = ast.getNextSibling(); } @@ -461,7 +463,7 @@ private void checkCompactNoArrayStyle(final DetailAST annotation) { * @param annotation the annotation token */ private void checkTrailingComma(final DetailAST annotation) { - if (trailingArrayComma != TrailingArrayComma.IGNORE) { + if (trailingArrayComma != TrailingArrayCommaOption.IGNORE) { DetailAST child = annotation.getFirstChild(); while (child != null) { @@ -494,7 +496,7 @@ private void logCommaViolation(final DetailAST ast) { // comma can be null if array is empty final DetailAST comma = rCurly.getPreviousSibling(); - if (trailingArrayComma == TrailingArrayComma.ALWAYS) { + if (trailingArrayComma == TrailingArrayCommaOption.ALWAYS) { if (comma == null || comma.getType() != TokenTypes.COMMA) { log(rCurly, MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING); } @@ -510,11 +512,11 @@ else if (comma != null && comma.getType() == TokenTypes.COMMA) { * * @param ast the annotation token */ - private void checkCheckClosingParens(final DetailAST ast) { - if (closingParens != ClosingParens.IGNORE) { + private void checkCheckClosingParensOption(final DetailAST ast) { + if (closingParens != ClosingParensOption.IGNORE) { final DetailAST paren = ast.getLastChild(); - if (closingParens == ClosingParens.ALWAYS) { + if (closingParens == ClosingParensOption.ALWAYS) { if (paren.getType() != TokenTypes.RPAREN) { log(ast, MSG_KEY_ANNOTATION_PARENS_MISSING); } diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheck.java index 4cc073c2d38..0085242005b 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheck.java @@ -56,7 +56,8 @@ * *
error
Each module has a severity property that a
+ href="property_types.html#SeverityLevel">severity property that a
Checkstyle audit assigns to all violations of the check. The
default severity level of a check is error
.
ElementStyle.COMPACT_NO_ARRAY
ElementStyle.COMPACT
ElementStyle.EXPANDED
ElementStyleOption.COMPACT_NO_ARRAY
ElementStyleOption.COMPACT
ElementStyleOption.EXPANDED
- To not enforce an element style a ElementStyle.IGNORE
type is provided.
+ To not enforce an element style a ElementStyleOption.IGNORE
type is provided.
The desired style can be set through the elementStyle
property.
- Using the ElementStyle.EXPANDED
style is more verbose.
+ Using the ElementStyleOption.EXPANDED
style is more verbose.
The expanded version is sometimes referred to as "named parameters" in other languages.
- Using the ElementStyle.COMPACT
style is less verbose.
+ Using the ElementStyleOption.COMPACT
style is less verbose.
This style can only be used when there is an element called 'value' which is either
the sole element or all other elements have default values.
- Using the ElementStyle.COMPACT_NO_ARRAY
style is less verbose.
- It is similar to the ElementStyle.COMPACT
style but single value arrays
+ Using the ElementStyleOption.COMPACT_NO_ARRAY
style is less verbose.
+ It is similar to the ElementStyleOption.COMPACT
style but single value arrays
are flagged.
With annotations a single value array does not need to be placed in an array initializer.
The ending parenthesis are optional when using annotations with no elements.
- To always require ending parenthesis use the ClosingParens.ALWAYS
type.
- To never have ending parenthesis use the ClosingParens.NEVER
type.
- To not enforce a closing parenthesis preference a ClosingParens.IGNORE
+ To always require ending parenthesis use the ClosingParensOption.ALWAYS
type.
+ To never have ending parenthesis use the ClosingParensOption.NEVER
type.
+ To not enforce a closing parenthesis preference a ClosingParensOption.IGNORE
type is provided. Set this through the closingParens
property.
Annotations also allow you to specify arrays of elements in a standard format.
As with normal arrays, a trailing comma is optional.
- To always require a trailing comma use the TrailingArrayComma.ALWAYS
type.
- To never have a trailing comma use the TrailingArrayComma.NEVER
type.
- To not enforce a trailing array comma preference a TrailingArrayComma.IGNORE
- type is provided.
+ To always require a trailing comma use the TrailingArrayCommaOption.ALWAYS
+ type.
+ To never have a trailing comma use the TrailingArrayCommaOption.NEVER
type.
+ To not enforce a trailing array comma preference a
+ TrailingArrayCommaOption.IGNORE
type is provided.
Set this through the trailingArrayComma
property.
- By default the ElementStyle
is set to COMPACT_NO_ARRAY
,
- the TrailingArrayComma
is set to NEVER
,
- and the ClosingParens
is set to NEVER
.
+ By default the ElementStyleOption
is set to COMPACT_NO_ARRAY
,
+ the TrailingArrayCommaOption
is set to NEVER
,
+ and the ClosingParensOption
is set to NEVER
.
According to the JLS, it is legal to include a trailing comma @@ -551,7 +552,7 @@ class Bar implements Foo { Define the annotation element styles.
compact_no_array
@@ -564,7 +565,7 @@ class Bar implements Foo {
Define the policy for ending parenthesis.
never
@@ -577,7 +578,7 @@ class Bar implements Foo {
Define the policy for trailing comma in arrays.
never
diff --git a/src/xdocs/config_blocks.xml b/src/xdocs/config_blocks.xml
index 5efbd6ad489..237fc85e111 100644
--- a/src/xdocs/config_blocks.xml
+++ b/src/xdocs/config_blocks.xml
@@ -201,7 +201,7 @@ switch (a) {
statement
'{'
).eol
'}'
).same
error
under
second_line
info
lf_cr_crlf
nospace
nospace
nospace
nl
nospace
eol
nospace
This type represents the policy for line returns. The following table describes the valid options: @@ -162,7 +162,7 @@
This type represents the policy for padding with white space. The following table describes the valid options: @@ -191,7 +191,7 @@
This type represents the policy for wrapping lines. The following table describes the valid options: @@ -231,7 +231,7 @@
This type represents the policy for checking block statements. The following table describes the valid options: @@ -273,7 +273,7 @@
This type represents the policy for checking the placement of a
left curly brace ('{'
). The following table
@@ -343,7 +343,7 @@
This type represents the policy for checking the placement of a
right curly brace ('}'
) in blocks but not blocks of expressions.
@@ -506,7 +506,7 @@
This type represents the severity level of a check violation. The valid options are: @@ -520,14 +520,14 @@
This type represents the policy for checking imports order. The following table describes the valid options:
Option | Definition | @@ -613,7 +613,7 @@ -
Option | Definition |