Posts

Showing posts from May, 2010

Understanding JavaScript libraries

I'd like to share with you some thoughts on supporting javascript libraries in an IDE. I found it quite interesting so far and I hope you'll enjoy the read :-) Let's assume we have to add content-assist for popular javascript libraries, like jQuery or Prototype, etc, there's dozens of those. First of all, if those libraries are written entierly in JavaScript, why do we have to add anything special? Can't some JS parser (e.g. JSDT) just take care of understanding those libraries, like it's done for Java or other languages? Unfortunately no. Most popular convention in JavaScript world is to write libraries that self-expand themselves in runtime. For example: /** this function adds all fields and functions to given object */ jQuery.extend = function(object, fields) { for (var field in fields) { object.prototype[field] = fields[field]; } }; jQuery.extend(Array, { /** Removes an object from array */ remove : function(obj) { } /** Pri