diff options
Diffstat (limited to 'script-beta/core/diagnostics')
-rw-r--r-- | script-beta/core/diagnostics/lowercase-global.lua | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/script-beta/core/diagnostics/lowercase-global.lua b/script-beta/core/diagnostics/lowercase-global.lua index bc48e1e6..c7e459cc 100644 --- a/script-beta/core/diagnostics/lowercase-global.lua +++ b/script-beta/core/diagnostics/lowercase-global.lua @@ -4,6 +4,18 @@ local lang = require 'language' local config = require 'config' local library = require 'library' +local function isDocClass(source) + if not source.bindDocs then + return false + end + for _, doc in ipairs(source.bindDocs) do + if doc.type == 'doc.class' then + return true + end + end + return false +end + -- 不允许定义首字母小写的全局变量(很可能是拼错或者漏删) return function (uri, callback) local ast = files.getAst(uri) @@ -28,12 +40,17 @@ return function (uri, callback) if not first then return end - if first:match '%l' then - callback { - start = source.start, - finish = source.finish, - message = lang.script.DIAG_LOWERCASE_GLOBAL, - } + if not first:match '%l' then + return + end + -- 如果赋值被标记为 doc.class ,则认为是允许的 + if isDocClass(source) then + return end + callback { + start = source.start, + finish = source.finish, + message = lang.script.DIAG_LOWERCASE_GLOBAL, + } end) end |