@codua/codeoutline-win32-x64 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -5
- package/README.zh-CN.md +32 -5
- package/THIRD_PARTY.md +3 -3
- package/bin/xnet.exe +0 -0
- package/build-info.json +1 -1
- package/package.json +1 -1
- package/scripts/codeoutline/cli.lua +2 -2
- package/scripts/codeoutline/command.lua +9 -1
- package/scripts/codeoutline/common.lua +36 -5
- package/scripts/codeoutline/completion.lua +913 -0
- package/scripts/codeoutline/control.lua +5 -1
- package/scripts/codeoutline/daemon.lua +4 -2
- package/scripts/codeoutline/documents.lua +154 -0
- package/scripts/codeoutline/explore.lua +32 -7
- package/scripts/codeoutline/graph.lua +264 -68
- package/scripts/codeoutline/index.lua +168 -48
- package/scripts/codeoutline/index_worker.lua +108 -17
- package/scripts/codeoutline/lang/c.lua +22 -12
- package/scripts/codeoutline/lang/cpp.lua +13 -12
- package/scripts/codeoutline/lang/csharp.lua +21 -21
- package/scripts/codeoutline/lang/go.lua +10 -10
- package/scripts/codeoutline/lang/java.lua +9 -9
- package/scripts/codeoutline/lang/js.lua +15 -14
- package/scripts/codeoutline/lang/lua.lua +9 -6
- package/scripts/codeoutline/lang/python.lua +6 -6
- package/scripts/codeoutline/lang/rust.lua +23 -15
- package/scripts/codeoutline/lsp.lua +574 -0
- package/scripts/codeoutline/main.lua +28 -5
- package/scripts/codeoutline/navigation.lua +934 -0
- package/scripts/codeoutline/parse.lua +8 -2
- package/scripts/codeoutline/parse_pool.lua +189 -0
- package/scripts/codeoutline/parse_worker.lua +24 -0
- package/scripts/codeoutline/service.lua +82 -31
- package/scripts/codeoutline/update_sequence.lua +1 -1
- package/scripts/codeoutline/updater.lua +1 -1
- package/scripts/codeoutline/version.lua +1 -1
- package/scripts/xupgate/client.lua +8 -0
- package/licenses/rpmalloc.txt +0 -12
|
@@ -79,7 +79,7 @@ end
|
|
|
79
79
|
-- Type name in `impl<T> Trait<X> for Type<Y> where ...` / `impl Type`.
|
|
80
80
|
local function impl_target(T, x, body)
|
|
81
81
|
x = skip_angle(T, x, body)
|
|
82
|
-
local first, trait
|
|
82
|
+
local first, trait, name_tok
|
|
83
83
|
local d, y = 0, x
|
|
84
84
|
local names = {}
|
|
85
85
|
while y < body do
|
|
@@ -87,9 +87,11 @@ local function impl_target(T, x, body)
|
|
|
87
87
|
if kw(T, y, 'for') and d == 0 then
|
|
88
88
|
trait = names[#names]
|
|
89
89
|
names = {}
|
|
90
|
+
name_tok = nil
|
|
90
91
|
elseif (T.k[y] == 'id' or kw(T, y, 'Self')) and d == 0 and not is(T, y + 1, '::')
|
|
91
92
|
and T:text(y):sub(1, 1) ~= "'" then -- 'static is a lifetime, not the type
|
|
92
93
|
names[#names + 1] = T:text(y)
|
|
94
|
+
name_tok = name_tok or y
|
|
93
95
|
end
|
|
94
96
|
d = math.max(0, d + angle(T, y))
|
|
95
97
|
y = y + 1
|
|
@@ -103,7 +105,7 @@ local function impl_target(T, x, body)
|
|
|
103
105
|
for z = from, body - 1 do if T.k[z] == 'kw' and T:text(z) == 'where' then to = z - 1; break end end
|
|
104
106
|
if to >= from then first = common.sig(T, from, to, 60):gsub('%s', '') end
|
|
105
107
|
end
|
|
106
|
-
return first, trait
|
|
108
|
+
return first, trait, name_tok or x
|
|
107
109
|
end
|
|
108
110
|
|
|
109
111
|
-- Record calls in [a, b], including macro invocations `name!(..)` / `name![..]`.
|
|
@@ -127,15 +129,20 @@ local function body_members(T, r, o, c, parent, kind)
|
|
|
127
129
|
x = x + 1
|
|
128
130
|
if is(T, x, '(') and T.m[x] then x = T.m[x] + 1 end
|
|
129
131
|
end
|
|
132
|
+
local field
|
|
130
133
|
if T.k[x] == 'id' and (kind == 'enum' or is(T, x + 1, ':')) then
|
|
131
|
-
common.add_node(r, T, { kind = kind == 'enum' and 'enum_member' or 'field', name = T:text(x),
|
|
134
|
+
field = common.add_node(r, T, { kind = kind == 'enum' and 'enum_member' or 'field', name = T:text(x), ni = x,
|
|
132
135
|
parent = parent, ti = x, tj = x })
|
|
136
|
+
if kind == 'enum' then field = nil end
|
|
133
137
|
end
|
|
138
|
+
local type_start = x + 2
|
|
134
139
|
while x < c and not is(T, x, ',') do
|
|
135
140
|
if T.m[x] and T.m[x] > x then x = T.m[x] + 1
|
|
136
141
|
elseif is(T, x, '<') then x = skip_angle(T, x, c)
|
|
137
142
|
else x = x + 1 end
|
|
138
143
|
end
|
|
144
|
+
-- Declared field types serve completion; compact index records omit them.
|
|
145
|
+
if field and r.ranges and type_start <= x - 1 then r.nodes[field].type = common.sig(T, type_start, x - 1, 120) end
|
|
139
146
|
x = x + 1
|
|
140
147
|
end
|
|
141
148
|
end
|
|
@@ -173,7 +180,7 @@ parse_items = function(T, r, a, b, parent, impl_type, in_trait)
|
|
|
173
180
|
local p = skip_angle(T, x + 2, b)
|
|
174
181
|
local e, body = item_end(T, p, b)
|
|
175
182
|
local node = common.add_node(r, T, {
|
|
176
|
-
kind = (impl_type or in_trait) and 'method' or 'function', name = T:text(name_tok),
|
|
183
|
+
kind = (impl_type or in_trait) and 'method' or 'function', name = T:text(name_tok), ni = name_tok,
|
|
177
184
|
parent = parent, ti = start, tj = e,
|
|
178
185
|
sig = common.sig(T, start, body and body - 1 or e, 200), abstract = (not body) or nil,
|
|
179
186
|
})
|
|
@@ -185,21 +192,22 @@ parse_items = function(T, r, a, b, parent, impl_type, in_trait)
|
|
|
185
192
|
stop = e
|
|
186
193
|
elseif (t == 'struct' or t == 'enum' or t == 'union') and T.k[x + 1] == 'id' then
|
|
187
194
|
local e, body = item_end(T, x + 2, b)
|
|
188
|
-
local node = common.add_node(r, T, { kind = t == 'enum' and 'enum' or 'struct', name = T:text(x + 1),
|
|
195
|
+
local node = common.add_node(r, T, { kind = t == 'enum' and 'enum' or 'struct', name = T:text(x + 1), ni = x + 1,
|
|
189
196
|
parent = parent, ti = start, tj = e, sig = common.sig(T, start, body and body - 1 or e, 160) })
|
|
190
197
|
if body then body_members(T, r, body, e, node, t) end
|
|
191
198
|
stop = e
|
|
192
199
|
elseif t == 'trait' and T.k[x + 1] == 'id' then
|
|
193
200
|
local e, body = item_end(T, x + 2, b)
|
|
194
|
-
local node = common.add_node(r, T, { kind = 'interface', name = T:text(x + 1), parent = parent,
|
|
201
|
+
local node = common.add_node(r, T, { kind = 'interface', name = T:text(x + 1), ni = x + 1, parent = parent,
|
|
195
202
|
ti = start, tj = e, sig = common.sig(T, start, body and body - 1 or e, 160) })
|
|
196
203
|
if body then parse_items(T, r, body + 1, e - 1, node, nil, true) end
|
|
197
204
|
stop = e
|
|
198
205
|
elseif t == 'impl' then
|
|
199
206
|
local e, body = item_end(T, x + 1, b)
|
|
200
207
|
if body then
|
|
201
|
-
local ty, trait = impl_target(T, x + 1, body)
|
|
208
|
+
local ty, trait, name_tok = impl_target(T, x + 1, body)
|
|
202
209
|
local node = common.add_node(r, T, { kind = 'impl', name = ty or 'impl', parent = parent,
|
|
210
|
+
ni = name_tok,
|
|
203
211
|
ti = start, tj = e, sig = common.sig(T, start, body - 1, 160), trait = trait })
|
|
204
212
|
r.nodes[node].qualified = ty or 'impl'
|
|
205
213
|
parse_items(T, r, body + 1, e - 1, node, ty, false)
|
|
@@ -208,12 +216,12 @@ parse_items = function(T, r, a, b, parent, impl_type, in_trait)
|
|
|
208
216
|
elseif t == 'mod' and T.k[x + 1] == 'id' then
|
|
209
217
|
local e, body = item_end(T, x + 2, b)
|
|
210
218
|
if body then
|
|
211
|
-
local node = common.add_node(r, T, { kind = 'namespace', name = T:text(x + 1), parent = parent,
|
|
219
|
+
local node = common.add_node(r, T, { kind = 'namespace', name = T:text(x + 1), ni = x + 1, parent = parent,
|
|
212
220
|
ti = start, tj = e })
|
|
213
221
|
parse_items(T, r, body + 1, e - 1, node, nil, false)
|
|
214
222
|
else
|
|
215
223
|
-- `mod x;` declares a file module: a node and an import of x.rs / x/mod.rs
|
|
216
|
-
common.add_node(r, T, { kind = 'namespace', name = T:text(x + 1), parent = parent, ti = start, tj = e })
|
|
224
|
+
common.add_node(r, T, { kind = 'namespace', name = T:text(x + 1), ni = x + 1, parent = parent, ti = start, tj = e })
|
|
217
225
|
r.imports[#r.imports + 1] = { path = T:text(x + 1), line = T:line(x), kind = 'mod' }
|
|
218
226
|
end
|
|
219
227
|
stop = e
|
|
@@ -223,7 +231,7 @@ parse_items = function(T, r, a, b, parent, impl_type, in_trait)
|
|
|
223
231
|
stop = e
|
|
224
232
|
elseif (t == 'type') and T.k[x + 1] == 'id' then
|
|
225
233
|
local e = item_end(T, x + 2, b)
|
|
226
|
-
common.add_node(r, T, { kind = 'typedef', name = T:text(x + 1), parent = parent, ti = start, tj = e,
|
|
234
|
+
common.add_node(r, T, { kind = 'typedef', name = T:text(x + 1), ni = x + 1, parent = parent, ti = start, tj = e,
|
|
227
235
|
sig = common.sig(T, start, e, 160) })
|
|
228
236
|
stop = e
|
|
229
237
|
elseif (t == 'const' or t == 'static') then
|
|
@@ -231,7 +239,7 @@ parse_items = function(T, r, a, b, parent, impl_type, in_trait)
|
|
|
231
239
|
if kw(T, y, 'mut') then y = y + 1 end
|
|
232
240
|
local e = item_end(T, y, b)
|
|
233
241
|
if T.k[y] == 'id' then
|
|
234
|
-
local node = common.add_node(r, T, { kind = t == 'const' and 'constant' or 'variable', name = T:text(y),
|
|
242
|
+
local node = common.add_node(r, T, { kind = t == 'const' and 'constant' or 'variable', name = T:text(y), ni = y,
|
|
235
243
|
parent = parent, ti = start, tj = e, sig = common.sig(T, start, math.min(e, y + 2), 120) })
|
|
236
244
|
if impl_type then r.nodes[node].qualified = impl_type .. '::' .. T:text(y) end
|
|
237
245
|
calls(r, T, y, e)
|
|
@@ -241,7 +249,7 @@ parse_items = function(T, r, a, b, parent, impl_type, in_trait)
|
|
|
241
249
|
local o = x + 3
|
|
242
250
|
local e = (T.m[o] or o)
|
|
243
251
|
if is(T, e + 1, ';') then e = e + 1 end
|
|
244
|
-
common.add_node(r, T, { kind = 'macro', name = T:text(x + 2), parent = parent, ti = start, tj = e })
|
|
252
|
+
common.add_node(r, T, { kind = 'macro', name = T:text(x + 2), ni = x + 2, parent = parent, ti = start, tj = e })
|
|
245
253
|
stop = e
|
|
246
254
|
elseif kw(T, x, 'extern') and kw(T, x + 1, 'crate') then
|
|
247
255
|
local e = item_end(T, x, b)
|
|
@@ -264,13 +272,13 @@ parse_items = function(T, r, a, b, parent, impl_type, in_trait)
|
|
|
264
272
|
end
|
|
265
273
|
end
|
|
266
274
|
|
|
267
|
-
function M.parse(path, src)
|
|
275
|
+
function M.parse(path, src, language, opts)
|
|
268
276
|
local T = M.lang:tokenize(src)
|
|
269
|
-
local r = common.new(path, 'rust')
|
|
277
|
+
local r = common.new(path, 'rust', opts)
|
|
270
278
|
parse_items(T, r, 1, T.n, nil, nil, false)
|
|
271
279
|
-- '::' is the path separator: fix qualified names built with '.'
|
|
272
280
|
for _, n in ipairs(r.nodes) do n.qualified = n.qualified:gsub('%.', '::') end
|
|
273
|
-
return common.finish(r), T
|
|
281
|
+
return common.finish(r, T), T
|
|
274
282
|
end
|
|
275
283
|
|
|
276
284
|
return M
|