1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
local guide = require 'parser.guide'
local files = require 'files'
local setmetatable = setmetatable
_ENV = nil
local specials = {
['_G'] = true,
['rawset'] = true,
['rawget'] = true,
['setmetatable'] = true,
['require'] = true,
['dofile'] = true,
['loadfile'] = true,
}
---@class searcher
local mt = {}
mt.__index = mt
mt.__name = 'searcher'
---@class engineer
local m = {}
--- 新建搜索器
---@param uri string
---@return searcher
function m.create(uri)
local ast = files.getAst(uri)
local searcher = setmetatable({
step = 0,
ast = ast.ast,
uri = uri,
cache = {
def = {},
ref = {},
field = {},
value = {},
specialName = {},
},
}, mt)
return searcher
end
return m
|