compiler/sem*: better lineinfo for templates (#10428)

* compiler/sem*: better lineinfo for templates

Lineinfo for templates is inconsistant across the compiler, for example:

    doAssert true
    ^        ^

    a[int](10)
    ^^    ^

The `^` marks where the compiler thinks the template starts.

For qualified call, we got the same situation with `proc`s before #10427:

    system.once
          ^

Generics lineinfo within template declaration is also incorrect, for
example, this is where the compiler believes the `T` in `[T]` is:

    template a[T](b: T)
                  ^

This PR addresses all of these problems.

* nimsuggest: add tests for template highlighting
This commit is contained in:
alaviss 2019-01-23 22:35:34 +07:00 • committed by Andreas Rumpf
commit 35d96d8749
5 changed files with 27 additions and 9 deletions

View file

@ -1,8 +1,8 @@
newSeq[int]()
system.newSeq[int]()#[!]#
offsetOf[int]()
discard """
disabled:true
$nimsuggest --tester $file
>highlight $1
highlight;;skType;;1;;7;;3
@ -15,4 +15,6 @@ highlight;;skProc;;2;;7;;6
highlight;;skProc;;2;;7;;6
highlight;;skType;;2;;14;;3
highlight;;skProc;;2;;7;;6
highlight;;skTemplate;;3;;0;;8
highlight;;skType;;3;;9;;3
"""

View file

@ -1,9 +1,12 @@
system.echo#[!]#
system.once
discard """
disabled:true
$nimsuggest --tester $file
>highlight $1
highlight;;skProc;;1;;7;;4
highlight;;skProc;;1;;7;;4
highlight;;skTemplate;;2;;7;;4
highlight;;skTemplate;;2;;7;;4
highlight;;skTemplate;;2;;7;;4
"""

View file

@ -0,0 +1,9 @@
doAssert true#[!]#
discard """
$nimsuggest --tester $1
>highlight $1
highlight;;skTemplate;;1;;0;;8
highlight;;skTemplate;;1;;0;;8
highlight;;skEnumField;;1;;9;;4
"""