summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-05 02:24:22 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-05 02:24:22 +0800
commit4d4efe71baae4c505153c40ed1a1bcbe40c1745b (patch)
tree717349f87201d68219c0e4d5494d43a11eb4fea2 /script
parent8661aaa67e749190c97ed2960bcc7453d6224876 (diff)
downloadlua-language-server-4d4efe71baae4c505153c40ed1a1bcbe40c1745b.zip
update
Diffstat (limited to 'script')
-rw-r--r--script/vm/compiler.lua32
-rw-r--r--script/vm/infer.lua3
2 files changed, 29 insertions, 6 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index c1ed4e95..b496d9cc 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -28,6 +28,12 @@ local searchFieldSwitch = util.switch()
pushResult(field)
end
end
+ if field.type == 'tableexp' then
+ if not key
+ or key == field.tindex then
+ pushResult(field)
+ end
+ end
end
end)
: case 'global'
@@ -340,6 +346,7 @@ end
local function bindDocs(source)
local hasFounded = false
local isParam = source.parent.type == 'funcargs'
+ or source.parent.type == 'in'
for _, doc in ipairs(source.bindDocs) do
if doc.type == 'doc.type' then
if not isParam then
@@ -349,7 +356,9 @@ local function bindDocs(source)
end
if doc.type == 'doc.class' then
if (source.type == 'local' and not isParam)
- or (source._globalNode and guide.isSet(source)) then
+ or (source._globalNode and guide.isSet(source))
+ or source.type == 'tablefield'
+ or source.type == 'tableindex' then
hasFounded = true
nodeMgr.setNode(source, m.compileNode(doc))
end
@@ -663,19 +672,32 @@ local compilerSwitch = util.switch()
: case 'tablefield'
: case 'tableindex'
: call(function (source)
+ local hasMarkDoc
+ if source.bindDocs then
+ hasMarkDoc = bindDocs(source)
+ end
+
if source.value then
- nodeMgr.setNode(source, m.compileNode(source.value))
+ if not hasMarkDoc or guide.isLiteral(source.value) then
+ nodeMgr.setNode(source, m.compileNode(source.value))
+ end
end
- m.compileByParentNode(source.parent, guide.getKeyName(source), function (src)
- nodeMgr.setNode(source, m.compileNode(src))
- end)
+ if not hasMarkDoc then
+ m.compileByParentNode(source.parent, guide.getKeyName(source), function (src)
+ nodeMgr.setNode(source, m.compileNode(src))
+ end)
+ end
end)
: case 'field'
: case 'method'
: call(function (source)
nodeMgr.setNode(source, m.compileNode(source.parent))
end)
+ : case 'tableexp'
+ : call(function (source)
+ nodeMgr.setNode(source, m.compileNode(source.value))
+ end)
: case 'function.return'
: call(function (source)
local func = source.parent
diff --git a/script/vm/infer.lua b/script/vm/infer.lua
index 760f340c..1b0ff800 100644
--- a/script/vm/infer.lua
+++ b/script/vm/infer.lua
@@ -315,7 +315,8 @@ function mt:viewLiterals()
for n in nodeMgr.eachNode(self.node) do
if n.type == 'string'
or n.type == 'number'
- or n.type == 'integer' then
+ or n.type == 'integer'
+ or n.type == 'boolean' then
local literal = util.viewLiteral(n[1])
if not mark[literal] then
literals[#literals+1] = literal