diff options
-rw-r--r-- | script/vm/compiler.lua | 15 | ||||
-rw-r--r-- | test/crossfile/definition.lua | 53 |
2 files changed, 49 insertions, 19 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 7c5eb721..57816e24 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -362,7 +362,6 @@ local function getReturn(func, index, args) end local function bindDocs(source) - local hasFounded = false local isParam = source.parent.type == 'funcargs' or source.parent.type == 'in' local docs = source.bindDocs @@ -389,6 +388,20 @@ local function bindDocs(source) return true end end + if doc.type == 'doc.module' then + local name = doc.module + local uri = rpath.findUrisByRequirePath(guide.getUri(source), name)[1] + if not uri then + return nil + end + local state = files.getState(uri) + local ast = state and state.ast + if not ast then + return nil + end + nodeMgr.setNode(source, m.compileNode(ast)) + return true + end end return false end diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua index 945960e9..f44f2707 100644 --- a/test/crossfile/definition.lua +++ b/test/crossfile/definition.lua @@ -47,8 +47,8 @@ function TEST(datas) uri, } end - if catched['?'] or catched['~'] then - sourceList = catched['?'] or catched['~'] + if #catched['?'] > 0 or #catched['~'] > 0 then + sourceList = catched['?'] + catched['~'] sourceUri = uri end files.setText(uri, newScript) @@ -149,7 +149,7 @@ config.set(nil, 'Lua.runtime.pathStrict', false) TEST { { path = 'a.lua', - content = 'local <!t!> = 1; return t', + content = 'return <!function () end!>', }, { path = 'b.lua', @@ -160,7 +160,7 @@ TEST { TEST { { path = 'a.lua', - content = 'local <!t!> = 1; return t', + content = 'return <!function () end!>', }, { path = 'b.lua', @@ -188,7 +188,7 @@ local <~t~> TEST { { path = 'a.lua', - content = 'local <!t!> = 1; return t', + content = 'return <!function () end!>', }, { path = 'b.lua', @@ -355,9 +355,7 @@ TEST { { path = 'a.lua', content = [[ - return <!{ - a = 1, - }!> + return <!function () end!> ]], }, { @@ -395,8 +393,8 @@ TEST { { path = 'a.lua', content = [[ - local function <!f!>() - end + local <!function f() + end!> return f ]] }, @@ -455,11 +453,11 @@ TEST { { path = 'a.lua', content = [[ - local function <!f!>() - end + local <!function f() + end!> return { - <!f!> = f, + f = f, } ]] }, @@ -610,7 +608,7 @@ TEST { path = 'a.lua', content = [[ ---@class Class - local <!obj!> + local obj ]] }, { @@ -636,7 +634,7 @@ TEST { path = 'b.lua', content = [[ ---@class Class - local <!obj!> + local obj ]] }, } @@ -804,9 +802,7 @@ TEST { { path = 'a.lua', content = [[ -local t = GlobalTable - -t.settings = { +GlobalTable.settings = { <!test!> = 1 } ]] @@ -825,6 +821,27 @@ TEST { { path = 'a.lua', content = [[ +GlobalTable = { + settings = { + <!test!> = 1 + } +} + ]] + }, + { + path = 'b.lua', + content = [[ +local b = GlobalTable.settings + +print(b.<?test?>) + ]] + } +} + +TEST { + { + path = 'a.lua', + content = [[ ---@class A local t |