views:

1257

answers:

4

Right off the bat, this is not your standard "I can't get javascript IntelliSense to work in Visual Studio." For the record:

  • I'm using Visual Studio 2008
  • I have installed SP 1
  • I have installed the hotfix for -vsdoc.js documentation files KB958502

I am developing a suite of interrelated jQuery plugins to be packaged as resources in a class library. So within a directory, I have (as an example):

  • jquery-vsdoc.js
  • core.js
  • plug1.js
  • plug2.js

In core.js, I have the following at the top of the file:

/// <reference path="jquery-vsdoc.js" />

Then in each of the plug#.js, I have:

/// <reference path="jquery-vsdoc.js" />
/// <reference path="core.js" />

The IntelliSense works initially, even including the additions from core.js when working in the plugins. However, sometimes the slightest change, even adding and removing a space from the reference XML tags, or pressing Ctrl-Shift-J, results in the dreaded "Error updating JScript IntelliSense: Client-side script IntelliSense information was not generated due to an error in an external script reference." Except it was working with that external script reference just a second ago!

For the jquery-vsdoc.js, I am using Comment Version 1.3.2b (that's what it says in the file) from http://jqueryjs.googlecode.com/files/jquery-1.3.2-vsdoc2.js. I am omitting the version number from the file so that I don't have to change a bunch of references when it's inevitably updated.

So what could be the problem? Restarting Visual Studio is proving to be a horribly inelegant (and time-consuming) workaround.

A: 

Have you tried increasing the IntelliSense timeout?

By default, every IntelliSense request is only allowed 15s to execute. This is to prevent IntelliSense from scripts with infinite loops. If you have a large script or slower machine, it may make sense to increase the timeout limit. The timeout value store within following registry keys (depending on if your are using Express or the full product). The value is in milliseconds so choose something greater than 15000.

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\HTML Editor\JsFailsafeTimeout HKEY_CURRENT_USER\Software\Microsoft\VWDExpress\9.0\HTML Editor\JsFailsafeTimeout

TML
Good suggestion! Unfortunately (or fortunately?) I don't have large scripts or a slow machine. The failure is instantaneous, it doesn't take 15 seconds.
David
A: 

Does closing and opening the file reset the state?

Open the task manager and watch the processes. Do you see a process called "typelibbuilder.exe" get started when you press Ctrl-Shift-J?

I'm trying to image what sort of problems might require a restart of VS. The processing of references (to which that message pertains) is done in a new and separate process every time you press Ctrl-Shift-J (unless processing has been disabled in which case you would see a different message). It almost sounds like the communication between VS and typelibbuilder or some other necessary component is failing.

In SP1, you shouldn't need to reference the "-vsdoc" files directly. If you reference "foo.js" and there is a "foo-vsdoc.js" file next to it, then VS will use the vsdoc version to generate intellisense. I doubt that is related to your problem though.

I know this isn't much consolation, but we've drastically improved performance and reliability of Javascript Intellisense in Visual Studio 2010. Beta1 is currently available to MSDN subscribers (although it is beta and there are still some bugs in it).

If you can get reliable repro steps, you could also file a bug report at http://connect.microsoft.com/.

Alan Oursland
A: 

I dont know if this will help you, but I've encountered the following bug in VS 2008 JS intellisense:

When adding jQuery as a reference in an external file, and then I update JS I get:

'XmlHttpRequest is undefined' on the line:

return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();

It seems like the JS intellisense engine is actually executing some of the jQuery code (more than likely to inspect it so it can provide some more information about it). However it looks like window.ActiveXObject is null to the engine, and so it falls into the 'new XMLHttpRequest()' block - which also fails.

I hacked a workaround that breaks all browsers except IE - so not a good solution. My fix changes the following:

    xhr: function()
    {
        // hack to fix VS 2008 intellisense... note this breaks any browser
        // except IE
        var objXhr = { open: function() { },
            setRequestHeader: function() { } 
        };

        return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : objXhr;
    },

Now my intellisense works.

Adam
A: 

You may want to disable JavaScript intellisense in Visual Studio.

When SP1 is installed you can disable JavaScript intellisense.
Go to Tools, Options...

The Options dialog will show up.

Navigate to the following node in the left hand sided panel:
Text Editor :: JScript :: General

Disable the following options (in the group Statement Completion):
* Auto list members
* Parameter information

mathijsuitmegen
That would get rid of the error. However, it's not the error that's bugging me. The IntelliSense is great and I like it - I want it to work! Hopefully the improvements in Visual Studio 2010 render this question moot.
David