diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-11-02 20:54:05 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-11-02 20:54:05 +0800 |
commit | b04dee92ee20fb4548c5f941af3ea40603828fac (patch) | |
tree | 36a561374b2d0da7b70a4febc9a8bdd78d46eb72 /script/parser/compile.lua | |
parent | bb192b1fb12c3d52a2505b5aa4e66ff4f1c7489c (diff) | |
download | lua-language-server-b04dee92ee20fb4548c5f941af3ea40603828fac.zip |
setting `runtime.special` supports fields
#1484
Diffstat (limited to 'script/parser/compile.lua')
-rw-r--r-- | script/parser/compile.lua | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/script/parser/compile.lua b/script/parser/compile.lua index 5575664c..8b8a7770 100644 --- a/script/parser/compile.lua +++ b/script/parser/compile.lua @@ -1721,7 +1721,23 @@ local function checkAmbiguityCall(call, parenPos) } end +local function bindSpecial(source, name) + if Specials[name] then + addSpecial(name, source) + else + local ospeicals = State.options.special + if ospeicals and ospeicals[name] then + addSpecial(ospeicals[name], source) + end + end +end + local function parseSimple(node, funcName) + local currentName + if node.type == 'getglobal' + or node.type == 'getlocal' then + currentName = node[1] + end local lastMethod while true do if lastMethod and node.node == lastMethod then @@ -1752,6 +1768,16 @@ local function parseSimple(node, funcName) if field then field.parent = getfield field.type = 'field' + if currentName then + if node.type == 'getlocal' + or node.type == 'getglobal' + or node.type == 'getfield' then + currentName = currentName .. '.' .. field[1] + bindSpecial(getfield, currentName) + else + currentName = nil + end + end else pushError { type = 'MISS_FIELD', @@ -2019,7 +2045,7 @@ local function resolveName(node) if not node then return nil end - local loc = getLocal(node[1], node.start) + local loc = getLocal(node[1], node.start) if loc then node.type = 'getlocal' node.node = loc @@ -2042,14 +2068,7 @@ local function resolveName(node) end end local name = node[1] - if Specials[name] then - addSpecial(name, node) - else - local ospeicals = State.options.special - if ospeicals and ospeicals[name] then - addSpecial(ospeicals[name], node) - end - end + bindSpecial(node, name) return node end |