luatree is a Lua package for code analysis and inspection.
The goal of this package is to provide tools for analysis of syntax trees generated by luametrics and function call graphs generated by luadb module.
Some of the functions require usage of newer version of luametrics which is not available from LuaDist.
luatree is distributed as a standalone luadist package.
git clone https://github.com/scholtzm/luatree.git/path/to/luadist /path/to/install/dir make luatree
You can also manually copy the luatree folder from the src subfolder
into your lib/lua folder.
Using luatree is pretty simple ...
local luatree = require("luatree")
local tree_a = luatree.ast.tree.get_tree("local a")
local tree_b = luatree.ast.tree.get_tree("local b")
luatree.ast.tree.compare(tree_a, tree_b)
local changed_nodes = luatree.utils.get_tree_flag_count(tree_b, "modified")
print("A total of " .. changed_nodes .. " have changed in tree_b.")Check different submodules to see what functions they export. Do not forget to read the comments.
luatree tests use busted library for their core functionality. Once you have busted and luatree installed, simply run the following command:
$ bustedMIT. See LICENSE.