Lua Inspect |
|
Inspect 是一款用于 Lua 代码分析的工具。分析结果也可以渲染成 HTML 格式。该工具还包含一个 SciTE 文本编辑器的插件,用于实时源代码分析、智能高亮和重构。代码处于工作状态,但仍处于初步阶段。
该工具通过静态和动态分析来运作,使用通过 MetaLua(纯 Lua 部分)转换的 AST。
lua luainspectlib/luainspect/command.lua examples.lua > test-output/examples.html
* analysis:
* identifies global (red) and local variables (blue), including locals that are
function arguments (dark blue) and upvalues (light blue)
* identifies unused local variables: e.g. `do local x=1 end` (white-on-blue)
* identifies local variables masking other locals (same name): e.g. `local x=1; local x=2`
(strikethrough and squiggle line)
* identifies local variables that have non-constant binding (`local x = 1; x = 2`) (italic)
* identifies unknown global variables (white-on-red) and table fields (red), inferred by
static and dynamic evaluation.
* infers values of variables (e.g. `local sum = math.pi + 2` is 5.14.
and defined-ness of members of imported modules
(`local mt = require "math"; math.sqrtt(2) -- undefined`)
* infers signatures of functions (including local, global, and module functions)
* checks number of function arguments against signatures (SciTE only)
* cross-references variables (locals and module fields) with their definitions and uses
(pink highlight), identifies range of lines/scope where the local is defined
(currently SciTE only), and supports jump-to-definition and jump-to-uses (SciTE only)
* identifies all keywords in selected block (underline)
* evaluate special comments (prefixed by '!') to inject semantic information into analysis
(similar to luaanalyze / lint).
* refactoring:
* command to rename all occurrences of selected variable (SciTE only)
* browsing:
* inspect members of selected table.
* select statement or comment containing current cursor selection (SciTE only)
* display real-time annotations of all local variables, like an Excel/Mathcad worksheet
(experimental feature via ANNOTATE_ALL_LOCALS) (currently SciTE only)
* auto-complete typing support (SciTE only) (experimental)
* interfaces: SciTE plugin, VIM plugin, and HTML output.
未实现的功能(但可能应该实现)
local x = "foo"; math.sqrt(x)
Doc 注释一致性。
.rockspec 文件、README、COPYRIGHT、库命名约定等。
math.sqrt(2) 的内容时,在输入最终的 (2) 使其成为有效语句之前,会显示错误,并且缺乏语法高亮。
math.sqrt(2) --> local math_sqrt = math.sqrt ..... math_sqrt(2))等
最新版本可在 [github] 上获取。
注意:捆绑了 SciteExtMan 的修补版本(SciteExtMan 上的旧版本 2006-11-10 将无法完全工作)。
已在 SciTE 版本 2.12(较旧的版本可能无法工作)和 SciteExtMan(截至 2010-07-20)上测试。来自完整 SciteExtMan 的 ctagsdx.lua 是可选的(允许“转到标记”命令在“转到定义”后返回到先前的位置)。
这可以在 lua-users wiki 和 [snippets.luacode.org] 上用于显示 Lua 代码。
Inspect 在 Vim 中对 Lua 执行语义突出显示
Inspect。
Inspect 的 Lua IDE [屏幕截图]
Brains IntelliJ IDEA 的 Lua [1]