Skip to content

Commit c95511b

Browse files
committed
rename: supports @field
1 parent bf65753 commit c95511b

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

changelog.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# changelog
22

33
## 3.6.5
4-
* `NEW` code lens. This feature is disabled by default.
4+
* `NEW` code lens: this feature is disabled by default.
55
* `NEW` settings:
66
* `Lua.codeLens.enable`: Enable code lens.
7-
* `CHG` supports finding definition for `@class` and `@alias`, since they may defined multi times.
7+
* `CHG` definition: supports finding definitions for `@class` and `@alias`, since they may be defined multi times.
8+
* `CHG` rename: supports `@field`
89
* `FIX` [#831]
910
* `FIX` [#1729]
1011
* `FIX` [#1737]

script/core/rename.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ local function ofFieldThen(key, src, newname, callback)
178178
if not suc then
179179
return
180180
end
181+
elseif src.type == 'doc.field' then
182+
local suc = renameField(src.field, newname, callback)
183+
if not suc then
184+
return
185+
end
181186
end
182187
end
183188

@@ -282,6 +287,8 @@ local function rename(source, newname, callback)
282287
return ofDocTypeName(source, newname, callback)
283288
elseif source.type == 'doc.param.name' then
284289
return ofDocParamName(source, newname, callback)
290+
elseif source.type == 'doc.field.name' then
291+
return ofField(source, newname, callback)
285292
elseif source.type == 'string'
286293
or source.type == 'number'
287294
or source.type == 'integer'
@@ -313,7 +320,8 @@ local function prepareRename(source)
313320
or source.type == 'doc.type.name'
314321
or source.type == 'doc.alias.name'
315322
or source.type == 'doc.enum.name'
316-
or source.type == 'doc.param.name' then
323+
or source.type == 'doc.param.name'
324+
or source.type == 'doc.field.name' then
317325
return source, source[1]
318326
elseif source.type == 'string'
319327
or source.type == 'number'
@@ -354,6 +362,7 @@ local accept = {
354362
['doc.alias.name'] = true,
355363
['doc.param.name'] = true,
356364
['doc.enum.name'] = true,
365+
['doc.field.name'] = true,
357366
}
358367

359368
local m = {}

test/rename/init.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,21 @@ function f(arg2)
212212
print(arg2)
213213
end
214214
]]
215+
216+
TEST ('field1', 'field2') [[
217+
---@class A
218+
---@field field1 number
219+
220+
---@type A
221+
local t
222+
223+
print(t.field1)
224+
]] [[
225+
---@class A
226+
---@field field2 number
227+
228+
---@type A
229+
local t
230+
231+
print(t.field2)
232+
]]

0 commit comments

Comments
 (0)