summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-15 10:29:07 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-15 10:29:07 +0800
commita0d017be1128485b189c24d47fdd087ae19602cb (patch)
tree58e017f874a0cb673c69f11c15f8ededa27de332
parentbfa16248754205f363134e61f930ebca16a2d21b (diff)
downloadlua-language-server-a0d017be1128485b189c24d47fdd087ae19602cb.zip
更新 parser
-rw-r--r--server-beta/src/parser/compile.lua15
-rw-r--r--server-beta/src/parser/guide.lua7
-rw-r--r--server-beta/src/parser/parse.lua1
-rw-r--r--server-beta/src/searcher/getLinks.lua5
-rw-r--r--server-beta/test/crossfile/init.lua2
5 files changed, 23 insertions, 7 deletions
diff --git a/server-beta/src/parser/compile.lua b/server-beta/src/parser/compile.lua
index 48cebcad..ef6f73a7 100644
--- a/server-beta/src/parser/compile.lua
+++ b/server-beta/src/parser/compile.lua
@@ -9,12 +9,14 @@ local specials = {
['require'] = true,
['dofile'] = true,
['loadfile'] = true,
+ ['pcall'] = true,
+ ['xpcall'] = true,
}
_ENV = nil
local LocalLimit = 200
-local pushError, Compile, CompileBlock, Block, GoToTag, ENVMode, Compiled, LocalCount, Version, Special
+local pushError, Compile, CompileBlock, Block, GoToTag, ENVMode, Compiled, LocalCount, Version, Root
local function addRef(node, obj)
if not node.ref then
@@ -25,10 +27,13 @@ local function addRef(node, obj)
end
local function addSpecial(name, obj)
- if not Special[name] then
- Special[name] = {}
+ if not Root.specials then
+ Root.specials = {}
end
- Special[name][#Special[name]+1] = obj
+ if not Root.specials[name] then
+ Root.specials[name] = {}
+ end
+ Root.specials[name][#Root.specials[name]+1] = obj
obj.special = name
end
@@ -532,7 +537,7 @@ return function (self, lua, mode, version)
GoToTag = {}
LocalCount = 0
Version = version
- Special = state.special
+ Root = state.ast
if type(state.ast) == 'table' then
Compile(state.ast)
end
diff --git a/server-beta/src/parser/guide.lua b/server-beta/src/parser/guide.lua
index bc19c816..c141feb5 100644
--- a/server-beta/src/parser/guide.lua
+++ b/server-beta/src/parser/guide.lua
@@ -355,6 +355,13 @@ function m.eachSource(ast, callback)
end
end
+--- 获取指定的 special
+function m.eachSpecialOf(ast, name, callback)
+ if not ast.special then
+
+ end
+end
+
--- 获取偏移对应的坐标
---@param lines table
---@return integer {name = 'row'}
diff --git a/server-beta/src/parser/parse.lua b/server-beta/src/parser/parse.lua
index ce6e74c1..bbc01b10 100644
--- a/server-beta/src/parser/parse.lua
+++ b/server-beta/src/parser/parse.lua
@@ -8,7 +8,6 @@ return function (self, lua, mode, version)
lua = lua,
emmy = {},
root = {},
- special = {},
errs = errs,
diags = diags,
pushError = function (err)
diff --git a/server-beta/src/searcher/getLinks.lua b/server-beta/src/searcher/getLinks.lua
index ba436f86..db1072e3 100644
--- a/server-beta/src/searcher/getLinks.lua
+++ b/server-beta/src/searcher/getLinks.lua
@@ -28,7 +28,12 @@ function searcher.getLinks(source)
if not unlock then
return nil
end
+ local clock = os.clock()
cache = getLinks(source) or false
+ local passed = os.clock() - clock
+ if passed > 0.1 then
+ log.warn(('getLinks takes [%.3f] sec!'):format(passed))
+ end
searcher.cache.getLinks[source] = cache
unlock()
return cache
diff --git a/server-beta/test/crossfile/init.lua b/server-beta/test/crossfile/init.lua
index 42fb1147..c516fc7f 100644
--- a/server-beta/test/crossfile/init.lua
+++ b/server-beta/test/crossfile/init.lua
@@ -1,5 +1,5 @@
-require 'crossfile.definition'
require 'crossfile.references'
+require 'crossfile.definition'
--require 'crossfile.hover'
--require 'crossfile.completion'
--require 'crossfile.document_symbol'