summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md5
-rw-r--r--script/core/rename.lua11
-rw-r--r--test/rename/init.lua18
3 files changed, 31 insertions, 3 deletions
diff --git a/changelog.md b/changelog.md
index 2ef507b1..e8667bf1 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,10 +1,11 @@
# changelog
## 3.6.5
-* `NEW` code lens. This feature is disabled by default.
+* `NEW` code lens: this feature is disabled by default.
* `NEW` settings:
* `Lua.codeLens.enable`: Enable code lens.
-* `CHG` supports finding definition for `@class` and `@alias`, since they may defined multi times.
+* `CHG` definition: supports finding definitions for `@class` and `@alias`, since they may be defined multi times.
+* `CHG` rename: supports `@field`
* `FIX` [#831]
* `FIX` [#1729]
* `FIX` [#1737]
diff --git a/script/core/rename.lua b/script/core/rename.lua
index 3d24b90c..98895826 100644
--- a/script/core/rename.lua
+++ b/script/core/rename.lua
@@ -178,6 +178,11 @@ local function ofFieldThen(key, src, newname, callback)
if not suc then
return
end
+ elseif src.type == 'doc.field' then
+ local suc = renameField(src.field, newname, callback)
+ if not suc then
+ return
+ end
end
end
@@ -282,6 +287,8 @@ local function rename(source, newname, callback)
return ofDocTypeName(source, newname, callback)
elseif source.type == 'doc.param.name' then
return ofDocParamName(source, newname, callback)
+ elseif source.type == 'doc.field.name' then
+ return ofField(source, newname, callback)
elseif source.type == 'string'
or source.type == 'number'
or source.type == 'integer'
@@ -313,7 +320,8 @@ local function prepareRename(source)
or source.type == 'doc.type.name'
or source.type == 'doc.alias.name'
or source.type == 'doc.enum.name'
- or source.type == 'doc.param.name' then
+ or source.type == 'doc.param.name'
+ or source.type == 'doc.field.name' then
return source, source[1]
elseif source.type == 'string'
or source.type == 'number'
@@ -354,6 +362,7 @@ local accept = {
['doc.alias.name'] = true,
['doc.param.name'] = true,
['doc.enum.name'] = true,
+ ['doc.field.name'] = true,
}
local m = {}
diff --git a/test/rename/init.lua b/test/rename/init.lua
index d4252d1e..3dfc19e6 100644
--- a/test/rename/init.lua
+++ b/test/rename/init.lua
@@ -212,3 +212,21 @@ function f(arg2)
print(arg2)
end
]]
+
+TEST ('field1', 'field2') [[
+---@class A
+---@field field1 number
+
+---@type A
+local t
+
+print(t.field1)
+]] [[
+---@class A
+---@field field2 number
+
+---@type A
+local t
+
+print(t.field2)
+]]