summaryrefslogtreecommitdiff
path: root/script-beta
diff options
context:
space:
mode:
Diffstat (limited to 'script-beta')
-rw-r--r--script-beta/core/hover/arg.lua7
-rw-r--r--script-beta/core/hover/label.lua7
-rw-r--r--script-beta/core/hover/name.lua6
-rw-r--r--script-beta/vm/dummySource.lua13
-rw-r--r--script-beta/vm/getLibrary.lua16
-rw-r--r--script-beta/vm/getValue.lua30
-rw-r--r--script-beta/vm/init.lua1
7 files changed, 49 insertions, 31 deletions
diff --git a/script-beta/core/hover/arg.lua b/script-beta/core/hover/arg.lua
index be344488..70285e6b 100644
--- a/script-beta/core/hover/arg.lua
+++ b/script-beta/core/hover/arg.lua
@@ -8,7 +8,12 @@ local function asFunction(source)
local args = {}
for i = 1, #source.args do
local arg = source.args[i]
- args[i] = ('%s: %s'):format(guide.getName(arg), vm.getType(arg))
+ local name = arg.name or guide.getName(arg)
+ if name then
+ args[i] = ('%s: %s'):format(name, vm.getType(arg))
+ else
+ args[i] = ('%s'):format(vm.getType(arg))
+ end
end
return table.concat(args, ', ')
end
diff --git a/script-beta/core/hover/label.lua b/script-beta/core/hover/label.lua
index 765b01c2..f5d49bb0 100644
--- a/script-beta/core/hover/label.lua
+++ b/script-beta/core/hover/label.lua
@@ -82,6 +82,13 @@ local function asField(source)
return asValue(source, 'field')
end
+local function asLibrary(source)
+ local lib = source.library
+ if lib.type == 'function' then
+ return asFunction(source)
+ end
+end
+
return function (source)
if source.type == 'function' then
return asFunction(source)
diff --git a/script-beta/core/hover/name.lua b/script-beta/core/hover/name.lua
index b96a8169..83c750c3 100644
--- a/script-beta/core/hover/name.lua
+++ b/script-beta/core/hover/name.lua
@@ -28,6 +28,12 @@ local function asGlobal(source)
end
local function buildName(source)
+ if source.doc then
+ return source.doc
+ end
+ if source.name then
+ return source.name
+ end
if source.type == 'local'
or source.type == 'getlocal'
or source.type == 'setlocal' then
diff --git a/script-beta/vm/dummySource.lua b/script-beta/vm/dummySource.lua
deleted file mode 100644
index 50ff13e7..00000000
--- a/script-beta/vm/dummySource.lua
+++ /dev/null
@@ -1,13 +0,0 @@
-local vm = require 'vm.vm'
-
-vm.librarySourceCache = setmetatable({}, { __mode = 'kv'})
-
-function vm.librarySource(lib)
- if not vm.librarySourceCache[lib] then
- vm.librarySourceCache[lib] = {
- type = 'library',
- library = lib,
- }
- end
- return vm.librarySourceCache[lib]
-end
diff --git a/script-beta/vm/getLibrary.lua b/script-beta/vm/getLibrary.lua
index fd05347e..959b7084 100644
--- a/script-beta/vm/getLibrary.lua
+++ b/script-beta/vm/getLibrary.lua
@@ -54,13 +54,17 @@ local function getNodeAsObject(source)
end
local function checkNode(source)
- if source.type ~= 'getfield'
- and source.type ~= 'getmethod'
- and source.type ~= 'getindex' then
- return nil
+ if source.type == 'method' then
+ source = source.parent
+ elseif source.type == 'field' then
+ source = source.parent
+ end
+ if source.type == 'getfield'
+ or source.type == 'getmethod'
+ or source.type == 'getindex' then
+ return getNodeAsTable(source)
+ or getNodeAsObject(source)
end
- return getNodeAsTable(source)
- or getNodeAsObject(source)
end
local function getLibrary(source)
diff --git a/script-beta/vm/getValue.lua b/script-beta/vm/getValue.lua
index 30fd00aa..9ad9e86b 100644
--- a/script-beta/vm/getValue.lua
+++ b/script-beta/vm/getValue.lua
@@ -97,6 +97,11 @@ local function checkLiteral(source)
source = source,
}
end
+ elseif source.type == 'integer' then
+ return alloc {
+ type = 'integer',
+ source = source,
+ }
elseif source.type == 'table' then
return alloc {
type = 'table',
@@ -107,6 +112,11 @@ local function checkLiteral(source)
type = 'function',
source = source,
}
+ elseif source.type == '...' then
+ return alloc {
+ type = '...',
+ source = source,
+ }
end
end
@@ -536,7 +546,7 @@ local function checkLibrary(source)
return alloc {
type = lib.type,
value = lib.value,
- source = vm.librarySource(lib),
+ source = lib,
}
end
@@ -573,7 +583,7 @@ local function checkLibraryReturn(source)
return alloc {
type = rtn.type,
value = rtn.value,
- source = vm.librarySource(rtn),
+ source = rtn,
}
end
@@ -614,7 +624,7 @@ local function checkLibraryArg(source)
return alloc {
type = arg.type,
value = arg.value,
- source = vm.librarySource(arg),
+ source = arg,
}
end
@@ -630,21 +640,21 @@ local function inferByUnary(results, source)
if op.type == '#' then
insert(results, {
type = 'string',
- source = vm.librarySource(source)
+ source = source
})
insert(results, {
type = 'table',
- source = vm.librarySource(source)
+ source = source
})
elseif op.type == '~' then
insert(results, {
type = 'integer',
- source = vm.librarySource(source)
+ source = source
})
elseif op.type == '-' then
insert(results, {
type = 'number',
- source = vm.librarySource(source)
+ source = source
})
end
end
@@ -670,7 +680,7 @@ local function inferByBinary(results, source)
or op.type == '%' then
insert(results, {
type = 'number',
- source = vm.librarySource(source)
+ source = source
})
elseif op.type == '|'
or op.type == '~'
@@ -681,12 +691,12 @@ local function inferByBinary(results, source)
or op.type == '//' then
insert(results, {
type = 'integer',
- source = vm.librarySource(source)
+ source = source
})
elseif op.type == '..' then
insert(results, {
type = 'string',
- source = vm.librarySource(source)
+ source = source
})
end
end
diff --git a/script-beta/vm/init.lua b/script-beta/vm/init.lua
index 4a423886..a4f81d07 100644
--- a/script-beta/vm/init.lua
+++ b/script-beta/vm/init.lua
@@ -7,6 +7,5 @@ require 'vm.getLinks'
require 'vm.getGlobal'
require 'vm.getLibrary'
require 'vm.getValue'
-require 'vm.dummySource'
require 'vm.eachMeta'
return vm