Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » experiences from writing a JSDT plugin
experiences from writing a JSDT plugin [message #759201] Sun, 27 November 2011 15:37
Philippe Marschall is currently offline Philippe MarschallFriend
Messages: 121
Registered: July 2009
Senior Member

This is a summary of the challenges of writing a jQuery plugin for JSDT [1].

I'll shortly explain jQuery for those not familiar with it. jQuery
revolves around the jQuery global object called "$" or "jQuery". The
global has several properties some of them are functions for example:


The global object is also a function that an be used to create something
like a collection DOM elements (think composite pattern). This object
offers several functions that generally return that object again. This
allows for cascading function application. Like this:


In this example the class "first" is added to all "a"-elements and then
class "second" is removed from all of them.

This is all that there's to model but I have hit several bumps in trying
to do so.
My approach was to generate jsdoc from the jQuery API XML [2] instead of
writing a custom type inferencer. With some limitations this worked
fairly well until Indigo SR1 when several things broke.

The first that caused trouble was that prototype of a function is now
only considered when the function is invoked with "new". This is correct
but I my generated jsdoc relied on the old behavior. That one was easy
to fix.

However the other change was more severe. It appears that now things can
either be functions or object but not both [3]. This meant that suddenly
I could only support half of my use cases either only the ones that
treat "$" as an object or the ones treating it as a function.

So I decided to look at implementing a type inferencer again. But I soon
got the impression that it isn't really well suited for my problem. I
can set the inferred type on function declarations, variable
declarations, assignments and object literals. That's not really the
problem I'm trying to solve. I'm trying to model the "$" global. The
only point where I see a type inferencer would help are arguments of
callback functions because they can't be modeled with jsdoc.

What I really seem need is a custom IJsGlobalScopeInitializer where I
can model the "$" object. However I couldn't find an easy way to do
this. IJsGlobalScopeInitializer seems to revolve around include paths.
My understanding is that this would mean jsdoc again. Am I missing
something here, is there an easy way to programmatically model a global?


Previous Topic:jsdoc, arrays, and @type
Next Topic:How to add CSS autocomplete in web pages in eclipse
Goto Forum:

Current Time: Sun May 27 01:32:04 GMT 2018

Powered by FUDForum. Page generated in 0.01800 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top