olov / ng-annotate

Add, remove and rebuild AngularJS dependency injection annotations
MIT License
2.03k stars 150 forks source link

"ngInject" directive can be anywhere inside a function #154

Closed tomca32 closed 9 years ago

tomca32 commented 9 years ago

This solves issue#152

Solving this issue is a pretty big priority for us since we use Coffeescript classes a lot in our codebase. As described in the issue above, none of the workarounds work in our case so scanning the full body of the function for "ngInject" seems to be the only option.

matchPrologueDirectives will now scan the whole body of the function instead of breaking after the first token. The performance impact is minimal. I ran the performance test a thousand times and compared to the old version and it was slower by up to 2%.

If this is not acceptable, I could put it behind a flag, such as --fullscan.