Skip to content

Commit

Permalink
JavaScript parser: fix parsing non-method properties
Browse files Browse the repository at this point in the history
If a property value had more than one token, the parser choked on it
and failed to parse further properties of the object.  Fix that by
properly skipping the property's value.  If that value is a sub-object,
parse it recursively.

Closes #3470609.
  • Loading branch information
b4n committed Sep 25, 2012
1 parent dc6e4f2 commit 5df551b
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions tagmanager/ctags/js.c
Expand Up @@ -1007,15 +1007,42 @@ static boolean parseMethods (tokenInfo *const token, tokenInfo *const class)
}
else
{
vString * saveScope = vStringNew ();
boolean has_child_methods = FALSE;

/* skip whatever is the value */
while (! isType (token, TOKEN_COMMA) &&
! isType (token, TOKEN_CLOSE_CURLY))
{
if (isType (token, TOKEN_OPEN_CURLY))
{
vStringCopy (saveScope, token->scope);
addToScope (token, class->string);
has_child_methods = parseMethods (token, name);
vStringCopy (token->scope, saveScope);
readToken (token);
}
else if (isType (token, TOKEN_OPEN_PAREN))
{
skipArgumentList (token);
}
else if (isType (token, TOKEN_OPEN_SQUARE))
{
skipArrayList (token);
}
else
{
readToken (token);
}
}
vStringDelete (saveScope);

has_methods = TRUE;
addToScope (name, class->string);
makeJsTag (name, JSTAG_PROPERTY);

/*
* Read the next token, if a comma
* we must loop again
*/
readToken (token);
if (has_child_methods)
makeJsTag (name, JSTAG_CLASS);
else
makeJsTag (name, JSTAG_PROPERTY);
}
}
}
Expand Down

0 comments on commit 5df551b

Please sign in to comment.