diff options
Diffstat (limited to 'script-beta')
-rw-r--r-- | script-beta/core/completion.lua | 22 | ||||
-rw-r--r-- | script-beta/core/diagnostics/undefined-doc-class.lua | 20 | ||||
-rw-r--r-- | script-beta/core/diagnostics/undefined-doc-name.lua | 20 | ||||
-rw-r--r-- | script-beta/vm/getDocs.lua | 29 |
4 files changed, 50 insertions, 41 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua index 52cc4096..fcf18151 100644 --- a/script-beta/core/completion.lua +++ b/script-beta/core/completion.lua @@ -955,7 +955,7 @@ local function getLuaDocByContain(ast, offset) if not src.start then return end - if range > offset - src.start then + if range >= offset - src.start then range = offset - src.start result = src end @@ -1005,6 +1005,17 @@ local function tryLuaDocBySource(source, results) end end end + elseif source.type == 'doc.type.name' then + for _, doc in ipairs(vm.getDocTypes '*') do + if (doc.type == 'doc.class.name' or doc.type == 'doc.alias.name') + and doc.parent ~= source.parent + and matchKey(source[1], doc[1]) then + results[#results+1] = { + label = doc[1], + kind = define.CompletionItemKind.Class, + } + end + end end end @@ -1019,6 +1030,15 @@ local function tryLuaDocByErr(err, docState, results) } end end + elseif err.type == 'LUADOC_MISS_TYPE_NAME' then + for _, doc in ipairs(vm.getDocTypes '*') do + if (doc.type == 'doc.class.name' or doc.type == 'doc.alias.name') then + results[#results+1] = { + label = doc[1], + kind = define.CompletionItemKind.Class, + } + end + end end end diff --git a/script-beta/core/diagnostics/undefined-doc-class.lua b/script-beta/core/diagnostics/undefined-doc-class.lua index e008c7fd..bbfdceec 100644 --- a/script-beta/core/diagnostics/undefined-doc-class.lua +++ b/script-beta/core/diagnostics/undefined-doc-class.lua @@ -4,23 +4,6 @@ local lang = require 'language' local define = require 'proto.define' local vm = require 'vm' --- TODO -local builtin = { - ['any'] = true, - ['nil'] = true, - ['void'] = true, - ['boolean'] = true, - ['number'] = true, - ['integer'] = true, - ['thread'] = true, - ['table'] = true, - ['file'] = true, - ['string'] = true, - ['userdata'] = true, - ['lightuserdata'] = true, - ['function'] = true, -} - return function (uri, callback) local state = files.getAst(uri) if not state then @@ -39,9 +22,6 @@ return function (uri, callback) goto CONTINUE end local name = ext[1] - if builtin[name] then - goto CONTINUE - end local docs = vm.getDocTypes(name) if cache[name] == nil then cache[name] = false diff --git a/script-beta/core/diagnostics/undefined-doc-name.lua b/script-beta/core/diagnostics/undefined-doc-name.lua index 8e832a2d..ba5e0a69 100644 --- a/script-beta/core/diagnostics/undefined-doc-name.lua +++ b/script-beta/core/diagnostics/undefined-doc-name.lua @@ -4,23 +4,6 @@ local lang = require 'language' local define = require 'proto.define' local vm = require 'vm' --- TODO -local builtin = { - ['any'] = true, - ['nil'] = true, - ['void'] = true, - ['boolean'] = true, - ['number'] = true, - ['integer'] = true, - ['thread'] = true, - ['table'] = true, - ['file'] = true, - ['string'] = true, - ['userdata'] = true, - ['lightuserdata'] = true, - ['function'] = true, -} - return function (uri, callback) local state = files.getAst(uri) if not state then @@ -41,9 +24,6 @@ return function (uri, callback) return end local name = source[1] - if builtin[name] then - return - end if cache[name] == nil then cache[name] = false local docs = vm.getDocTypes(name) diff --git a/script-beta/vm/getDocs.lua b/script-beta/vm/getDocs.lua index 2b1aead5..a89247b1 100644 --- a/script-beta/vm/getDocs.lua +++ b/script-beta/vm/getDocs.lua @@ -3,6 +3,30 @@ local util = require 'utility' local guide = require 'parser.guide' local vm = require 'vm.vm' +local builtin = {} +for _, name in ipairs { + 'any' , + 'nil' , + 'void' , + 'boolean' , + 'number' , + 'integer' , + 'thread' , + 'table' , + 'file' , + 'string' , + 'userdata' , + 'lightuserdata', + 'function' , +} do + builtin[#builtin+1] = { + type = 'doc.class.name', + start = 0, + finish = 0, + [1] = name, + } +end + local function getTypesOfFile(uri) local types = {} local ast = files.getAst(uri) @@ -45,6 +69,11 @@ local function getDocTypes(name) end end end + for _, source in ipairs(builtin) do + if name == '*' or name == source[1] then + results[#results+1] = source + end + end return results end |