language-server: fixup tests

This commit is contained in:
Liam Fitzgerald 2020-01-22 11:16:28 +10:00
parent 04225dff73
commit 3187d6725b
4 changed files with 155 additions and 116 deletions

View File

@ -178,7 +178,6 @@
++ handle-did-save
|= [uri=@t version=(unit @)]
^- (quip card _state)
~& "Committing"
:_ state
:_ (give-rpc-notification (get-diagnostics uri))
:*
@ -206,7 +205,6 @@
?. ?=([%made *] gift)
[~ state]
?. ?=([%complete *] result.gift)
~& tang.result.gift
[~ state]
=/ uri=@t
(snag 1 path)
@ -225,7 +223,6 @@
[%error *]
=/ error-ranges=(list =range:lsp-sur)
(get-errors-from-tang:build uri message.build-result)
~& message.build-result
?~ error-ranges
[~ state]
=. ford-diagnostics
@ -265,10 +262,8 @@
^- (list diagnostic:lsp-sur)
=/ t=tape
(zing (join "\0a" `wall`(~(got by bufs) uri)))
:: ~& t
=/ parse
(lily:auto t (lsp-parser *beam))
:: ~& parse
?. ?=(%| -.parse)
~
=/ loc=position:lsp-sur

View File

@ -30,7 +30,6 @@
(parse-error p.tank)
?~ error
~
~& path.u.error
?: =(path path.u.error)
`range.u.error
~

View File

@ -92,7 +92,6 @@
|= jon=json
^- text-document--did-change:notification:lsp
:- %text-document--did-change
=, dejs:format
%. jon
%: ot
'textDocument'^text-document-id
@ -103,7 +102,6 @@
++ text-document--did-open
|= jon=json
^- text-document--did-open:notification:lsp
=, dejs:format
?> ?=([%o *] jon)
:- %text-document--did-open
(text-document-item (~(got by p.jon) 'textDocument'))
@ -114,7 +112,6 @@
|= jon=json
^- text-document-item:lsp
%. jon
=, dejs:format
%: ot
uri+so
version+(mu ni)
@ -130,7 +127,6 @@
==
::
++ text-document-changes
=, dejs:format
%- ar
%: ou
range+(uf ~ (pe ~ range))
@ -198,7 +194,6 @@
==
~! -.notification
=/ method=cord (crip (unparse-method -.notification))
~& method
%: pairs
method+s+method
params+params
@ -278,97 +273,5 @@
~
==
::
--
:: examples
++ pos-jon
^- json
:- %o
%: malt
['character' %n '3']
['line' %n '5']
~
==
::
++ range-jon
^- json
:- %o
%: malt
['start' pos-jon]
['end' pos-jon]
~
==
::
++ change-jon
^- json
:- %o
%: malt
['text' `json`[%s `@t`'text']]
['rangeLength' [%n '3']]
['range' range-jon]
~
==
::
++ changes-jon
^- json
:- %a
^- (list json)
[change-jon ~]
::
++ text-document-jon
^- json
:- %o
%: malt
['uri' `json`[%s 'file://']]
['version' `json`[%n '1']]
~
==
::
++ did-change-jon
^- json
:- %o
%: malt
['contentChanges' changes-jon]
['textDocument' text-document-jon]
~
==
::
++ did-c-event-jon
^- json
:- %o
%: malt
['id' `json`[%s '1']]
['method' `json`[%s `@t`'textDocument/didChange']]
['params' did-change-jon]
~
==
::
++ did-open-jon
^- json
:- %o
%: malt
['textDocument' text-document-item-jon]
~
==
::
++ did-open-event-jon
^- json
:- %o
^- (map cord json)
%: malt
['id' `json`[%s '3']]
['method' `json`[%s 'textDocument/didOpen']]
['params' did-open-jon]
~
==
++ text-document-item-jon
^- json
:- %o
^- (map cord json)
%: malt
['text' `json`[%s 'text']]
['uri' `json`[%s 'file://uri']]
['version' `json`[%n '1']]
~
==
--

View File

@ -1,9 +1,12 @@
:: tests for lsp JSON parsing
/- lsp-types=language-server
/- lsp-sur=language-server
/+ *test, *language-server-json
=, enjs:format
|%
::
++ pos-jon
++ position
[5 3]
++ position-jon
^- json
:- %o
%: malt
@ -12,12 +15,15 @@
~
==
::
++ range
[position position]
::
++ range-jon
^- json
:- %o
%: malt
['start' pos-jon]
['end' pos-jon]
['start' position-jon]
['end' position-jon]
~
==
::
@ -37,24 +43,160 @@
^- (list json)
[change-jon ~]
::
++ text-document-jon
++ text-document-item
^- text-document-item:lsp-sur
['file://' `1 'text']
::
++ text-document-item-jon
^- json
:- %o
%: malt
['uri' %s 'file://']
['version' %s '1']
['uri' `json`[%s 'file://']]
['version' `json`[%n '1']]
['text' `json`[%s 'text']]
~
==
::
++ test-parse-did-change
%+ expect-eq
!> [%text-document--did-change ['file://' '1'] [[~ [[5 3] [5 3]]] `3 'text']~]
!> %- parse-text-document--did-change
++ text-document-id
^- versioned-doc-id:lsp-sur
['file://' `1]
::
++ text-document-id-jon
^- json
:- %o
%: malt
['contentChanges' changes-jon]
['textDocument' text-document-jon]
['uri' `json`[%s 'file://']]
['version' `json`[%n '1']]
~
==
++ diagnostic
^- diagnostic:lsp-sur
[range 1 'Syntax Error']
::
++ diagnostic-jon
^- json
:- %o
%: malt
['range' range-jon]
['severity' `json`[%n '1']]
['message' `json`[%s 'Syntax Error']]
~
==
::
++ make-notification-jon
|= [method=@t params=json]
^- json
%: pairs
['method' `json`[%s method]]
params+params
~
==
++ make-request-jon
|= [id=@t method=@t params=json]
^- json
%: pairs
['id' `json`[%s id]]
['method' `json`[%s method]]
params+params
~
==
++ make-response-jon
|= [id=@t result=json]
%: pairs
id+s+id
result+result
~
==
::
:: Notifications
::
++ test-parse-did-change
%+ expect-eq
!> ^- all:notification:lsp-sur
[%text-document--did-change text-document-id [[~ [[5 3] [5 3]]] `3 'text']~]
!> %- notification:dejs
%+ make-notification-jon 'textDocument/didChange'
:- %o
%: malt
['contentChanges' changes-jon]
['textDocument' text-document-id-jon]
~
==
::
++ test-parse-did-save
%+ expect-eq
!> ^- all:notification:lsp-sur
[%text-document--did-save text-document-id]
!> %- notification:dejs
%+ make-notification-jon 'textDocument/didSave'
:- %o
%: malt
['textDocument' text-document-id-jon]
~
==
::
++ test-parse-did-close
%+ expect-eq
!> ^- all:notification:lsp-sur
[%text-document--did-close text-document-id]
!> %- notification:dejs
%+ make-notification-jon 'textDocument/didClose'
:- %o
%: malt
['textDocument' text-document-id-jon]
~
==
::
++ test-parse-did-open
%+ expect-eq
!> ^- all:notification:lsp-sur
[%text-document--did-open text-document-item]
!> %- notification:dejs
%+ make-notification-jon 'textDocument/didOpen'
:- %o
%: malt
['textDocument' text-document-item-jon]
~
==
::
:: Requests
::
++ test-parse-hover
%+ expect-eq
!> ^- all:request:lsp-sur
[%text-document--hover '3' position text-document-id]
!> %- request:dejs
^- json
%^ make-request-jon '3' 'textDocument/hover'
:- %o
%: malt
['position' position-jon]
['textDocument' text-document-id-jon]
~
==
:: to JSON
::
:: notifications
::
++ test-enjs-publish-diagnostics
%+ expect-eq
!> %- notification:enjs
[%text-document--publish-diagnostics 'file://' [diagnostic ~]]
!> ^- json
%+ make-notification-jon 'textDocument/publishDiagnostics'
:- %o
%: malt
['uri' `json`[%s 'file://']]
['diagnostics' `json`[%a [diagnostic-jon ~]]]
~
==
:: responses
++ test-enjs-hover
%+ expect-eq
!> %- response:enjs
[%text-document--hover '1' `'text']
!> ^- json
%+ make-response-jon '1'
%+ frond 'contents'
s+'text'
--