From 668b3ad04d841eedad73000e431f1b5e1bdbed31 Mon Sep 17 00:00:00 2001 From: Daniel Mathiot Date: Thu, 5 May 2022 10:18:02 +0200 Subject: [PATCH] feat(java) Improve throws statements (#91) --- lua/neogen/configurations/java.lua | 10 ++++------ lua/neogen/templates/javadoc.lua | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lua/neogen/configurations/java.lua b/lua/neogen/configurations/java.lua index aa51680..f703bd7 100644 --- a/lua/neogen/configurations/java.lua +++ b/lua/neogen/configurations/java.lua @@ -19,7 +19,9 @@ local function_tree = { { retrieve = "all", node_type = "throws", - extract = true, + subtree = { + { retrieve = "all",node_type= "type_identifier", extract = true, as="throw_statement"} + } }, { retrieve = "first", @@ -65,11 +67,7 @@ return { local nodes = nodes_utils:matching_nodes_from(node, tree) local res = extractors:extract_from_matched(nodes) - if res.throws then - results.throw_statement = res.throws - else - results.throw_statement = res.throw_statement - end + results.throw_statement = res.throw_statement results.parameters = res.identifier return results end, diff --git a/lua/neogen/templates/javadoc.lua b/lua/neogen/templates/javadoc.lua index 65ad272..c97ee54 100644 --- a/lua/neogen/templates/javadoc.lua +++ b/lua/neogen/templates/javadoc.lua @@ -11,6 +11,6 @@ return { { i.Parameter, " * @param %s $1" }, { i.ClassAttribute, " * @property %s $1" }, { i.Return, " * @return $1" }, - { i.Throw, " * @throws $1" }, + { i.Throw, " * @throws %s $1" }, { nil, " */" }, }