summaryrefslogtreecommitdiff
path: root/script-beta/vm
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-08-16 02:35:14 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-08-16 02:35:14 +0800
commit36b69f2c7f11e337897d282a10151548cb8876ea (patch)
treee3f5ced6617da4018648a415ae0c519fd74de61d /script-beta/vm
parentc3cec6c8cd20c319c291431fbec55f1d1d596c6d (diff)
downloadlua-language-server-36b69f2c7f11e337897d282a10151548cb8876ea.zip
暂时屏蔽类型推断
Diffstat (limited to 'script-beta/vm')
-rw-r--r--script-beta/vm/eachDef.lua1
-rw-r--r--script-beta/vm/getLinks.lua2
-rw-r--r--script-beta/vm/getValue.lua32
-rw-r--r--script-beta/vm/guideInterface.lua13
-rw-r--r--script-beta/vm/vm.lua18
5 files changed, 41 insertions, 25 deletions
diff --git a/script-beta/vm/eachDef.lua b/script-beta/vm/eachDef.lua
index 7ab65581..030fccea 100644
--- a/script-beta/vm/eachDef.lua
+++ b/script-beta/vm/eachDef.lua
@@ -1,6 +1,5 @@
local vm = require 'vm.vm'
local guide = require 'parser.guide'
-local ws = require 'workspace'
local files = require 'files'
local util = require 'utility'
local await = require 'await'
diff --git a/script-beta/vm/getLinks.lua b/script-beta/vm/getLinks.lua
index 0d95fa89..cc1ed190 100644
--- a/script-beta/vm/getLinks.lua
+++ b/script-beta/vm/getLinks.lua
@@ -1,9 +1,9 @@
local guide = require 'parser.guide'
local vm = require 'vm.vm'
local files = require 'files'
-local ws = require 'workspace'
local function getFileLinks(uri)
+ local ws = require 'workspace'
local links = {}
local ast = files.getAst(uri)
if not ast then
diff --git a/script-beta/vm/getValue.lua b/script-beta/vm/getValue.lua
index 00ca0e6d..9837e093 100644
--- a/script-beta/vm/getValue.lua
+++ b/script-beta/vm/getValue.lua
@@ -814,27 +814,27 @@ end
local function getValue(source)
local results = checkLiteral(source)
- or checkValue(source)
- or checkUnary(source)
- or checkBinary(source)
- or checkLibraryTypes(source)
- or checkLibrary(source)
- or checkSpecialReturn(source)
- or checkLibraryReturn(source)
+ --or checkValue(source)
+ --or checkUnary(source)
+ --or checkBinary(source)
+ --or checkLibraryTypes(source)
+ --or checkLibrary(source)
+ --or checkSpecialReturn(source)
+ --or checkLibraryReturn(source)
if results then
return results
end
results = {}
- inferByLibraryArg(results, source)
- inferByDef(results, source)
- inferBySet(results, source)
- inferByCall(results, source)
- inferByGetTable(results, source)
- inferByUnary(results, source)
- inferByBinary(results, source)
- inferByCallReturn(results, source)
- inferByPCallReturn(results, source)
+ --inferByLibraryArg(results, source)
+ --inferByDef(results, source)
+ --inferBySet(results, source)
+ --inferByCall(results, source)
+ --inferByGetTable(results, source)
+ --inferByUnary(results, source)
+ --inferByBinary(results, source)
+ --inferByCallReturn(results, source)
+ --inferByPCallReturn(results, source)
if #results == 0 then
return nil
diff --git a/script-beta/vm/guideInterface.lua b/script-beta/vm/guideInterface.lua
index c7c8afec..eae22b68 100644
--- a/script-beta/vm/guideInterface.lua
+++ b/script-beta/vm/guideInterface.lua
@@ -59,6 +59,11 @@ end
vm.interface = {}
+-- 向前寻找引用的层数限制,一般情况下都为0
+-- 在自动完成/漂浮提示等情况时设置为5(需要清空缓存)
+-- 在查找引用时设置为10(需要清空缓存)
+vm.interface.searchLevel = 0
+
function vm.interface.call(func, args, index)
local lib = vm.getLibrary(func)
if not lib then
@@ -101,3 +106,11 @@ function vm.interface.cache(source, mode)
end
end
end
+
+function vm.setSearchLevel(n)
+ -- 只有在搜索等级由低变高时,才需要清空缓存
+ if n > vm.interface.searchLevel then
+ vm.flushCache()
+ end
+ vm.interface.searchLevel = n
+end
diff --git a/script-beta/vm/vm.lua b/script-beta/vm/vm.lua
index 85df007f..d5028bdc 100644
--- a/script-beta/vm/vm.lua
+++ b/script-beta/vm/vm.lua
@@ -143,15 +143,19 @@ end
m.cacheTracker = setmetatable({}, { __mode = 'kv' })
+function m.flushCache()
+ if m.cache then
+ m.cache.dead = true
+ end
+ m.cacheVersion = files.globalVersion
+ m.cache = {}
+ m.locked = setmetatable({}, { __mode = 'k' })
+ m.cacheTracker[m.cache] = true
+end
+
function m.getCache(name)
if m.cacheVersion ~= files.globalVersion then
- if m.cache then
- m.cache.dead = true
- end
- m.cacheVersion = files.globalVersion
- m.cache = {}
- m.locked = setmetatable({}, { __mode = 'k' })
- m.cacheTracker[m.cache] = true
+ m.flushCache()
end
if not m.cache[name] then
m.cache[name] = {}