feat(java) Update configuration

This commit is contained in:
danymat
2022-01-10 20:08:28 +01:00
parent c372879758
commit 0cb45647db
2 changed files with 72 additions and 45 deletions

View File

@@ -193,7 +193,7 @@ There is a list of supported languages and fields, with their annotation style
| go | | | | | go | | | |
| | [Godoc](https://go.dev/blog/godoc) (`"godoc"`) | | | | [Godoc](https://go.dev/blog/godoc) (`"godoc"`) | |
| java | | | `func`, `class` | | java | | | `func`, `class` |
| | [Javadoc](https://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/javadoc.html#documentationcomments) (`"javadoc"`) | | | | [Javadoc](https://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/javadoc.html#documentationcomments) (`"javadoc"`) | `@param`, `@return`, `@throws`|
| rust | | | `func`, `file`, `class` | | rust | | | `func`, `file`, `class` |
| | [Rustdoc](https://doc.rust-lang.org/rustdoc/what-is-rustdoc.html) (`"rustdoc"`) | | | | [Rustdoc](https://doc.rust-lang.org/rustdoc/what-is-rustdoc.html) (`"rustdoc"`) | |
| | [Alternative](https://stackoverflow.com/questions/30009650/how-do-you-document-function-arguments) (`"alternative"`) | | | | [Alternative](https://stackoverflow.com/questions/30009650/how-do-you-document-function-arguments) (`"alternative"`) | |

View File

@@ -1,23 +1,4 @@
return { local function_tree = {
parent = {
class = { "class_declaration" },
func = { "method_declaration", "constructor_declaration" },
},
data = {
func = {
["constructor_declaration"] = {
["0"] = {
extract = function(_)
return { class_declaration = {} }
end,
},
},
["method_declaration"] = {
["0"] = {
extract = function(node)
local results = {}
local tree = {
{ {
retrieve = "first", retrieve = "first",
node_type = "formal_parameters", node_type = "formal_parameters",
@@ -31,11 +12,17 @@ return {
}, },
}, },
}, },
{
retrieve = "all",
node_type = "throws",
extract = true,
},
{ {
retrieve = "first", retrieve = "first",
node_type = "block", node_type = "block|constructor_body",
subtree = { subtree = {
{ retrieve = "first", node_type = "return_statement", extract = true }, { retrieve = "first", node_type = "return_statement", extract = true },
{ retrieve = "all", recursive = true, node_type = "throw_statement", extract = true },
{ {
retrieve = "first", retrieve = "first",
node_type = "try_statement", node_type = "try_statement",
@@ -57,10 +44,48 @@ return {
}, },
} }
return {
parent = {
class = { "class_declaration" },
func = { "method_declaration", "constructor_declaration" },
},
data = {
func = {
["constructor_declaration"] = {
["0"] = {
extract = function(node)
local results = {}
local tree = function_tree
local nodes = neogen.utilities.nodes:matching_nodes_from(node, tree)
local res = neogen.utilities.extractors:extract_from_matched(nodes)
if res.throws then
results.throw_statement = res.throws
else
results.throw_statement = res.throw_statement
end
results.parameters = res.identifier
return results
end,
},
},
["method_declaration"] = {
["0"] = {
extract = function(node)
local results = {}
local tree = function_tree
local nodes = neogen.utilities.nodes:matching_nodes_from(node, tree) local nodes = neogen.utilities.nodes:matching_nodes_from(node, tree)
local res = neogen.utilities.extractors:extract_from_matched(nodes) local res = neogen.utilities.extractors:extract_from_matched(nodes)
results.parameters = res.identifier results.parameters = res.identifier
if res.throws then
results.throw_statement = res.throws
else
results.throw_statement = res.throw_statement
end
results.return_statement = res.return_statement results.return_statement = res.return_statement
return results return results
end, end,
@@ -89,14 +114,16 @@ return {
use_default_comment = false, use_default_comment = false,
javadoc = { javadoc = {
{ nil, "/**", { no_results = true } }, { nil, "/**", { no_results = true, type = { "class", "func" } } },
{ nil, " * $1", { no_results = true } }, { nil, " * $1", { no_results = true, type = { "class", "func" } } },
{ nil, " */", { no_results = true } }, { nil, " */", { no_results = true, type = { "class", "func" } } },
{ nil, "/**" }, { nil, "/**" },
{ nil, " * $1" }, { nil, " * $1" },
{ nil, " *" },
{ "parameters", " * @param %s $1" }, { "parameters", " * @param %s $1" },
{ "return_statement", " * @return $1" }, { "return_statement", " * @return $1" },
{ "throw_statement", " * @throws $1" },
{ nil, " */" }, { nil, " */" },
}, },
}, },