feat(java) Update configuration
This commit is contained in:
@@ -193,7 +193,7 @@ There is a list of supported languages and fields, with their annotation style
|
||||
| go | | | |
|
||||
| | [Godoc](https://go.dev/blog/godoc) (`"godoc"`) | |
|
||||
| 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` |
|
||||
| | [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"`) | |
|
||||
|
||||
@@ -1,3 +1,49 @@
|
||||
local function_tree = {
|
||||
{
|
||||
retrieve = "first",
|
||||
node_type = "formal_parameters",
|
||||
subtree = {
|
||||
{
|
||||
retrieve = "all",
|
||||
node_type = "formal_parameter",
|
||||
subtree = {
|
||||
{ retrieve = "all", node_type = "identifier", extract = true },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
retrieve = "all",
|
||||
node_type = "throws",
|
||||
extract = true,
|
||||
},
|
||||
{
|
||||
retrieve = "first",
|
||||
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 = "first",
|
||||
node_type = "try_statement",
|
||||
subtree = {
|
||||
{
|
||||
retrieve = "first",
|
||||
node_type = "block",
|
||||
subtree = {
|
||||
{
|
||||
retrieve = "first",
|
||||
node_type = "return_statement",
|
||||
extract = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return {
|
||||
parent = {
|
||||
class = { "class_declaration" },
|
||||
@@ -8,8 +54,20 @@ return {
|
||||
func = {
|
||||
["constructor_declaration"] = {
|
||||
["0"] = {
|
||||
extract = function(_)
|
||||
return { class_declaration = {} }
|
||||
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,
|
||||
},
|
||||
},
|
||||
@@ -17,50 +75,17 @@ return {
|
||||
["0"] = {
|
||||
extract = function(node)
|
||||
local results = {}
|
||||
local tree = {
|
||||
{
|
||||
retrieve = "first",
|
||||
node_type = "formal_parameters",
|
||||
subtree = {
|
||||
{
|
||||
retrieve = "all",
|
||||
node_type = "formal_parameter",
|
||||
subtree = {
|
||||
{ retrieve = "all", node_type = "identifier", extract = true },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
retrieve = "first",
|
||||
node_type = "block",
|
||||
subtree = {
|
||||
{ retrieve = "first", node_type = "return_statement", extract = true },
|
||||
{
|
||||
retrieve = "first",
|
||||
node_type = "try_statement",
|
||||
subtree = {
|
||||
{
|
||||
retrieve = "first",
|
||||
node_type = "block",
|
||||
subtree = {
|
||||
{
|
||||
retrieve = "first",
|
||||
node_type = "return_statement",
|
||||
extract = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
local tree = function_tree
|
||||
|
||||
local nodes = neogen.utilities.nodes:matching_nodes_from(node, tree)
|
||||
local res = neogen.utilities.extractors:extract_from_matched(nodes)
|
||||
|
||||
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
|
||||
return results
|
||||
end,
|
||||
@@ -89,14 +114,16 @@ return {
|
||||
use_default_comment = false,
|
||||
|
||||
javadoc = {
|
||||
{ nil, "/**", { no_results = true } },
|
||||
{ nil, " * $1", { no_results = true } },
|
||||
{ nil, " */", { no_results = true } },
|
||||
{ nil, "/**", { no_results = true, type = { "class", "func" } } },
|
||||
{ nil, " * $1", { no_results = true, type = { "class", "func" } } },
|
||||
{ nil, " */", { no_results = true, type = { "class", "func" } } },
|
||||
|
||||
{ nil, "/**" },
|
||||
{ nil, " * $1" },
|
||||
{ nil, " *" },
|
||||
{ "parameters", " * @param %s $1" },
|
||||
{ "return_statement", " * @return $1" },
|
||||
{ "throw_statement", " * @throws $1" },
|
||||
{ nil, " */" },
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user