JSDoc Disabled in 'If' Statement

Questions, tips and tricks and techniques for scripting in Servoy

JSDoc Disabled in 'If' Statement

Postby kwpsd » Fri Jun 22, 2012 8:13 pm

Version: 6.0.6 - build 1232

When testing code, I disable certain sections by temporarily including them in an 'if' statement, for example:

Code: Select all
    if ( true )
    {
        /** @type {JSFoundset<db:/databaseName/tableName>} */
       
        var fs = databaseManager.getFoundSet( 'databaseName', 'tableName' )
       
        fs.fieldName1 = data1
    }


Within the 'if' statement, if I add another line of code, for example:

Code: Select all
fs.fieldName2 = data2


the JSDoc code completion works as I type. However, if I change 'true' to 'false', then code completion is disabled within the 'if' statement.

What is the purpose of disabling code completion based on a conditional statement in my code? This strikes me as odd behavior, but, perhaps there is a plausable explanation?
Kim W. Premuda
San Diego, CA USA
User avatar
kwpsd
 
Posts: 635
Joined: Sat Jul 28, 2007 6:59 pm
Location: San Diego, CA USA

Re: JSDoc Disabled in 'If' Statement

Postby omar » Sat Jun 23, 2012 4:38 pm

This has nothing to do with JSDoc but is a result of the way syntax checking is performed. The compiler recognizes the 'dead code' situation and handles accordingly. Not only the intellisense is disabled but error and warning checking as well. The following will compile without any errors or warnings.

Code: Select all
function test() {
    if ( false )
    {
       var x = bigFatError;   
    }
}


Maybe a dead code warning would be appropriate in this situation...
Intrasoft, Founder
Omar van Galen
omar@intrasoft.nl
+31-(0)6-21234586
Servoy Developer
omar
 
Posts: 340
Joined: Sat Feb 12, 2011 4:51 pm
Location: Intrasoft, The Netherlands


Return to Methods

Who is online

Users browsing this forum: No registered users and 2 guests

cron