File tree 5 files changed +72
-7
lines changed
5 files changed +72
-7
lines changed Original file line number Diff line number Diff line change 5
5
* ` FIX ` [ #2042 ]
6
6
* ` FIX ` [ #2062 ]
7
7
* ` FIX ` [ #2083 ]
8
+ * ` FIX ` [ #2088 ]
8
9
9
10
[ #2038 ] : https://github.com/LuaLS/lua-language-server/issues/2038
10
11
[ #2042 ] : https://github.com/LuaLS/lua-language-server/issues/2042
11
12
[ #2062 ] : https://github.com/LuaLS/lua-language-server/issues/2062
12
13
[ #2083 ] : https://github.com/LuaLS/lua-language-server/issues/2083
14
+ [ #2088 ] : https://github.com/LuaLS/lua-language-server/issues/2088
13
15
14
16
## 3.6.21
15
17
` 2023-5-24 `
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ local function asField(source)
134
134
end
135
135
136
136
local function asDocFieldName (source )
137
- local name = source . field [ 1 ]
137
+ local name = vm . viewKey ( source , guide . getUri ( source )) or ' ? '
138
138
local class
139
139
for _ , doc in ipairs (source .bindGroup ) do
140
140
if doc .type == ' doc.class' then
@@ -143,10 +143,12 @@ local function asDocFieldName(source)
143
143
end
144
144
end
145
145
local view = vm .getInfer (source .extends ):view (guide .getUri (source ))
146
- if not class then
147
- return (' (field) ?.%s: %s' ):format (name , view )
146
+ local className = class and class .class [1 ] or ' ?'
147
+ if name :match (guide .namePatternFull ) then
148
+ return (' (field) %s.%s: %s' ):format (className , name , view )
149
+ else
150
+ return (' (field) %s%s: %s' ):format (className , name , view )
148
151
end
149
- return (' (field) %s.%s: %s' ):format (class .class [1 ], name , view )
150
152
end
151
153
152
154
local function asString (source )
Original file line number Diff line number Diff line change @@ -565,11 +565,12 @@ function vm.viewKey(source, uri)
565
565
return vm .viewKey (source .types [1 ], uri )
566
566
else
567
567
local key = vm .getInfer (source ):view (uri )
568
- return ' [' .. key .. ' ]'
568
+ return ' [' .. key .. ' ]' , key
569
569
end
570
570
end
571
571
if source .type == ' tableindex'
572
- or source .type == ' setindex' then
572
+ or source .type == ' setindex'
573
+ or source .type == ' getindex' then
573
574
local index = source .index
574
575
local name = vm .getInfer (index ):viewLiterals ()
575
576
if not name then
@@ -587,7 +588,11 @@ function vm.viewKey(source, uri)
587
588
return vm .viewKey (source .name , uri )
588
589
end
589
590
if source .type == ' doc.type.name' then
590
- return ' [' .. source [1 ] .. ' ]'
591
+ return ' [' .. source [1 ] .. ' ]' , source [1 ]
592
+ end
593
+ if source .type == ' doc.type.string' then
594
+ local name = util .viewString (source [1 ], source [2 ])
595
+ return (' [%s]' ):format (name ), name
591
596
end
592
597
local key = vm .getKeyName (source )
593
598
if key == nil then
Original file line number Diff line number Diff line change @@ -4184,3 +4184,46 @@ end
4184
4184
}
4185
4185
},
4186
4186
}
4187
+
4188
+ Cared [' description' ] = true
4189
+ TEST [[
4190
+ ---@class Foo
4191
+ ---@field ['with quotes'] integer
4192
+ ---@field without_quotes integer
4193
+
4194
+ ---@type Foo
4195
+ local bar = {}
4196
+
4197
+ bar.<??>
4198
+ ]]
4199
+ {
4200
+ {
4201
+ label = " 'with quotes'" ,
4202
+ kind = define .CompletionItemKind .Field ,
4203
+ textEdit = {
4204
+ start = 70004 ,
4205
+ finish = 70004 ,
4206
+ newText = " ['with quotes']"
4207
+ },
4208
+ additionalTextEdits = {
4209
+ {
4210
+ start = 70003 ,
4211
+ finish = 70004 ,
4212
+ newText = ' ' ,
4213
+ }
4214
+ },
4215
+ description = [[
4216
+ ```lua
4217
+ (field) Foo['with quotes']: integer
4218
+ ```]]
4219
+ },
4220
+ {
4221
+ label = ' without_quotes' ,
4222
+ kind = define .CompletionItemKind .Field ,
4223
+ description = [[
4224
+ ```lua
4225
+ (field) Foo.without_quotes: integer
4226
+ ```]]
4227
+ },
4228
+ }
4229
+ Cared [' description' ] = false
Original file line number Diff line number Diff line change @@ -1795,3 +1795,16 @@ local x: integer = 1
1795
1795
1796
1796
comment1]]
1797
1797
}
1798
+
1799
+ TEST { {path = ' a.lua' , content = [[
1800
+ local t = {}
1801
+
1802
+ print(<?t?>['a b'])
1803
+ ]] },
1804
+ hover = [[
1805
+ ```lua
1806
+ local t: {
1807
+ ['a b']: unknown,
1808
+ }
1809
+ ```]]
1810
+ }
You can’t perform that action at this time.
0 commit comments