diff options
| author | ruki <[email protected]> | 2023-02-01 22:55:34 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-02-01 22:55:34 +0800 |
| commit | d2f69f28647643f501628a793fbc8d8a83728b84 (patch) | |
| tree | bb8d2458df429186438ceff76fad72530f8db035 /xmake/plugins/check/checkers/api/api_checker.lua | |
| parent | a4325b99fd3c359c213818f17509c5b3d3aaceb2 (diff) | |
improve to show tips
Diffstat (limited to 'xmake/plugins/check/checkers/api/api_checker.lua')
| -rw-r--r-- | xmake/plugins/check/checkers/api/api_checker.lua | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/xmake/plugins/check/checkers/api/api_checker.lua b/xmake/plugins/check/checkers/api/api_checker.lua index 934f27c1a..6fc9c1cae 100644 --- a/xmake/plugins/check/checkers/api/api_checker.lua +++ b/xmake/plugins/check/checkers/api/api_checker.lua @@ -34,6 +34,16 @@ function _show(apiname, value, target, opt) return end + -- get source information + local sourceinfo = (target:get("__sourceinfo_" .. apiname) or {})[value] or {} + local sourcetips = sourceinfo.file or "" + if sourceinfo.line then + sourcetips = sourcetips .. ":" .. sourceinfo.line .. ": " + end + if #sourcetips == 0 then + sourcetips = string.format("target(%s)", target:name()) + end + -- do show local level_tips = "note" if level == "warning" then @@ -41,7 +51,16 @@ function _show(apiname, value, target, opt) elseif level == "error" then level_tips = "${color.error}${text.error}${clear}" end - cprint("%s: unknown %s value(%s) in target(%s)!", level_tips, apiname, value, target:name()) + if apiname:endswith("s") then + apiname = apiname:sub(1, #apiname - 1) + end + _g.showed = _g.showed or {} + local showed = _g.showed + local infostr = string.format("%s%s: unknown %s value '%s'", sourcetips, level_tips, apiname, value) + if not showed[infostr] then + cprint(infostr) + showed[infostr] = true + end end -- check api configuration in targets |
