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 使用者 wiki 和 [snippets.luacode.org] 來顯示 Lua 程式碼。
Inspect 在 Vim 中為 Lua 執行語意重點顯示
Inspect。
Inspect 的 Lua IDE [螢幕錄影畫面]
Brains IntelliJ IDEA 的 Lua [1]