Skip to content

Commit 0e159ee

Browse files
committed
update
1 parent 9310038 commit 0e159ee

18 files changed

Lines changed: 167 additions & 154 deletions

‎script/core/completion/completion.lua‎

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ local guide = require 'parser.guide'
1919
localinfer=require'vm.infer'
2020
localawait=require'await'
2121
localpostfix=require'core.completion.postfix'
22+
localglobalMgr=require'vm.global-manager'
2223

2324
localdiagnosticModes= {
2425
'disable-next-line',
@@ -287,7 +288,7 @@ local function checkLocal(state, word, position, results)
287288
ifname:sub(1, 1) =='@' then
288289
gotoCONTINUE
289290
end
290-
ifinfer.hasType(source,'function')then
291+
ifinfer.getInfer(source):hasType'function' then
291292
for_, definipairs(vm.getDefs(source)) do
292293
ifdef.type=='function'
293294
ordef.type=='doc.type.function' then
@@ -335,7 +336,7 @@ local function checkModule(state, word, position, results)
335336
localfileName=path:match'[^/\\]*$'
336337
localstemName=fileName:gsub('%..+', '')
337338
ifnotlocals[stemName]
338-
andnotvm.hasGlobalSets(state.uri, stemName)
339+
andnotglobalMgr.hasGlobalSets(state.uri, 'variable', stemName)
339340
andnotconfig.get(state.uri, 'Lua.diagnostics.globals')[stemName]
340341
andstemName:match'^[%a_][%w_]*$'
341342
andmatchKey(word, stemName) then
@@ -482,7 +483,7 @@ local function checkFieldThen(state, name, src, word, startPos, position, parent
482483
})
483484
return
484485
end
485-
ifoopandnotinfer.hasType(src,'function')then
486+
ifoopandnotinfer.getInfer(src):hasType'function' then
486487
return
487488
end
488489
localliteral=guide.getLiteral(value)
@@ -584,17 +585,17 @@ end
584585
---@async
585586
localfunctioncheckGlobal(state, word, startPos, position, parent, oop, results)
586587
locallocals=guide.getVisibleLocals(state.ast, position)
587-
localglobals=vm.getGlobalSets(state.uri, '*')
588+
localglobals=globalMgr.getGlobalSets(state.uri, 'variable')
588589
checkFieldOfRefs(globals, state, word, startPos, position, parent, oop, results, locals, 'global')
589590
end
590591

591592
---@async
592593
localfunctioncheckField(state, word, start, position, parent, oop, results)
593594
ifparent.tag=='_ENV' orparent.special=='_G' then
594-
localglobals=vm.getGlobalSets(state.uri, '*')
595+
localglobals=globalMgr.getGlobalSets(state.uri, 'variable')
595596
checkFieldOfRefs(globals, state, word, start, position, parent, oop, results)
596597
else
597-
localrefs=vm.getRefs(parent, '*')
598+
localrefs=vm.getFields(parent)
598599
checkFieldOfRefs(refs, state, word, start, position, parent, oop, results)
599600
end
600601
end
@@ -1106,7 +1107,7 @@ local function checkTypingEnum(state, position, defs, str, results)
11061107
localenums= {}
11071108
for_, definipairs(defs) do
11081109
ifdef.type=='doc.type.string'
1109-
ordef.type=='doc.resume' then
1110+
ordef.type=='doc.type.integer' then
11101111
enums[#enums+1] = {
11111112
label=def[1],
11121113
description=def.commentanddef.comment.text,
@@ -1312,20 +1313,20 @@ function (%s)\
13121313
end"):format(table.concat(args, ', '))
13131314
end
13141315

1315-
localfunctionpushCallEnumsAndFuncs(defs)
1316+
localfunctionpushCallEnumsAndFuncs(source)
1317+
localdefs=vm.getDefs(source)
13161318
localresults= {}
13171319
for_, definipairs(defs) do
1318-
ifdef.type=='doc.type.string'
1319-
ordef.type=='doc.resume' then
1320+
ifdef.type=='doc.type.string' then
13201321
results[#results+1] = {
1321-
label=def[1],
1322+
label=util.viewLiteral(def[1]),
13221323
description=def.comment,
13231324
kind=define.CompletionItemKind.EnumMember,
13241325
}
13251326
end
13261327
ifdef.type=='doc.type.function' then
13271328
results[#results+1] = {
1328-
label=infer.viewDocFunction(def),
1329+
label=infer.getInfer(def):view(),
13291330
description=def.comment,
13301331
kind=define.CompletionItemKind.Function,
13311332
insertText=buildInsertDocFunction(def),
@@ -1354,17 +1355,17 @@ local function getCallEnumsAndFuncs(source, index, oop, call)
13541355
for_, docinipairs(source.bindDocs) do
13551356
ifdoc.type=='doc.param'
13561357
anddoc.param[1] ==arg[1] then
1357-
returnpushCallEnumsAndFuncs(vm.getDefs(doc.extends))
1358+
returnpushCallEnumsAndFuncs(doc.extends)
13581359
elseifdoc.type=='doc.vararg'
13591360
andarg.type=='...' then
1360-
returnpushCallEnumsAndFuncs(vm.getDefs(doc.vararg))
1361+
returnpushCallEnumsAndFuncs(doc.vararg)
13611362
end
13621363
end
13631364
end
13641365
ifsource.type=='doc.type.function' then
13651366
localarg=source.args[index]
13661367
ifargandarg.extendsthen
1367-
returnpushCallEnumsAndFuncs(vm.getDefs(arg.extends))
1368+
returnpushCallEnumsAndFuncs(arg.extends)
13681369
end
13691370
end
13701371
ifsource.type=='doc.field.name' then
@@ -1400,7 +1401,7 @@ local function getCallEnumsAndFuncs(source, index, oop, call)
14001401
ifeventNameandeventName==myEventNamethen
14011402
localdocFunc=doc.extends.types[1].args[2].extends.types[1]
14021403
results[#results+1] = {
1403-
label=infer.viewDocFunction(docFunc),
1404+
label=infer.getInfer(docFunc):view(),
14041405
description=doc.comment,
14051406
kind=define.CompletionItemKind.Function,
14061407
insertText=buildInsertDocFunction(docFunc),
@@ -1520,7 +1521,7 @@ local function tryTable(state, position, results)
15201521
ifsource.type~='table' then
15211522
tbl=source.parent
15221523
end
1523-
localdefs=vm.getDefs(tbl, '*')
1524+
localdefs=vm.getFields(tbl)
15241525
for_, fieldinipairs(defs) do
15251526
localname=guide.getKeyName(field)
15261527
ifnameandnotmark[name] then
@@ -1635,19 +1636,20 @@ local function tryluaDocBySource(state, position, source, results)
16351636
ifsource.type=='doc.extends.name' then
16361637
ifsource.parent.type=='doc.class' then
16371638
localused= {}
1638-
for_, docinipairs(vm.getDocDefines(state.uri, '*')) do
1639-
ifdoc.type=='doc.class.name'
1640-
anddoc.parent~=source.parent
1641-
andnotused[doc[1]]
1642-
andmatchKey(source[1], doc[1]) then
1643-
used[doc[1]] =true
1639+
for_, docinipairs(vm.getDocSets(state.uri)) do
1640+
localname=doc.type=='doc.class' anddoc.class[1]
1641+
ifname
1642+
andname~=source.parent.class[1]
1643+
andnotused[name]
1644+
andmatchKey(source[1], name) then
1645+
used[name] =true
16441646
results[#results+1] = {
1645-
label=doc[1],
1647+
label=name,
16461648
kind=define.CompletionItemKind.Class,
1647-
textEdit=doc[1]:find'[^%w_]' and {
1649+
textEdit=name:find'[^%w_]' and {
16481650
start=source.start,
16491651
finish=position,
1650-
newText=doc[1],
1652+
newText=name,
16511653
},
16521654
}
16531655
end
@@ -1656,19 +1658,20 @@ local function tryluaDocBySource(state, position, source, results)
16561658
returntrue
16571659
elseifsource.type=='doc.type.name' then
16581660
localused= {}
1659-
for_, docinipairs(vm.getDocDefines(state.uri, '*')) do
1660-
if (doc.type=='doc.class.name' ordoc.type=='doc.alias.name')
1661-
anddoc.parent~=source.parent
1662-
andnotused[doc[1]]
1663-
andmatchKey(source[1], doc[1]) then
1664-
used[doc[1]] =true
1661+
for_, docinipairs(vm.getDocSets(state.uri)) do
1662+
localname= (doc.type=='doc.class' anddoc.class[1])
1663+
or (doc.type=='doc.alias' anddoc.alias[1])
1664+
ifname
1665+
andnotused[name]
1666+
andmatchKey(source[1], name) then
1667+
used[name] =true
16651668
results[#results+1] = {
1666-
label=doc[1],
1669+
label=name,
16671670
kind=define.CompletionItemKind.Class,
1668-
textEdit=doc[1]:find'[^%w_]' and {
1671+
textEdit=name:find'[^%w_]' and {
16691672
start=source.start,
16701673
finish=position,
1671-
newText=doc[1],
1674+
newText=name,
16721675
},
16731676
}
16741677
end
@@ -1734,17 +1737,17 @@ end
17341737

17351738
localfunctiontryluaDocByErr(state, position, err, docState, results)
17361739
iferr.type=='LUADOC_MISS_CLASS_EXTENDS_NAME' then
1737-
for_, docinipairs(vm.getDocDefines(state.uri, '*')) do
1738-
ifdoc.type=='doc.class.name'
1739-
anddoc.parent~=docStatethen
1740+
for_, docinipairs(vm.getDocSets(state.uri)) do
1741+
ifdoc.type=='doc.class'
1742+
anddoc.class[1]~=docState.class[1]then
17401743
results[#results+1] = {
1741-
label=doc[1],
1744+
label=doc.class[1],
17421745
kind=define.CompletionItemKind.Class,
17431746
}
17441747
end
17451748
end
17461749
elseiferr.type=='LUADOC_MISS_TYPE_NAME' then
1747-
for_, docinipairs(vm.getDocDefines(state.uri, '*')) do
1750+
for_, docinipairs(vm.getDocSets(state.uri)) do
17481751
if (doc.type=='doc.class.name' ordoc.type=='doc.alias.name') then
17491752
results[#results+1] = {
17501753
label=doc[1],

‎script/core/definition.lua‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ return function (uri, offset)
152152
gotoCONTINUE
153153
end
154154
else
155-
ifguide.isLiteral(src) andsrc.type~='function' then
155+
ifguide.isLiteral(src)
156+
andsrc.type~='function'
157+
andsrc.type~='doc.type.function'
158+
andsrc.type~='doc.type.table' then
156159
gotoCONTINUE
157160
end
158161
end

‎script/core/diagnostics/circle-doc-class.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ return function (uri, callback)
3939
end
4040
ifnotmark[newName] then
4141
mark[newName] =true
42-
localdocs=vm.getDocDefines(uri, newName)
42+
localdocs=vm.getDocSets(uri, newName)
4343
for_, otherDocinipairs(docs) do
4444
ifotherDoc.type=='doc.class.name' then
4545
list[#list+1] =otherDoc.parent

‎script/core/diagnostics/duplicate-doc-class.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ return function (uri, callback)
1818
ifdoc.type=='doc.alias' then
1919
localname=guide.getKeyName(doc)
2020
ifnotcache[name] then
21-
localdocs=vm.getDocDefines(uri, name)
21+
localdocs=vm.getDocSets(uri, name)
2222
cache[name] = {}
2323
for_, otherDocinipairs(docs) do
2424
ifotherDoc.type=='doc.class.name'

‎script/core/diagnostics/type-check.lua‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ local typeNameMap = {
1717
['doc.class.name'] =true,
1818
['doc.alias.name'] =true,
1919
['doc.type.name'] =true,
20-
['doc.type.string'] =true,
21-
['doc.resume'] =true,
20+
['doc.type.string'] =true,
21+
['doc.type.integer']=true,
2222

2323
}
2424

@@ -37,10 +37,10 @@ local function isTable(name)
3737
end
3838

3939
localfunctionisUserDefineClass(uri, name)
40-
ifvm.isBuiltinType(name) then
40+
ifguide.isBasicType(name) then
4141
returnfalse
4242
else
43-
localdefs=vm.getDocDefines(uri, name)
43+
localdefs=vm.getDocSets(uri, name)
4444
for_, vinipairs(defs) do
4545
ifv.type=='doc.class.name' then
4646
returntrue
@@ -54,7 +54,7 @@ local function isClassOralias(typeName)
5454
ifnottypeNamethen
5555
returnfalse
5656
elseiftypeNameMap[typeName]
57-
orvm.isBuiltinType(typeName) then
57+
orguide.isBasicType(typeName) then
5858
returntrue
5959
else
6060
returnfalse
@@ -99,7 +99,7 @@ end
9999
-- if not type[1] then
100100
-- return
101101
-- end
102-
-- local docDefs = vm.getDocDefines(type[1])
102+
-- local docDefs = vm.getDocSets(type[1])
103103
-- for _, doc in ipairs(docDefs) do
104104
-- if doc.parent
105105
-- and doc.parent.type == 'doc.class'
@@ -119,7 +119,7 @@ end
119119
localfunctionaddFatherClass(uri, infers)
120120
forkinpairs(infers) do
121121
iftype(k) =='string' then
122-
localdocDefs=vm.getDocDefines(uri, k)
122+
localdocDefs=vm.getDocSets(uri, k)
123123
for_, docinipairs(docDefs) do
124124
ifdoc.parent
125125
anddoc.parent.type=='doc.class'

‎script/core/diagnostics/undefined-doc-class.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ return function (uri, callback)
2323
end
2424
for_, extinipairs(doc.extends) do
2525
localname=ext[1]
26-
localdocs=vm.getDocDefines(uri, name)
26+
localdocs=vm.getDocSets(uri, name)
2727
ifcache[name] ==nilthen
2828
cache[name] =false
2929
for_, otherDocinipairs(docs) do

‎script/core/diagnostics/undefined-doc-name.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ return function (uri, callback)
3535
ifname=='...' then
3636
return
3737
end
38-
ifvm.isDocDefined(uri, name)
38+
if#vm.getDocSets(uri, name)>0
3939
orhasNameOfGeneric(name, source) then
4040
return
4141
end

‎script/core/hover/description.lua‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ local function buildEnumChunk(docType, name)
158158
end
159159
localtypes= {}
160160
for_, tpinipairs(docType.types) do
161-
iftp.type~='doc.enum'
162-
andtp.type~='doc.resume' then
161+
iftp.type~='doc.string'
162+
andtp.type~='doc.integer' then
163163
types[#types+1] =tp[1]
164164
end
165165
end

‎script/core/semantic-tokens.lua‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -513,24 +513,6 @@ local Care = util.switch()
513513
modifieres=define.TokenModifiers.static,
514514
}
515515
end)
516-
: case'doc.resume'
517-
: call(function (source, options, results)
518-
ifnotoptions.annotationthen
519-
return
520-
end
521-
results[#results+1] = {
522-
start=source.start,
523-
finish=source.finish,
524-
type=define.TokenTypes.string,
525-
modifieres=define.TokenModifiers.static,
526-
}
527-
localrow=guide.rowColOf(source.start)
528-
results[#results+1] = {
529-
start=source.finish,
530-
finish=guide.positionOf(row, guide.getLineRange(options.state, row)),
531-
type=define.TokenTypes.comment,
532-
}
533-
end)
534516
: case'doc.type.function'
535517
: call(function (source, options, results)
536518
ifnotoptions.annotationthen

‎script/parser/guide.lua‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ function m.isLiteral(obj)
231231
ortp=='integer'
232232
ortp=='table'
233233
ortp=='function'
234+
ortp=='doc.type.function'
235+
ortp=='doc.type.table'
236+
ortp=='doc.type.string'
237+
ortp=='doc.type.integer'
234238
end
235239

236240
--- 获取字面量
@@ -820,8 +824,6 @@ local isSetMap = {
820824
['doc.class'] =true,
821825
['doc.alias'] =true,
822826
['doc.field'] =true,
823-
['doc.type.function'] =true,
824-
['doc.type.table'] =true,
825827
['doc.class.name'] =true,
826828
['doc.alias.name'] =true,
827829
['doc.field.name'] =true,

0 commit comments

Comments
 (0)