JScript IntelliSense in Visual Studio Orcas

JScript IntelliSense in Visual Studio Orcas

Rate This
  • Comments 96

The March CTP of Visual Studio marks the debut of a much-requested and long-awaited feature: improved JScript IntelliSense.  We’ve been working on this for almost a year now and I’m pretty excited to finally be able to share it with the public.  There are a variety of topics I’d like to deep dive into, but for today let’s just take a quick aerial tour of the new features.

1. Proactive Completion List

Our old list was a bit lazy and only “awoke” when you typed a period while accessing a member.  Our new one is on-its-toes and is wired up to the language grammar.  Net effect: it comes up when you would expect it, and you can spend less time pressing ctrl+J. =)

2. Keywords in Completion List

In practice, you will spend half of your time typing keywords.  Now they’re part of the list.

3. ASP.NET AJAX Concepts in Completion List

We have new glyphs corresponding to objects and functions that have registered themselves as ASP.NET AJAX Namespaces, Classes, Interfaces, Properties, Enumerations, etc.  Since lists are usually long, this is particularly useful for quickly discovering that particular member you’re looking for.

The glyphs are aligned with the ones you would see in managed programming.  Vanilla fields and functions are now just marked as blue and magenta boxes respectively.

4. IntelliSense from Script Libraries for ASPX Pages

The cornerstone feature is the new ability to see objects and functions declared in external script files.  Note below that $addHandler was not defined in the current document:

How do we know which files you’re referencing?  We look for Script Managers (and Proxies), and infer what scripts it will bring into the page:

We look for the normal HTML script reference tags:

We also take into account any Master Pages that may contain any of the above.

5. IntelliSense from Script Libraries for JS Files

The example above works great for pages, but what if you’re in a JS file?  Since there’s no standard syntax, we decided on the following XML comment syntax (which you’ll see a parallelism in the next section):

The above declaration simply states that the current JS file should display IntelliSense including objects and functions declared in JScript1.js.  The following declaration references a script library embedded within an assembly (note the subtle usage of “name” instead of “path”):

If the “assembly” attribute is left out, we assume it to be the System.Web.Extensions assembly.  This keeps standard references to ASP.NET AJAX scripts succinct.

It’s worthwhile to remember that these declarations must be found at the top of the page before any script or any regular comments.  Additionally, these declarations are not used during the runtime in any way—they are for the editor only.

6. Enhanced Function and Parameter Tips

Function and parameter tips now have the ability to show ASP.NET AJAX type information as well as summaries.  This should help minimize context-switching when looking for documentation.  Tips appear both from the completion list:

…and underneath the function as you’re typing:

Where is this information coming from?  The editor simply reads the XML comments from the source code:

ASP.NET AJAX employs a XML documentation comment scheme akin to the .NET XML Documentation Comments.  As long as your sources are commented, we leverage them to display the additional information.  ASP.NET AJAX scripts and AJAX Control Toolkit scripts come in commented flavors.  For older files that don’t have these comments, we will still show at least the function name and parameter names.

7. Type Inferencing

A foundational feature enabling much of the IntelliSense is our ability to infer types across assignments between JScript variables—which are inherently type-less.  The JScript Team, our partner team, has a great post on this topic.  I’ll defer the discussion of this feature to them.

Summary

JScript IntelliSense is a (purposefully) subtle set of features.  I hope this introduction spotlights some of the functionality you might otherwise have missed and gets you up and running.  I’ll blog in more depth later.  For now, have fun playing with the March CTP and let us know what you think!

Jeff King
Program Manager
Visual Studio Web Tools

  • Will other js library be supported?

    For example dojo declares class using this syntax...

    dojo.declare("namespace.class", parent.class, {

    functionname : function(){}

    });

  • Thisisanabsolutelyawesomefeature.IntelliSense/autocompletionforJavaScriptisadifficultp...

  • Looks like there were some questions about dojo and jsdocs support.  There are no current plans to support those.  We have a few more general Javascript/JScript goals that we want to meet such as formatting and even maybe compressing/"crunching".  After that, we can look at more specific features.

  • Do you have plans for releasing a tool which will extract the comments from the JS files, e.g. for documentation purposes?

    TIA

  • You've been kicked (a good thing) - Trackback from DotNetKicks.com

  • I have downloaded the March CTP release and tried to get the intellisense to work with no avail.  I can't get a propety on a custom object to show up in the intellisense. I also can't get the tooltip data to show either. Can you write up a simple example on how to get this to work?  Here is my code I was trying to get to work.

    <code>

    /// <reference path="JScript1.js />

    function init()

    {

       var testobject = new test("hello");

       alert(testobject.property1);

    }

    function test(txt)

    {

    /// <summary>

    ///     A test function

    /// </summary>

    /// <param name="txt" type="String">

    ///     This is a string

    /// </param>

    /// <returns type="none" />        

       this.property1 = txt;

    }

    </code>

  • Now this is what I've wanted for years! :)  Orcas can't be completed fast enough for me!  Thanks for the quick rundown on the new javascript features.

  • How is performance? VS 2005 C++ Intellisense updating is so bad that I had to disable it to be able to get any work done. That must be fixed before piling more features on top of it.

  • Hi Randy,

    This feature is not related to VS 2005 C++ intellisense since the code for JScript intellisense is completely separate.  We have already done our initial performance analysis and made some improvements based on this.  If there are situations where you find the performance is not up to the mark, send us those cases and we'll look to fix them before we ship Orcas.  Getting this kind of feedback early is actually one of the main reasons to release this early CTP.

    Thanks,

    -- Bash

  • Hi Valeri,

    With regards to your question the doc generation tool, see this link: http://weblogs.asp.net/bleroy/archive/2006/05/01/ScriptDoc_3A00_-document-your-Atlas-classes.aspx

    HTH,

    Jeff

  • Jeff, thank you very much!

  • This is great but when I try to reference javascript file, TypeLibBuilder.exe crashes. Is there any workaround? Or maybe it's my installation problems?

  • I would like to re-iterate the question about other js libraries.

    This is extremely important.

  • Hi Sys_Admin, we realized that there's actually a bug where the TypeLibBuilder.exe isn't signed properly thus causing this crash.  I'll be making a post soon to on how to fix it.

    Hi JSP, one characteristic of the XML Comments is that is only works for externally referenced scripts. Currently for the active document, we don't have the ability to parse out the comments... only our engine that processes external documents has the know-how to read XML comments.  It's wasn't easy to get the current doc to recognize comments (otherwise we would have done so), but if this becomes a critical need, we can revisit this issue.

    Thanks for your patience,

    Jeff

  • Hi Ayende,

    While I can't promise we'll have support for any other js libraries, I'd like to get an idea from you (and everyone else reading) which libraries you feel are the most important that we support (in priority order).  We'll definitely take the information in to account as we plan for the future.

    Thanks,

    Jeff

Page 2 of 7 (96 items) 12345»