Skip to content

Commit

Permalink
Added new method findMatchingToken() to skip over blocks of code. Upd…
Browse files Browse the repository at this point in the history
…ated parseSwitch() to use the new method.

Updated tests/ctags/ui5.ui.controller.js with code that broke the switch statement.

git-svn-id: https://svn.code.sf.net/p/ctags/code/trunk@809 c5d04d22-be80-434c-894e-aa346cc9e8e8
  • Loading branch information
dfishburn authored and b4n committed Nov 24, 2014
1 parent 52d2d73 commit c54c3ad
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
35 changes: 27 additions & 8 deletions tagmanager/ctags/js.c
Expand Up @@ -674,10 +674,35 @@ static void findCmdTerm (tokenInfo *const token)
}
}

static void findMatchingToken (tokenInfo *const token, tokenType begin_token, tokenType end_token)
{
int nest_level = 0;

if ( ! isType (token, end_token))
{
nest_level++;
while (! (isType (token, end_token) && (nest_level == 0)))
{
readToken (token);
if (isType (token, begin_token))
{
nest_level++;
}
if (isType (token, end_token))
{
if (nest_level > 0)
{
nest_level--;
}
}
}
}
}

static void parseSwitch (tokenInfo *const token)
{
/*
* switch (expression){
* switch (expression) {
* case value1:
* statement;
* break;
Expand All @@ -701,13 +726,7 @@ static void parseSwitch (tokenInfo *const token)

if (isType (token, TOKEN_OPEN_CURLY))
{
/*
* This will be either a function or a class.
* We can only determine this by checking the body
* of the function. If we find a "this." we know
* it is a class, otherwise it is a function.
*/
parseBlock (token, token);
findMatchingToken (token, TOKEN_OPEN_CURLY, TOKEN_CLOSE_CURLY);
}

}
Expand Down
8 changes: 8 additions & 0 deletions tests/ctags/ui5.controller.js
@@ -1,5 +1,13 @@
sap.ui.controller("app.my_form", {

successfulRequest: function(data) {
switch( data.mParameters.headers.SAAP_SERVICE ) {
case SAAP_SERVICE.APPROVAL_DETAIL:
if (thisForm.getController().mApproval) {
}
}
},

onInit : function () {
this.selectListView = null;
sap.ui.getCore().byId("id_createButton").setEnabled(true);
Expand Down
1 change: 1 addition & 0 deletions tests/ctags/ui5.controller.js.tags
Expand Up @@ -3,3 +3,4 @@ onInit
refreshForm�128�sap.app.my_form�0
refreshSettlements�128�sap.app.my_form�0
setRefreshed�128�sap.app.my_form�0
successfulRequest�128�app.my_form�0

0 comments on commit c54c3ad

Please sign in to comment.