Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.0.2Release
-
Fix Version/s: 2.1.1Release
-
Component/s: None
-
Labels:None
-
Environment:Groovy-Eclipse Feature 2.0.2.20100607-1300-e35 org.codehaus.groovy.eclipse.feature.feature.group
-
Number of attachments :
Description
Spock's AST transform relies on correct source positions for AST nodes (esp. expressions). But for some reason, some AST nodes have wrong source position when the transform is run with Groovy Eclipse. Example:
package org.spockframework.smoke import spock.lang.* class EclipseAstProblems extends Specification { def foo() { expect: def map = [:] map = [:] } }
Here is the transform's log output for capturing the last expression's source code when run with groovyc (tried both with 1.7.2 and 1.7.0):
AST node: BinaryExpression Position: (10,5)-(10,14) Text: map = [:]
And here is the output when run with Groovy Eclipse (1.7 mode):
AST node: BinaryExpression Position: (10,5)-(10,12) Text: map = [
As you can see, the last two characters are missing, resulting in an error when the Spock runtime later tries to reparse the expression. Same problem exists for other, more complicated expressions.
I also recently ran into an example where AST position info was incorrect: http://jira.codehaus.org/browse/GRECLIPSE-758
I was thinking it might be a good idea to implement some kind of sanity check (e.g. a node's children should have positions that are inside the node's position). Unfortunately I did not proceed to implement this sanity check because I couldn't find an easy way to "getChildren" on an AST node in a generic way.
Maybe I should look into this again. Any hints on how to get AST children easily would be much appreciated