2022-07-03 11:29:00 +00:00
|
|
|
local busted = require('plenary/busted')
|
|
|
|
|
|
|
|
local eq = assert.are.same
|
|
|
|
local cur_dir = vim.fn.expand('%:p:h')
|
|
|
|
-- local status = require("plenary.reload").reload_module("go.nvim")
|
|
|
|
-- status = require("plenary.reload").reload_module("nvim-treesitter")
|
|
|
|
|
|
|
|
-- local ulog = require('go.utils').log
|
|
|
|
describe('should run lsp call hierarchy', function()
|
|
|
|
vim.cmd([[packadd navigator.lua]])
|
|
|
|
vim.cmd([[packadd guihua.lua]])
|
2022-07-03 12:19:17 +00:00
|
|
|
local status = require('plenary.reload').reload_module('navigator')
|
|
|
|
status = require('plenary.reload').reload_module('guihua')
|
|
|
|
status = require('plenary.reload').reload_module('lspconfig')
|
|
|
|
|
2022-07-03 11:29:00 +00:00
|
|
|
local path = cur_dir .. '/tests/fixtures/interface.go' -- %:p:h ? %:p
|
|
|
|
local cmd = " silent exe 'e " .. path .. "'"
|
|
|
|
vim.cmd(cmd)
|
|
|
|
vim.cmd([[cd %:p:h]])
|
|
|
|
local bufn = vim.fn.bufnr('')
|
|
|
|
require('navigator').setup({
|
|
|
|
debug = true, -- log output, set to true and log path: ~/.local/share/nvim/gh.log
|
|
|
|
width = 0.75, -- max width ratio (number of cols for the floating window) / (window width)
|
|
|
|
height = 0.3, -- max list window height, 0.3 by default
|
|
|
|
preview_height = 0.35, -- max height of preview windows
|
|
|
|
border = 'none',
|
|
|
|
})
|
|
|
|
|
|
|
|
-- allow gopls start
|
|
|
|
for _ = 1, 20 do
|
|
|
|
vim.wait(400, function() end)
|
|
|
|
local found = false
|
|
|
|
for _, client in ipairs(vim.lsp.get_active_clients()) do
|
|
|
|
if client.name == 'gopls' then
|
|
|
|
found = true
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if found then
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it('should show panel', function()
|
|
|
|
vim.fn.setpos('.', { bufn, 24, 15, 0 })
|
|
|
|
require('navigator.hierarchy').incoming_calls_panel()
|
|
|
|
|
2022-07-03 12:19:17 +00:00
|
|
|
vim.wait(300, function() end)
|
|
|
|
|
2022-07-03 11:29:00 +00:00
|
|
|
local panel = require('guihua.panel').debug()
|
|
|
|
eq(panel.name, 'Panel')
|
|
|
|
|
2022-07-03 12:19:17 +00:00
|
|
|
vim.wait(500, function() end)
|
2022-07-03 11:29:00 +00:00
|
|
|
panel = require('guihua.panel').debug()
|
2022-07-03 12:19:17 +00:00
|
|
|
print(vim.inspect(panel))
|
|
|
|
-- eq(
|
|
|
|
-- panel.activePanel.sections[1].header[1],
|
|
|
|
-- '──────────Call Hierarchy──────────'
|
|
|
|
-- )
|
|
|
|
-- eq(panel.activePanel.sections[1].nodes[1].name, 'measure')
|
2022-07-03 11:29:00 +00:00
|
|
|
end)
|
|
|
|
|
2022-07-16 23:26:26 +00:00
|
|
|
it('should not crash and show hierarchy', function()
|
2022-07-03 11:29:00 +00:00
|
|
|
vim.fn.setpos('.', { bufn, 24, 15, 0 })
|
2022-07-03 12:19:17 +00:00
|
|
|
local ret = require('navigator.hierarchy')._call_hierarchy()
|
2022-07-03 11:29:00 +00:00
|
|
|
vim.wait(400, function() end)
|
2022-07-16 23:26:26 +00:00
|
|
|
eq(ret, ret) -- make sure doesn't crash the result
|
2022-07-03 11:29:00 +00:00
|
|
|
end)
|
|
|
|
end)
|