special? and op? shouldn't be in the compiler if we're not using them
This commit is contained in:
parent
38cfd9a249
commit
08e5d38b57
@ -6,7 +6,7 @@ compiler's plugin hook callbacks. It stores lexical info about which
|
||||
identifiers are declared / referenced in which places."
|
||||
|
||||
(local {: sym? : list? : sequence? : table? : varg? : sym : view &as fennel} (require :fennel))
|
||||
(local {:scopes {:global {: specials} :compiler compiler-scope}} (require :fennel.compiler))
|
||||
(local {:scopes {:compiler compiler-scope}} (require :fennel.compiler))
|
||||
(local {: make-compiler-env} (require :fennel.specials))
|
||||
|
||||
(local docs (require :fennel-ls.docs))
|
||||
@ -26,20 +26,6 @@ identifiers are declared / referenced in which places."
|
||||
|
||||
(local nil* (sym :nil))
|
||||
|
||||
(fn special? [item]
|
||||
(and (sym? item)
|
||||
(. specials (tostring item))
|
||||
item))
|
||||
|
||||
(local ops {"+" 1 "-" 1 "*" 1 "/" 1 "//" 1 "%" 1 "^" 1 ">" 1 "<" 1 ">=" 1
|
||||
"<=" 1 "=" 1 "not=" 1 ".." 1 "." 1 "and" 1 "or" 1 "band" 1
|
||||
"bor" 1 "bxor" 1 "bnot" 1 "lshift" 1 "rshift" 1})
|
||||
|
||||
(fn op? [item]
|
||||
(and (sym? item)
|
||||
(. ops (tostring item))
|
||||
item))
|
||||
|
||||
(fn scope? [candidate]
|
||||
;; just checking a couple of the fields
|
||||
(and
|
||||
@ -480,6 +466,4 @@ identifiers are declared / referenced in which places."
|
||||
(set file.macro-refs macro-refs)
|
||||
(set file.macro-calls macro-calls))))
|
||||
|
||||
{: special?
|
||||
: op?
|
||||
: compile}
|
||||
{: compile}
|
||||
|
||||
@ -6,7 +6,8 @@ You can read more about how to add lints in docs/linting.md"
|
||||
|
||||
(local {: sym? : list? : table? : varg? : view
|
||||
: sym : list &as fennel} (require :fennel))
|
||||
(local {: special? : op?} (require :fennel-ls.compiler))
|
||||
(local {:scopes {:global {:specials SPECIALS}}} (require :fennel.compiler))
|
||||
|
||||
(local analyzer (require :fennel-ls.analyzer))
|
||||
(local message (require :fennel-ls.message))
|
||||
(local utils (require :fennel-ls.utils))
|
||||
@ -14,6 +15,28 @@ You can read more about how to add lints in docs/linting.md"
|
||||
(local docs (require :fennel-ls.docs))
|
||||
(local dkjson (require :dkjson))
|
||||
|
||||
|
||||
(fn special? [item]
|
||||
(and (sym? item)
|
||||
(. SPECIALS (tostring item))
|
||||
item))
|
||||
|
||||
(local ops {"+" 1 "-" 1 "*" 1 "/" 1 "//" 1 "%" 1 "^" 1 ">" 1 "<" 1 ">=" 1
|
||||
"<=" 1 "=" 1 "not=" 1 ".." 1 "." 1 "and" 1 "or" 1 "band" 1
|
||||
"bor" 1 "bxor" 1 "bnot" 1 "lshift" 1 "rshift" 1})
|
||||
|
||||
(fn op? [item]
|
||||
(and (sym? item)
|
||||
(. ops (tostring item))
|
||||
item))
|
||||
|
||||
(local op-identity-value {:+ 0 :* 1 :and true :or false :band -1 :bor 0 :.. ""})
|
||||
(local associative-ops {:+ true :* true :and true :or true :band true :bor true :.. true})
|
||||
(local redundant-wrappers {:+ true :* true :and true :or true :band true :bor true :.. true :do true :values true})
|
||||
(local implicit-do-forms (collect [form {: body-form?} (pairs (fennel.syntax))]
|
||||
form body-form?))
|
||||
|
||||
|
||||
(local lints {:definition []
|
||||
:reference []
|
||||
:macro-call []
|
||||
@ -227,9 +250,6 @@ You can read more about how to add lints in docs/linting.md"
|
||||
(table.concat ast "." 3 (- (length ast) 1))
|
||||
(view (. ast (length ast))))}]}})))})
|
||||
|
||||
(local redundant-wrappers
|
||||
{:do true :values true :+ true :* true :and true :or true :band true :bor true ".." true})
|
||||
|
||||
(add-lint :unnecessary-unary
|
||||
{:what-it-does
|
||||
"Warns about unnecessary `do` or `values` forms that only contain a single expression."
|
||||
@ -261,9 +281,6 @@ You can read more about how to add lints in docs/linting.md"
|
||||
:changes [{:range (message.ast->range server file ast)
|
||||
:newText (view (. ast 2))}]}}))})
|
||||
|
||||
(local implicit-do-forms (collect [form {: body-form?} (pairs (fennel.syntax))]
|
||||
form body-form?))
|
||||
|
||||
(add-lint :redundant-do
|
||||
{:what-it-does
|
||||
"Identifies redundant `do` blocks within implicit do forms like `fn`, `let`, etc."
|
||||
@ -377,8 +394,6 @@ You can read more about how to add lints in docs/linting.md"
|
||||
" Consider using (local) instead of (var)")
|
||||
:severity message.severity.WARN}))})
|
||||
|
||||
(local op-identity-value {:+ 0 :* 1 :and true :or false :band -1 :bor 0 :.. ""})
|
||||
|
||||
(add-lint :op-with-no-arguments
|
||||
{:what-it-does
|
||||
"Warns when an operator is called with no arguments, which can be replaced with
|
||||
@ -784,8 +799,6 @@ You can read more about how to add lints in docs/linting.md"
|
||||
:severity message.severity.WARN}))))
|
||||
nil)})
|
||||
|
||||
(local associative-ops {:and true :or true :+ true :* true :band true :bor true :.. true})
|
||||
|
||||
(add-lint :nested-associative-operator
|
||||
{:what-it-does
|
||||
"Identifies forms that could be written in a flatter way, like `(and foo (and bar baz))`."
|
||||
|
||||
Loading…
Reference in New Issue
Block a user