Brainstorming needed. I have a problem with Javascript libraries (jQuery, ExtJS etc.) that don't seem to play well along with Javascript Intellisense built in Visual Studio 2008. They provide certain utility helper functions that intellisense fails to understand.
ie. ExtJS code
// convenience function to create namespace object placeholders
Ext.namespace("Root.Sub.Subsub");
or jQuery
// doing the same thing in jQuery
$.extend(window, {
Root: {
Sub: {
Subsub: {}
}
},
});
or even (I pitty thou that shalt maintain this code)
$.extend(window, { Root: {}});
$.extend(Root, { Sub: {}});
$.extend(Root.Sub, { Subsub: {}});
The end result of these calls is basically the same. None of them would make Root
namespace visible to Javascript Intellisense in Visual Studio 2008. If we would know how intellisense works under the hood we could probably be able to overcome this situation.
Is it possible to convince Intellisense to display/recognise these namespaces, without writing objects directly like:
Root = {
Sub: {
Subsub: {}
}
};
I admit that the first jQuery call is quite similar to this one, but it's better to use extend functionality to prevent removing/overwriting existing functionality/namespaces.
Question
How should we use these utility functions to make Intellisense work?
Any brainstorming answer that would shed some light on this is welcome?
Edit
I've found out that namespaces created with utility functions are shown if they are defined outside (ie. in a different script file) and you make a reference to that file like:
/// <reference path="different.script.file.js" />
In this case everything's fine. But if you call utility functions within the same file, they're not listed in intellisense drop down list.