[ 
https://issues.apache.org/jira/browse/GROOVY-11690?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King updated GROOVY-11690:
-------------------------------
    Description: 
Consider the following script (with intentional errors since we can't multiply 
strings):
{code:groovy}
@TypeChecked
def method() {
    def alphabet = 'abcdefghijklmnopqrstuvwxyz'
    def alphabet2 = 'abcdefghijklmnopqrstuvwxyz' * 'abcdefghijklmnopqrstuvwxyz'
    def alphabet3 = 'abcdefghijklmnopqrstuvwxyz' + '' * 
'abcdefghijklmnopqrstuvwxyz'
}
{code}
When reporting on the first error we don't truncate at all:
{noformat}
[Static type checking] - Cannot find matching method 
java.lang.String#multiply(java.lang.String). Please check if the declared type 
is correct and if the method exists.
 @ line 12, column 21.
       def alphabet2 = 'abcdefghijklmnopqrstuvwxyz' * 
'abcdefghijklmnopqrstuvwxyz'
                       ^
{noformat}
For the second, since the error position is above position 40, we shrink the 
output taking 30 chars before and (up to) 10 after the position where the error 
occurs. It becomes quite minimal context and seems a quite drastic truncation 
given we don't care how long the above non-truncated string may be:
{noformat}
[Static type checking] - Cannot find matching method 
java.lang.String#multiply(java.lang.String). Please check if the declared type 
is correct and if the method exists.
 @ line 13, column 52.
   abcdefghijklmnopqrstuvwxyz' + '' * 'abcd
                                 ^
{noformat}
Instead of 40, 30 and 10, I propose we use 50, 40 and 20, a very modest 
increase. This then gives a little more context:
{noformat}
[Static type checking] - Cannot find matching method 
java.lang.String#multiply(java.lang.String). Please check if the declared type 
is correct and if the method exists.
 @ line 13, column 52.
   habet3 = 'abcdefghijklmnopqrstuvwxyz' + '' * 'abcdefghijklmn
                                           ^
{noformat}

  was:
Consider the following script (with intentional errors since we can't multiply 
strings):
{code:groovy}
@TypeChecked
def method() {
    def alphabet = 'abcdefghijklmnopqrstuvwxyz'
    def alphabet2 = 'abcdefghijklmnopqrstuvwxyz' * 'abcdefghijklmnopqrstuvwxyz'
    def alphabet3 = 'abcdefghijklmnopqrstuvwxyz' + '' * 
'abcdefghijklmnopqrstuvwxyz'
}
{code}
When reporting on the first error we don't truncate at all:
{noformat}
[Static type checking] - Cannot find matching method 
java.lang.String#multiply(java.lang.String). Please check if the declared type 
is correct and if the method exists.
 @ line 12, column 21.
       def alphabet2 = 'abcdefghijklmnopqrstuvwxyz' * 
'abcdefghijklmnopqrstuvwxyz'
                       ^
{noformat}
For the second, since the cursor is above position 40, we shrink the output 
taking 30 chars before and (up to) 10 after the position where the error 
occurs. It becomes quite minimal context and seems a quite drastic truncation 
given we don't care how long the above non-truncated string may be:
{noformat}
[Static type checking] - Cannot find matching method 
java.lang.String#multiply(java.lang.String). Please check if the declared type 
is correct and if the method exists.
 @ line 13, column 52.
   abcdefghijklmnopqrstuvwxyz' + '' * 'abcd
                                 ^
{noformat}
Instead of 40, 30 and 10, I propose we use 50, 40 and 20, a very modest 
increase. This then gives a little more context:
{noformat}
[Static type checking] - Cannot find matching method 
java.lang.String#multiply(java.lang.String). Please check if the declared type 
is correct and if the method exists.
 @ line 13, column 52.
   habet3 = 'abcdefghijklmnopqrstuvwxyz' + '' * 'abcdefghijklmn
                                           ^
{noformat}


> Slightly expanded error messages
> --------------------------------
>
>                 Key: GROOVY-11690
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11690
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>
> Consider the following script (with intentional errors since we can't 
> multiply strings):
> {code:groovy}
> @TypeChecked
> def method() {
>     def alphabet = 'abcdefghijklmnopqrstuvwxyz'
>     def alphabet2 = 'abcdefghijklmnopqrstuvwxyz' * 
> 'abcdefghijklmnopqrstuvwxyz'
>     def alphabet3 = 'abcdefghijklmnopqrstuvwxyz' + '' * 
> 'abcdefghijklmnopqrstuvwxyz'
> }
> {code}
> When reporting on the first error we don't truncate at all:
> {noformat}
> [Static type checking] - Cannot find matching method 
> java.lang.String#multiply(java.lang.String). Please check if the declared 
> type is correct and if the method exists.
>  @ line 12, column 21.
>        def alphabet2 = 'abcdefghijklmnopqrstuvwxyz' * 
> 'abcdefghijklmnopqrstuvwxyz'
>                        ^
> {noformat}
> For the second, since the error position is above position 40, we shrink the 
> output taking 30 chars before and (up to) 10 after the position where the 
> error occurs. It becomes quite minimal context and seems a quite drastic 
> truncation given we don't care how long the above non-truncated string may be:
> {noformat}
> [Static type checking] - Cannot find matching method 
> java.lang.String#multiply(java.lang.String). Please check if the declared 
> type is correct and if the method exists.
>  @ line 13, column 52.
>    abcdefghijklmnopqrstuvwxyz' + '' * 'abcd
>                                  ^
> {noformat}
> Instead of 40, 30 and 10, I propose we use 50, 40 and 20, a very modest 
> increase. This then gives a little more context:
> {noformat}
> [Static type checking] - Cannot find matching method 
> java.lang.String#multiply(java.lang.String). Please check if the declared 
> type is correct and if the method exists.
>  @ line 13, column 52.
>    habet3 = 'abcdefghijklmnopqrstuvwxyz' + '' * 'abcdefghijklmn
>                                            ^
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to