File tree 3 files changed +9
-3
lines changed
3 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ lsp = [
50
50
lua = [
51
51
" dep:mlua" ,
52
52
" dep:mlua-tree-sitter" ,
53
+ " lsp-positions/lua" ,
54
+ " lsp-positions/tree-sitter" ,
53
55
" stack-graphs/lua" ,
54
56
]
55
57
Original file line number Diff line number Diff line change 9
9
10
10
use std:: borrow:: Cow ;
11
11
12
+ use lsp_positions:: lua:: Module as _;
12
13
use mlua:: Lua ;
13
- use mlua_tree_sitter:: Module ;
14
+ use mlua_tree_sitter:: Module as _ ;
14
15
use mlua_tree_sitter:: WithSource ;
15
16
use stack_graphs:: arena:: Handle ;
16
17
use stack_graphs:: graph:: File ;
@@ -82,6 +83,7 @@ impl StackGraphLanguageLua {
82
83
// Create a Lua environment and load the language's stack graph rules.
83
84
// TODO: Sandbox the Lua environment
84
85
let lua = Lua :: new ( ) ;
86
+ lua. open_lsp_positions ( ) ?;
85
87
lua. open_ltreesitter ( ) ?;
86
88
lua. load ( self . lua_source . as_ref ( ) )
87
89
. set_name ( & self . lua_source_name )
Original file line number Diff line number Diff line change @@ -31,8 +31,10 @@ impl CheckLua for mlua::Lua {
31
31
fn can_build_stack_graph_from_lua ( ) -> Result < ( ) , anyhow:: Error > {
32
32
const LUA : & [ u8 ] = br#"
33
33
function process(parsed, file)
34
- -- TODO: fill in the definiens span from the parse tree root
34
+ local sc = lsp_positions.SpanCalculator.new_from_tree(parsed)
35
+ local module_ast = parsed:root()
35
36
local module = file:internal_scope_node()
37
+ module:set_definiens_span(sc:for_node(module_ast))
36
38
module:add_edge_from(file:root_node())
37
39
end
38
40
"# ;
@@ -54,7 +56,7 @@ fn can_build_stack_graph_from_lua() -> Result<(), anyhow::Error> {
54
56
local graph = ...
55
57
local file = graph:file("test.py")
56
58
assert_deepeq("nodes", {
57
- "[test.py(0) scope]",
59
+ "[test.py(0) scope def 1:6-3:4 ]",
58
60
}, iter_tostring(file:nodes()))
59
61
"# ,
60
62
) ?;
You can’t perform that action at this time.
0 commit comments