I have a strange issue with outlining of JavaScript files in Eclipse 4.2 using JSDT 1.4.1. I have a closure defined like this:
var myClosure = (function() {
var calcGridLocation,
detectCollision;
/**
* Calculate the grid cell coordinates from the offset of an element and the editorgrid offset
*
* @param {jQuery object} obj jQuery object of the object whose location will be calculated
* @param {String} [subgrid=""] Specify the currently active subgrid
* @returns {Object} Coordinate object with x, y and obj properties, obj hols a jQuery object of the target cell, null for locations outside the editorgrid
* @memberOf myClosure
*/
calcGridLocation = function(obj, subgrid) {
var gridOffset, // Offset (relative to document) of the editorgrid
objOffset, // Offset (relative to document) of the provided object
rv = {}; // Return value object
if(subgrid === null || subgrid === undefined) {
subgrid = "";
// Get the grid's offset
gridOffset = $("#editorgrid").offset();
}
else {
// Get the grid's offset
gridOffset = $("#" + subgrid).offset();
subgrid += "_";
}
// Get the object's offset
objOffset = obj.offset();
// Calculate the grid coordinates of the object
if(objOffset === undefined || gridOffset === undefined) {
debugger;
}
rv.x = Math.floor((objOffset.left - gridOffset.left) / cellSize);
rv.y = Math.floor((objOffset.top - gridOffset.top) / cellSize);
// Check if the location is a valid grid location
if(rv.x >= 0 && rv.x < tblCellCount && rv.y >= 0 && rv.y < tblRowCount) {
if(obj.hasClass("gridCell")) {
rv.obj = obj;
}
else {
// Get the grid cell object and return the return value object
rv.obj = $("#" + subgrid + "c_" + rv.y + "_" + rv.x);
}
return rv;
}
else {
// Return null, no valid grid location
return null;
}
}; //calcGridLocation = function()
/**
* Detect a collision of an object with other dragboxes
*
* @param {jQuery object} obj Object to check for collisions
* @returns {Object} Object with collision, obstacle, shift.x and shift.y attributes
* @memberOf myClosure
*/
detectCollision = function(obj) {
// Some code here
}; //detectCollision = function()
})();
After some researching I found out that I need the jsDoc annotations to make the functions show up in Eclipse. The first functions shows up but the second does not. It is just not listed.
And the really weird thing: If I remove the contents of the first function completely, the second function will show up just fine. Is there some mistake in my syntax that does cause this behaviour? The complete script works fine when I test my project in the browser (Google Chrome) and gets validated by jsLint (except some things where I do not accept the jsLint way of writing code).
Additional information
Eclipse does not show several functions of this closure, the above is just a minimal example. The "lost" functions seem to be quite random, sometimes a single one is missing, sometimes several in a row. Also there are functions between the missing ones that are shown in the outline like this: shown, shown, missing, shown, missing, missing, ...
I double checked that every single function has the @memberOf
jsDoc annotation which should make it visible in the outline.
The missing functions are not recognized as function blocks by the editor so I cannot fold them (the shown function can be folded). Removing the content from the calcGridLocation
function enables code folding on the detectCollision
function.