fix: support interfaces in Java and PHP (#183)

Closes #182
This commit is contained in:
Michael Härtl
2024-08-02 16:37:02 +02:00
committed by GitHub
parent f027ac49f6
commit 88698b12c3
6 changed files with 65 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
local extractors = require("neogen.utilities.extractors")
local nodes_utils = require("neogen.utilities.nodes")
local template = require("neogen.template")
local i = require("neogen.types.template").item
local function_tree = {
{
@@ -28,7 +29,7 @@ local function_tree = {
node_type = "block|constructor_body",
subtree = {
{ retrieve = "first", node_type = "return_statement", extract = true },
{ retrieve = "all", recursive = true, node_type = "throw_statement", extract = true },
{ retrieve = "all", recursive = true, node_type = "throw_statement", extract = true },
{
retrieve = "first",
node_type = "try_statement",
@@ -52,7 +53,7 @@ local function_tree = {
return {
parent = {
class = { "class_declaration" },
class = { "class_declaration", "interface_declaration" },
func = { "method_declaration", "constructor_declaration" },
},
@@ -103,8 +104,23 @@ return {
local nodes = nodes_utils:matching_nodes_from(node, tree)
local res = extractors:extract_from_matched(nodes)
results.class_name = res.identifier
return results
return {
[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,
},
},

View File

@@ -7,7 +7,7 @@ return {
parent = {
type = { "property_declaration", "const_declaration", "foreach_statement" },
func = { "function_definition", "method_declaration" },
class = { "class_declaration" },
class = { "class_declaration", "interface_declaration" },
},
data = {
type = {
@@ -83,6 +83,13 @@ return {
end,
},
},
["interface_declaration"] = {
["0"] = {
extract = function()
return {}
end,
},
},
},
},
template = template:add_default_annotation("phpdoc"),

View File

@@ -309,7 +309,7 @@ end
--- with multiple annotation conventions.
---@tag neogen-changelog
---@toc_entry Changes in neogen plugin
neogen.version = "2.19.2"
neogen.version = "2.19.3"
--minidoc_afterlines_end
return neogen