From 9c7ff6f05360f0bfc8bd992eeab23aa6a1095c85 Mon Sep 17 00:00:00 2001 From: Florin Pop Date: Mon, 27 May 2013 19:37:42 +0200 Subject: [PATCH] Output Objective-C parameter names where $(javaparam) is used in a comment block. --- src/output.cpp | 63 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/src/output.cpp b/src/output.cpp index d4c4181ee0..0fc2b72ac8 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -667,16 +667,52 @@ static void add_comment_javaparam(chunk_t *pc, cmt_reflow& cmt) bool has_param = true; bool need_nl = false; - fpo = chunk_get_next_type(pc, CT_FPAREN_OPEN, pc->level); - if (fpo == NULL) - { - return; - } - fpc = chunk_get_next_type(fpo, CT_FPAREN_CLOSE, pc->level); - if (fpc == NULL) - { - return; - } + if (pc->type == CT_OC_MSG_DECL) + { + chunk_t *tmp = chunk_get_next_ncnl(pc); + has_param = false; + while (tmp) + { + if ((tmp->type == CT_BRACE_OPEN) || (tmp->type == CT_SEMICOLON)) + { + break; + } + + if (has_param) + { + if (need_nl) + { + add_comment_text("\n", cmt, false); + } + need_nl = true; + add_text("@param"); + add_text(" "); + add_text(tmp->str); + add_text(" TODO"); + } + + has_param = false; + if (tmp->type == CT_PAREN_CLOSE) + { + has_param = true; + } + tmp = chunk_get_next_ncnl(tmp); + } + fpo = fpc = NULL; + } + else + { + fpo = chunk_get_next_type(pc, CT_FPAREN_OPEN, pc->level); + if (fpo == NULL) + { + return; + } + fpc = chunk_get_next_type(fpo, CT_FPAREN_CLOSE, pc->level); + if (fpc == NULL) + { + return; + } + } /* Check for 'foo()' and 'foo(void)' */ if (chunk_get_next_ncnl(fpo) == fpc) @@ -728,11 +764,16 @@ static void add_comment_javaparam(chunk_t *pc, cmt_reflow& cmt) /* Do the return stuff */ tmp = chunk_get_prev_ncnl(pc); + /* For Objective-C we need to go to the previous chunk */ + if (tmp->parent_type == CT_OC_MSG_DECL && tmp->type == CT_PAREN_CLOSE) + { + tmp = chunk_get_prev_ncnl(tmp); + } if ((tmp != NULL) && !chunk_is_str(tmp, "void", 4)) { if (need_nl) { - add_comment_text("\n ", cmt, false); + add_comment_text("\n", cmt, false); } add_text("@return TODO"); }