Child pages
  • JSDoc Annotations

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note

Type Casting can only be performed on variable declarations. It is not possible switch the type of an already declared variable later in code


Shallow parsing property in the Servoy preferences

In the Preferences->Servoy→Javascript Validation we have an option called shallow parsing. That property is enabled by default and if checked will make sure that when parsing over files the other files are not fully parsed but only functions that are marked with @parse or @constructor are parsed internally.

This greatly enhances performance because Servoy doesn't have to go over multiply files (deeply nested) to get the the type info of a object that is created in another file.

Problem is that you really need to document all the functions correctly that are not fully parsed. Because we can't extract on those the actual runtime return type from the function body. So @return is important to have for all the functions describing its object that it returns (together with the @param)

So to force Servoy to do parse the function because it is a constructor function like:


Code Block
/** 
 * @constructor
 */
function MyObject () {}


If you want to have a normal function (that for example does some prototyping) to be parsed you can use the @parse  annotation:

Code Block
/**
 * @parse
 */
function myInit() {
  MyObject.prototype = xxx
}


If those init methods are auto initializing variables like this:

Code Block
var init = (
		/**
		 * @parse 
		 */
		function(){
	SomeClass.prototype = Object.create(SomeClass.prototype);
	SomeClass.prototype.constructor = SomeClass;
	
	/**
	 * @constructor 
	 */
	SomeClass.prototype.anotherFunction = function() {
		
	}
})()


make sure the @parse doc is on the function itself, not on the doc of the var init!