jmbledsoe / angularjs-visualstudio-intellisense

Visual Studio extension providing statement completion for injected AngularJS components in JavaScript files.
MIT License
110 stars 22 forks source link

angularjs intellisense not working in Visual Studio Enterprise 2015 #27

Open GregLarden opened 9 years ago

GregLarden commented 9 years ago

I thought I would just go ahead and open a new issue, as suggested. Thanks!

I have current release version and it still does not work. My script paths are in App_Start\BundleConfig.cs. Could this be why?

I also have "~/Scripts/_references.js" in "Options/JavaScript/Intellisense/References" dialog.

have a repository with the sample project demonstrating the intellisense issue.

Repository name is: VS2015-Angular-Intellisense-Test

jmatthiesen commented 9 years ago

Thanks for this, @GregLarden! I forked your repo, made some tweaks to get IntelliSense working in the Admin module, and I've submitted a pull request back to you. Here's what I had to change:

  1. In _references.js replaced ../../localhost/bower_components references with ../bower_components. The file paths were bad.
  2. Replaced the reference to ../test/app/app.module.js to ../app/app.module.js. Again, bad path.
  3. In your admin.module.js file I needed to references the blocks.logger module, otherwise the code in admin.js could not understand the logger factory.

Let me know if that works well enough for you, or if you have other questions! Jordan

GregLarden commented 9 years ago

@jmatthiesen Thank you very much for the help! This worked! Would you mind explaining this situation below?

So I have a dataservice service that is added to the app.core module and the app.core module is added to the app module where all modules are added.

The interesting part is, I get the yellow explanation mark on the dataservice intellisense unless I add app.core directly into the admin.module. Do you know why that is?

//ALL MODULES ADDED angular.module('app', [

'app.core', 'app.widgets', 'app.admin', 'app.dashboard', 'app.layout' ]);

angular .module('app.core') .factory('dataservice', dataservice);

jmbledsoe commented 9 years ago

I believe you have identified a legitimate bug in the Intellisense processor, although I'm not 100% sure how to fix it at the moment. The block that starts on line 476 of angular.intellisense.js is what "tracks" modules. When the "app" module is added, it recursively tracks all of its dependent modules, decorating their provider functions for Intellisense, but at that point the "app.core" module hasn't been defined yet, so I think it might be overwritten.

As a workaround, declare the "app.core" module before the "app" module and see if that works.

desertmark commented 9 years ago

i've just realized that the automatic order that _reference.js file uses (first my files then the framework's files) prevented intellinsense to work on other files that weren't the app.js file

jmbledsoe commented 9 years ago

Yes script order in _references.js is very important. It's just as important as script order on your HTML pages. AngularJS needs to be present and your modules declared before you start registering providers.