diff options
-rw-r--r-- | script/vm/compiler.lua | 32 | ||||
-rw-r--r-- | script/vm/infer.lua | 3 | ||||
-rw-r--r-- | test/hover/init.lua | 2 |
3 files changed, 30 insertions, 7 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 diff --git a/test/hover/init.lua b/test/hover/init.lua index 8ffb89fd..59c68c56 100644 --- a/test/hover/init.lua +++ b/test/hover/init.lua @@ -414,7 +414,7 @@ t.a = true ]] [[ local t: { - a: boolean|integer = 1, + a: boolean|integer = 1|true, } ]] |