JSDoc Object Functions

Servoy Version: 7.4.2 - build 2033

I created a JavaScript object that contains properties along with private and public methods. The public methods are of the form:

    this.functionName = function( parameterName )
    {
        ...do some processing...

        return someValue
    }

The object methods work fine, but the JSDoc (or lack thereof) is generating a warning (100’s in my case) every time the object’s methods are used. The warning message is:

Call to something which is not known to be a function

In Developer, when I reference the object, IntelliSense/Autocomplete shows the function as a property, not a function.

What is the best way to JSDoc annotate object functions in order to eliminate the warnings?

Thanks!

This should do the trick

/**
* Doc String
* @param {String} parameterName
* @return {Number}
*/
this.functionName = function( parameterName )
{
    ...do some processing...

    return someValue
}

Thank you for responding.

Adding the JSDoc annotation to the object’s methods does not get rid of the warnings (I tried with and without the annotation). When adding the annotation, I used the ALT-SHIFT-J method just to make certain it was being added correctly. The warnings are at the instance of the object’s usage, not in the object itself. For example,

var x = scopes.globals.objectName.functionName()

emits the warning (even though the function works).

what is exactly the code that you have that creates that object?
And where do you exactly use it?

Our solution has many modules of which one is a ‘core’ module. The declaration of the _oSystem object as well as the class definiton of the object are in the ‘core’ module.

/**
 * @properties={typeid:35,uuid:"85A98ABB-29CD-4E16-BAC3-6E94EB301B79",variableType:-4}
 */
var _oSystem = {};
/**
 * @properties={typeid:24,uuid:"915ABC14-6C82-4955-AB08-B498609FA02D"}
 *
 */
function classARMSystem()
{
    // DEFAULT PROPERTIES
    
    this.FacilityID = 'ARMSD';
    this.FacilityName = 'Animal Resource Management';
    this.Country = 'USA';
    this.ReportHeading = '';
    this.PainLevel1 = 'A';
    this.PainLevel2 = 'B';
    this.PainLevel3 = 'C';
    this.PainLevel4 = 'D';
    this.PainLevel5 = 'E';
    this.OrderFundRequired = 'Yes';
    this.OrderOveragePerCent = 0;
    this.confirmRecordChanges = false;
    
    // INTERNAL METHODS:
    
    /**
     * @param {String} pKey
     * 
     * @return {String}
     */
    function getConfigurationItem( pKey )
    {
        var sql = 'SELECT arm_configuration_value FROM arm_configuration WHERE arm_configuration_key = ?';
            
        var ds = databaseManager.getDataSetByQuery( 'arm_data', sql, [ pKey ], -1 );
        
        if ( ds.getMaxRowIndex() > 0 ) return ds.getValue( 1, 1 );
        
        return null;
    }
    
    
    // EXTERNAL METHODS
    
    
    /**
     * @param {String} pItemName
     * 
     * @return {String}
     */
    this.getItem = function( pItemName )
    {
        return getConfigurationItem( pItemName );
    }
    
    
    
    /**
     * @return 
     */
    this.load = function ()
    {
        this.FacilityID = getConfigurationItem( 'Facility ID' );
        this.FacilityName = getConfigurationItem( 'Facility Name' );
        this.Country = getConfigurationItem( 'Country' );
        this.ReportHeading = getConfigurationItem( 'Report: Company Heading' );
        this.PainLevel1 = getConfigurationItem( 'Protocol: Pain Level 1' );
        this.PainLevel2 = getConfigurationItem( 'Protocol: Pain Level 2' );
        this.PainLevel3 = getConfigurationItem( 'Protocol: Pain Level 3' );
        this.PainLevel4 = getConfigurationItem( 'Protocol: Pain Level 4' );
        this.PainLevel5 = getConfigurationItem( 'Protocol: Pain Level 5' );
        this.OrderFundRequired = getConfigurationItem( 'Order: Fund Required?' );
        this.OrderOveragePerCent = parseFloat( getConfigurationItem( 'Order: Per Cent Overage' ) );

        var x = getConfigurationItem( 'System: Confirm Record Changes' );
        
        this.confirmRecordChanges = ( x == 'Yes' ) ? true : false;
    }

    /**
     * @return
     */
    this.display = function()
    {
        var message = 'oSystem Contents:\n' +
                      '    ' + this.FacilityID + '\n' +
                      '    ' + this.FacilityName + '\n' +
                      '    ' + this.Country + '\n' +
                      '    ' + this.ReportHeading + '\n' +
                      '    ' + this.PainLevel1 + '\n' +
                      '    ' + this.PainLevel2 + '\n' +
                      '    ' + this.PainLevel3 + '\n' +
                      '    ' + this.PainLevel4 + '\n' +
                      '    ' + this.PainLevel5 + '\n' +
                      '    ' + this.OrderFundRequired + '\n' +
                      '    ' + this.OrderOveragePerCent + '\n'
                      '    ' + this.confirmRecordChanges + '\n';
                      
        plugins.dialogs.showInfoDialog( 'DEBUG: oSystem Object', message, 'OK' );
    }

    
    /**
     * @return {String[]}
     */
    this.getPainLevelNames = function ()
    {
        return [ this.PainLevel1, this.PainLevel2, this.PainLevel3, this.PainLevel4, this.PainLevel5 ];
    }
}

Below is typical code usage:

var InOut = globals._oSystem.getItem( 'Billing: Care Day Count Method (In/Out or Total)' )

but _oSystem is not typed at all
I guess you just assign it somewhere to an instance of that classARMSystem ?

but if you do this:

globals._oSystem.

then _oSystem is just an object because thats how you init it and it is not really typed
i would expect at least something like:

/**
* @type {classARMSystem}
* @properties={typeid:35,uuid:"85A98ABB-29CD-4E16-BAC3-6E94EB301B79",variableType:-4}
*/
var _oSystem = {};

This object design was designed/created in early 2010 with a much earlier version of Servoy. Originally, the object was typed as follows:

// * @type {{FacilityID:String, FacilityName:String, Country:String, ReportHeading:String, PainLevel1:String, PainLevel2:String, PainLevel3:String, PainLevel4:String, PainLevel5:String, OrderFundRequired:String, OrderOveragePerCent:Number, confirmRecordChanges:Boolean, load:null, getItem:String }}

Thinking that this could be the cause of the warnings, the object ‘type’ was removed altogether, but it did not make a difference. I tried your ‘type’ suggestion as well (copied it verbatim), but, it too, did not make any difference.

The global object is declared in the core module using the ‘add variable’ method for that module and selecting ‘media’ type (just as you show it). The object class is in the same core module.

I vaguely recall seeing something in the referenced JSDoc links in the Servoy wiki about a ‘@method’ type, but I do not believe Servoy supports this. Do you have any other suggestions…perhaps, a way to turn off this warning?

I spoke too soon…I just restarted Servoy Developer and the warnings went away using your ‘type’:

   /**
    * @type {classARMSystem}
    * @properties={typeid:35,uuid:"85A98ABB-29CD-4E16-BAC3-6E94EB301B79",variableType:-4}
    */
    var _oSystem = {};

Thanks so much, Johan! This is a huge relief for me.