groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul King <pa...@asert.com.au>
Subject Re: incubator-groovy git commit: remove costmetic Java'isms
Date Mon, 12 Oct 2015 10:45:22 GMT
Nice!

On Mon, Oct 12, 2015 at 4:47 PM,  <pascalschumacher@apache.org> wrote:
> Repository: incubator-groovy
> Updated Branches:
>   refs/heads/master b889ba1b6 -> 5ad839345
>
>
> remove costmetic Java'isms
>
>
> Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo
> Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/5ad83934
> Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/5ad83934
> Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/5ad83934
>
> Branch: refs/heads/master
> Commit: 5ad8393451648ea560b972cce066f9d7fa2e8530
> Parents: b889ba1
> Author: pascalschumacher <pascalschumacher@gmx.net>
> Authored: Mon Oct 12 08:46:51 2015 +0200
> Committer: pascalschumacher <pascalschumacher@gmx.net>
> Committed: Mon Oct 12 08:47:23 2015 +0200
>
> ----------------------------------------------------------------------
>  .../groovy/ast/LineColumnCheckTest.groovy       | 367 +++++++++----------
>  1 file changed, 183 insertions(+), 184 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/5ad83934/src/test/org/codehaus/groovy/ast/LineColumnCheckTest.groovy
> ----------------------------------------------------------------------
> diff --git a/src/test/org/codehaus/groovy/ast/LineColumnCheckTest.groovy b/src/test/org/codehaus/groovy/ast/LineColumnCheckTest.groovy
> index 23cb4d7..9f31807 100644
> --- a/src/test/org/codehaus/groovy/ast/LineColumnCheckTest.groovy
> +++ b/src/test/org/codehaus/groovy/ast/LineColumnCheckTest.groovy
> @@ -85,32 +85,32 @@ import org.junit.runners.Parameterized
>   *
>   */
>
> -@RunWith(Parameterized.class)
> +@RunWith(Parameterized)
>  class LineColumnCheckTest extends ASTTest {
>
> -    static final String TEST_FILE_PATH = "./src/test/org/codehaus/groovy/ast/LineColumnCheck.txt";
> +    static final String TEST_FILE_PATH = './src/test/org/codehaus/groovy/ast/LineColumnCheck.txt'
>
>      private LineCheckVisitor visitor
>      private String name
>      private String source
>      private String[] expected
>
> -    @Parameterized.Parameters(name = "Test {0}: Source: {1} Expected: {2}")
> +    @Parameterized.Parameters(name = 'Test {0}: Source: {1} Expected: {2}')
>      static Iterable<Object[]> data() {
>          String content = new File(TEST_FILE_PATH).text
> -        String[] tests = content.split("###")
> +        String[] tests = content.split('###')
>          tests = tests.drop(1) // remove apache header
>          List testdata = []
>          for (String test : tests) {
> -            testdata << (test.split(":::").collect { it.trim() } as Object[])
> +            testdata << (test.split(':::').collect { it.trim() } as Object[])
>          }
> -        return testdata
> +        testdata
>      }
>
>      LineColumnCheckTest(String name, String source, String expected) {
>          this.name = name
>          this.source = source
> -        this.expected = expected.split(";")
> +        this.expected = expected.split(';')
>      }
>
>      @Before
> @@ -120,12 +120,12 @@ class LineColumnCheckTest extends ASTTest {
>
>      @Test
>      void testLineColumnInfo() {
> -        visitor.visitModuleNode(getAST(source));
> -        String was = visitor.getASTString();
> +        visitor.visitModuleNode(getAST(source))
> +        String was = visitor.getASTString()
>          //comment out next line to view the output of the visitor
> -        //System.out.println(name + ": " + was);
> +        println(name + ': ' + was)
>          for (String anExpected : expected) {
> -            assertTrue("'" + anExpected + "' not found in '" + was + "'", was.indexOf(anExpected.trim())
!= -1);
> +            assertTrue("'" + anExpected + "' not found in '" + was + "'", was.indexOf(anExpected.trim())
!= -1)
>          }
>      }
>  }
> @@ -138,40 +138,40 @@ class LineColumnCheckTest extends ASTTest {
>   */
>  class LineCheckVisitor extends ClassCodeVisitorSupport {
>
> -    private StringBuffer astString = new StringBuffer();
> +    private StringBuffer astString = new StringBuffer()
>
> -    public String getASTString() {
> -        return astString.toString();
> +    String getASTString() {
> +        astString.toString()
>      }
>
>      protected void visitStatement(Statement statement) {
> -        visitNode(statement);
> +        visitNode(statement)
>      }
>
>      protected void visitType(ClassNode node) {
> -        visitNode(node);
> -        visitGenerics(node);
> +        visitNode(node)
> +        visitGenerics(node)
>      }
>
>      protected void visitTypes(ClassNode[] classNodes) {
>          if (classNodes != null) {
>              for (ClassNode classNode : classNodes) {
> -                visitType(classNode);
> +                visitType(classNode)
>              }
>          }
>      }
>
>      protected void visitGenerics(ClassNode node) {
>          if (node.isUsingGenerics()) {
> -            GenericsType[] generics = node.getGenericsTypes();
> -            if(generics == null) return;
> +            GenericsType[] generics = node.getGenericsTypes()
> +            if(generics == null) return
>              for (GenericsType genericType : generics) {
> -                visitNode(genericType);
> -                visitType(genericType.getType());
> +                visitNode(genericType)
> +                visitType(genericType.getType())
>                  if (genericType.getLowerBound() != null) {
> -                    visitType(genericType.getLowerBound());
> +                    visitType(genericType.getLowerBound())
>                  }
> -                visitTypes(genericType.getUpperBounds());
> +                visitTypes(genericType.getUpperBounds())
>              }
>          }
>      }
> @@ -179,124 +179,124 @@ class LineCheckVisitor extends ClassCodeVisitorSupport {
>      protected void visitNodes(ASTNode[] nodes) {
>          if (nodes != null) {
>              for (ASTNode node : nodes) {
> -                visitNode(node);
> +                visitNode(node)
>              }
>          }
>      }
>
>      protected void visitNode(ASTNode node) {
> -        String nodeName = node.getClass().getName();
> +        String nodeName = node.getClass().getName()
>          //get classname without package
> -        nodeName = nodeName.substring(nodeName.lastIndexOf(".") + 1,nodeName.length());
> -        astString.append("[");
> -        astString.append(nodeName);
> -        astString.append(",(");
> -        astString.append(node.getLineNumber());
> -        astString.append(":");
> -        astString.append(node.getColumnNumber());
> -        astString.append("),(");
> -        astString.append(node.getLastLineNumber());
> -        astString.append(":");
> -        astString.append(node.getLastColumnNumber());
> -        astString.append(")]");
> +        nodeName = nodeName.substring(nodeName.lastIndexOf('.') + 1,nodeName.length())
> +        astString.append('[')
> +        astString.append(nodeName)
> +        astString.append(',(')
> +        astString.append(node.getLineNumber())
> +        astString.append(':')
> +        astString.append(node.getColumnNumber())
> +        astString.append('),(')
> +        astString.append(node.getLastLineNumber())
> +        astString.append(':')
> +        astString.append(node.getLastColumnNumber())
> +        astString.append(')]')
>          //String of each node looks like: [AssertStatement,(1:1),(1:20)]
>      }
>
> -    public SourceUnit getSourceUnit() {
> -        return null;
> +    SourceUnit getSourceUnit() {
> +        null
>      }
>
> -    public void visitModuleNode(ModuleNode moduleNode) {
> +    void visitModuleNode(ModuleNode moduleNode) {
>
>          //visit imports like import java.io.File and import java.io.File as MyFile
>          for (ImportNode importNode : moduleNode.getImports()) {
> -            visitNode(importNode.getType());
> +            visitNode(importNode.getType())
>          }
>
>          //visit static imports like import java.lang.Math.*
>          for (ImportNode importNode : moduleNode.getStaticStarImports().values()) {
> -            visitNode(importNode.getType());
> +            visitNode(importNode.getType())
>          }
>
>          //visit static imports like import java.lang.Math.cos
>          for (ImportNode importNode : moduleNode.getStaticImports().values()) {
> -            visitNode(importNode.getType());
> +            visitNode(importNode.getType())
>          }
>
>          for (ClassNode classNode : moduleNode.getClasses()) {
>              if (!classNode.isScript()) {
> -                visitClass(classNode);
> +                visitClass(classNode)
>              } else {
>                  for (MethodNode method : moduleNode.getMethods()) {
> -                    visitMethod(method);
> +                    visitMethod(method)
>                  }
>              }
>          }
>          //visit Statements that are not inside a class
>          if (!moduleNode.getStatementBlock().isEmpty()) {
> -            visitBlockStatement(moduleNode.getStatementBlock());
> +            visitBlockStatement(moduleNode.getStatementBlock())
>          }
>      }
>
> -    public void visitClass(ClassNode node) {
> -        visitType(node);
> -        visitType(node.getUnresolvedSuperClass());
> -        visitTypes(node.getInterfaces());
> -        super.visitClass(node);
> +    void visitClass(ClassNode node) {
> +        visitType(node)
> +        visitType(node.getUnresolvedSuperClass())
> +        visitTypes(node.getInterfaces())
> +        super.visitClass(node)
>      }
>
> -    public void visitAnnotations(AnnotatedNode node) {
> -        List<AnnotationNode> annotationMap = node.getAnnotations();
> -        if (annotationMap.isEmpty()) return;
> -        visitNode(node);
> +    void visitAnnotations(AnnotatedNode node) {
> +        List<AnnotationNode> annotationMap = node.getAnnotations()
> +        if (annotationMap.isEmpty()) return
> +        visitNode(node)
>          for (AnnotationNode annotationNode : annotationMap) {
> -            visitNode(annotationNode);
> +            visitNode(annotationNode)
>          }
>      }
>
>      protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor)
{
> -        visitAnnotations(node);
> -        analyseMethodHead(node);
> -        Statement code = node.getCode();
> +        visitAnnotations(node)
> +        analyseMethodHead(node)
> +        Statement code = node.getCode()
>
> -        visitClassCodeContainer(code);
> +        visitClassCodeContainer(code)
>      }
>
>      private void analyseMethodHead(MethodNode node) {
> -        visitNode(node.getReturnType());
> -        analyseParameters(node.getParameters());
> -        visitNodes(node.getExceptions());
> +        visitNode(node.getReturnType())
> +        analyseParameters(node.getParameters())
> +        visitNodes(node.getExceptions())
>      }
>
>      private void analyseParameters(Parameter[] parameters) {
>          for (Parameter parameter : parameters) {
> -            visitType(parameter.getOriginType());
> +            visitType(parameter.getOriginType())
>              if (parameter.hasInitialExpression()) {
> -                parameter.getInitialExpression().visit(this);
> +                parameter.getInitialExpression().visit(this)
>              }
>          }
>      }
>
> -    public void visitConstructor(ConstructorNode node) {
> -        visitNode(node);
> -        super.visitConstructor(node);
> +    void visitConstructor(ConstructorNode node) {
> +        visitNode(node)
> +        super.visitConstructor(node)
>      }
>
> -    public void visitMethod(MethodNode node) {
> -        visitNode(node);
> -        super.visitMethod(node);
> +    void visitMethod(MethodNode node) {
> +        visitNode(node)
> +        super.visitMethod(node)
>      }
>
> -    public void visitField(FieldNode node) {
> +    void visitField(FieldNode node) {
>          // Do not visit fields which are manually added due to optimization
>          if (!node.getName().startsWith('$')) {
> -            visitType(node.getOriginType());
> -            visitNode(node);
> -            super.visitField(node);
> +            visitType(node.getOriginType())
> +            visitNode(node)
> +            super.visitField(node)
>          }
>      }
>
> -    public void visitProperty(PropertyNode node) {
> +    void visitProperty(PropertyNode node) {
>          // do nothing, also visited as FieldNode
>      }
>
> @@ -310,180 +310,179 @@ class LineCheckVisitor extends ClassCodeVisitorSupport {
>      /*
>       * Expressions
>       */
> -    public void visitMethodCallExpression(MethodCallExpression call) {
> -        visitNode(call);
> -        super.visitMethodCallExpression(call);
> +    void visitMethodCallExpression(MethodCallExpression call) {
> +        visitNode(call)
> +        super.visitMethodCallExpression(call)
>      }
>
> -    public void visitStaticMethodCallExpression(StaticMethodCallExpression call) {
> -        visitNode(call);
> -        super.visitStaticMethodCallExpression(call);
> +    void visitStaticMethodCallExpression(StaticMethodCallExpression call) {
> +        visitNode(call)
> +        super.visitStaticMethodCallExpression(call)
>      }
>
> -    public void visitConstructorCallExpression(ConstructorCallExpression call) {
> -        visitNode(call);
> -        visitType(call.getType());
> -        super.visitConstructorCallExpression(call);
> +    void visitConstructorCallExpression(ConstructorCallExpression call) {
> +        visitNode(call)
> +        visitType(call.getType())
> +        super.visitConstructorCallExpression(call)
>      }
>
> -    public void visitBinaryExpression(BinaryExpression expression) {
> -        visitNode(expression);
> -        super.visitBinaryExpression(expression);
> +    void visitBinaryExpression(BinaryExpression expression) {
> +        visitNode(expression)
> +        super.visitBinaryExpression(expression)
>      }
>
> -    public void visitTernaryExpression(TernaryExpression expression) {
> -        visitNode(expression);
> -        super.visitTernaryExpression(expression);
> +    void visitTernaryExpression(TernaryExpression expression) {
> +        visitNode(expression)
> +        super.visitTernaryExpression(expression)
>      }
>
> -    public void visitPostfixExpression(PostfixExpression expression) {
> -        visitNode(expression);
> -        super.visitPostfixExpression(expression);
> +    void visitPostfixExpression(PostfixExpression expression) {
> +        visitNode(expression)
> +        super.visitPostfixExpression(expression)
>      }
>
> -    public void visitPrefixExpression(PrefixExpression expression) {
> -        visitNode(expression);
> -        super.visitPrefixExpression(expression);
> +    void visitPrefixExpression(PrefixExpression expression) {
> +        visitNode(expression)
> +        super.visitPrefixExpression(expression)
>      }
>
> -    public void visitBooleanExpression(BooleanExpression expression) {
> -        visitNode(expression);
> -        super.visitBooleanExpression(expression);
> +    void visitBooleanExpression(BooleanExpression expression) {
> +        visitNode(expression)
> +        super.visitBooleanExpression(expression)
>      }
>
> -    public void visitNotExpression(NotExpression expression) {
> -        visitNode(expression);
> -        super.visitNotExpression(expression);
> +    void visitNotExpression(NotExpression expression) {
> +        visitNode(expression)
> +        super.visitNotExpression(expression)
>      }
>
> -    public void visitClosureExpression(ClosureExpression expression) {
> -        visitNode(expression);
> -        super.visitClosureExpression(expression);
> +    void visitClosureExpression(ClosureExpression expression) {
> +        visitNode(expression)
> +        super.visitClosureExpression(expression)
>      }
>
> -    public void visitTupleExpression(TupleExpression expression) {
> -        visitNode(expression);
> -        super.visitTupleExpression(expression);
> +    void visitTupleExpression(TupleExpression expression) {
> +        visitNode(expression)
> +        super.visitTupleExpression(expression)
>      }
>
> -    public void visitListExpression(ListExpression expression) {
> -        visitNode(expression);
> -        super.visitListExpression(expression);
> +    void visitListExpression(ListExpression expression) {
> +        visitNode(expression)
> +        super.visitListExpression(expression)
>      }
>
> -    public void visitArrayExpression(ArrayExpression expression) {
> -        visitNode(expression);
> -        visitNode(expression.getElementType());
> -        super.visitArrayExpression(expression);
> +    void visitArrayExpression(ArrayExpression expression) {
> +        visitNode(expression)
> +        visitNode(expression.getElementType())
> +        super.visitArrayExpression(expression)
>      }
>
> -    public void visitMapExpression(MapExpression expression) {
> -        visitNode(expression);
> -        super.visitMapExpression(expression);
> +    void visitMapExpression(MapExpression expression) {
> +        visitNode(expression)
> +        super.visitMapExpression(expression)
>      }
>
> -    public void visitMapEntryExpression(MapEntryExpression expression) {
> -        visitNode(expression);
> -        super.visitMapEntryExpression(expression);
> +    void visitMapEntryExpression(MapEntryExpression expression) {
> +        visitNode(expression)
> +        super.visitMapEntryExpression(expression)
>      }
>
> -    public void visitRangeExpression(RangeExpression expression) {
> -        visitNode(expression);
> -        super.visitRangeExpression(expression);
> +    void visitRangeExpression(RangeExpression expression) {
> +        visitNode(expression)
> +        super.visitRangeExpression(expression)
>      }
>
> -    public void visitSpreadExpression(SpreadExpression expression) {
> -        visitNode(expression);
> -        super.visitSpreadExpression(expression);
> +    void visitSpreadExpression(SpreadExpression expression) {
> +        visitNode(expression)
> +        super.visitSpreadExpression(expression)
>      }
>
> -    public void visitSpreadMapExpression(SpreadMapExpression expression) {
> -        visitNode(expression);
> -        super.visitSpreadMapExpression(expression);
> +    void visitSpreadMapExpression(SpreadMapExpression expression) {
> +        visitNode(expression)
> +        super.visitSpreadMapExpression(expression)
>      }
>
> -    public void visitMethodPointerExpression(MethodPointerExpression expression) {
> -        visitNode(expression);
> -        super.visitMethodPointerExpression(expression);
> +    void visitMethodPointerExpression(MethodPointerExpression expression) {
> +        visitNode(expression)
> +        super.visitMethodPointerExpression(expression)
>      }
>
> -    public void visitBitwiseNegationExpression(
> -            BitwiseNegationExpression expression) {
> -        visitNode(expression);
> -        super.visitBitwiseNegationExpression(expression);
> +    void visitBitwiseNegationExpression(BitwiseNegationExpression expression) {
> +        visitNode(expression)
> +        super.visitBitwiseNegationExpression(expression)
>      }
>
> -    public void visitCastExpression(CastExpression expression) {
> -        visitNode(expression);
> -        visitType(expression.getType());
> -        super.visitCastExpression(expression);
> +    void visitCastExpression(CastExpression expression) {
> +        visitNode(expression)
> +        visitType(expression.getType())
> +        super.visitCastExpression(expression)
>      }
>
> -    public void visitConstantExpression(ConstantExpression expression) {
> -        visitNode(expression);
> -        super.visitConstantExpression(expression);
> +    void visitConstantExpression(ConstantExpression expression) {
> +        visitNode(expression)
> +        super.visitConstantExpression(expression)
>      }
>
> -    public void visitClassExpression(ClassExpression expression) {
> -        visitNode(expression);
> -        super.visitClassExpression(expression);
> +    void visitClassExpression(ClassExpression expression) {
> +        visitNode(expression)
> +        super.visitClassExpression(expression)
>      }
>
> -    public void visitVariableExpression(VariableExpression expression) {
> -        visitNode(expression);
> -        super.visitVariableExpression(expression);
> +    void visitVariableExpression(VariableExpression expression) {
> +        visitNode(expression)
> +        super.visitVariableExpression(expression)
>      }
>
> -    public void visitDeclarationExpression(DeclarationExpression expression) {
> -        //visitNode(expression); is visited afterwards in BinaryExpression. Because
> +    void visitDeclarationExpression(DeclarationExpression expression) {
> +        //visitNode(expression) is visited afterwards in BinaryExpression. Because
>          //super.visitDeclarationExpression calls visitBinaryExpression
> -        visitType(expression.getLeftExpression().getType());
> -        super.visitDeclarationExpression(expression);
> +        visitType(expression.getLeftExpression().getType())
> +        super.visitDeclarationExpression(expression)
>      }
>
> -    public void visitPropertyExpression(PropertyExpression expression) {
> -        visitNode(expression);
> -        super.visitPropertyExpression(expression);
> +    void visitPropertyExpression(PropertyExpression expression) {
> +        visitNode(expression)
> +        super.visitPropertyExpression(expression)
>      }
>
> -    public void visitAttributeExpression(AttributeExpression expression) {
> -        visitNode(expression);
> -        super.visitAttributeExpression(expression);
> +    void visitAttributeExpression(AttributeExpression expression) {
> +        visitNode(expression)
> +        super.visitAttributeExpression(expression)
>      }
>
> -    public void visitFieldExpression(FieldExpression expression) {
> -        visitNode(expression);
> -        super.visitFieldExpression(expression);
> +    void visitFieldExpression(FieldExpression expression) {
> +        visitNode(expression)
> +        super.visitFieldExpression(expression)
>      }
>
> -    public void visitGStringExpression(GStringExpression expression) {
> -        visitNode(expression);
> -        super.visitGStringExpression(expression);
> +    void visitGStringExpression(GStringExpression expression) {
> +        visitNode(expression)
> +        super.visitGStringExpression(expression)
>      }
>
> -    public void visitArgumentlistExpression(ArgumentListExpression ale) {
> -        //visitNode(ale); is visited afterwards in TupleExpression. Because
> +    void visitArgumentlistExpression(ArgumentListExpression ale) {
> +        //visitNode(ale) is visited afterwards in TupleExpression. Because
>          //super.visitArgumentlistExpression calls visitTupleExpression
> -        super.visitArgumentlistExpression(ale);
> +        super.visitArgumentlistExpression(ale)
>      }
>
> -    public void visitShortTernaryExpression(ElvisOperatorExpression expression) {
> -        visitNode(expression);
> -        super.visitShortTernaryExpression(expression);
> +    void visitShortTernaryExpression(ElvisOperatorExpression expression) {
> +        visitNode(expression)
> +        super.visitShortTernaryExpression(expression)
>      }
>
> -    public void visitUnaryPlusExpression(UnaryPlusExpression expression) {
> -        visitNode(expression);
> -        super.visitUnaryPlusExpression(expression);
> +    void visitUnaryPlusExpression(UnaryPlusExpression expression) {
> +        visitNode(expression)
> +        super.visitUnaryPlusExpression(expression)
>      }
>
> -    public void visitUnaryMinusExpression(UnaryMinusExpression expression) {
> -        visitNode(expression);
> -        super.visitUnaryMinusExpression(expression);
> +    void visitUnaryMinusExpression(UnaryMinusExpression expression) {
> +        visitNode(expression)
> +        super.visitUnaryMinusExpression(expression)
>      }
>
> -    public void visitClosureListExpression(ClosureListExpression cle) {
> -        visitNode(cle);
> -        super.visitClosureListExpression(cle);
> +    void visitClosureListExpression(ClosureListExpression cle) {
> +        visitNode(cle)
> +        super.visitClosureListExpression(cle)
>      }
>  }
>

Mime
View raw message