docs get-global takes a self parameter
This commit is contained in:
parent
10aeb63142
commit
db7a911b7f
@ -88,7 +88,7 @@ identifiers are declared / referenced in which places."
|
|||||||
;; find reference
|
;; find reference
|
||||||
(let [name (string.match (tostring symbol) "[^%.:]+")]
|
(let [name (string.match (tostring symbol) "[^%.:]+")]
|
||||||
(case (or (find-definition (tostring name) scope)
|
(case (or (find-definition (tostring name) scope)
|
||||||
(docs.get-global-metadata name))
|
(docs.get-global self name))
|
||||||
target (let [ref {: symbol : target : ref-type}]
|
target (let [ref {: symbol : target : ref-type}]
|
||||||
(tset references symbol ref)
|
(tset references symbol ref)
|
||||||
(when target.referenced-by
|
(when target.referenced-by
|
||||||
@ -360,8 +360,6 @@ identifiers are declared / referenced in which places."
|
|||||||
|
|
||||||
(collect-everything ast lexical)
|
(collect-everything ast lexical)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;; This is bad; we mutate fennel.macro-path
|
;; This is bad; we mutate fennel.macro-path
|
||||||
(let [old-macro-path fennel.macro-path]
|
(let [old-macro-path fennel.macro-path]
|
||||||
(set fennel.macro-path
|
(set fennel.macro-path
|
||||||
|
|||||||
@ -3,19 +3,21 @@
|
|||||||
:macros MACROS}}}
|
:macros MACROS}}}
|
||||||
(require :fennel.compiler))
|
(require :fennel.compiler))
|
||||||
|
|
||||||
(local specials-metadata
|
(local specials
|
||||||
(collect [name value (pairs SPECIALS)]
|
(collect [name value (pairs SPECIALS)]
|
||||||
name {:binding name :metadata (. METADATA value)}))
|
name {:binding name :metadata (. METADATA value)}))
|
||||||
|
|
||||||
(local macros-metadata
|
(local macros*
|
||||||
(collect [name value (pairs MACROS)]
|
(collect [name value (pairs MACROS)]
|
||||||
name {:binding name :metadata (. METADATA value)}))
|
name {:binding name :metadata (. METADATA value)}))
|
||||||
|
|
||||||
(local lua54-metadata (require :fennel-ls.docs.lua54))
|
(local lua54 (require :fennel-ls.docs.lua54))
|
||||||
|
|
||||||
(fn get-global-metadata [global-name]
|
(fn get-global [_self global-name]
|
||||||
(or (. specials-metadata global-name)
|
(or (. specials global-name)
|
||||||
(. macros-metadata global-name)
|
(. macros* global-name)
|
||||||
(. lua54-metadata global-name)))
|
(. lua54 global-name)))
|
||||||
|
|
||||||
{: get-global-metadata}
|
;; TODO get-module-metadata
|
||||||
|
|
||||||
|
{: get-global}
|
||||||
|
|||||||
@ -162,7 +162,7 @@ Every time the client sends a message, it gets handled by a function in the corr
|
|||||||
{: definition : file}
|
{: definition : file}
|
||||||
(case (values definition (type definition))
|
(case (values definition (type definition))
|
||||||
;; fields of a string are hardcoded to "string"
|
;; fields of a string are hardcoded to "string"
|
||||||
(_str :string) (icollect [label info (pairs (. (docs.get-global-metadata :string) :fields))]
|
(_str :string) (icollect [label info (pairs (. (docs.get-global self :string) :fields))]
|
||||||
(formatter.completion-item-format label info))
|
(formatter.completion-item-format label info))
|
||||||
;; fields of a table
|
;; fields of a table
|
||||||
(tbl :table) (let [keys []]
|
(tbl :table) (let [keys []]
|
||||||
|
|||||||
@ -38,7 +38,7 @@ find the definition `10`, but if `opts.stop-early?` is set, it would find
|
|||||||
{:binding z :definition y}, referring to the `(local z y)` binding.
|
{:binding z :definition y}, referring to the `(local z y)` binding.
|
||||||
"
|
"
|
||||||
|
|
||||||
(local {: sym? : list? : sequence? : varg? : sym} (require :fennel))
|
(local {: sym? : list? : sequence? : varg?} (require :fennel))
|
||||||
(local utils (require :fennel-ls.utils))
|
(local utils (require :fennel-ls.utils))
|
||||||
(local state (require :fennel-ls.state))
|
(local state (require :fennel-ls.state))
|
||||||
(local docs (require :fennel-ls.docs))
|
(local docs (require :fennel-ls.docs))
|
||||||
@ -155,7 +155,7 @@ find the definition `10`, but if `opts.stop-early?` is set, it would find
|
|||||||
(if (sym? ast) (search-symbol self file ast stack opts)
|
(if (sym? ast) (search-symbol self file ast stack opts)
|
||||||
(= 0 (length stack)) {:definition ast : file} ;; BASE CASE !!
|
(= 0 (length stack)) {:definition ast : file} ;; BASE CASE !!
|
||||||
(= :table (type ast)) (search-table self file ast stack opts)
|
(= :table (type ast)) (search-table self file ast stack opts)
|
||||||
(= :string (type ast)) (search-document self (docs.get-global-metadata :string) stack opts))
|
(= :string (type ast)) (search-document self (docs.get-global self :string) stack opts))
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ find the definition `10`, but if `opts.stop-early?` is set, it would find
|
|||||||
split (utils.multi-sym-split symbol (if ?byte (- ?byte symbol.bytestart)))]
|
split (utils.multi-sym-split symbol (if ?byte (- ?byte symbol.bytestart)))]
|
||||||
(stack-add-split! [] split)))]
|
(stack-add-split! [] split)))]
|
||||||
|
|
||||||
(case (docs.get-global-metadata (utils.multi-sym-base symbol))
|
(case (docs.get-global self (utils.multi-sym-base symbol))
|
||||||
document (search-document self document stack opts)
|
document (search-document self document stack opts)
|
||||||
_ (case (. file.references symbol)
|
_ (case (. file.references symbol)
|
||||||
ref (search-reference self file ref stack opts)
|
ref (search-reference self file ref stack opts)
|
||||||
@ -193,7 +193,7 @@ find the definition `10`, but if `opts.stop-early?` is set, it would find
|
|||||||
(assert (= (type name) :string))
|
(assert (= (type name) :string))
|
||||||
(let [split (utils.multi-sym-split name)
|
(let [split (utils.multi-sym-split name)
|
||||||
stack (stack-add-split! [] split)]
|
stack (stack-add-split! [] split)]
|
||||||
(case (docs.get-global-metadata (. split 1))
|
(case (docs.get-global self (. split 1))
|
||||||
metadata (search-document self metadata stack (or ?opts {}))
|
metadata (search-document self metadata stack (or ?opts {}))
|
||||||
_ (case (find-local-definition file name scope)
|
_ (case (find-local-definition file name scope)
|
||||||
def (search-val self file def.definition (stack-add-keys! stack def.keys) (or ?opts {}))))))
|
def (search-val self file def.definition (stack-add-keys! stack def.keys) (or ?opts {}))))))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user