2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
|||||||
- name: Compile Needed Parsers
|
- name: Compile Needed Parsers
|
||||||
working-directory: ./neogen
|
working-directory: ./neogen
|
||||||
run: |
|
run: |
|
||||||
nvim -u tests/minimal_init.lua --headless -c "TSInstallSync python lua julia" -c "q"
|
nvim -u tests/minimal_init.lua --headless -c "TSInstallSync python lua julia java" -c "q"
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
working-directory: ./neogen
|
working-directory: ./neogen
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
local extractors = require("neogen.utilities.extractors")
|
local extractors = require("neogen.utilities.extractors")
|
||||||
local nodes_utils = require("neogen.utilities.nodes")
|
local nodes_utils = require("neogen.utilities.nodes")
|
||||||
local template = require("neogen.template")
|
local template = require("neogen.template")
|
||||||
|
local i = require("neogen.types.template").item
|
||||||
|
|
||||||
local function_tree = {
|
local function_tree = {
|
||||||
{
|
{
|
||||||
@@ -52,7 +53,7 @@ local function_tree = {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
parent = {
|
parent = {
|
||||||
class = { "class_declaration" },
|
class = { "class_declaration", "interface_declaration" },
|
||||||
func = { "method_declaration", "constructor_declaration" },
|
func = { "method_declaration", "constructor_declaration" },
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -103,8 +104,23 @@ return {
|
|||||||
local nodes = nodes_utils:matching_nodes_from(node, tree)
|
local nodes = nodes_utils:matching_nodes_from(node, tree)
|
||||||
local res = extractors:extract_from_matched(nodes)
|
local res = extractors:extract_from_matched(nodes)
|
||||||
|
|
||||||
results.class_name = res.identifier
|
return {
|
||||||
return results
|
[i.ClassName] = res.identifier
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
["interface_declaration"] = {
|
||||||
|
["0"] = {
|
||||||
|
extract = function(node)
|
||||||
|
local results = {}
|
||||||
|
local tree = { { retrieve = "all", node_type = "identifier", extract = true } }
|
||||||
|
local nodes = nodes_utils:matching_nodes_from(node, tree)
|
||||||
|
local res = extractors:extract_from_matched(nodes)
|
||||||
|
|
||||||
|
return {
|
||||||
|
[i.ClassName] = res.identifier
|
||||||
|
}
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ return {
|
|||||||
parent = {
|
parent = {
|
||||||
type = { "property_declaration", "const_declaration", "foreach_statement" },
|
type = { "property_declaration", "const_declaration", "foreach_statement" },
|
||||||
func = { "function_definition", "method_declaration" },
|
func = { "function_definition", "method_declaration" },
|
||||||
class = { "class_declaration" },
|
class = { "class_declaration", "interface_declaration" },
|
||||||
},
|
},
|
||||||
data = {
|
data = {
|
||||||
type = {
|
type = {
|
||||||
@@ -83,6 +83,13 @@ return {
|
|||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
["interface_declaration"] = {
|
||||||
|
["0"] = {
|
||||||
|
extract = function()
|
||||||
|
return {}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
template = template:add_default_annotation("phpdoc"),
|
template = template:add_default_annotation("phpdoc"),
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ end
|
|||||||
--- with multiple annotation conventions.
|
--- with multiple annotation conventions.
|
||||||
---@tag neogen-changelog
|
---@tag neogen-changelog
|
||||||
---@toc_entry Changes in neogen plugin
|
---@toc_entry Changes in neogen plugin
|
||||||
neogen.version = "2.19.2"
|
neogen.version = "2.19.3"
|
||||||
--minidoc_afterlines_end
|
--minidoc_afterlines_end
|
||||||
|
|
||||||
return neogen
|
return neogen
|
||||||
|
|||||||
@@ -21,13 +21,4 @@ require("plenary.busted")
|
|||||||
|
|
||||||
vim.cmd("runtime plugin/nvim-treesitter.lua")
|
vim.cmd("runtime plugin/nvim-treesitter.lua")
|
||||||
|
|
||||||
-- -- Some tests require the Python parser
|
|
||||||
-- -- vim.cmd([[TSInstallSync! python]])
|
|
||||||
-- require("nvim-treesitter.configs").setup({
|
|
||||||
-- ensured_installed = {
|
|
||||||
-- "python",
|
|
||||||
-- "lua"
|
|
||||||
-- }
|
|
||||||
-- })
|
|
||||||
|
|
||||||
require("neogen").setup({ snippet_engine = "nvim" })
|
require("neogen").setup({ snippet_engine = "nvim" })
|
||||||
|
|||||||
35
tests/neogen/java_javadoc_spec.lua
Normal file
35
tests/neogen/java_javadoc_spec.lua
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
--- Test cases for emmylua
|
||||||
|
---
|
||||||
|
--- @module 'tests.neogen.lua_spec'
|
||||||
|
|
||||||
|
local specs = require('tests.utils.specs')
|
||||||
|
|
||||||
|
local function make_emmylua(source, type)
|
||||||
|
return specs.make_docstring(source, 'java', { type = type, annotation_convention = { java = 'javadoc' } })
|
||||||
|
end
|
||||||
|
|
||||||
|
describe("java: javadoc", function()
|
||||||
|
describe("class", function()
|
||||||
|
it("works with an basic interface", function()
|
||||||
|
local source = [[
|
||||||
|
public interface Entity {
|
||||||
|
@NonNull UUID getId();|cursor|
|
||||||
|
}
|
||||||
|
]]
|
||||||
|
|
||||||
|
local expected = [[
|
||||||
|
/**
|
||||||
|
* [TODO:description]
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface Entity {
|
||||||
|
@NonNull UUID getId();
|
||||||
|
}
|
||||||
|
]]
|
||||||
|
|
||||||
|
local result = make_emmylua(source, "class")
|
||||||
|
|
||||||
|
assert.equal(expected, result)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
Reference in New Issue
Block a user