1+ local parser = require (" clapi.parser.init" )
2+ local t = require (" plenary.async.tests" )
3+
4+ t .describe (" parser.parse_file with recursive inheritance" , function ()
5+ t .it (" should handle recursive inheritance without infinite loops" , function ()
6+ local src_root_dir = vim .fn .getcwd () .. " /tests/clapi/functional/resources/code/php/example/src"
7+ local filename = src_root_dir .. " /Course/Recursive.php"
8+ vim .cmd (" edit " .. filename )
9+ local bufnr = vim .api .nvim_get_current_buf ()
10+ local client_id = vim .lsp .start ({
11+ name = " phpactor" ,
12+ cmd = { " phpactor" , " language-server" , " -vvv" },
13+ root_dir = src_root_dir ,
14+ capabilities = vim .lsp .protocol .make_client_capabilities (),
15+ })
16+ vim .lsp .buf_attach_client (bufnr , client_id )
17+ vim .wait (3000 )
18+
19+ local result = parser .parse_file ({
20+ bufnr = bufnr ,
21+ show_inherited = true ,
22+ })
23+
24+ -- Test that we get results without hanging due to recursion
25+ assert .is_table (result )
26+
27+ -- Verify the expected methods are found
28+ local found_get_subscribed_services = false
29+ local found_get_view_handler = false
30+
31+ for _ , item in ipairs (result ) do
32+ if item .text == " [Function] getSubscribedServices" or
33+ item .text == " [Function] BaseAbstractFOSRestController::getSubscribedServices" then
34+ found_get_subscribed_services = true
35+ end
36+ if item .text == " [Function] getViewHandler" or
37+ item .text == " [Function] AbstractFOSRestController::getViewHandler" then
38+ found_get_view_handler = true
39+ end
40+ end
41+
42+ assert .is_true (found_get_subscribed_services , " Should find getSubscribedServices method" )
43+ assert .is_true (found_get_view_handler , " Should find getViewHandler method" )
44+ end )
45+ end )
0 commit comments