summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script-beta/core/code-action.lua7
-rw-r--r--script-beta/core/completion.lua42
-rw-r--r--script-beta/core/diagnostics/lowercase-global.lua4
-rw-r--r--script-beta/core/diagnostics/redundant-parameter.lua18
-rw-r--r--script-beta/core/diagnostics/undefined-global.lua9
-rw-r--r--script-beta/core/hover/arg.lua60
-rw-r--r--script-beta/core/hover/description.lua110
-rw-r--r--script-beta/core/hover/label.lua6
-rw-r--r--script-beta/core/hover/name.lua33
-rw-r--r--script-beta/core/hover/return.lua40
-rw-r--r--script-beta/core/hover/table.lua8
-rw-r--r--script-beta/core/semantic-tokens.lua3
-rw-r--r--script-beta/library.lua320
-rw-r--r--script-beta/parser/guide.lua63
-rw-r--r--script-beta/vm/eachField.lua25
-rw-r--r--script-beta/vm/getClass.lua9
-rw-r--r--script-beta/vm/getDocs.lua34
-rw-r--r--script-beta/vm/getGlobals.lua18
-rw-r--r--script-beta/vm/getLibrary.lua59
-rw-r--r--script-beta/vm/guideInterface.lua21
-rw-r--r--script-beta/vm/vm.lua3
-rw-r--r--test-beta/hover/init.lua2
22 files changed, 12 insertions, 882 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
diff --git a/script-beta/library.lua b/script-beta/library.lua
index a8c45738..5a48499b 100644
--- a/script-beta/library.lua
+++ b/script-beta/library.lua
@@ -7,278 +7,6 @@ local client = require 'provider.client'
local m = {}
-local function mergeEnum(lib, locale)
- if not lib or not locale then
- return
- end
- local pack = {}
- for _, enum in ipairs(lib) do
- if enum.enum then
- pack[enum.enum] = enum
- end
- if enum.code then
- pack[enum.code] = enum
- end
- end
- for _, enum in ipairs(locale) do
- if pack[enum.enum] then
- if enum.description then
- pack[enum.enum].description = enum.description
- end
- end
- if pack[enum.code] then
- if enum.description then
- pack[enum.code].description = enum.description
- end
- end
- end
-end
-
-local function mergeField(lib, locale)
- if not lib or not locale then
- return
- end
- local pack = {}
- for _, field in ipairs(lib) do
- if field.field then
- pack[field.field] = field
- end
- end
- for _, field in ipairs(locale) do
- if pack[field.field] then
- if field.description then
- pack[field.field].description = field.description
- end
- end
- end
-end
-
-local function mergeLocale(libs, locale)
- if not libs or not locale then
- return
- end
- for name in pairs(locale) do
- if libs[name] then
- if locale[name].description then
- libs[name].description = locale[name].description
- end
- mergeEnum(libs[name].enums, locale[name].enums)
- mergeField(libs[name].fields, locale[name].fields)
- end
- end
-end
-
-local function isMatchVersion(version)
- if not version then
- return true
- end
- local runtimeVersion = config.config.runtime.version
- if type(version) == 'table' then
- for i = 1, #version do
- if version[i] == runtimeVersion then
- return true
- end
- end
- else
- if version == runtimeVersion then
- return true
- end
- end
- return false
-end
-
-local function insertGlobal(tbl, key, value)
- if not isMatchVersion(value.version) then
- return false
- end
- if not value.doc then
- value.doc = key
- end
- tbl[key] = {
- type = 'library',
- name = key,
- child = {},
- value = value,
- }
- value.library = tbl[key]
- return true
-end
-
-local function insertOther(tbl, key, value)
- if not value.version then
- return
- end
- if not tbl[key] then
- tbl[key] = {}
- end
- if type(value.version) == 'string' then
- tbl[key][#tbl[key]+1] = value.version
- elseif type(value.version) == 'table' then
- for _, version in ipairs(value.version) do
- if type(version) == 'string' then
- tbl[key][#tbl[key]+1] = version
- end
- end
- end
- table.sort(tbl[key])
-end
-
-local function insertCustom(tbl, key, value, libName)
- if not tbl[key] then
- tbl[key] = {}
- end
- tbl[key][#tbl[key]+1] = libName
- table.sort(tbl[key])
-end
-
-local function isEnableGlobal(libName)
- if config.config.runtime.library[libName] then
- return true
- end
- if libName:sub(1, 1) == '@' then
- return true
- end
- return false
-end
-
-local function mergeSource(alllibs, name, lib, libName)
- if not lib.source then
- if isEnableGlobal(libName) then
- local suc = insertGlobal(alllibs.global, name, lib)
- if not suc then
- insertOther(alllibs.other, name, lib)
- end
- else
- insertCustom(alllibs.custom, name, lib, libName)
- end
- return
- end
- for _, source in ipairs(lib.source) do
- local sourceName = source.name or name
- if source.type == 'global' then
- if isEnableGlobal(libName) then
- local suc = insertGlobal(alllibs.global, sourceName, lib)
- if not suc then
- insertOther(alllibs.other, sourceName, lib)
- end
- else
- insertCustom(alllibs.custom, sourceName, lib, libName)
- end
- elseif source.type == 'library' then
- insertGlobal(alllibs.library, sourceName, lib)
- elseif source.type == 'object' then
- insertGlobal(alllibs.object, sourceName, lib)
- end
- end
-end
-
-local function copy(t)
- local new = {}
- for k, v in pairs(t) do
- new[k] = v
- end
- return new
-end
-
-local function insertChild(tbl, name, key, value)
- if not name or not key then
- return
- end
- if not isMatchVersion(value.version) then
- return
- end
- if not value.doc then
- value.doc = ('%s.%s'):format(name, key)
- end
- if not tbl[name] then
- tbl[name] = {
- type = 'library',
- name = name,
- child = {},
- }
- end
- tbl[name].child[key] = {
- type = 'library',
- name = key,
- value = value,
- }
- value.library = tbl[name].child[key]
-end
-
-local function mergeParent(alllibs, name, lib, libName)
- for _, parent in ipairs(lib.parent) do
- if parent.type == 'global' then
- if isEnableGlobal(libName) then
- insertChild(alllibs.global, parent.name, name, lib)
- end
- elseif parent.type == 'library' then
- insertChild(alllibs.library, parent.name, name, lib)
- elseif parent.type == 'object' then
- insertChild(alllibs.object, parent.name, name, lib)
- end
- end
-end
-
-local function mergeLibs(alllibs, libs, libName)
- if not libs then
- return
- end
- for _, lib in pairs(libs) do
- if lib.parent then
- mergeParent(alllibs, lib.name, lib, libName)
- else
- mergeSource(alllibs, lib.name, lib, libName)
- end
- end
-end
-
-local function loadLocale(language, relative)
- local localePath = ROOT / 'locale' / language / relative
- local localeBuf = util.loadFile(localePath:string())
- if localeBuf then
- local locale = util.container()
- xpcall(lni, log.error, localeBuf, localePath:string(), {locale})
- return locale
- end
- return nil
-end
-
-local function fix(libs)
- for name, lib in pairs(libs) do
- lib.name = lib.name or name
- end
-end
-
-local function scan(path)
- local result = {path}
- local i = 0
- return function ()
- i = i + 1
- local current = result[i]
- if not current then
- return nil
- end
- if fs.is_directory(current) then
- for path in current:list_directory() do
- result[#result+1] = path
- end
- end
- return current
- end
-end
-
-local function markLibrary(library)
- for _, lib in pairs(library) do
- lib.fields = {}
- if lib.child then
- for _, child in util.sortPairs(lib.child) do
- table.insert(lib.fields, child)
- child.parent = library
- end
- end
- end
-end
-
local function getDocFormater()
local version = config.config.runtime.version
if client.client() == 'vscode' then
@@ -462,58 +190,12 @@ local function compileMetaDoc()
end
end
-local function initFromLni()
- local id = lang.id
- m.global = util.container()
- m.library = util.container()
- m.object = util.container()
- m.other = util.container()
- m.custom = util.container()
-
- for libPath in (ROOT / 'libs'):list_directory() do
- local libName = libPath:filename():string()
- for path in scan(libPath) do
- local libs
- local buf = util.loadFile(path:string())
- if buf then
- libs = util.container()
- xpcall(lni, log.error, buf, path:string(), {libs})
- fix(libs)
- end
- local relative = fs.relative(path, ROOT)
-
- local locale = loadLocale('en-US', relative)
- mergeLocale(libs, locale)
- if id ~= 'en-US' then
- locale = loadLocale(id, relative)
- mergeLocale(libs, locale)
- end
- mergeLibs(m, libs, libName)
- end
- end
-
- markLibrary(m.global)
- markLibrary(m.library)
- markLibrary(m.object)
- markLibrary(m.other)
- markLibrary(m.custom)
-end
-
local function initFromMetaDoc()
- m.global = util.container()
- m.library = util.container()
- m.object = util.container()
- m.other = util.container()
- m.custom = util.container()
compileMetaDoc()
end
local function init()
- if DEVELOP or TEST then
- initFromMetaDoc()
- else
- initFromLni()
- end
+ initFromMetaDoc()
end
function m.init()
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua
index b24f1cd8..6ef239f1 100644
--- a/script-beta/parser/guide.lua
+++ b/script-beta/parser/guide.lua
@@ -786,8 +786,6 @@ function m.getSimpleName(obj)
return ('v|%p'):format(obj)
elseif obj.type == 'string' then
return ('z|%p'):format(obj)
- elseif obj.type == 'library' then
- return ('s|%s'):format(obj.name)
elseif obj.type == 'doc.class.name'
or obj.type == 'doc.type.name' then
return ('c|%s'):format(obj[1])
@@ -973,9 +971,6 @@ function m.getStepRef(status, obj, mode)
if obj.type == 'goto' then
return stepRefOfLabel(obj.node, mode)
end
- if obj.type == 'library' then
- return { obj }
- end
if obj.type == 'doc.class.name'
or obj.type == 'doc.type.name'
or obj.type == 'doc.extends.name'
@@ -1347,9 +1342,6 @@ function m.getObjectValue(obj)
return nil
end
end
- if obj.library then
- return nil
- end
if obj.type == 'boolean'
or obj.type == 'number'
or obj.type == 'integer'
@@ -2116,8 +2108,6 @@ function m.pushResult(status, mode, ref, simple)
results[#results+1] = ref
elseif ref.type == 'table' then
results[#results+1] = ref
- elseif ref.type == 'library' then
- results[#results+1] = ref
elseif ref.type == 'doc.type.function'
or ref.type == 'doc.class.name'
or ref.type == 'doc.field' then
@@ -2155,8 +2145,6 @@ function m.pushResult(status, mode, ref, simple)
or ref.node.special == 'rawget' then
results[#results+1] = ref
end
- elseif ref.type == 'library' then
- results[#results+1] = ref
elseif ref.type == 'doc.type.function'
or ref.type == 'doc.class.name'
or ref.type == 'doc.field' then
@@ -2189,8 +2177,6 @@ function m.pushResult(status, mode, ref, simple)
or ref.node.special == 'rawget' then
results[#results+1] = ref
end
- elseif ref.type == 'library' then
- results[#results+1] = ref
elseif ref.type == 'doc.type.function'
or ref.type == 'doc.class.name'
or ref.type == 'doc.field' then
@@ -2827,17 +2813,6 @@ function m.inferCheckLiteral(status, source)
end
end
-function m.inferCheckLibrary(status, source)
- if source.type ~= 'library' then
- return
- end
- status.results = m.allocInfer {
- type = source.value.type,
- source = source,
- }
- return true
-end
-
local function getDocAliasExtends(status, name)
if not status.interface.docType then
return nil
@@ -3598,29 +3573,6 @@ function m.inferByBinary(status, source)
end
end
-local function mergeLibraryFunctionReturns(status, source, index)
- local returns = source.returns
- if not returns then
- return
- end
- local rtn = returns[index]
- if rtn then
- if type(rtn.type) == 'table' then
- for _, tp in ipairs(rtn.type) do
- status.results[#status.results+1] = {
- type = tp,
- source = rtn,
- }
- end
- else
- status.results[#status.results+1] = {
- type = rtn.type,
- source = rtn,
- }
- end
- end
-end
-
local function mergeFunctionReturnsByDoc(status, source, index, call)
if not source or source.type ~= 'function' then
return
@@ -3741,12 +3693,8 @@ function m.inferByCallReturnAndIndex(status, call, index)
if not hasDocReturn then
for _, src in ipairs(newStatus.results) do
if src.value and src.value.type == 'function' then
- if src.type == 'library' then
- mergeLibraryFunctionReturns(status, src.value, index)
- else
- if not m.checkReturnMark(status, src.value, true) then
- mergeFunctionReturns(status, src.value, index, call)
- end
+ if not m.checkReturnMark(status, src.value, true) then
+ mergeFunctionReturns(status, src.value, index, call)
end
end
end
@@ -3799,11 +3747,7 @@ function m.inferByPCallReturn(status, source)
m.searchRefs(newStatus, func, 'def')
for _, src in ipairs(newStatus.results) do
if src.value and src.value.type == 'function' then
- if src.type == 'library' then
- mergeLibraryFunctionReturns(status, src.value, index)
- else
- mergeFunctionReturns(status, src.value, index)
- end
+ mergeFunctionReturns(status, src.value, index)
end
end
end
@@ -3860,7 +3804,6 @@ function m.searchInfer(status, obj)
local checked = m.inferCheckDoc(status, obj)
or m.inferCheckUpDoc(status, obj)
or m.inferCheckFieldDoc(status, obj)
- or m.inferCheckLibrary(status, obj)
or m.inferCheckLiteral(status, obj)
or m.inferCheckUnary(status, obj)
or m.inferCheckBinary(status, obj)
diff --git a/script-beta/vm/eachField.lua b/script-beta/vm/eachField.lua
index 38087d6a..ce0e3928 100644
--- a/script-beta/vm/eachField.lua
+++ b/script-beta/vm/eachField.lua
@@ -1,25 +1,6 @@
local vm = require 'vm.vm'
local guide = require 'parser.guide'
-local library = require 'library'
local await = require 'await'
-local config = require 'config'
-
-local function eachFieldInLibrary(source, lib, results)
- if not lib or not lib.child then
- return
- end
- for _, value in pairs(lib.child) do
- if value.name:sub(1, 1) ~= '@' then
- results[#results+1] = value
- end
- end
-end
-
-local function eachFieldOfLibrary(results)
- for _, lib in pairs(library.global) do
- results[#results+1] = lib
- end
-end
local function eachField(source, deep)
local unlock = vm.lock('eachField', source)
@@ -36,12 +17,6 @@ local function eachField(source, deep)
await.delay()
local results = guide.requestFields(source, vm.interface, deep)
- if source.special == '_G' then
- eachFieldOfLibrary(results)
- end
- if library.object[source.type] then
- eachFieldInLibrary(source, library.object[source.type], results)
- end
unlock()
return results
diff --git a/script-beta/vm/getClass.lua b/script-beta/vm/getClass.lua
index 1623090c..a8bd7e40 100644
--- a/script-beta/vm/getClass.lua
+++ b/script-beta/vm/getClass.lua
@@ -12,15 +12,6 @@ local function lookUpDocClass(source)
end
local function getClass(source, classes, depth, deep)
- local lib = vm.getLibrary(source, deep)
- if lib then
- if lib.value.type == 'table' then
- classes[#classes+1] = lib.value.name
- else
- classes[#classes+1] = lib.value.type
- end
- return
- end
local docClass = lookUpDocClass(source)
if docClass then
classes[#classes+1] = docClass
diff --git a/script-beta/vm/getDocs.lua b/script-beta/vm/getDocs.lua
index fcc67d32..c06efc11 100644
--- a/script-beta/vm/getDocs.lua
+++ b/script-beta/vm/getDocs.lua
@@ -4,30 +4,6 @@ local guide = require 'parser.guide'
local vm = require 'vm.vm'
local config = require 'config'
-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)
@@ -70,13 +46,6 @@ local function getDocTypes(name)
end
end
end
- if not DEVELOP then
- for _, source in ipairs(builtin) do
- if name == '*' or name == source[1] then
- results[#results+1] = source
- end
- end
- end
return results
end
@@ -193,9 +162,6 @@ local function isDeprecated(value)
end
function vm.isDeprecated(value)
- if isDeprecated(value) then
- return true
- end
local defs = vm.getDefs(value, 'deep')
if #defs == 0 then
return false
diff --git a/script-beta/vm/getGlobals.lua b/script-beta/vm/getGlobals.lua
index 4fe95ee9..83d6a5e6 100644
--- a/script-beta/vm/getGlobals.lua
+++ b/script-beta/vm/getGlobals.lua
@@ -1,7 +1,6 @@
local guide = require 'parser.guide'
local vm = require 'vm.vm'
local files = require 'files'
-local library = require 'library'
local util = require 'utility'
local config = require 'config'
@@ -67,19 +66,6 @@ local function getGlobalSetsOfFile(uri)
return globals
end
-local function insertLibrary(results, name)
- if name:sub(1, 2) == 's|' then
- local libname = name:sub(3)
- results[#results+1] = library.global[libname]
- local asName = config.config.runtime.special[libname]
- results[#results+1] = library.global[asName]
- elseif name == '*' then
- for _, lib in pairs(library.global) do
- results[#results+1] = lib
- end
- end
-end
-
local function getGlobals(name)
local results = {}
for uri in files.eachFile() do
@@ -98,7 +84,6 @@ local function getGlobals(name)
end
end
end
- insertLibrary(results, name)
return results
end
@@ -120,7 +105,6 @@ local function getGlobalSets(name)
end
end
end
- insertLibrary(results, name)
return results
end
@@ -143,7 +127,6 @@ local function fastGetAnyGlobals()
end
end
end
- insertLibrary(results, '*')
return results
end
@@ -159,7 +142,6 @@ local function fastGetAnyGlobalSets()
end
end
end
- insertLibrary(results, '*')
return results
end
diff --git a/script-beta/vm/getLibrary.lua b/script-beta/vm/getLibrary.lua
index eaeeafa3..5803a73b 100644
--- a/script-beta/vm/getLibrary.lua
+++ b/script-beta/vm/getLibrary.lua
@@ -1,65 +1,6 @@
local vm = require 'vm.vm'
-local guide = require 'parser.guide'
-local library = require 'library'
-
-local function getLibrary(source, deep)
- if source.type == 'library' then
- return source
- end
- if source.library then
- return source.library
- end
- if source.type == 'getglobal'
- or source.type == 'setglobal' then
- if source.node and source.node.type == 'local' then
- local lib = library.global[guide.getName(source)]
- if lib then
- return lib
- end
- end
- end
-
- local unlock = vm.lock('getLibrary', source)
- if not unlock then
- return
- end
-
- local defs = vm.getDefs(source, deep)
- unlock()
-
- for _, def in ipairs(defs) do
- if def.type == 'library' then
- return def
- end
- end
-
- return nil
-end
-
-function vm.getLibrary(source, deep)
- if guide.isGlobal(source) then
- local name = guide.getKeyName(source)
- local cache = vm.getCache('getLibraryOfGlobal')[name]
- or vm.getCache('getLibrary')[source]
- or getLibrary(source, 'deep')
- vm.getCache('getLibraryOfGlobal')[name] = cache
- vm.getCache('getLibrary')[source] = cache
- return cache
- else
- local cache = vm.getCache('getLibrary')[source]
- or getLibrary(source, deep)
- if deep then
- vm.getCache('getLibrary')[source] = cache
- end
- return cache
- end
-end
function vm.getLibraryName(source, deep)
- local lib = vm.getLibrary(source, deep)
- if lib then
- return lib.name
- end
local defs = vm.getDefs(source, deep)
for _, def in ipairs(defs) do
if def.special then
diff --git a/script-beta/vm/guideInterface.lua b/script-beta/vm/guideInterface.lua
index 6ecae5a8..e646def8 100644
--- a/script-beta/vm/guideInterface.lua
+++ b/script-beta/vm/guideInterface.lua
@@ -3,7 +3,6 @@ local files = require 'files'
local ws = require 'workspace'
local guide = require 'parser.guide'
local await = require 'await'
-local library = require 'library'
local config = require 'config'
local m = {}
@@ -38,9 +37,6 @@ function m.require(args, index)
end
end
- local lib = library.library[reqName]
- results[#results+1] = lib
-
return results
end
@@ -97,23 +93,6 @@ function vm.interface.link(uri)
end
function vm.interface.index(obj)
- if obj.type == 'library' then
- return obj.fields
- end
-
- local tp = obj.type
- if tp == 'getglobal' and obj.node.special == '_G' then
- local lib = library.global[obj[1]]
- if not lib then
- return nil
- end
- tp = lib.value.type
- end
- local lib = library.object[tp]
- if lib then
- return lib.fields
- end
-
return nil
end
diff --git a/script-beta/vm/vm.lua b/script-beta/vm/vm.lua
index 90f75b4a..e942d55e 100644
--- a/script-beta/vm/vm.lua
+++ b/script-beta/vm/vm.lua
@@ -105,9 +105,6 @@ function m.getKeyName(source)
if not source then
return nil
end
- if source.type == 'library' then
- return 's|' .. source.name
- end
if source.type == 'call' then
local special = m.getSpecial(source.node)
if special == 'rawset'
diff --git a/test-beta/hover/init.lua b/test-beta/hover/init.lua
index 8bb20665..cb7d49f3 100644
--- a/test-beta/hover/init.lua
+++ b/test-beta/hover/init.lua
@@ -793,7 +793,7 @@ TEST [[
]]
[[
global _G: _G {
- _G: _G,
+ _G: table,
_VERSION: string = "Lua 5.4",
arg: table,
assert: function,