Repository: groovy Updated Branches: refs/heads/master 44782e057 -> ef33ab744
Minor refactoring Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/ef33ab74 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/ef33ab74 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/ef33ab74 Branch: refs/heads/master Commit: ef33ab744fc2864cf6444a14874f93ca914d1b21 Parents: 44782e0 Author: sunlan <[email protected]> Authored: Sat Jul 15 07:50:37 2017 +0800 Committer: sunlan <[email protected]> Committed: Sat Jul 15 07:50:37 2017 +0800 ---------------------------------------------------------------------- .../apache/groovy/parser/antlr4/AstBuilder.java | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/ef33ab74/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java ---------------------------------------------------------------------- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index 369ecae..9daacbf 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -837,7 +837,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov classNode.setUsingGenerics(classNode.getSuperClass().isUsingGenerics()); } - if (!classNode.isUsingGenerics() && asBoolean((Object) classNode.getInterfaces())) { + if (!classNode.isUsingGenerics() && null != classNode.getInterfaces()) { for (ClassNode anInterface : classNode.getInterfaces()) { classNode.setUsingGenerics(classNode.isUsingGenerics() || anInterface.isUsingGenerics()); @@ -850,7 +850,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov @Override public ClassNode visitClassDeclaration(ClassDeclarationContext ctx) { String packageName = moduleNode.getPackageName(); - packageName = asBoolean((Object) packageName) ? packageName : ""; + packageName = null != packageName ? packageName : ""; List<ModifierNode> modifierNodeList = ctx.getNodeMetaData(TYPE_DECLARATION_MODIFIERS); Objects.requireNonNull(modifierNodeList, "modifierNodeList should not be null"); @@ -1869,7 +1869,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov Expression expression = this.visitExpressionInPar(ctx.expressionInPar()); Integer insideParenLevel = expression.getNodeMetaData(INSIDE_PARENTHESES_LEVEL); - if (asBoolean((Object) insideParenLevel)) { + if (null != insideParenLevel) { insideParenLevel++; } else { insideParenLevel = 1; @@ -2468,12 +2468,12 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov ConstantExpression constantExpression = (ConstantExpression) expression; String integerLiteralText = constantExpression.getNodeMetaData(INTEGER_LITERAL_TEXT); - if (asBoolean((Object) integerLiteralText)) { + if (null != integerLiteralText) { return this.configureAST(new ConstantExpression(Numbers.parseInteger(null, SUB_STR + integerLiteralText)), ctx); } String floatingPointLiteralText = constantExpression.getNodeMetaData(FLOATING_POINT_LITERAL_TEXT); - if (asBoolean((Object) floatingPointLiteralText)) { + if (null != floatingPointLiteralText) { return this.configureAST(new ConstantExpression(Numbers.parseDecimal(SUB_STR + floatingPointLiteralText)), ctx); } @@ -2769,7 +2769,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov InnerClassNode anonymousInnerClassNode = this.visitAnonymousInnerClassDeclaration(ctx.anonymousInnerClassDeclaration()); List<InnerClassNode> anonymousInnerClassList = anonymousInnerClassesDefinedInMethodStack.peek(); - if (asBoolean((Object) anonymousInnerClassList)) { // if the anonymous class is created in a script, no anonymousInnerClassList is available. + if (null != anonymousInnerClassList) { // if the anonymous class is created in a script, no anonymousInnerClassList is available. anonymousInnerClassList.add(anonymousInnerClassNode); } @@ -4048,7 +4048,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov private boolean isPackageInfoDeclaration() { String name = this.sourceUnit.getName(); - if (asBoolean((Object) name) && name.endsWith(PACKAGE_INFO_FILE_NAME)) { + if (null != name && name.endsWith(PACKAGE_INFO_FILE_NAME)) { return true; } @@ -4062,7 +4062,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov private boolean isInsideParentheses(NodeMetaDataHandler nodeMetaDataHandler) { Integer insideParenLevel = nodeMetaDataHandler.getNodeMetaData(INSIDE_PARENTHESES_LEVEL); - if (asBoolean((Object) insideParenLevel)) { + if (null != insideParenLevel) { return insideParenLevel > 0; } @@ -4165,7 +4165,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov String stopText = token.getText(); int stopTextLength = 0; int newLineCnt = 0; - if (asBoolean((Object) stopText)) { + if (null != stopText) { stopTextLength = stopText.length(); newLineCnt = (int) StringUtils.countChar(stopText, '\n'); } @@ -4375,9 +4375,9 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov List<String> declarationListStatementLabels = this.getStatementLabels(); this.declarationStatements.forEach(e -> { - if (asBoolean((Object) declarationListStatementLabels)) { + if (null != declarationListStatementLabels) { // clear existing statement labels before setting labels - if (asBoolean((Object) e.getStatementLabels())) { + if (null != e.getStatementLabels()) { e.getStatementLabels().clear(); }
