Skip to content

Commit

Permalink
Output Objective-C parameter names where $(javaparam) is used in a co…
Browse files Browse the repository at this point in the history
…mment block.
  • Loading branch information
Florin Pop authored and bengardner committed Jun 1, 2013
1 parent 6f840f2 commit 9c7ff6f
Showing 1 changed file with 52 additions and 11 deletions.
63 changes: 52 additions & 11 deletions src/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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");
}
Expand Down

0 comments on commit 9c7ff6f

Please sign in to comment.