From 5df551b1ce7d2192f8ddec8eda6da4ac05662969 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Tue, 25 Sep 2012 16:45:57 +0200 Subject: [PATCH] JavaScript parser: fix parsing non-method properties 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. --- tagmanager/ctags/js.c | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/tagmanager/ctags/js.c b/tagmanager/ctags/js.c index 37c3b6540d..bd3e8a1fa9 100644 --- a/tagmanager/ctags/js.c +++ b/tagmanager/ctags/js.c @@ -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); } } }