Skip to content

Commit f5d631b

Browse files
committed
respect quotation marks
1 parent de82efa commit f5d631b

File tree

9 files changed

+117
-115
lines changed

9 files changed

+117
-115
lines changed

meta/template/basic.lua

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ arg = {}
1313
function assert(v, message, ...) end
1414

1515
---@alias gcoptions
16-
---|>'"collect"' # ---#DESTAIL 'cgopt.collect'
17-
---| '"stop"' # ---#DESTAIL 'cgopt.stop'
18-
---| '"restart"' # ---#DESTAIL 'cgopt.restart'
19-
---| '"count"' # ---#DESTAIL 'cgopt.count'
20-
---| '"step"' # ---#DESTAIL 'cgopt.step'
21-
---| '"isrunning"' # ---#DESTAIL 'cgopt.isrunning'
16+
---|>"collect" # ---#DESTAIL 'cgopt.collect'
17+
---| "stop" # ---#DESTAIL 'cgopt.stop'
18+
---| "restart" # ---#DESTAIL 'cgopt.restart'
19+
---| "count" # ---#DESTAIL 'cgopt.count'
20+
---| "step" # ---#DESTAIL 'cgopt.step'
21+
---| "isrunning" # ---#DESTAIL 'cgopt.isrunning'
2222
---#if VERSION >= 5.4 then
23-
---| '"incremental"' # ---#DESTAIL 'cgopt.incremental'
24-
---| '"generational"' # ---#DESTAIL 'cgopt.generational'
23+
---| "incremental" # ---#DESTAIL 'cgopt.incremental'
24+
---| "generational" # ---#DESTAIL 'cgopt.generational'
2525
---#else
26-
---| '"setpause"' # ---#DESTAIL 'cgopt.setpause'
27-
---| '"setstepmul"' # ---#DESTAIL 'cgopt.setstepmul'
26+
---| "setpause" # ---#DESTAIL 'cgopt.setpause'
27+
---| "setstepmul" # ---#DESTAIL 'cgopt.setstepmul'
2828
---#end
2929

3030
---#if VERSION >= 5.4 then
@@ -76,9 +76,9 @@ function getmetatable(object) end
7676
function ipairs(t) end
7777

7878
---@alias loadmode
79-
---| '"b"' # ---#DESTAIL 'loadmode.b'
80-
---| '"t"' # ---#DESTAIL 'loadmode.t'
81-
---|>'"bt"' # ---#DESTAIL 'loadmode.bt'
79+
---| "b" # ---#DESTAIL 'loadmode.b'
80+
---| "t" # ---#DESTAIL 'loadmode.t'
81+
---|>"bt" # ---#DESTAIL 'loadmode.bt'
8282

8383
---#if VERSION <= 5.1 and not JIT then
8484
---#DES 'load<5.1'
@@ -197,7 +197,7 @@ function rawlen(v) end
197197
function rawset(table, index, value) end
198198

199199
---#DES 'select'
200-
---@param index integer|'"#"'
200+
---@param index integer|"#"
201201
---@return any
202202
---@nodiscard
203203
function select(index, ...) end
@@ -229,16 +229,16 @@ function tonumber(e) end
229229
function tostring(v) end
230230

231231
---@alias type
232-
---| '"nil"'
233-
---| '"number"'
234-
---| '"string"'
235-
---| '"boolean"'
236-
---| '"table"'
237-
---| '"function"'
238-
---| '"thread"'
239-
---| '"userdata"'
232+
---| "nil"
233+
---| "number"
234+
---| "string"
235+
---| "boolean"
236+
---| "table"
237+
---| "function"
238+
---| "thread"
239+
---| "userdata"
240240
---#if VERSION == JIT then
241-
---| '"cdata"'
241+
---| "cdata"
242242
---#end
243243

244244
---#DES 'type'
@@ -249,13 +249,13 @@ function type(v) end
249249

250250
---#DES '_VERSION'
251251
---#if VERSION == 5.1 then
252-
_VERSION = 'Lua 5.1'
252+
_VERSION = "Lua 5.1"
253253
---#elseif VERSION == 5.2 then
254-
_VERSION = 'Lua 5.2'
254+
_VERSION = "Lua 5.2"
255255
---#elseif VERSION == 5.3 then
256-
_VERSION = 'Lua 5.3'
256+
_VERSION = "Lua 5.3"
257257
---#elseif VERSION == 5.4 then
258-
_VERSION = 'Lua 5.4'
258+
_VERSION = "Lua 5.4"
259259
---#end
260260

261261
---@version >5.4

meta/template/debug.lua

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,20 @@ function debug.getfenv(o) end
4545
function debug.gethook(co) end
4646

4747
---@alias infowhat string
48-
---|+'"n"' # ---#DESTAIL 'infowhat.n'
49-
---|+'"S"' # ---#DESTAIL 'infowhat.S'
50-
---|+'"l"' # ---#DESTAIL 'infowhat.l'
51-
---|+'"t"' # ---#DESTAIL 'infowhat.t'
48+
---|+"n" # ---#DESTAIL 'infowhat.n'
49+
---|+"S" # ---#DESTAIL 'infowhat.S'
50+
---|+"l" # ---#DESTAIL 'infowhat.l'
51+
---|+"t" # ---#DESTAIL 'infowhat.t'
5252
---#if VERSION <= 5.1 and not JIT then
53-
---|+'"u"' # ---#DESTAIL 'infowhat.u<5.1'
53+
---|+"u" # ---#DESTAIL 'infowhat.u<5.1'
5454
---#else
55-
---|+'"u"' # ---#DESTAIL 'infowhat.u>5.2'
55+
---|+"u" # ---#DESTAIL 'infowhat.u>5.2'
5656
---#end
57-
---|+'"f"' # ---#DESTAIL 'infowhat.f'
57+
---|+"f" # ---#DESTAIL 'infowhat.f'
5858
---#if VERSION >= 5.4 then
59-
---|+'"r"' # ---#DESTAIL 'infowhat.r'
59+
---|+"r" # ---#DESTAIL 'infowhat.r'
6060
---#end
61-
---|+'"L"' # ---#DESTAIL 'infowhat.L'
61+
---|+"L" # ---#DESTAIL 'infowhat.L'
6262

6363
---#DES 'debug.getinfo'
6464
---@overload fun(f: integer|function, what?: infowhat):debuginfo
@@ -141,9 +141,9 @@ function debug.setcstacklimit(limit) end
141141
function debug.setfenv(object, env) end
142142

143143
---@alias hookmask string
144-
---|+'"c"' # ---#DESTAIL 'hookmask.c'
145-
---|+'"r"' # ---#DESTAIL 'hookmask.r'
146-
---|+'"l"' # ---#DESTAIL 'hookmask.l'
144+
---|+"c" # ---#DESTAIL 'hookmask.c'
145+
---|+"r" # ---#DESTAIL 'hookmask.r'
146+
---|+"l" # ---#DESTAIL 'hookmask.l'
147147

148148
---#DES 'debug.sethook'
149149
---@overload fun(hook: (async fun(...):...), mask: hookmask, count?: integer)

meta/template/io.lua

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111
io = {}
1212

1313
---@alias openmode
14-
---|>'"r"' # ---#DESTAIL 'openmode.r'
15-
---| '"w"' # ---#DESTAIL 'openmode.w'
16-
---| '"a"' # ---#DESTAIL 'openmode.a'
17-
---| '"r+"' # ---#DESTAIL 'openmode.r+'
18-
---| '"w+"' # ---#DESTAIL 'openmode.w+'
19-
---| '"a+"' # ---#DESTAIL 'openmode.a+'
20-
---| '"rb"' # ---#DESTAIL 'openmode.rb'
21-
---| '"wb"' # ---#DESTAIL 'openmode.wb'
22-
---| '"ab"' # ---#DESTAIL 'openmode.ab'
23-
---| '"r+b"' # ---#DESTAIL 'openmode.r+b'
24-
---| '"w+b"' # ---#DESTAIL 'openmode.w+b'
25-
---| '"a+b"' # ---#DESTAIL 'openmode.a+b'
14+
---|>"r" # ---#DESTAIL 'openmode.r'
15+
---| "w" # ---#DESTAIL 'openmode.w'
16+
---| "a" # ---#DESTAIL 'openmode.a'
17+
---| "r+" # ---#DESTAIL 'openmode.r+'
18+
---| "w+" # ---#DESTAIL 'openmode.w+'
19+
---| "a+" # ---#DESTAIL 'openmode.a+'
20+
---| "rb" # ---#DESTAIL 'openmode.rb'
21+
---| "wb" # ---#DESTAIL 'openmode.wb'
22+
---| "ab" # ---#DESTAIL 'openmode.ab'
23+
---| "r+b" # ---#DESTAIL 'openmode.r+b'
24+
---| "w+b" # ---#DESTAIL 'openmode.w+b'
25+
---| "a+b" # ---#DESTAIL 'openmode.a+b'
2626

2727
---#DES 'io.close'
2828
---@param file? file*
@@ -59,8 +59,8 @@ function io.open(filename, mode) end
5959
function io.output(file) end
6060

6161
---@alias popenmode
62-
---| '"r"' # ---#DESTAIL 'popenmode.r'
63-
---| '"w"' # ---#DESTAIL 'popenmode.w'
62+
---| "r" # ---#DESTAIL 'popenmode.r'
63+
---| "w" # ---#DESTAIL 'popenmode.w'
6464

6565
---#DES 'io.popen'
6666
---@param prog string
@@ -82,9 +82,9 @@ function io.read(...) end
8282
function io.tmpfile() end
8383

8484
---@alias filetype
85-
---| '"file"' # ---#DESTAIL 'filetype.file'
86-
---| '"closed file"' # ---#DESTAIL 'filetype.closed file'
87-
---| 'nil' # ---#DESTAIL 'filetype.nil'
85+
---| "file" # ---#DESTAIL 'filetype.file'
86+
---| "closed file" # ---#DESTAIL 'filetype.closed file'
87+
---| `nil` # ---#DESTAIL 'filetype.nil'
8888

8989
---#DES 'io.type'
9090
---@param file file*
@@ -103,20 +103,20 @@ local file = {}
103103

104104
---@alias readmode integer|string
105105
---#if VERSION >= 5.3 then
106-
---| '"n"' # ---#DESTAIL 'readmode.n'
107-
---| '"a"' # ---#DESTAIL 'readmode.a'
108-
---|>'"l"' # ---#DESTAIL 'readmode.l'
109-
---| '"L"' # ---#DESTAIL 'readmode.L'
106+
---| "n" # ---#DESTAIL 'readmode.n'
107+
---| "a" # ---#DESTAIL 'readmode.a'
108+
---|>"l" # ---#DESTAIL 'readmode.l'
109+
---| "L" # ---#DESTAIL 'readmode.L'
110110
---#else
111-
---| '"*n"' # ---#DESTAIL 'readmode.n'
112-
---| '"*a"' # ---#DESTAIL 'readmode.a'
113-
---|>'"*l"' # ---#DESTAIL 'readmode.l'
111+
---| "*n" # ---#DESTAIL 'readmode.n'
112+
---| "*a" # ---#DESTAIL 'readmode.a'
113+
---|>"*l" # ---#DESTAIL 'readmode.l'
114114
---#if JIT then
115-
---| '"*L"' # ---#DESTAIL 'readmode.L'
115+
---| "*L" # ---#DESTAIL 'readmode.L'
116116
---#end
117117
---#end
118118

119-
---@alias exitcode '"exit"'|'"signal"'
119+
---@alias exitcode "exit"|"signal"
120120

121121
---#DES 'file:close'
122122
---@return boolean? suc
@@ -140,9 +140,9 @@ function file:lines(...) end
140140
function file:read(...) end
141141

142142
---@alias seekwhence
143-
---| '"set"' # ---#DESTAIL 'seekwhence.set'
144-
---|>'"cur"' # ---#DESTAIL 'seekwhence.cur'
145-
---| '"end"' # ---#DESTAIL 'seekwhence.end'
143+
---| "set" # ---#DESTAIL 'seekwhence.set'
144+
---|>"cur" # ---#DESTAIL 'seekwhence.cur'
145+
---| "end" # ---#DESTAIL 'seekwhence.end'
146146

147147
---#DES 'file:seek'
148148
---@param whence? seekwhence
@@ -152,9 +152,9 @@ function file:read(...) end
152152
function file:seek(whence, offset) end
153153

154154
---@alias vbuf
155-
---| '"no"' # ---#DESTAIL 'vbuf.no'
156-
---| '"full"' # ---#DESTAIL 'vbuf.full'
157-
---| '"line"' # ---#DESTAIL 'vbuf.line'
155+
---| "no" # ---#DESTAIL 'vbuf.no'
156+
---| "full" # ---#DESTAIL 'vbuf.full'
157+
---| "line" # ---#DESTAIL 'vbuf.line'
158158

159159
---#DES 'file:setvbuf'
160160
---@param mode vbuf

meta/template/os.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ function os.remove(filename) end
8787
function os.rename(oldname, newname) end
8888

8989
---@alias localecategory
90-
---|>'"all"'
91-
---| '"collate"'
92-
---| '"ctype"'
93-
---| '"monetary"'
94-
---| '"numeric"'
95-
---| '"time"'
90+
---|>"all"
91+
---| "collate"
92+
---| "ctype"
93+
---| "monetary"
94+
---| "numeric"
95+
---| "time"
9696

9797
---#DES 'os.setlocale'
9898
---@param locale string|nil

script/core/completion/completion.lua

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ local function checkFieldFromFieldToIndex(state, name, src, parent, word, startP
443443
or config.get(state.uri, 'Lua.runtime.unicodeName') then
444444
return nil
445445
end
446+
name = ('%q'):format(name)
446447
end
447448
local textEdit, additionalTextEdits
448449
local startOffset = guide.positionToOffset(state, startPos)
@@ -459,12 +460,7 @@ local function checkFieldFromFieldToIndex(state, name, src, parent, word, startP
459460
wordStartOffset = offset - #word
460461
end
461462
local wordStartPos = guide.offsetToPosition(state, wordStartOffset)
462-
local newText
463-
if vm.getKeyType(src) == 'string' then
464-
newText = ('[%q]'):format(name)
465-
else
466-
newText = ('[%s]'):format(name)
467-
end
463+
local newText = ('[%s]'):format(name)
468464
textEdit = {
469465
start = wordStartPos,
470466
finish = position,
@@ -541,7 +537,7 @@ local function checkFieldThen(state, name, src, word, startPos, position, parent
541537
textEdit = {
542538
start = str.start + #str[2],
543539
finish = position,
544-
newText = name,
540+
newText = name:sub(#str[2] + 1, - #str[2] - 1),
545541
}
546542
else
547543
textEdit, additionalTextEdits = checkFieldFromFieldToIndex(state, name, src, parent, word, startPos, position)
@@ -583,7 +579,7 @@ local function checkFieldOfRefs(refs, state, word, startPos, position, parent, o
583579
if isGlobal and locals and locals[name] then
584580
goto CONTINUE
585581
end
586-
if not matchKey(word, name, count >= 100) then
582+
if not matchKey(word, name:gsub([=[^['"]]=], ''), count >= 100) then
587583
goto CONTINUE
588584
end
589585
if not vm.isVisible(parent, src) then

script/vm/compiler.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,8 @@ local compilerSwitch = util.switch()
11771177
end
11781178

11791179
-- { f = function (<?x?>) end }
1180-
if guide.isAssign(parent) then
1180+
if guide.isAssign(parent)
1181+
and parent.value == source then
11811182
vm.setNode(source, vm.compileNode(parent))
11821183
end
11831184
end)

script/vm/infer.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,12 @@ function mt:viewLiterals()
483483
or n.type == 'number'
484484
or n.type == 'integer'
485485
or n.type == 'boolean' then
486-
local literal = util.viewLiteral(n[1])
486+
local literal
487+
if n.type == 'string' then
488+
literal = util.viewString(n[1], n[2])
489+
else
490+
literal = util.viewLiteral(n[1])
491+
end
487492
if literal and not mark[literal] then
488493
literals[#literals+1] = literal
489494
mark[literal] = true

0 commit comments

Comments
 (0)