JetBrains / resharper-angularjs

ReSharper plugin for AngularJS support
Apache License 2.0
134 stars 25 forks source link

option to create/navigate to a controller from ng-controller #20

Open kkozmic opened 10 years ago

kkozmic commented 10 years ago

Those are effectively two features, so I'm happy to split it into two requests:

One is to be able to write ng-controller="FooController" or ng-controller="FooController as vm" and have an option to alt + Enter to create a new controller with this name.

Second one would be to navigate to definition when the controller exists.

citizenmatt commented 10 years ago

This is similar to PR #11, which would add a reference between the value of the ng-controller attribute and the controller function in JavaScript. Adding a reference enables the ctrl+click navigation, (mostly) code completion when editing, and partaking in renaming. @DerAlbertCom has done some work on this already - Albert, it would be great if you could do a new PR with your changes, even if they're unfinished.

The second part, create from usage, isn't covered and will have to be a separate piece of work. How would you expect it to work - where would it create the controller? In the HTML file, or in a new file, alongside, or in the scripts folder?

kkozmic commented 10 years ago

re: 2nd part

I realise that's not everybody's preference, but the way I structure the code is having them side by side:

/shoppingCart/
    shoppingCart.html
    shoppingCartController.js

That would obviously be my preference.

citizenmatt commented 10 years ago

Is there a convention in angularjs world (I'm not familiar enough)?

kkozmic commented 10 years ago

I'm not sure,,, haven't seen any strong guidance around that, but I'm quite new to Angular myself, and figuring it out as I go

DerAlbertCom commented 10 years ago

No it is not a convention. most from what i see put the view in seperate folders

DerAlbertCom commented 10 years ago

@citizenmatt i think on the weekend i can work in the plugin

DerAlbertCom commented 10 years ago

btw. the "other" guys uses often yeoman

For an example of the structure look here.

http://www.sitepoint.com/kickstart-your-angularjs-development-with-yeoman-grunt-and-bower/

citizenmatt commented 10 years ago

Hi @DerAlbertCom - any movement on the PR? I'm going to need an ICache implementation soon. I'm happy if you just want to push what you've got.

DerAlbertCom commented 10 years ago

@citizenmatt my last work is on https://github.com/deralbertcom/resharper-angularjs

Some initial Cache implementation

https://github.com/DerAlbertCom/resharper-angularjs/tree/master/src/resharper-angularjs/JavaScript

and support for a solution specific xml with "own" directives.

https://github.com/DerAlbertCom/resharper-angularjs/blob/master/src/resharper-angularjs/Html/SolutionDeclaredElementsProvider.cs

citizenmatt commented 10 years ago

@DerAlbertCom, are you ok if I cherry pick some of those commits? I want to get back onto this, but the project's changed a lot since the branch started, so I think it might be easier to pull in the most relevant commits and work from there. How does that sound?

DerAlbertCom commented 10 years ago

Pick it.