GRECLIPSE
  1. GRECLIPSE
  2. GRECLIPSE-292

[groovycbug] using return statements in methods declared with a void return value causes "exception occurred during problem dection"

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0alpha
    • Fix Version/s: 2.0.1Release
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      1

      Description

      public class VoidReturnTestCase {

      void returnSomething()

      { return true }

      }

      This causes an "Exception occurred during problem detection" message to appear when the file is saved and every time you hover over the first line of the method.

      Additionally a orange marker appears at the top of the file on the first line which contains a useful message but the message marker should appear in the gutter of the first line of the method and should be highlighted better.

      I'm not sure if the correct marker should be a round red X instead of orange warning triangle.

        Activity

        Hide
        Dominic Clifton added a comment -

        Actually thinking about it, maybe the message should appear on the line that contains the return statement? I think I'll leave that to the groovy language experts to decide though.

        Show
        Dominic Clifton added a comment - Actually thinking about it, maybe the message should appear on the line that contains the return statement? I think I'll leave that to the groovy language experts to decide though.
        Hide
        Dominic Clifton added a comment -

        This is the exception that occurs:

        java.lang.NullPointerException
        at org.objectweb.asm.MethodWriter.visitJumpInsn(Unknown Source)
        at org.objectweb.asm.MethodAdapter.visitJumpInsn(Unknown Source)
        at org.codehaus.groovy.classgen.AsmClassGenerator$MyMethodAdapter.visitJumpInsn(AsmClassGenerator.java:4406)
        at org.codehaus.groovy.classgen.AsmClassGenerator.visitContinueStatement(AsmClassGenerator.java:1169)
        at org.codehaus.groovy.ast.stmt.ContinueStatement.visit(ContinueStatement.java:44)
        at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:122)
        at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:665)
        at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:51)
        at org.codehaus.groovy.ast.CodeVisitorSupport.visitCatchStatement(CodeVisitorSupport.java:263)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitCatchStatement(ClassCodeVisitorSupport.java:137)
        at org.codehaus.groovy.ast.stmt.CatchStatement.visit(CatchStatement.java:41)
        at org.codehaus.groovy.classgen.AsmClassGenerator.visitTryCatchFinally(AsmClassGenerator.java:1039)
        at org.codehaus.groovy.ast.stmt.TryCatchStatement.visit(TryCatchStatement.java:42)
        at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:122)
        at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:665)
        at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:51)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:66)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:73)
        at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:542)
        at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:518)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:81)
        at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:622)
        at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:967)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:47)
        at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:243)
        at org.codehaus.groovy.control.CompilationUnit$7.call(CompilationUnit.java:770)
        at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:981)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:462)
        at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompilationUnitDeclaration.java:133)
        at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.generateCode(GroovyCompilationUnitDeclaration.java:1043)
        at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:904)
        at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:186)
        at org.codehaus.jdt.groovy.model.GroovyCompilationUnit.buildStructure(GroovyCompilationUnit.java:309)
        at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:258)
        at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:515)
        at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:252)
        at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:238)
        at org.eclipse.jdt.internal.core.JavaElement.getChildren(JavaElement.java:193)
        at org.eclipse.jdt.internal.core.JavaElement.getChildrenOfType(JavaElement.java:207)
        at org.eclipse.jdt.internal.core.CompilationUnit.getTypes(CompilationUnit.java:930)
        at org.eclipse.jdt.internal.core.NameLookup.<init>(NameLookup.java:185)
        at org.eclipse.jdt.internal.core.JavaProjectElementInfo.newNameLookup(JavaProjectElementInfo.java:346)
        at org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.java:2241)
        at org.eclipse.jdt.internal.core.SearchableEnvironment.<init>(SearchableEnvironment.java:56)
        at org.eclipse.jdt.internal.core.JavaProject.newSearchableNameEnvironment(JavaProject.java:2258)
        at org.eclipse.jdt.internal.core.hierarchy.HierarchyBuilder.<init>(HierarchyBuilder.java:81)
        at org.eclipse.jdt.internal.core.hierarchy.IndexBasedHierarchyBuilder.<init>(IndexBasedHierarchyBuilder.java:96)
        at org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.compute(TypeHierarchy.java:297)
        at org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.refresh(TypeHierarchy.java:1255)
        at org.eclipse.jdt.internal.core.CreateTypeHierarchyOperation.executeOperation(CreateTypeHierarchyOperation.java:90)
        at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
        at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:788)
        at org.eclipse.jdt.internal.core.SourceType.newSupertypeHierarchy(SourceType.java:726)
        at org.eclipse.jdt.internal.core.SourceType.newSupertypeHierarchy(SourceType.java:678)
        at org.eclipse.jdt.internal.corext.util.SuperTypeHierarchyCache.getTypeHierarchy(SuperTypeHierarchyCache.java:139)
        at org.eclipse.jdt.internal.corext.util.SuperTypeHierarchyCache.getTypeHierarchy(SuperTypeHierarchyCache.java:91)
        at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2$JavadocLookup.getTypeHierarchy(JavadocContentAccess2.java:383)
        at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2$JavadocLookup.getInheritedDescription(JavadocContentAccess2.java:337)
        at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2$JavadocLookup.getInheritedMainDescription(JavadocContentAccess2.java:254)
        at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.toHTML(JavadocContentAccess2.java:768)
        at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.javadoc2HTML(JavadocContentAccess2.java:620)
        at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.getHTMLContentFromSource(JavadocContentAccess2.java:566)
        at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.getHTMLContent(JavadocContentAccess2.java:458)
        at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo(JavadocHover.java:555)
        at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.internalGetHoverInfo(JavadocHover.java:512)
        at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo2(JavadocHover.java:495)
        at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:129)
        at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo2(JavaEditorTextHoverProxy.java:82)
        at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:166)

        Show
        Dominic Clifton added a comment - This is the exception that occurs: java.lang.NullPointerException at org.objectweb.asm.MethodWriter.visitJumpInsn(Unknown Source) at org.objectweb.asm.MethodAdapter.visitJumpInsn(Unknown Source) at org.codehaus.groovy.classgen.AsmClassGenerator$MyMethodAdapter.visitJumpInsn(AsmClassGenerator.java:4406) at org.codehaus.groovy.classgen.AsmClassGenerator.visitContinueStatement(AsmClassGenerator.java:1169) at org.codehaus.groovy.ast.stmt.ContinueStatement.visit(ContinueStatement.java:44) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:122) at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:665) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:51) at org.codehaus.groovy.ast.CodeVisitorSupport.visitCatchStatement(CodeVisitorSupport.java:263) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitCatchStatement(ClassCodeVisitorSupport.java:137) at org.codehaus.groovy.ast.stmt.CatchStatement.visit(CatchStatement.java:41) at org.codehaus.groovy.classgen.AsmClassGenerator.visitTryCatchFinally(AsmClassGenerator.java:1039) at org.codehaus.groovy.ast.stmt.TryCatchStatement.visit(TryCatchStatement.java:42) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:122) at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:665) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:51) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:66) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:73) at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:542) at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:518) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:81) at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:622) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:967) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:47) at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:243) at org.codehaus.groovy.control.CompilationUnit$7.call(CompilationUnit.java:770) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:981) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:462) at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompilationUnitDeclaration.java:133) at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.generateCode(GroovyCompilationUnitDeclaration.java:1043) at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:904) at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:186) at org.codehaus.jdt.groovy.model.GroovyCompilationUnit.buildStructure(GroovyCompilationUnit.java:309) at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:258) at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:515) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:252) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:238) at org.eclipse.jdt.internal.core.JavaElement.getChildren(JavaElement.java:193) at org.eclipse.jdt.internal.core.JavaElement.getChildrenOfType(JavaElement.java:207) at org.eclipse.jdt.internal.core.CompilationUnit.getTypes(CompilationUnit.java:930) at org.eclipse.jdt.internal.core.NameLookup.<init>(NameLookup.java:185) at org.eclipse.jdt.internal.core.JavaProjectElementInfo.newNameLookup(JavaProjectElementInfo.java:346) at org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.java:2241) at org.eclipse.jdt.internal.core.SearchableEnvironment.<init>(SearchableEnvironment.java:56) at org.eclipse.jdt.internal.core.JavaProject.newSearchableNameEnvironment(JavaProject.java:2258) at org.eclipse.jdt.internal.core.hierarchy.HierarchyBuilder.<init>(HierarchyBuilder.java:81) at org.eclipse.jdt.internal.core.hierarchy.IndexBasedHierarchyBuilder.<init>(IndexBasedHierarchyBuilder.java:96) at org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.compute(TypeHierarchy.java:297) at org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.refresh(TypeHierarchy.java:1255) at org.eclipse.jdt.internal.core.CreateTypeHierarchyOperation.executeOperation(CreateTypeHierarchyOperation.java:90) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728) at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:788) at org.eclipse.jdt.internal.core.SourceType.newSupertypeHierarchy(SourceType.java:726) at org.eclipse.jdt.internal.core.SourceType.newSupertypeHierarchy(SourceType.java:678) at org.eclipse.jdt.internal.corext.util.SuperTypeHierarchyCache.getTypeHierarchy(SuperTypeHierarchyCache.java:139) at org.eclipse.jdt.internal.corext.util.SuperTypeHierarchyCache.getTypeHierarchy(SuperTypeHierarchyCache.java:91) at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2$JavadocLookup.getTypeHierarchy(JavadocContentAccess2.java:383) at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2$JavadocLookup.getInheritedDescription(JavadocContentAccess2.java:337) at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2$JavadocLookup.getInheritedMainDescription(JavadocContentAccess2.java:254) at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.toHTML(JavadocContentAccess2.java:768) at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.javadoc2HTML(JavadocContentAccess2.java:620) at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.getHTMLContentFromSource(JavadocContentAccess2.java:566) at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.getHTMLContent(JavadocContentAccess2.java:458) at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo(JavadocHover.java:555) at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.internalGetHoverInfo(JavadocHover.java:512) at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo2(JavadocHover.java:495) at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:129) at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo2(JavaEditorTextHoverProxy.java:82) at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:166)
        Hide
        Dominic Clifton added a comment -

        This is the content that appears in the tooltip that pops up when hovering over the annotation at the top of the file:

        General error during class generation: Cannot use return statement with an expression on a method that returns void. Node:
        org.codehaus.groovy.ast.stmt.ReturnStatement. At [5:3] /grails-testing/src/groovy/VoidReturnTestCase.groovy
        org.codehaus.groovy.syntax.RuntimeParserException: Cannot use return statement with an expression on a method that returns void.
        Node: org.codehaus.groovy.ast.stmt.ReturnStatement. At [5:3] /grails-testing/src/groovy/VoidReturnTestCase.groovy at
        org.codehaus.groovy.classgen.AsmClassGenerator.throwException(AsmClassGenerator.java:1532) at
        org.codehaus.groovy.classgen.AsmClassGenerator.visitReturnStatement(AsmClassGenerator.java:1238) at
        org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:47) at
        org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35) at
        org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:122) at
        org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:665) at
        org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:51) at
        org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:66) at
        org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:73) at
        org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:542) at
        org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:518) at
        org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:81) at
        org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:622) at
        org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:967) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass
        (ClassCodeVisitorSupport.java:47) at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:243) at
        org.codehaus.groovy.control.CompilationUnit$7.call(CompilationUnit.java:770) at
        org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:981) at
        org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:462) at
        org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase
        (GroovyCompilationUnitDeclaration.java:133) at
        org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.generateCode(GroovyCompilationUnitDeclaration.java:
        1043) at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:904) at
        org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:186) at
        org.codehaus.jdt.groovy.model.GroovyCompilationUnit.buildStructure(GroovyCompilationUnit.java:328) at
        org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:258) at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed
        (JavaElement.java:515) at org.eclipse.jdt.internal.core.CompilationUnit.makeConsistent(CompilationUnit.java:1094) at
        org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:170) at
        org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:89) at
        org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728) at
        org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:788) at
        org.codehaus.jdt.groovy.model.GroovyCompilationUnit.reconcile(GroovyCompilationUnit.java:589) at
        org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:126) at
        org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.access$0(JavaReconcilingStrategy.java:108) at
        org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:89) at
        org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile
        (JavaReconcilingStrategy.java:87) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:
        151) at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86) at
        org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:102) at
        org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77) at org.eclipse.jface.text.reconciler.AbstractReconciler
        $BackgroundThread.run(AbstractReconciler.java:206)

        Show
        Dominic Clifton added a comment - This is the content that appears in the tooltip that pops up when hovering over the annotation at the top of the file: General error during class generation: Cannot use return statement with an expression on a method that returns void. Node: org.codehaus.groovy.ast.stmt.ReturnStatement. At [5:3] /grails-testing/src/groovy/VoidReturnTestCase.groovy org.codehaus.groovy.syntax.RuntimeParserException: Cannot use return statement with an expression on a method that returns void. Node: org.codehaus.groovy.ast.stmt.ReturnStatement. At [5:3] /grails-testing/src/groovy/VoidReturnTestCase.groovy at org.codehaus.groovy.classgen.AsmClassGenerator.throwException(AsmClassGenerator.java:1532) at org.codehaus.groovy.classgen.AsmClassGenerator.visitReturnStatement(AsmClassGenerator.java:1238) at org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:47) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:122) at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:665) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:51) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:66) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:73) at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:542) at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:518) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:81) at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:622) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:967) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass (ClassCodeVisitorSupport.java:47) at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:243) at org.codehaus.groovy.control.CompilationUnit$7.call(CompilationUnit.java:770) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:981) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:462) at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase (GroovyCompilationUnitDeclaration.java:133) at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.generateCode(GroovyCompilationUnitDeclaration.java: 1043) at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:904) at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:186) at org.codehaus.jdt.groovy.model.GroovyCompilationUnit.buildStructure(GroovyCompilationUnit.java:328) at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:258) at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed (JavaElement.java:515) at org.eclipse.jdt.internal.core.CompilationUnit.makeConsistent(CompilationUnit.java:1094) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:170) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:89) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728) at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:788) at org.codehaus.jdt.groovy.model.GroovyCompilationUnit.reconcile(GroovyCompilationUnit.java:589) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:126) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.access$0(JavaReconcilingStrategy.java:108) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:89) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile (JavaReconcilingStrategy.java:87) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java: 151) at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86) at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:102) at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77) at org.eclipse.jface.text.reconciler.AbstractReconciler $BackgroundThread.run(AbstractReconciler.java:206)
        Hide
        Andy Clement added a comment -

        On the latest builds I cannot get the NPE to happen - I do think (whilst working on another bug) I fixed something vaguely in that error that may have stopped it occurring.
        The "Cannot use return statement with an expression on a method that returns void." is a groovy bug, not a groovy eclipse bug since the same thing goes wrong on the command line with 1.7 beta 1. Once the exception is recorded properly the plugin will be highlighting the right area of source.

        Show
        Andy Clement added a comment - On the latest builds I cannot get the NPE to happen - I do think (whilst working on another bug) I fixed something vaguely in that error that may have stopped it occurring. The "Cannot use return statement with an expression on a method that returns void." is a groovy bug, not a groovy eclipse bug since the same thing goes wrong on the command line with 1.7 beta 1. Once the exception is recorded properly the plugin will be highlighting the right area of source.
        Hide
        Andy Clement added a comment -

        tagging as groovycbug so that I know to raise an issue with them when I get a moment.

        Show
        Andy Clement added a comment - tagging as groovycbug so that I know to raise an issue with them when I get a moment.
        Hide
        Andy Clement added a comment -

        I'm adding a testcase for this to GroovySimpleTest. The NPE is fixed, but in the UI the highlighting is still horrible. In my example project it highlights the line before the method with the error.

        Show
        Andy Clement added a comment - I'm adding a testcase for this to GroovySimpleTest. The NPE is fixed, but in the UI the highlighting is still horrible. In my example project it highlights the line before the method with the error.
        Hide
        Andy Clement added a comment -

        Two problems with the positioning.

        (1) In GroovyCompilationUnitDeclaration, if the exception is not a PreciseSyntaxException then we are recalculating the start and end offsets. This may overwrite better offsets we have already worked out. So the solution is only to recalculate them if we haven't already worked them out.

        (2) The groovy parser is behaving as follows, it uses the 'following' token to mark the end of the current construct. This means in this line "public int foo()

        { return 25 }

        " it uses the '}' to mark the end of the return statement. Really it should use the last column information for the last component of the return statement, ie. the 25.

        The second change looks like a general problem throughout the groovy parser - anything that causes attachLast to run in the recognizer will be getting the end column a little bit wrong.

        Show
        Andy Clement added a comment - Two problems with the positioning. (1) In GroovyCompilationUnitDeclaration, if the exception is not a PreciseSyntaxException then we are recalculating the start and end offsets. This may overwrite better offsets we have already worked out. So the solution is only to recalculate them if we haven't already worked them out. (2) The groovy parser is behaving as follows, it uses the 'following' token to mark the end of the current construct. This means in this line "public int foo() { return 25 } " it uses the '}' to mark the end of the return statement. Really it should use the last column information for the last component of the return statement, ie. the 25. The second change looks like a general problem throughout the groovy parser - anything that causes attachLast to run in the recognizer will be getting the end column a little bit wrong.
        Hide
        Andy Clement added a comment -

        All fixed up. Following changes:

        1) modified the groovy grammar again. Instead of using the token following the return expression to mark the end it now uses the last token of the expression. So you won't get trailing whitespace between the expression end and the next token considered as part of the expression.

        2) Adjusted the computation in GroovyCompilationUnitDeclaration. Inclusion of a -1 when retreiving the end column because groovy is working where the end position is the character after the end of the token whilst eclipse is working where the end position is the last character of the token.

        With these changes it now correctly underlines the return expression. The change also meant I could update some old tests that had incorrect underlining.

        Show
        Andy Clement added a comment - All fixed up. Following changes: 1) modified the groovy grammar again. Instead of using the token following the return expression to mark the end it now uses the last token of the expression. So you won't get trailing whitespace between the expression end and the next token considered as part of the expression. 2) Adjusted the computation in GroovyCompilationUnitDeclaration. Inclusion of a -1 when retreiving the end column because groovy is working where the end position is the character after the end of the token whilst eclipse is working where the end position is the last character of the token. With these changes it now correctly underlines the return expression. The change also meant I could update some old tests that had incorrect underlining.

          People

          • Assignee:
            Andy Clement
            Reporter:
            Dominic Clifton
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: