diff options
Diffstat (limited to 'script-beta/core')
-rw-r--r-- | script-beta/core/code-action.lua | 7 | ||||
-rw-r--r-- | script-beta/core/completion.lua | 42 | ||||
-rw-r--r-- | script-beta/core/diagnostics/lowercase-global.lua | 4 | ||||
-rw-r--r-- | script-beta/core/diagnostics/redundant-parameter.lua | 18 | ||||
-rw-r--r-- | script-beta/core/diagnostics/undefined-global.lua | 9 | ||||
-rw-r--r-- | script-beta/core/hover/arg.lua | 60 | ||||
-rw-r--r-- | script-beta/core/hover/description.lua | 110 | ||||
-rw-r--r-- | script-beta/core/hover/label.lua | 6 | ||||
-rw-r--r-- | script-beta/core/hover/name.lua | 33 | ||||
-rw-r--r-- | script-beta/core/hover/return.lua | 40 | ||||
-rw-r--r-- | script-beta/core/hover/table.lua | 8 | ||||
-rw-r--r-- | script-beta/core/semantic-tokens.lua | 3 |
12 files changed, 7 insertions, 333 deletions
diff --git a/script-beta/core/code-action.lua b/script-beta/core/code-action.lua index 0c77ea4f..69304f98 100644 --- a/script-beta/core/code-action.lua +++ b/script-beta/core/code-action.lua @@ -2,7 +2,6 @@ local files = require 'files' local lang = require 'language' local define = require 'proto.define' local guide = require 'parser.guide' -local library = require 'library' local util = require 'utility' local sp = require 'bee.subprocess' @@ -76,11 +75,7 @@ local function solveUndefinedGlobal(uri, diag, results) local name = guide.getName(source) markGlobal(uri, name, results) - if library.other[name] then - for _, version in ipairs(library.other[name]) do - changeVersion(uri, version, results) - end - end + -- TODO check other version end) end diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua index cfca754e..44874b39 100644 --- a/script-beta/core/completion.lua +++ b/script-beta/core/completion.lua @@ -3,7 +3,6 @@ local files = require 'files' local guide = require 'parser.guide' local matchKey = require 'core.matchkey' local vm = require 'vm' -local library = require 'library' local getLabel = require 'core.hover.label' local getName = require 'core.hover.name' local getArg = require 'core.hover.arg' @@ -259,9 +258,6 @@ local function buildFunction(results, source, oop, data) end local function isSameSource(ast, source, pos) - if source.type == 'library' then - return false - end if not files.eq(guide.getUri(source), guide.getUri(ast.ast)) then return false end @@ -369,7 +365,7 @@ local function checkFieldThen(name, src, word, start, offset, parent, oop, resul buildFunction(results, src, oop, { label = name, kind = kind, - deprecated = vm.isDeprecated(value) or nil, + deprecated = vm.isDeprecated(src) or nil, id = stack(function () return { detail = buildDetail(src), @@ -415,11 +411,6 @@ local function checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, res local fields = {} local count = 0 for _, src in ipairs(refs) do - if src.type == 'library' then - if src.name:sub(1, 1) == '@' then - goto CONTINUE - end - end local key = vm.getKeyName(src) if not key or key:sub(1, 1) ~= 's' then goto CONTINUE @@ -903,37 +894,6 @@ local function trySymbol(ast, text, offset, results) end local function getCallEnums(source, index) - if source.type == 'library' and source.value.type == 'function' then - local func = source.value - if not func then - return nil - end - if not func.args then - return nil - end - if not func.enums then - return nil - end - local arg = func.args[index] - if not arg then - return nil - end - local argName = arg.name - if not argName then - return nil - end - local enums = {} - for _, enum in ipairs(func.enums) do - if enum.name == argName then - enums[#enums+1] = { - label = enum.enum, - description = enum.description, - kind = define.CompletionItemKind.EnumMember, - } - end - end - return enums - end if source.type == 'function' and source.bindDocs then if not source.args then return diff --git a/script-beta/core/diagnostics/lowercase-global.lua b/script-beta/core/diagnostics/lowercase-global.lua index d88af685..fe5d1eca 100644 --- a/script-beta/core/diagnostics/lowercase-global.lua +++ b/script-beta/core/diagnostics/lowercase-global.lua @@ -2,7 +2,6 @@ local files = require 'files' local guide = require 'parser.guide' local lang = require 'language' local config = require 'config' -local library = require 'library' local vm = require 'vm' local function isDocClass(source) @@ -28,9 +27,6 @@ return function (uri, callback) for name in pairs(config.config.diagnostics.globals) do definedGlobal[name] = true end - for name in pairs(library.global) do - definedGlobal[name] = true - end guide.eachSourceType(ast.ast, 'setglobal', function (source) local name = guide.getName(source) diff --git a/script-beta/core/diagnostics/redundant-parameter.lua b/script-beta/core/diagnostics/redundant-parameter.lua index dda6c014..2fae20e8 100644 --- a/script-beta/core/diagnostics/redundant-parameter.lua +++ b/script-beta/core/diagnostics/redundant-parameter.lua @@ -5,23 +5,6 @@ local lang = require 'language' local define = require 'proto.define' local await = require 'await' -local function countLibraryArgs(source) - local lib = vm.getLibrary(source) - if not lib then - return nil - end - local func = lib.value - local result = 0 - if not func.args then - return result - end - if func.args[#func.args].type == '...' then - return math.maxinteger - end - result = result + #func.args - return result -end - local function countCallArgs(source) local result = 0 if not source.args then @@ -76,7 +59,6 @@ return function (uri, callback) end end - funcArgs = funcArgs or countLibraryArgs(func) if not funcArgs then return end diff --git a/script-beta/core/diagnostics/undefined-global.lua b/script-beta/core/diagnostics/undefined-global.lua index 9ef80182..778fc1f1 100644 --- a/script-beta/core/diagnostics/undefined-global.lua +++ b/script-beta/core/diagnostics/undefined-global.lua @@ -1,7 +1,6 @@ local files = require 'files' local vm = require 'vm' local lang = require 'language' -local library = require 'library' local config = require 'config' local guide = require 'parser.guide' @@ -20,15 +19,13 @@ return function (uri, callback) if config.config.diagnostics.globals[key] then return end - if library.global[key] then - return - end if #vm.getGlobalSets(guide.getKeyName(src)) > 0 then return end local message = lang.script('DIAG_UNDEF_GLOBAL', key) - local otherVersion = library.other[key] - local customVersion = library.custom[key] + -- TODO check other version + local otherVersion + local customVersion if otherVersion then message = ('%s(%s)'):format(message, lang.script('DIAG_DEFINED_VERSION', table.concat(otherVersion, '/'), config.config.runtime.version)) elseif customVersion then diff --git a/script-beta/core/hover/arg.lua b/script-beta/core/hover/arg.lua index 4ea2cafe..9cd19f02 100644 --- a/script-beta/core/hover/arg.lua +++ b/script-beta/core/hover/arg.lua @@ -1,61 +1,6 @@ local guide = require 'parser.guide' local vm = require 'vm' -local function mergeTypesInLibrary(types) - if type(types) == 'table' then - return table.concat(types, '|') - else - return types or 'any' - end -end - -local function asLibrary(source, oop) - if not source.args then - return '' - end - local start = 1 - local methodDef - local parent = source.parent - if parent and parent.type == 'setmethod' then - methodDef = true - end - if not methodDef and oop then - start = 2 - end - local args = {} - local afterCount = 0 - for i = start, #source.args do - local buf = {} - local arg = source.args[i] - local name = arg.name - if arg.optional then - if i == start then - buf[#buf+1] = '[' - else - buf[#buf+1] = ' [' - end - end - if i > start then - buf[#buf+1] = ', ' - end - if name then - buf[#buf+1] = ('%s: %s'):format(name, mergeTypesInLibrary(arg.type)) - else - buf[#buf+1] = ('%s'):format(mergeTypesInLibrary(arg.type)) - end - if arg.optional == 'after' then - afterCount = afterCount + 1 - elseif arg.optional == 'self' then - buf[#buf+1] = ']' - end - if i == #source.args and afterCount > 0 then - buf[#buf+1] = (']'):rep(afterCount) - end - args[#args+1] = table.concat(buf) - end - return table.concat(args) -end - local function optionalArg(arg) if not arg.bindDocs then return false @@ -116,11 +61,6 @@ local function asDocFunction(source) end return function (source, oop) - if source.type == 'library' then - return asLibrary(source.value, oop) - elseif source.library then - return asLibrary(source, oop) - end if source.type == 'function' then return asFunction(source, oop) end diff --git a/script-beta/core/hover/description.lua b/script-beta/core/hover/description.lua index c421e3b6..7d89ee6c 100644 --- a/script-beta/core/hover/description.lua +++ b/script-beta/core/hover/description.lua @@ -5,10 +5,7 @@ local files = require 'files' local guide = require 'parser.guide' local markdown = require 'provider.markdown' local config = require 'config' -local client = require 'provider.client' local lang = require 'language' -local platform = require 'bee.platform' -local library = require 'library' local function asStringInRequire(source, literal) local rootPath = ws.path or '' @@ -80,110 +77,6 @@ local function asString(source) or asStringView(source, literal) end -local function getDocFormater() - local version = config.config.runtime.version - if client.client() == 'vscode' then - if version == 'Lua 5.1' then - return 'HOVER_NATIVE_DOCUMENT_LUA51' - elseif version == 'Lua 5.2' then - return 'HOVER_NATIVE_DOCUMENT_LUA52' - elseif version == 'Lua 5.3' then - return 'HOVER_NATIVE_DOCUMENT_LUA53' - elseif version == 'Lua 5.4' then - return 'HOVER_NATIVE_DOCUMENT_LUA54' - elseif version == 'LuaJIT' then - return 'HOVER_NATIVE_DOCUMENT_LUAJIT' - end - else - if version == 'Lua 5.1' then - return 'HOVER_DOCUMENT_LUA51' - elseif version == 'Lua 5.2' then - return 'HOVER_DOCUMENT_LUA52' - elseif version == 'Lua 5.3' then - return 'HOVER_DOCUMENT_LUA53' - elseif version == 'Lua 5.4' then - return 'HOVER_DOCUMENT_LUA54' - elseif version == 'LuaJIT' then - return 'HOVER_DOCUMENT_LUAJIT' - end - end -end - -local function buildLibEnum(enum) - local line = {} - if enum.default then - line[#line+1] = ' ->' - else - line[#line+1] = ' |' - end - line[#line+1] = enum.enum - if enum.description then - line[#line+1] = '--' - line[#line+1] = enum.description - end - return table.concat(line, ' ') -end - -local function getArgType(value, name) - if not value.args then - return '' - end - for _, arg in ipairs(value.args) do - if arg.name == name then - if type(arg.type) == 'table' then - return ' ' .. table.concat(arg.type, '|') - else - return arg.type and (' ' .. arg.type) or '' - end - end - end - return '' -end - -local function buildLibEnums(value) - local results = {} - local sorts = {} - - for _, enum in ipairs(value.enums) do - local name = enum.name - if not results[name] then - results[name] = { name .. ':' .. getArgType(value, name) } - sorts[#sorts+1] = name - end - results[name][#results[name]+1] = buildLibEnum(enum) - end - - local lines = {} - for _, name in ipairs(sorts) do - lines[#lines+1] = table.concat(results[name], '\n') - end - return table.concat(lines, '\n\n') -end - -local function tryLibrary(source) - local lib = vm.getLibrary(source) - if not lib then - return nil - end - local fmt = getDocFormater() - local md = markdown() - if lib.value.description then - md:add('md', lib.value.description:gsub('%(doc%:(.-)%)', function (tag) - if fmt then - return '(' .. lang.script(fmt, tag) .. ')' - end - end)) - end - if lib.value.enums then - md:add('md', '-------------') - md:add('lua', buildLibEnums(lib.value)) - end - if lib.value.doc and fmt then - md:add('md', ('[%s](%s)'):format(lang.script.HOVER_VIEW_DOCUMENTS, lang.script(fmt, 'pdf-' .. lib.value.doc))) - end - return md:string() -end - local function getBindComment(docGroup, base) local lines = {} for _, doc in ipairs(docGroup) do @@ -305,8 +198,7 @@ return function (source) if source.type == 'string' then return asString(source) end - return tryLibrary(source) - or tryDocOverloadToComment(source) + return tryDocOverloadToComment(source) or tryDocFieldUpComment(source) or tryDocComment(source) end diff --git a/script-beta/core/hover/label.lua b/script-beta/core/hover/label.lua index 1933adfe..d785bc27 100644 --- a/script-beta/core/hover/label.lua +++ b/script-beta/core/hover/label.lua @@ -83,10 +83,6 @@ local function asGlobal(source) return asValue(source, 'global') end -local function asLibrary(source) - return asValue(source, 'global') -end - local function isGlobalField(source) if source.type == 'field' or source.type == 'method' then @@ -205,8 +201,6 @@ return function (source, oop) return asString(source) elseif source.type == 'number' then return asNumber(source) - elseif source.type == 'library' then - return asLibrary(source) elseif source.type == 'doc.type.function' then return asDocFunction(source) elseif source.type == 'doc.type.name' then diff --git a/script-beta/core/hover/name.lua b/script-beta/core/hover/name.lua index ee8b3961..9ad32e09 100644 --- a/script-beta/core/hover/name.lua +++ b/script-beta/core/hover/name.lua @@ -41,34 +41,6 @@ local function asGlobal(source) return guide.getName(source) end -local function asLibrary(source, oop) - local p - if oop then - if source.parent then - for _, parent in ipairs(source.parent) do - if parent.type == 'object' then - p = parent.name .. ':' - break - end - end - end - else - if source.parent then - for _, parent in ipairs(source.parent) do - if parent.type == 'global' then - p = parent.name .. '.' - break - end - end - end - end - if p then - return ('%s%s'):format(p, source.name) - else - return source.name - end -end - local function asDocFunction(source) local doc = guide.getParentType(source, 'doc.type') or guide.getParentType(source, 'doc.overload') @@ -93,11 +65,6 @@ function buildName(source, oop) oop = source.type == 'setmethod' or source.type == 'getmethod' end - if source.type == 'library' then - return asLibrary(source.value, oop) or '' - elseif source.library then - return asLibrary(source, oop) or '' - end if source.type == 'local' or source.type == 'getlocal' or source.type == 'setlocal' then diff --git a/script-beta/core/hover/return.lua b/script-beta/core/hover/return.lua index c6406395..3829dbed 100644 --- a/script-beta/core/hover/return.lua +++ b/script-beta/core/hover/return.lua @@ -8,41 +8,6 @@ local function mergeTypes(returns) return guide.mergeTypes(returns) end -local function asLibrary(source) - if not source.returns then - return nil - end - local returns = {} - for i, rtn in ipairs(source.returns) do - local line = {} - local name = rtn.name - local tp = rtn.type and mergeTypes(rtn.type) or 'any' - if i == 1 then - line[#line+1] = ' ->' - else - line[#line+1] = ('% 3d.'):format(i) - end - if rtn.optional then - line[#line+1] = '[' - else - line[#line+1] = ' ' - end - if name then - line[#line+1] = ('%s: %s'):format(name, tp) - else - line[#line+1] = tp - end - if rtn.optional then - line[#line+1] = ']' - end - returns[i] = table.concat(line) - end - if #returns == 0 then - return nil - end - return table.concat(returns, '\n') -end - local function getReturnDualByDoc(source) local docs = source.bindDocs if not docs then @@ -151,11 +116,6 @@ local function asDocFunction(source) end return function (source) - if source.type == 'library' then - return asLibrary(source.value) - elseif source.library then - return asLibrary(source) - end if source.type == 'function' then return asFunction(source) end diff --git a/script-beta/core/hover/table.lua b/script-beta/core/hover/table.lua index 94657000..02be5271 100644 --- a/script-beta/core/hover/table.lua +++ b/script-beta/core/hover/table.lua @@ -5,11 +5,6 @@ local config = require 'config' local lang = require 'language' local function getKey(src) - if src.type == 'library' then - if src.name:sub(1, 1) == '@' then - return - end - end local key = vm.getKeyName(src) if not key or #key <= 2 then if not src.index then @@ -42,9 +37,6 @@ local function getFieldFast(src) if not value then return 'any' end - if value.library then - return value.type, util.viewLiteral(value.value) - end if value.type == 'boolean' then return value.type, util.viewLiteral(value[1]) end diff --git a/script-beta/core/semantic-tokens.lua b/script-beta/core/semantic-tokens.lua index 351e544a..e6b35cdd 100644 --- a/script-beta/core/semantic-tokens.lua +++ b/script-beta/core/semantic-tokens.lua @@ -48,8 +48,7 @@ Care['getlocal'] = function (source, results) if node then for _, ref in ipairs(node.ref) do local def = ref.value - if def.type == 'function' - or (def.type == 'library' and def.value.type == 'function') then + if def.type == 'function' then hasFunc = true break end |