diff options
-rw-r--r-- | script/core/diagnostics/duplicate-doc-field.lua | 5 | ||||
-rw-r--r-- | script/core/noder.lua | 2 | ||||
-rw-r--r-- | test/diagnostics/init.lua | 17 |
3 files changed, 24 insertions, 0 deletions
diff --git a/script/core/diagnostics/duplicate-doc-field.lua b/script/core/diagnostics/duplicate-doc-field.lua index 1ee27ff2..ab3084c9 100644 --- a/script/core/diagnostics/duplicate-doc-field.lua +++ b/script/core/diagnostics/duplicate-doc-field.lua @@ -1,5 +1,6 @@ local files = require 'files' local lang = require 'language' +local noder = require 'core.noder' return function (uri, callback) local state = files.getState(uri) @@ -19,6 +20,10 @@ return function (uri, callback) elseif doc.type == 'doc.field' then if mark then local name = doc.field[1] + local eventName = noder.getFieldEventName(doc) + if eventName then + name = name .. '|' .. eventName + end if mark[name] then callback { start = doc.field.start, diff --git a/script/core/noder.lua b/script/core/noder.lua index 030c69cf..66f88e34 100644 --- a/script/core/noder.lua +++ b/script/core/noder.lua @@ -1638,6 +1638,8 @@ function m.eachID(noders) return next, noders.source end +m.getFieldEventName = getFieldEventName + ---获取对象的noders ---@param source parser.guide.object ---@return noders diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua index bb613112..574d93f9 100644 --- a/test/diagnostics/init.lua +++ b/test/diagnostics/init.lua @@ -1135,6 +1135,23 @@ return { } ]] +TEST [[ +--- @class Emit +--- @field on fun(eventName: string, cb: function) +--- @field on fun(eventName: '"died"', cb: fun(i: integer)) +--- @field on fun(eventName: '"won"', cb: fun(s: string)) +local emit = {} +]] + +TEST [[ +--- @class Emit +--- @field on fun(eventName: string, cb: function) +--- @field on fun(eventName: '"died"', cb: fun(i: integer)) +--- @field on fun(eventName: '"won"', cb: fun(s: string)) +--- @field <!on!> fun(eventName: '"died"', cb: fun(i: integer)) +local emit = {} +]] + -- TODO do return end |