More language.fnl changes
This commit is contained in:
parent
2e1a2b74b5
commit
b8565bd146
@ -80,7 +80,8 @@ Every time the client sends a message, it gets handled by a function in the corr
|
|||||||
;; regular symbol
|
;; regular symbol
|
||||||
(language.search-main self file symbol {:stop-early? true} byte))
|
(language.search-main self file symbol {:stop-early? true} byte))
|
||||||
result
|
result
|
||||||
(message.range-and-uri self result.file (or result.binding result.definition))
|
(if result.file
|
||||||
|
(message.range-and-uri self result.file (or result.binding result.definition)))
|
||||||
(catch _ nil))))
|
(catch _ nil))))
|
||||||
|
|
||||||
(λ requests.textDocument/references [self send {: position
|
(λ requests.textDocument/references [self send {: position
|
||||||
|
|||||||
@ -80,7 +80,9 @@ but that info does
|
|||||||
|
|
||||||
(λ search-symbol [self file symbol stack opts]
|
(λ search-symbol [self file symbol stack opts]
|
||||||
(if (= (tostring symbol) :nil)
|
(if (= (tostring symbol) :nil)
|
||||||
{:definition symbol : file}
|
(if (= 0 (length stack))
|
||||||
|
{:definition symbol : file}
|
||||||
|
nil)
|
||||||
;; TODO globals
|
;; TODO globals
|
||||||
(case (. file.references symbol)
|
(case (. file.references symbol)
|
||||||
to (search-assignment self file to (stack-add-multisym! stack symbol) opts))))
|
to (search-assignment self file to (stack-add-multisym! stack symbol) opts))))
|
||||||
@ -120,7 +122,7 @@ but that info does
|
|||||||
(search-val self file (. call 2) stack opts)
|
(search-val self file (. call 2) stack opts)
|
||||||
|
|
||||||
(where (or :fn :lambda :λ))
|
(where (or :fn :lambda :λ))
|
||||||
(if (= multival 1)
|
(if (and (= multival 1) (= 0 (length stack)))
|
||||||
{:definition call : file}) ;; BASE CASE !!
|
{:definition call : file}) ;; BASE CASE !!
|
||||||
;; TODO expand-macros
|
;; TODO expand-macros
|
||||||
|
|
||||||
@ -151,7 +153,7 @@ but that info does
|
|||||||
(if (sym? symbol)
|
(if (sym? symbol)
|
||||||
(let [split (utils.multi-sym-split symbol (if ?byte (+ 1 (- ?byte symbol.bytestart))))
|
(let [split (utils.multi-sym-split symbol (if ?byte (+ 1 (- ?byte symbol.bytestart))))
|
||||||
stack (stack-add-split! [] split)]
|
stack (stack-add-split! [] split)]
|
||||||
(case (. METADATA (. SPECIALS (tostring symbol)))
|
(case (. METADATA (or (. MACROS (tostring symbol)) (. SPECIALS (tostring symbol))))
|
||||||
metadata {:binding symbol : metadata}
|
metadata {:binding symbol : metadata}
|
||||||
_ (case (. file.references symbol)
|
_ (case (. file.references symbol)
|
||||||
ref (search-assignment self file ref stack opts)
|
ref (search-assignment self file ref stack opts)
|
||||||
|
|||||||
@ -104,6 +104,12 @@
|
|||||||
_response (c:definition :foo.fnl 1 8)]
|
_response (c:definition :foo.fnl 1 8)]
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
|
(it "doesn't crash when going to hashfn"
|
||||||
|
(let [c (create-client)
|
||||||
|
_ (c:open-file! :foo.fnl "#$...")
|
||||||
|
_response (c:definition :foo.fnl 0 0)]
|
||||||
|
nil))
|
||||||
|
|
||||||
(it "can go through multival destructures"
|
(it "can go through multival destructures"
|
||||||
(let [c (doto (create-client)
|
(let [c (doto (create-client)
|
||||||
(: :open-file! :foo.fnl "(local [x y] (values [1 2] [3 4]))\n(local (a b) (values {:x y : y} {: x : y}))\n(print b.x a)"))
|
(: :open-file! :foo.fnl "(local [x y] (values [1 2] [3 4]))\n(local (a b) (values {:x y : y} {: x : y}))\n(print b.x a)"))
|
||||||
|
|||||||
@ -81,4 +81,18 @@
|
|||||||
(is (hover-x.result.contents.value:find "```fnl\n1\n```"))
|
(is (hover-x.result.contents.value:find "```fnl\n1\n```"))
|
||||||
(is (hover-y.result.contents.value:find "```fnl\n2\n```"))
|
(is (hover-y.result.contents.value:find "```fnl\n2\n```"))
|
||||||
(is (hover-z.result.contents.value:find "```fnl\n3\n```"))
|
(is (hover-z.result.contents.value:find "```fnl\n3\n```"))
|
||||||
nil)))
|
nil))
|
||||||
|
|
||||||
|
(it "hovers over a special"
|
||||||
|
(let [client (doto (create-client)
|
||||||
|
(: :open-file! :foo.fnl "(do nil)"))
|
||||||
|
[hover-do] (client:hover :foo.fnl 0 2)]
|
||||||
|
(is.equal hover-do.result.contents.value
|
||||||
|
"```fnl\n(do ...)\n```\nEvaluate multiple forms; return last value.")))
|
||||||
|
|
||||||
|
(it "hovers over a builtin macro"
|
||||||
|
(let [client (doto (create-client)
|
||||||
|
(: :open-file! :foo.fnl "(doto nil (print))"))
|
||||||
|
[hover-do] (client:hover :foo.fnl 0 2)]
|
||||||
|
(is.equal hover-do.result.contents.value
|
||||||
|
"```fnl\n(doto val ...)\n```\nEvaluate val and splice it into the first argument of subsequent forms."))))
|
||||||
|
|||||||
@ -23,4 +23,5 @@
|
|||||||
|
|
||||||
(let [{: passes : errors} (require :test.lust)]
|
(let [{: passes : errors} (require :test.lust)]
|
||||||
(print (.. passes " passes. " errors " errors."))
|
(print (.. passes " passes. " errors " errors."))
|
||||||
(os.exit errors))
|
(if (not= errors 0)
|
||||||
|
(os.exit errors)))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user