Skip to content

Commit a01ab28

Browse files
committed
fix renaming
1 parent 116e22a commit a01ab28

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

script/core/rename.lua

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ local function ofDocTypeName(source, newname, callback)
239239
end
240240
local refs = vm.getRefs(source)
241241
for _, doc in ipairs(refs) do
242-
if doc.type == 'doc.type.name' then
242+
if doc.type == 'doc.type.name'
243+
or doc.type == 'doc.extends.name' then
243244
callback(doc, doc.start, doc.finish, newname)
244245
end
245246
end
@@ -283,7 +284,8 @@ local function rename(source, newname, callback)
283284
elseif source.type == 'doc.class.name'
284285
or source.type == 'doc.type.name'
285286
or source.type == 'doc.alias.name'
286-
or source.type == 'doc.enum.name' then
287+
or source.type == 'doc.enum.name'
288+
or source.type == 'doc.extends.name' then
287289
return ofDocTypeName(source, newname, callback)
288290
elseif source.type == 'doc.param.name' then
289291
return ofDocParamName(source, newname, callback)
@@ -321,7 +323,8 @@ local function prepareRename(source)
321323
or source.type == 'doc.alias.name'
322324
or source.type == 'doc.enum.name'
323325
or source.type == 'doc.param.name'
324-
or source.type == 'doc.field.name' then
326+
or source.type == 'doc.field.name'
327+
or source.type == 'doc.extends.name' then
325328
return source, source[1]
326329
elseif source.type == 'string'
327330
or source.type == 'number'
@@ -357,12 +360,13 @@ local accept = {
357360
['number'] = true,
358361
['integer'] = true,
359362

360-
['doc.class.name'] = true,
361-
['doc.type.name'] = true,
362-
['doc.alias.name'] = true,
363-
['doc.param.name'] = true,
364-
['doc.enum.name'] = true,
365-
['doc.field.name'] = true,
363+
['doc.class.name'] = true,
364+
['doc.type.name'] = true,
365+
['doc.alias.name'] = true,
366+
['doc.param.name'] = true,
367+
['doc.enum.name'] = true,
368+
['doc.field.name'] = true,
369+
['doc.extends.name'] = true,
366370
}
367371

368372
local m = {}

script/parser/guide.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,8 @@ function m.getKeyName(obj)
10131013
or tp == 'doc.type.name'
10141014
or tp == 'doc.class.name'
10151015
or tp == 'doc.alias.name'
1016-
or tp == 'doc.enum.name' then
1016+
or tp == 'doc.enum.name'
1017+
or tp == 'doc.extends.name' then
10171018
return obj[1]
10181019
elseif tp == 'doc.type.field' then
10191020
return m.getKeyName(obj.name)

test/rename/init.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,19 @@ local t
230230
231231
print(t.field2)
232232
]]
233+
234+
TEST ('A', 'C') [[
235+
---@class A
236+
237+
---@class B: A
238+
]] [[
239+
---@class C
240+
241+
---@class B: C
242+
]]
243+
244+
TEST ('A', 'C') [[
245+
---@class B: A
246+
]] [[
247+
---@class B: C
248+
]]

0 commit comments

Comments
 (0)