parent
fce339f506
commit
bf3f353b8d
@ -137,9 +137,12 @@ we support completionItem/resolve."
|
||||
|
||||
(fn binding-completions []
|
||||
"completions when you're writing a destructure pattern. We suggest identifiers which are unknown"
|
||||
(each [_ {: message} (ipairs file.compile-errors)]
|
||||
(case (message:match "unknown identifier: ([a-zA-Z0-9_-]+)")
|
||||
identifier (add-completion! identifier {} :Variable))))
|
||||
(let [seen {}]
|
||||
(each [_ {: message} (ipairs file.compile-errors)]
|
||||
(case (message:match "unknown identifier: ([a-zA-Z0-9_-]+)")
|
||||
(where identifier (not (. seen identifier)))
|
||||
(do (tset seen identifier true)
|
||||
(add-completion! identifier {} :Variable))))))
|
||||
|
||||
(when symbol
|
||||
(if (. file.definitions symbol)
|
||||
|
||||
@ -116,6 +116,13 @@
|
||||
(+ number-of-x 1)
|
||||
number-of-x))))
|
||||
[])
|
||||
(check "(let [f| 10] foo foo foo"
|
||||
(fn [completions]
|
||||
(faith.= 1 (accumulate [number-of-foo 0 _ completion (ipairs completions.items)]
|
||||
(if (= completion.label :foo)
|
||||
(+ number-of-foo 1)
|
||||
number-of-foo))))
|
||||
[])
|
||||
;; completions of fields (nested)
|
||||
(check "(local x {:y {:z {:a {:b 1}}}}) ; deep tables
|
||||
(local m {}) ; split modules
|
||||
|
||||
@ -381,6 +381,22 @@
|
||||
(assert-ok "(and true (or false true))") ; different operators
|
||||
nil)
|
||||
|
||||
(fn test-zero-indexed []
|
||||
(let [add-opts #{:main.fnl $ :flsproject.fnl "{:lints {:zero-indexed true}}"}]
|
||||
(check (add-opts "(local x {})
|
||||
(. x 0)")
|
||||
[{:code "zero-indexed"
|
||||
:message "indexing a table with 0; did you forget that Lua is 1-indexed?"}])
|
||||
(check (add-opts "(. math 0)")
|
||||
[{:code "zero-indexed"
|
||||
:message "indexing a table with 0; did you forget that Lua is 1-indexed?"}])
|
||||
(assert-ok (add-opts "(. math 1)"))
|
||||
(assert-ok (add-opts "(. arg 0)"))
|
||||
(assert-ok (add-opts "(. math :0)")))
|
||||
nil)
|
||||
|
||||
|
||||
|
||||
{: test-unused
|
||||
: test-ampersand
|
||||
: test-unknown-module-field
|
||||
@ -397,4 +413,5 @@
|
||||
: test-decreasing-comparison
|
||||
: test-arg-count
|
||||
: test-duplicate-keys
|
||||
: test-nested-associative-operator}
|
||||
: test-nested-associative-operator
|
||||
: test-zero-indexed}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user