ng-annotate
Advanced tools
Comparing version 0.9.3 to 0.9.4
@@ -37,4 +37,2 @@ // ng-annotate-main.js | ||
function matchDirectiveReturnObject(node) { | ||
// TODO make these more strict by checking that we're inside an angular module? | ||
// return { .. controller: function($scope, $timeout), ...} | ||
@@ -48,4 +46,2 @@ | ||
function matchProviderGet(node) { | ||
// TODO make these more strict by checking that we're inside an angular module? | ||
// (this|self|that).$get = function($scope, $timeout) | ||
@@ -112,3 +108,3 @@ // { ... $get: function($scope, $timeout), ...} | ||
// $stateProvider.state("myState", {... resolve: {f: function($scope) {}, ..} ..}) | ||
// $stateProvider.state("myState", {... views: {... somename: {... controller: fn, templateProvider: fn, resolve: {f: fn}}}}) | ||
// $stateProvider.state("myState", {... views: {... somename: {... controller: fn, controllerProvider: fn, templateProvider: fn, resolve: {f: fn}}}}) | ||
// | ||
@@ -182,2 +178,3 @@ // $urlRouterProvider.when(.., function($scope) {}) | ||
res.push(matchProp("controller", prop.value.properties)); | ||
res.push(matchProp("controllerProvider", prop.value.properties)); | ||
res.push(matchProp("templateProvider", prop.value.properties)); | ||
@@ -226,5 +223,10 @@ res.push.apply(res, matchResolve(prop.value.properties)); | ||
var args = node.arguments; | ||
return (is.someof(method.name, ["config", "run"]) ? | ||
var target = (is.someof(method.name, ["config", "run"]) ? | ||
args.length === 1 && args[0] : | ||
args.length === 2 && args[0].type === "Literal" && is.string(args[0].value) && args[1]); | ||
if (target) { | ||
target.$always = true; | ||
} | ||
return target; | ||
} | ||
@@ -327,3 +329,4 @@ | ||
function replaceRemoveOrInsertArrayForTarget(target, ctx) { | ||
function judgeSuspects(ctx) { | ||
var suspects = ctx.suspects; | ||
var mode = ctx.mode; | ||
@@ -333,14 +336,38 @@ var fragments = ctx.fragments; | ||
if (mode === "rebuild" && isAnnotatedArray(target)) { | ||
replaceArray(target, fragments, quot); | ||
} else if (mode === "remove" && isAnnotatedArray(target)) { | ||
removeArray(target, fragments); | ||
} else if (is.someof(mode, ["add", "rebuild"]) && isFunctionExpressionWithArgs(target)) { | ||
insertArray(target, fragments, quot); | ||
} else { | ||
return false; | ||
for (var i = 0; i < suspects.length; i++) { | ||
var target = suspects[i]; | ||
if (target.$once) { | ||
continue; | ||
} | ||
target.$once = true; | ||
if (!target.$always) { | ||
var $caller = target.$caller; | ||
for (; $caller && $caller.$chained !== chainedRegular; $caller = $caller.$caller) { | ||
} | ||
if (!$caller) { | ||
continue; | ||
} | ||
} | ||
if (mode === "rebuild" && isAnnotatedArray(target)) { | ||
replaceArray(target, fragments, quot); | ||
} else if (mode === "remove" && isAnnotatedArray(target)) { | ||
removeArray(target, fragments); | ||
} else if (is.someof(mode, ["add", "rebuild"]) && isFunctionExpressionWithArgs(target)) { | ||
insertArray(target, fragments, quot); | ||
} | ||
} | ||
return true; | ||
} | ||
function addModuleContextDependentSuspect(target, ctx) { | ||
ctx.suspects.push(target); | ||
} | ||
function addModuleContextIndependentSuspect(target, ctx) { | ||
target.$always = true; | ||
ctx.suspects.push(target); | ||
} | ||
function isAnnotatedArray(node) { | ||
@@ -408,2 +435,10 @@ return node.type === "ArrayExpression" && node.elements.length >= 1 && last(node.elements).type === "FunctionExpression"; | ||
// suspects is built up with suspect nodes by match. | ||
// A suspect node will get annotations added / removed if it | ||
// fulfills the arrayexpression or functionexpression look, | ||
// and if it is in the correct context (inside an angular | ||
// module definition) - alternatively is forced to ignore | ||
// context with node.$always = true | ||
var suspects = []; | ||
var ctx = { | ||
@@ -416,6 +451,8 @@ mode: mode, | ||
triggers: triggers, | ||
suspects: suspects, | ||
isFunctionExpressionWithArgs: isFunctionExpressionWithArgs, | ||
isFunctionDeclarationWithArgs: isFunctionDeclarationWithArgs, | ||
isAnnotatedArray: isAnnotatedArray, | ||
replaceRemoveOrInsertArrayForTarget: replaceRemoveOrInsertArrayForTarget, | ||
addModuleContextDependentSuspect: addModuleContextDependentSuspect, | ||
addModuleContextIndependentSuspect: addModuleContextIndependentSuspect, | ||
stringify: stringify, | ||
@@ -441,3 +478,11 @@ }; | ||
var recentCaller = undefined; // micro-optimization | ||
var callerIds = []; | ||
traverse(ast, {pre: function(node) { | ||
node.$caller = recentCaller; | ||
if (node.type === "CallExpression") { | ||
callerIds.push(node); | ||
recentCaller = node; | ||
} | ||
var pos = node.range[0]; | ||
@@ -449,2 +494,7 @@ while (pos >= triggers.pos) { | ||
}, post: function(node) { | ||
if (node === recentCaller) { | ||
callerIds.pop(); | ||
recentCaller = last(callerIds); | ||
} | ||
var targets = match(node, re, matchPluginsOrNull); | ||
@@ -458,8 +508,9 @@ if (!targets) { | ||
// TODO add something to know that node has been altered so it won't happen again | ||
for (var i = 0; i < targets.length; i++) { | ||
replaceRemoveOrInsertArrayForTarget(targets[i], ctx); | ||
addModuleContextDependentSuspect(targets[i], ctx); | ||
} | ||
}}); | ||
judgeSuspects(ctx); | ||
var out = alter(src, fragments); | ||
@@ -466,0 +517,0 @@ |
@@ -12,3 +12,3 @@ // ng-annotate.js | ||
var ngAnnotate = require("./ng-annotate-main"); | ||
var version = "0.9.3"; | ||
var version = "0.9.4"; | ||
var optimist = require("optimist") | ||
@@ -15,0 +15,0 @@ .usage("ng-annotate v" + version + "\n\nUsage: ng-annotate OPTIONS file.js") |
@@ -45,3 +45,4 @@ "use strict"; | ||
// handle most common case: /*@ngInject*/ prepended to an array or function expression | ||
if (ctx.replaceRemoveOrInsertArrayForTarget(node, ctx)) { | ||
if (node.type === "ArrayExpression" || node.type === "FunctionExpression") { | ||
ctx.addModuleContextIndependentSuspect(node, ctx); | ||
return; | ||
@@ -52,3 +53,3 @@ } | ||
nestedObjectValues(node).forEach(function(n) { | ||
ctx.replaceRemoveOrInsertArrayForTarget(n, ctx); | ||
ctx.addModuleContextIndependentSuspect(n, ctx); | ||
}); | ||
@@ -70,5 +71,14 @@ return; | ||
function getIndent(pos) { | ||
var src = ctx.src; | ||
var lineStart = src.lastIndexOf("\n", pos - 1) + 1; | ||
var i = lineStart; | ||
for (; src[i] === " " || src[i] === "\t"; i++) { | ||
} | ||
return src.slice(lineStart, i); | ||
} | ||
function addRemoveInjectsArray(params, posAfterFunctionDeclaration, name) { | ||
var str = fmt("\n{0}.$injects = {1};", name, ctx.stringify(params, ctx.quot)); | ||
var indent = getIndent(posAfterFunctionDeclaration); | ||
var str = fmt("\n{0}{1}.$injects = {2};", indent, name, ctx.stringify(params, ctx.quot)); | ||
@@ -75,0 +85,0 @@ ctx.triggers.add({ |
@@ -153,103 +153,155 @@ "use strict"; | ||
// $httpProvider | ||
$httpProvider.interceptors.push(function($scope) { a }); | ||
$httpProvider.responseInterceptors.push(function($scope) { a }, function(a, b) { b }, function() { c }); | ||
var interceptor = /*@ngInject*/ function($scope) { a }; | ||
$httpProvider.interceptors.push(interceptor); | ||
// all the patterns below matches only when we're inside a detected angular module | ||
angular.module("MyMod").directive("pleasematchthis", function() { | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: function($scope) { | ||
a; | ||
} | ||
}).when("path2", { | ||
controller: function($scope) { | ||
b; | ||
// $httpProvider | ||
$httpProvider.interceptors.push(function($scope) { a }); | ||
$httpProvider.responseInterceptors.push(function($scope) { a }, function(a, b) { b }, function() { c }); | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: function($scope) { a } | ||
}).when("path2", { | ||
controller: function($scope) { b }, | ||
resolve: { | ||
zero: function() { a }, | ||
more: function($scope, $timeout) { b }, | ||
something: "else", | ||
}, | ||
dontAlterMe: function(arg) {}, | ||
}); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
simpleObj: function() { a }, | ||
promiseObj: function($scope, $timeout) { b }, | ||
translations: "translations", | ||
}, | ||
resolve: { | ||
zero: function() { | ||
a; | ||
views: { | ||
viewa: { | ||
controller: function($scope, myParam) {}, | ||
controllerProvider: function($stateParams) {}, | ||
templateProvider: function($scope) {}, | ||
dontAlterMe: function(arg) {}, | ||
resolve: { | ||
myParam: function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
} | ||
}, | ||
}, | ||
more: function($scope, $timeout) { | ||
b; | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: function($scope) {}, | ||
controller: function($scope) {}, | ||
}, | ||
something: "else", | ||
dontAlterMe: null, | ||
}, | ||
dontAlterMe: function(arg) {}, | ||
}); | ||
controller: function($scope, simpleObj, promiseObj, translations) { c }, | ||
controllerProvider: function($scope) { g }, | ||
templateProvider: function($scope) { h }, | ||
onEnter: function($scope) { d }, | ||
onExit: function($scope) { e }, | ||
dontAlterMe: function(arg) { f }, | ||
}).state("myState2", { | ||
controller: function($scope) {}, | ||
}).state({ | ||
name: "myState3", | ||
controller: function($scope, simpleObj, promiseObj, translations) { c }, | ||
}); | ||
$urlRouterProvider.when("/", function($match) { a; }); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", function($location) { a; }); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
simpleObj: function() { | ||
a; | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: function($scope) {}, | ||
resolve: { | ||
items: function(MyService) {}, | ||
data: function(a, b) {}, | ||
its: 42, | ||
}, | ||
donttouch: function(me) {}, | ||
}); | ||
}); | ||
promiseObj: function($scope, $timeout) { | ||
b; | ||
}, | ||
// none of the patterns below matches because they are not in an angular module context | ||
// this should be a straight copy of the code above, with identical copies in | ||
// with_annotations(_single).js | ||
foobar.irrespective("dontmatchthis", function() { | ||
translations: "translations", | ||
}, | ||
views: { | ||
viewa: { | ||
controller: function($scope, myParam) {}, | ||
templateProvider: function($scope) {}, | ||
dontAlterMe: function(arg) {}, | ||
// $httpProvider | ||
$httpProvider.interceptors.push(function($scope) { a }); | ||
$httpProvider.responseInterceptors.push(function($scope) { a }, function(a, b) { b }, function() { c }); | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: function($scope) { a } | ||
}).when("path2", { | ||
controller: function($scope) { b }, | ||
resolve: { | ||
myParam: function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
} | ||
zero: function() { a }, | ||
more: function($scope, $timeout) { b }, | ||
something: "else", | ||
}, | ||
dontAlterMe: function(arg) {}, | ||
}); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
simpleObj: function() { a }, | ||
promiseObj: function($scope, $timeout) { b }, | ||
translations: "translations", | ||
}, | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: function($scope) {}, | ||
views: { | ||
viewa: { | ||
controller: function($scope, myParam) {}, | ||
controllerProvider: function($stateParams) {}, | ||
templateProvider: function($scope) {}, | ||
dontAlterMe: function(arg) {}, | ||
resolve: { | ||
myParam: function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
} | ||
}, | ||
}, | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: function($scope) {}, | ||
controller: function($scope) {}, | ||
}, | ||
dontAlterMe: null, | ||
}, | ||
controller: function($scope, simpleObj, promiseObj, translations) { c }, | ||
controllerProvider: function($scope) { g }, | ||
templateProvider: function($scope) { h }, | ||
onEnter: function($scope) { d }, | ||
onExit: function($scope) { e }, | ||
dontAlterMe: function(arg) { f }, | ||
}).state("myState2", { | ||
controller: function($scope) {}, | ||
}).state({ | ||
name: "myState3", | ||
controller: function($scope, simpleObj, promiseObj, translations) { c }, | ||
}); | ||
$urlRouterProvider.when("/", function($match) { a; }); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", function($location) { a; }); | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: function($scope) {}, | ||
resolve: { | ||
items: function(MyService) {}, | ||
data: function(a, b) {}, | ||
its: 42, | ||
}, | ||
dontAlterMe: null, | ||
}, | ||
controller: function($scope, simpleObj, promiseObj, translations) { | ||
c; | ||
}, | ||
controllerProvider: function($scope) { | ||
g; | ||
}, | ||
templateProvider: function($scope) { | ||
h; | ||
}, | ||
onEnter: function($scope) { | ||
d; | ||
}, | ||
onExit: function($scope) { | ||
e; | ||
}, | ||
dontAlterMe: function(arg) { | ||
f; | ||
}, | ||
}).state("myState2", { | ||
controller: function($scope) {}, | ||
}).state({ | ||
name: "myState3", | ||
controller: function($scope, simpleObj, promiseObj, translations) { | ||
c; | ||
}, | ||
donttouch: function(me) {}, | ||
}); | ||
}); | ||
$urlRouterProvider.when("/", function($match) { a; }); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", function($location) { a; }); | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: function($scope) {}, | ||
resolve: { | ||
items: function(MyService) {}, | ||
data: function(a, b) {}, | ||
its: 42, | ||
}, | ||
donttouch: function(me) {}, | ||
}); | ||
// explicit annotations | ||
@@ -296,1 +348,46 @@ var x = /* @ngInject */ function($scope) { | ||
} | ||
// let's zip-zag indentation to make sure that the $injects array lines up properly | ||
// @ngInject | ||
function foo($scope) {} | ||
// @ngInject | ||
function foo($scope) { | ||
} | ||
/* @ngInject */ function foo($scope) {} | ||
/* @ngInject */ function foo($scope) { | ||
} | ||
// @ngInject | ||
var foo = function($scope) { | ||
}; | ||
// @ngInject | ||
var foo = function($scope) {}; | ||
// @ngInject | ||
var foo = function($scope) { | ||
} | ||
// @ngInject | ||
var foo = function($scope) {} | ||
/* @ngInject */ var foo = function($scope) { | ||
}; | ||
/* @ngInject */var foo = function($scope) {}; | ||
/* @ngInject */var foo = function($scope) { | ||
} | ||
/* @ngInject */var foo = function($scope) {} | ||
// adding an explicit annotation where it isn't needed should work fine | ||
myMod.controller("foo", /*@ngInject*/ function($scope, $timeout) { | ||
}); | ||
// snippets that shouldn't fool ng-annotate into generating false positives, | ||
// whether we're inside an angular module or not | ||
myMod.controller("donttouchme", function() { | ||
// lo-dash regression that happened in the brief time frame when | ||
// notes (instad of "notes") would match. see issue #22 | ||
var notesForCurrentPage = _.filter(notes, function (note) { | ||
return note.page.uid === page.uid; | ||
}); | ||
}); |
@@ -153,101 +153,153 @@ "use strict"; | ||
// $httpProvider | ||
$httpProvider.interceptors.push(['$scope', function($scope) { a }]); | ||
$httpProvider.responseInterceptors.push(['$scope', function($scope) { a }], ['a', 'b', function(a, b) { b }], function() { c }); | ||
var interceptor = /*@ngInject*/ ['$scope', function($scope) { a }]; | ||
$httpProvider.interceptors.push(interceptor); | ||
// all the patterns below matches only when we're inside a detected angular module | ||
angular.module("MyMod").directive("pleasematchthis", function() { | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: ['$scope', function($scope) { | ||
a; | ||
}] | ||
}).when("path2", { | ||
controller: ['$scope', function($scope) { | ||
b; | ||
}], | ||
// $httpProvider | ||
$httpProvider.interceptors.push(['$scope', function($scope) { a }]); | ||
$httpProvider.responseInterceptors.push(['$scope', function($scope) { a }], ['a', 'b', function(a, b) { b }], function() { c }); | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: ['$scope', function($scope) { a }] | ||
}).when("path2", { | ||
controller: ['$scope', function($scope) { b }], | ||
resolve: { | ||
zero: function() { a }, | ||
more: ['$scope', '$timeout', function($scope, $timeout) { b }], | ||
something: "else", | ||
}, | ||
dontAlterMe: function(arg) {}, | ||
}); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
zero: function() { | ||
a; | ||
simpleObj: function() { a }, | ||
promiseObj: ['$scope', '$timeout', function($scope, $timeout) { b }], | ||
translations: "translations", | ||
}, | ||
views: { | ||
viewa: { | ||
controller: ['$scope', 'myParam', function($scope, myParam) {}], | ||
controllerProvider: ['$stateParams', function($stateParams) {}], | ||
templateProvider: ['$scope', function($scope) {}], | ||
dontAlterMe: function(arg) {}, | ||
resolve: { | ||
myParam: ['$stateParams', function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
}] | ||
}, | ||
}, | ||
more: ['$scope', '$timeout', function($scope, $timeout) { | ||
b; | ||
}], | ||
something: "else", | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: ['$scope', function($scope) {}], | ||
controller: ['$scope', function($scope) {}], | ||
}, | ||
dontAlterMe: null, | ||
}, | ||
dontAlterMe: function(arg) {}, | ||
}); | ||
controller: ['$scope', 'simpleObj', 'promiseObj', 'translations', function($scope, simpleObj, promiseObj, translations) { c }], | ||
controllerProvider: ['$scope', function($scope) { g }], | ||
templateProvider: ['$scope', function($scope) { h }], | ||
onEnter: ['$scope', function($scope) { d }], | ||
onExit: ['$scope', function($scope) { e }], | ||
dontAlterMe: function(arg) { f }, | ||
}).state("myState2", { | ||
controller: ['$scope', function($scope) {}], | ||
}).state({ | ||
name: "myState3", | ||
controller: ['$scope', 'simpleObj', 'promiseObj', 'translations', function($scope, simpleObj, promiseObj, translations) { c }], | ||
}); | ||
$urlRouterProvider.when("/", ['$match', function($match) { a; }]); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", ['$location', function($location) { a; }]); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
simpleObj: function() { | ||
a; | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: ['$scope', function($scope) {}], | ||
resolve: { | ||
items: ['MyService', function(MyService) {}], | ||
data: ['a', 'b', function(a, b) {}], | ||
its: 42, | ||
}, | ||
donttouch: function(me) {}, | ||
}); | ||
}); | ||
promiseObj: ['$scope', '$timeout', function($scope, $timeout) { | ||
b; | ||
}], | ||
// none of the patterns below matches because they are not in an angular module context | ||
// this should be a straight copy of the code above, with identical copies in | ||
// with_annotations(_single).js | ||
foobar.irrespective("dontmatchthis", function() { | ||
translations: "translations", | ||
}, | ||
views: { | ||
viewa: { | ||
controller: ['$scope', 'myParam', function($scope, myParam) {}], | ||
templateProvider: ['$scope', function($scope) {}], | ||
dontAlterMe: function(arg) {}, | ||
// $httpProvider | ||
$httpProvider.interceptors.push(function($scope) { a }); | ||
$httpProvider.responseInterceptors.push(function($scope) { a }, function(a, b) { b }, function() { c }); | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: function($scope) { a } | ||
}).when("path2", { | ||
controller: function($scope) { b }, | ||
resolve: { | ||
myParam: ['$stateParams', function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
}] | ||
zero: function() { a }, | ||
more: function($scope, $timeout) { b }, | ||
something: "else", | ||
}, | ||
}, | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: ['$scope', function($scope) {}], | ||
controller: ['$scope', function($scope) {}], | ||
}); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
simpleObj: function() { a }, | ||
promiseObj: function($scope, $timeout) { b }, | ||
translations: "translations", | ||
}, | ||
dontAlterMe: null, | ||
}, | ||
controller: ['$scope', 'simpleObj', 'promiseObj', 'translations', function($scope, simpleObj, promiseObj, translations) { | ||
c; | ||
}], | ||
controllerProvider: ['$scope', function($scope) { | ||
g; | ||
}], | ||
templateProvider: ['$scope', function($scope) { | ||
h; | ||
}], | ||
onEnter: ['$scope', function($scope) { | ||
d; | ||
}], | ||
onExit: ['$scope', function($scope) { | ||
e; | ||
}], | ||
dontAlterMe: function(arg) { | ||
f; | ||
}, | ||
}).state("myState2", { | ||
controller: ['$scope', function($scope) {}], | ||
}).state({ | ||
name: "myState3", | ||
controller: ['$scope', 'simpleObj', 'promiseObj', 'translations', function($scope, simpleObj, promiseObj, translations) { | ||
c; | ||
}], | ||
}); | ||
$urlRouterProvider.when("/", ['$match', function($match) { a; }]); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", ['$location', function($location) { a; }]); | ||
views: { | ||
viewa: { | ||
controller: function($scope, myParam) {}, | ||
controllerProvider: function($stateParams) {}, | ||
templateProvider: function($scope) {}, | ||
dontAlterMe: function(arg) {}, | ||
resolve: { | ||
myParam: function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
} | ||
}, | ||
}, | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: function($scope) {}, | ||
controller: function($scope) {}, | ||
}, | ||
dontAlterMe: null, | ||
}, | ||
controller: function($scope, simpleObj, promiseObj, translations) { c }, | ||
controllerProvider: function($scope) { g }, | ||
templateProvider: function($scope) { h }, | ||
onEnter: function($scope) { d }, | ||
onExit: function($scope) { e }, | ||
dontAlterMe: function(arg) { f }, | ||
}).state("myState2", { | ||
controller: function($scope) {}, | ||
}).state({ | ||
name: "myState3", | ||
controller: function($scope, simpleObj, promiseObj, translations) { c }, | ||
}); | ||
$urlRouterProvider.when("/", function($match) { a; }); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", function($location) { a; }); | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: ['$scope', function($scope) {}], | ||
resolve: { | ||
items: ['MyService', function(MyService) {}], | ||
data: ['a', 'b', function(a, b) {}], | ||
its: 42, | ||
}, | ||
donttouch: function(me) {}, | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: function($scope) {}, | ||
resolve: { | ||
items: function(MyService) {}, | ||
data: function(a, b) {}, | ||
its: 42, | ||
}, | ||
donttouch: function(me) {}, | ||
}); | ||
}); | ||
@@ -300,1 +352,58 @@ | ||
foo.$injects = ['$scope']; | ||
// let's zip-zag indentation to make sure that the $injects array lines up properly | ||
// @ngInject | ||
function foo($scope) {} | ||
foo.$injects = ['$scope']; | ||
// @ngInject | ||
function foo($scope) { | ||
} | ||
foo.$injects = ['$scope']; | ||
/* @ngInject */ function foo($scope) {} | ||
foo.$injects = ['$scope']; | ||
/* @ngInject */ function foo($scope) { | ||
} | ||
foo.$injects = ['$scope']; | ||
// @ngInject | ||
var foo = function($scope) { | ||
}; | ||
foo.$injects = ['$scope']; | ||
// @ngInject | ||
var foo = function($scope) {}; | ||
foo.$injects = ['$scope']; | ||
// @ngInject | ||
var foo = function($scope) { | ||
} | ||
foo.$injects = ['$scope']; | ||
// @ngInject | ||
var foo = function($scope) {} | ||
foo.$injects = ['$scope']; | ||
/* @ngInject */ var foo = function($scope) { | ||
}; | ||
foo.$injects = ['$scope']; | ||
/* @ngInject */var foo = function($scope) {}; | ||
foo.$injects = ['$scope']; | ||
/* @ngInject */var foo = function($scope) { | ||
} | ||
foo.$injects = ['$scope']; | ||
/* @ngInject */var foo = function($scope) {} | ||
foo.$injects = ['$scope']; | ||
// adding an explicit annotation where it isn't needed should work fine | ||
myMod.controller("foo", /*@ngInject*/ ['$scope', '$timeout', function($scope, $timeout) { | ||
}]); | ||
// snippets that shouldn't fool ng-annotate into generating false positives, | ||
// whether we're inside an angular module or not | ||
myMod.controller("donttouchme", function() { | ||
// lo-dash regression that happened in the brief time frame when | ||
// notes (instad of "notes") would match. see issue #22 | ||
var notesForCurrentPage = _.filter(notes, function (note) { | ||
return note.page.uid === page.uid; | ||
}); | ||
}); |
@@ -153,101 +153,153 @@ "use strict"; | ||
// $httpProvider | ||
$httpProvider.interceptors.push(["$scope", function($scope) { a }]); | ||
$httpProvider.responseInterceptors.push(["$scope", function($scope) { a }], ["a", "b", function(a, b) { b }], function() { c }); | ||
var interceptor = /*@ngInject*/ ["$scope", function($scope) { a }]; | ||
$httpProvider.interceptors.push(interceptor); | ||
// all the patterns below matches only when we're inside a detected angular module | ||
angular.module("MyMod").directive("pleasematchthis", function() { | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: ["$scope", function($scope) { | ||
a; | ||
}] | ||
}).when("path2", { | ||
controller: ["$scope", function($scope) { | ||
b; | ||
}], | ||
// $httpProvider | ||
$httpProvider.interceptors.push(["$scope", function($scope) { a }]); | ||
$httpProvider.responseInterceptors.push(["$scope", function($scope) { a }], ["a", "b", function(a, b) { b }], function() { c }); | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: ["$scope", function($scope) { a }] | ||
}).when("path2", { | ||
controller: ["$scope", function($scope) { b }], | ||
resolve: { | ||
zero: function() { a }, | ||
more: ["$scope", "$timeout", function($scope, $timeout) { b }], | ||
something: "else", | ||
}, | ||
dontAlterMe: function(arg) {}, | ||
}); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
zero: function() { | ||
a; | ||
simpleObj: function() { a }, | ||
promiseObj: ["$scope", "$timeout", function($scope, $timeout) { b }], | ||
translations: "translations", | ||
}, | ||
views: { | ||
viewa: { | ||
controller: ["$scope", "myParam", function($scope, myParam) {}], | ||
controllerProvider: ["$stateParams", function($stateParams) {}], | ||
templateProvider: ["$scope", function($scope) {}], | ||
dontAlterMe: function(arg) {}, | ||
resolve: { | ||
myParam: ["$stateParams", function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
}] | ||
}, | ||
}, | ||
more: ["$scope", "$timeout", function($scope, $timeout) { | ||
b; | ||
}], | ||
something: "else", | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: ["$scope", function($scope) {}], | ||
controller: ["$scope", function($scope) {}], | ||
}, | ||
dontAlterMe: null, | ||
}, | ||
dontAlterMe: function(arg) {}, | ||
}); | ||
controller: ["$scope", "simpleObj", "promiseObj", "translations", function($scope, simpleObj, promiseObj, translations) { c }], | ||
controllerProvider: ["$scope", function($scope) { g }], | ||
templateProvider: ["$scope", function($scope) { h }], | ||
onEnter: ["$scope", function($scope) { d }], | ||
onExit: ["$scope", function($scope) { e }], | ||
dontAlterMe: function(arg) { f }, | ||
}).state("myState2", { | ||
controller: ["$scope", function($scope) {}], | ||
}).state({ | ||
name: "myState3", | ||
controller: ["$scope", "simpleObj", "promiseObj", "translations", function($scope, simpleObj, promiseObj, translations) { c }], | ||
}); | ||
$urlRouterProvider.when("/", ["$match", function($match) { a; }]); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", ["$location", function($location) { a; }]); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
simpleObj: function() { | ||
a; | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: ["$scope", function($scope) {}], | ||
resolve: { | ||
items: ["MyService", function(MyService) {}], | ||
data: ["a", "b", function(a, b) {}], | ||
its: 42, | ||
}, | ||
donttouch: function(me) {}, | ||
}); | ||
}); | ||
promiseObj: ["$scope", "$timeout", function($scope, $timeout) { | ||
b; | ||
}], | ||
// none of the patterns below matches because they are not in an angular module context | ||
// this should be a straight copy of the code above, with identical copies in | ||
// with_annotations(_single).js | ||
foobar.irrespective("dontmatchthis", function() { | ||
translations: "translations", | ||
}, | ||
views: { | ||
viewa: { | ||
controller: ["$scope", "myParam", function($scope, myParam) {}], | ||
templateProvider: ["$scope", function($scope) {}], | ||
dontAlterMe: function(arg) {}, | ||
// $httpProvider | ||
$httpProvider.interceptors.push(function($scope) { a }); | ||
$httpProvider.responseInterceptors.push(function($scope) { a }, function(a, b) { b }, function() { c }); | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: function($scope) { a } | ||
}).when("path2", { | ||
controller: function($scope) { b }, | ||
resolve: { | ||
myParam: ["$stateParams", function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
}] | ||
zero: function() { a }, | ||
more: function($scope, $timeout) { b }, | ||
something: "else", | ||
}, | ||
}, | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: ["$scope", function($scope) {}], | ||
controller: ["$scope", function($scope) {}], | ||
}); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
simpleObj: function() { a }, | ||
promiseObj: function($scope, $timeout) { b }, | ||
translations: "translations", | ||
}, | ||
dontAlterMe: null, | ||
}, | ||
controller: ["$scope", "simpleObj", "promiseObj", "translations", function($scope, simpleObj, promiseObj, translations) { | ||
c; | ||
}], | ||
controllerProvider: ["$scope", function($scope) { | ||
g; | ||
}], | ||
templateProvider: ["$scope", function($scope) { | ||
h; | ||
}], | ||
onEnter: ["$scope", function($scope) { | ||
d; | ||
}], | ||
onExit: ["$scope", function($scope) { | ||
e; | ||
}], | ||
dontAlterMe: function(arg) { | ||
f; | ||
}, | ||
}).state("myState2", { | ||
controller: ["$scope", function($scope) {}], | ||
}).state({ | ||
name: "myState3", | ||
controller: ["$scope", "simpleObj", "promiseObj", "translations", function($scope, simpleObj, promiseObj, translations) { | ||
c; | ||
}], | ||
}); | ||
$urlRouterProvider.when("/", ["$match", function($match) { a; }]); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", ["$location", function($location) { a; }]); | ||
views: { | ||
viewa: { | ||
controller: function($scope, myParam) {}, | ||
controllerProvider: function($stateParams) {}, | ||
templateProvider: function($scope) {}, | ||
dontAlterMe: function(arg) {}, | ||
resolve: { | ||
myParam: function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
} | ||
}, | ||
}, | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: function($scope) {}, | ||
controller: function($scope) {}, | ||
}, | ||
dontAlterMe: null, | ||
}, | ||
controller: function($scope, simpleObj, promiseObj, translations) { c }, | ||
controllerProvider: function($scope) { g }, | ||
templateProvider: function($scope) { h }, | ||
onEnter: function($scope) { d }, | ||
onExit: function($scope) { e }, | ||
dontAlterMe: function(arg) { f }, | ||
}).state("myState2", { | ||
controller: function($scope) {}, | ||
}).state({ | ||
name: "myState3", | ||
controller: function($scope, simpleObj, promiseObj, translations) { c }, | ||
}); | ||
$urlRouterProvider.when("/", function($match) { a; }); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", function($location) { a; }); | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: ["$scope", function($scope) {}], | ||
resolve: { | ||
items: ["MyService", function(MyService) {}], | ||
data: ["a", "b", function(a, b) {}], | ||
its: 42, | ||
}, | ||
donttouch: function(me) {}, | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: function($scope) {}, | ||
resolve: { | ||
items: function(MyService) {}, | ||
data: function(a, b) {}, | ||
its: 42, | ||
}, | ||
donttouch: function(me) {}, | ||
}); | ||
}); | ||
@@ -300,1 +352,58 @@ | ||
foo.$injects = ["$scope"]; | ||
// let's zip-zag indentation to make sure that the $injects array lines up properly | ||
// @ngInject | ||
function foo($scope) {} | ||
foo.$injects = ["$scope"]; | ||
// @ngInject | ||
function foo($scope) { | ||
} | ||
foo.$injects = ["$scope"]; | ||
/* @ngInject */ function foo($scope) {} | ||
foo.$injects = ["$scope"]; | ||
/* @ngInject */ function foo($scope) { | ||
} | ||
foo.$injects = ["$scope"]; | ||
// @ngInject | ||
var foo = function($scope) { | ||
}; | ||
foo.$injects = ["$scope"]; | ||
// @ngInject | ||
var foo = function($scope) {}; | ||
foo.$injects = ["$scope"]; | ||
// @ngInject | ||
var foo = function($scope) { | ||
} | ||
foo.$injects = ["$scope"]; | ||
// @ngInject | ||
var foo = function($scope) {} | ||
foo.$injects = ["$scope"]; | ||
/* @ngInject */ var foo = function($scope) { | ||
}; | ||
foo.$injects = ["$scope"]; | ||
/* @ngInject */var foo = function($scope) {}; | ||
foo.$injects = ["$scope"]; | ||
/* @ngInject */var foo = function($scope) { | ||
} | ||
foo.$injects = ["$scope"]; | ||
/* @ngInject */var foo = function($scope) {} | ||
foo.$injects = ["$scope"]; | ||
// adding an explicit annotation where it isn't needed should work fine | ||
myMod.controller("foo", /*@ngInject*/ ["$scope", "$timeout", function($scope, $timeout) { | ||
}]); | ||
// snippets that shouldn't fool ng-annotate into generating false positives, | ||
// whether we're inside an angular module or not | ||
myMod.controller("donttouchme", function() { | ||
// lo-dash regression that happened in the brief time frame when | ||
// notes (instad of "notes") would match. see issue #22 | ||
var notesForCurrentPage = _.filter(notes, function (note) { | ||
return note.page.uid === page.uid; | ||
}); | ||
}); |
@@ -0,1 +1,7 @@ | ||
## v0.9.4 2014-05-19 | ||
* stricter match: only match code inside of angular modules (except explicit) | ||
* ui-router declarations improvements | ||
* bugfix duplicated injects array in case of redundant /* @ngInject */ | ||
* indent generated fn.$injects = [..] arrays nicely | ||
## v0.9.3 2014-05-16 | ||
@@ -2,0 +8,0 @@ * /* @ngInject */ object literal support |
@@ -37,4 +37,2 @@ // ng-annotate-main.js | ||
function matchDirectiveReturnObject(node) { | ||
// TODO make these more strict by checking that we're inside an angular module? | ||
// return { .. controller: function($scope, $timeout), ...} | ||
@@ -48,4 +46,2 @@ | ||
function matchProviderGet(node) { | ||
// TODO make these more strict by checking that we're inside an angular module? | ||
// (this|self|that).$get = function($scope, $timeout) | ||
@@ -112,3 +108,3 @@ // { ... $get: function($scope, $timeout), ...} | ||
// $stateProvider.state("myState", {... resolve: {f: function($scope) {}, ..} ..}) | ||
// $stateProvider.state("myState", {... views: {... somename: {... controller: fn, templateProvider: fn, resolve: {f: fn}}}}) | ||
// $stateProvider.state("myState", {... views: {... somename: {... controller: fn, controllerProvider: fn, templateProvider: fn, resolve: {f: fn}}}}) | ||
// | ||
@@ -182,2 +178,3 @@ // $urlRouterProvider.when(.., function($scope) {}) | ||
res.push(matchProp("controller", prop.value.properties)); | ||
res.push(matchProp("controllerProvider", prop.value.properties)); | ||
res.push(matchProp("templateProvider", prop.value.properties)); | ||
@@ -226,5 +223,10 @@ res.push.apply(res, matchResolve(prop.value.properties)); | ||
const args = node.arguments; | ||
return (is.someof(method.name, ["config", "run"]) ? | ||
const target = (is.someof(method.name, ["config", "run"]) ? | ||
args.length === 1 && args[0] : | ||
args.length === 2 && args[0].type === "Literal" && is.string(args[0].value) && args[1]); | ||
if (target) { | ||
target.$always = true; | ||
} | ||
return target; | ||
} | ||
@@ -327,3 +329,4 @@ | ||
function replaceRemoveOrInsertArrayForTarget(target, ctx) { | ||
function judgeSuspects(ctx) { | ||
const suspects = ctx.suspects; | ||
const mode = ctx.mode; | ||
@@ -333,14 +336,38 @@ const fragments = ctx.fragments; | ||
if (mode === "rebuild" && isAnnotatedArray(target)) { | ||
replaceArray(target, fragments, quot); | ||
} else if (mode === "remove" && isAnnotatedArray(target)) { | ||
removeArray(target, fragments); | ||
} else if (is.someof(mode, ["add", "rebuild"]) && isFunctionExpressionWithArgs(target)) { | ||
insertArray(target, fragments, quot); | ||
} else { | ||
return false; | ||
for (let i = 0; i < suspects.length; i++) { | ||
const target = suspects[i]; | ||
if (target.$once) { | ||
continue; | ||
} | ||
target.$once = true; | ||
if (!target.$always) { | ||
let $caller = target.$caller; | ||
for (; $caller && $caller.$chained !== chainedRegular; $caller = $caller.$caller) { | ||
} | ||
if (!$caller) { | ||
continue; | ||
} | ||
} | ||
if (mode === "rebuild" && isAnnotatedArray(target)) { | ||
replaceArray(target, fragments, quot); | ||
} else if (mode === "remove" && isAnnotatedArray(target)) { | ||
removeArray(target, fragments); | ||
} else if (is.someof(mode, ["add", "rebuild"]) && isFunctionExpressionWithArgs(target)) { | ||
insertArray(target, fragments, quot); | ||
} | ||
} | ||
return true; | ||
} | ||
function addModuleContextDependentSuspect(target, ctx) { | ||
ctx.suspects.push(target); | ||
} | ||
function addModuleContextIndependentSuspect(target, ctx) { | ||
target.$always = true; | ||
ctx.suspects.push(target); | ||
} | ||
function isAnnotatedArray(node) { | ||
@@ -408,2 +435,10 @@ return node.type === "ArrayExpression" && node.elements.length >= 1 && last(node.elements).type === "FunctionExpression"; | ||
// suspects is built up with suspect nodes by match. | ||
// A suspect node will get annotations added / removed if it | ||
// fulfills the arrayexpression or functionexpression look, | ||
// and if it is in the correct context (inside an angular | ||
// module definition) - alternatively is forced to ignore | ||
// context with node.$always = true | ||
const suspects = []; | ||
const ctx = { | ||
@@ -416,6 +451,8 @@ mode: mode, | ||
triggers: triggers, | ||
suspects: suspects, | ||
isFunctionExpressionWithArgs: isFunctionExpressionWithArgs, | ||
isFunctionDeclarationWithArgs: isFunctionDeclarationWithArgs, | ||
isAnnotatedArray: isAnnotatedArray, | ||
replaceRemoveOrInsertArrayForTarget: replaceRemoveOrInsertArrayForTarget, | ||
addModuleContextDependentSuspect: addModuleContextDependentSuspect, | ||
addModuleContextIndependentSuspect: addModuleContextIndependentSuspect, | ||
stringify: stringify, | ||
@@ -441,3 +478,11 @@ }; | ||
let recentCaller = undefined; // micro-optimization | ||
const callerIds = []; | ||
traverse(ast, {pre: function(node) { | ||
node.$caller = recentCaller; | ||
if (node.type === "CallExpression") { | ||
callerIds.push(node); | ||
recentCaller = node; | ||
} | ||
const pos = node.range[0]; | ||
@@ -449,2 +494,7 @@ while (pos >= triggers.pos) { | ||
}, post: function(node) { | ||
if (node === recentCaller) { | ||
callerIds.pop(); | ||
recentCaller = last(callerIds); | ||
} | ||
let targets = match(node, re, matchPluginsOrNull); | ||
@@ -458,8 +508,9 @@ if (!targets) { | ||
// TODO add something to know that node has been altered so it won't happen again | ||
for (let i = 0; i < targets.length; i++) { | ||
replaceRemoveOrInsertArrayForTarget(targets[i], ctx); | ||
addModuleContextDependentSuspect(targets[i], ctx); | ||
} | ||
}}); | ||
judgeSuspects(ctx); | ||
const out = alter(src, fragments); | ||
@@ -466,0 +517,0 @@ |
@@ -45,3 +45,4 @@ "use strict"; | ||
// handle most common case: /*@ngInject*/ prepended to an array or function expression | ||
if (ctx.replaceRemoveOrInsertArrayForTarget(node, ctx)) { | ||
if (node.type === "ArrayExpression" || node.type === "FunctionExpression") { | ||
ctx.addModuleContextIndependentSuspect(node, ctx); | ||
return; | ||
@@ -52,3 +53,3 @@ } | ||
nestedObjectValues(node).forEach(function(n) { | ||
ctx.replaceRemoveOrInsertArrayForTarget(n, ctx); | ||
ctx.addModuleContextIndependentSuspect(n, ctx); | ||
}); | ||
@@ -70,5 +71,14 @@ return; | ||
function getIndent(pos) { | ||
const src = ctx.src; | ||
const lineStart = src.lastIndexOf("\n", pos - 1) + 1; | ||
let i = lineStart; | ||
for (; src[i] === " " || src[i] === "\t"; i++) { | ||
} | ||
return src.slice(lineStart, i); | ||
} | ||
function addRemoveInjectsArray(params, posAfterFunctionDeclaration, name) { | ||
const str = fmt("\n{0}.$injects = {1};", name, ctx.stringify(params, ctx.quot)); | ||
const indent = getIndent(posAfterFunctionDeclaration); | ||
const str = fmt("\n{0}{1}.$injects = {2};", indent, name, ctx.stringify(params, ctx.quot)); | ||
@@ -75,0 +85,0 @@ ctx.triggers.add({ |
{ | ||
"name": "ng-annotate", | ||
"version": "0.9.3", | ||
"version": "0.9.4", | ||
"description": "add, remove and rebuild angularjs dependency injection annotations", | ||
@@ -5,0 +5,0 @@ "main": "build/es5/ng-annotate-main.js", |
@@ -153,103 +153,155 @@ "use strict"; | ||
// $httpProvider | ||
$httpProvider.interceptors.push(function($scope) { a }); | ||
$httpProvider.responseInterceptors.push(function($scope) { a }, function(a, b) { b }, function() { c }); | ||
var interceptor = /*@ngInject*/ function($scope) { a }; | ||
$httpProvider.interceptors.push(interceptor); | ||
// all the patterns below matches only when we're inside a detected angular module | ||
angular.module("MyMod").directive("pleasematchthis", function() { | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: function($scope) { | ||
a; | ||
} | ||
}).when("path2", { | ||
controller: function($scope) { | ||
b; | ||
// $httpProvider | ||
$httpProvider.interceptors.push(function($scope) { a }); | ||
$httpProvider.responseInterceptors.push(function($scope) { a }, function(a, b) { b }, function() { c }); | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: function($scope) { a } | ||
}).when("path2", { | ||
controller: function($scope) { b }, | ||
resolve: { | ||
zero: function() { a }, | ||
more: function($scope, $timeout) { b }, | ||
something: "else", | ||
}, | ||
dontAlterMe: function(arg) {}, | ||
}); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
simpleObj: function() { a }, | ||
promiseObj: function($scope, $timeout) { b }, | ||
translations: "translations", | ||
}, | ||
resolve: { | ||
zero: function() { | ||
a; | ||
views: { | ||
viewa: { | ||
controller: function($scope, myParam) {}, | ||
controllerProvider: function($stateParams) {}, | ||
templateProvider: function($scope) {}, | ||
dontAlterMe: function(arg) {}, | ||
resolve: { | ||
myParam: function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
} | ||
}, | ||
}, | ||
more: function($scope, $timeout) { | ||
b; | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: function($scope) {}, | ||
controller: function($scope) {}, | ||
}, | ||
something: "else", | ||
dontAlterMe: null, | ||
}, | ||
dontAlterMe: function(arg) {}, | ||
}); | ||
controller: function($scope, simpleObj, promiseObj, translations) { c }, | ||
controllerProvider: function($scope) { g }, | ||
templateProvider: function($scope) { h }, | ||
onEnter: function($scope) { d }, | ||
onExit: function($scope) { e }, | ||
dontAlterMe: function(arg) { f }, | ||
}).state("myState2", { | ||
controller: function($scope) {}, | ||
}).state({ | ||
name: "myState3", | ||
controller: function($scope, simpleObj, promiseObj, translations) { c }, | ||
}); | ||
$urlRouterProvider.when("/", function($match) { a; }); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", function($location) { a; }); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
simpleObj: function() { | ||
a; | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: function($scope) {}, | ||
resolve: { | ||
items: function(MyService) {}, | ||
data: function(a, b) {}, | ||
its: 42, | ||
}, | ||
donttouch: function(me) {}, | ||
}); | ||
}); | ||
promiseObj: function($scope, $timeout) { | ||
b; | ||
}, | ||
// none of the patterns below matches because they are not in an angular module context | ||
// this should be a straight copy of the code above, with identical copies in | ||
// with_annotations(_single).js | ||
foobar.irrespective("dontmatchthis", function() { | ||
translations: "translations", | ||
}, | ||
views: { | ||
viewa: { | ||
controller: function($scope, myParam) {}, | ||
templateProvider: function($scope) {}, | ||
dontAlterMe: function(arg) {}, | ||
// $httpProvider | ||
$httpProvider.interceptors.push(function($scope) { a }); | ||
$httpProvider.responseInterceptors.push(function($scope) { a }, function(a, b) { b }, function() { c }); | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: function($scope) { a } | ||
}).when("path2", { | ||
controller: function($scope) { b }, | ||
resolve: { | ||
myParam: function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
} | ||
zero: function() { a }, | ||
more: function($scope, $timeout) { b }, | ||
something: "else", | ||
}, | ||
dontAlterMe: function(arg) {}, | ||
}); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
simpleObj: function() { a }, | ||
promiseObj: function($scope, $timeout) { b }, | ||
translations: "translations", | ||
}, | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: function($scope) {}, | ||
views: { | ||
viewa: { | ||
controller: function($scope, myParam) {}, | ||
controllerProvider: function($stateParams) {}, | ||
templateProvider: function($scope) {}, | ||
dontAlterMe: function(arg) {}, | ||
resolve: { | ||
myParam: function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
} | ||
}, | ||
}, | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: function($scope) {}, | ||
controller: function($scope) {}, | ||
}, | ||
dontAlterMe: null, | ||
}, | ||
controller: function($scope, simpleObj, promiseObj, translations) { c }, | ||
controllerProvider: function($scope) { g }, | ||
templateProvider: function($scope) { h }, | ||
onEnter: function($scope) { d }, | ||
onExit: function($scope) { e }, | ||
dontAlterMe: function(arg) { f }, | ||
}).state("myState2", { | ||
controller: function($scope) {}, | ||
}).state({ | ||
name: "myState3", | ||
controller: function($scope, simpleObj, promiseObj, translations) { c }, | ||
}); | ||
$urlRouterProvider.when("/", function($match) { a; }); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", function($location) { a; }); | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: function($scope) {}, | ||
resolve: { | ||
items: function(MyService) {}, | ||
data: function(a, b) {}, | ||
its: 42, | ||
}, | ||
dontAlterMe: null, | ||
}, | ||
controller: function($scope, simpleObj, promiseObj, translations) { | ||
c; | ||
}, | ||
controllerProvider: function($scope) { | ||
g; | ||
}, | ||
templateProvider: function($scope) { | ||
h; | ||
}, | ||
onEnter: function($scope) { | ||
d; | ||
}, | ||
onExit: function($scope) { | ||
e; | ||
}, | ||
dontAlterMe: function(arg) { | ||
f; | ||
}, | ||
}).state("myState2", { | ||
controller: function($scope) {}, | ||
}).state({ | ||
name: "myState3", | ||
controller: function($scope, simpleObj, promiseObj, translations) { | ||
c; | ||
}, | ||
donttouch: function(me) {}, | ||
}); | ||
}); | ||
$urlRouterProvider.when("/", function($match) { a; }); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", function($location) { a; }); | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: function($scope) {}, | ||
resolve: { | ||
items: function(MyService) {}, | ||
data: function(a, b) {}, | ||
its: 42, | ||
}, | ||
donttouch: function(me) {}, | ||
}); | ||
// explicit annotations | ||
@@ -296,1 +348,46 @@ var x = /* @ngInject */ function($scope) { | ||
} | ||
// let's zip-zag indentation to make sure that the $injects array lines up properly | ||
// @ngInject | ||
function foo($scope) {} | ||
// @ngInject | ||
function foo($scope) { | ||
} | ||
/* @ngInject */ function foo($scope) {} | ||
/* @ngInject */ function foo($scope) { | ||
} | ||
// @ngInject | ||
var foo = function($scope) { | ||
}; | ||
// @ngInject | ||
var foo = function($scope) {}; | ||
// @ngInject | ||
var foo = function($scope) { | ||
} | ||
// @ngInject | ||
var foo = function($scope) {} | ||
/* @ngInject */ var foo = function($scope) { | ||
}; | ||
/* @ngInject */var foo = function($scope) {}; | ||
/* @ngInject */var foo = function($scope) { | ||
} | ||
/* @ngInject */var foo = function($scope) {} | ||
// adding an explicit annotation where it isn't needed should work fine | ||
myMod.controller("foo", /*@ngInject*/ function($scope, $timeout) { | ||
}); | ||
// snippets that shouldn't fool ng-annotate into generating false positives, | ||
// whether we're inside an angular module or not | ||
myMod.controller("donttouchme", function() { | ||
// lo-dash regression that happened in the brief time frame when | ||
// notes (instad of "notes") would match. see issue #22 | ||
var notesForCurrentPage = _.filter(notes, function (note) { | ||
return note.page.uid === page.uid; | ||
}); | ||
}); |
@@ -153,101 +153,153 @@ "use strict"; | ||
// $httpProvider | ||
$httpProvider.interceptors.push(['$scope', function($scope) { a }]); | ||
$httpProvider.responseInterceptors.push(['$scope', function($scope) { a }], ['a', 'b', function(a, b) { b }], function() { c }); | ||
var interceptor = /*@ngInject*/ ['$scope', function($scope) { a }]; | ||
$httpProvider.interceptors.push(interceptor); | ||
// all the patterns below matches only when we're inside a detected angular module | ||
angular.module("MyMod").directive("pleasematchthis", function() { | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: ['$scope', function($scope) { | ||
a; | ||
}] | ||
}).when("path2", { | ||
controller: ['$scope', function($scope) { | ||
b; | ||
}], | ||
// $httpProvider | ||
$httpProvider.interceptors.push(['$scope', function($scope) { a }]); | ||
$httpProvider.responseInterceptors.push(['$scope', function($scope) { a }], ['a', 'b', function(a, b) { b }], function() { c }); | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: ['$scope', function($scope) { a }] | ||
}).when("path2", { | ||
controller: ['$scope', function($scope) { b }], | ||
resolve: { | ||
zero: function() { a }, | ||
more: ['$scope', '$timeout', function($scope, $timeout) { b }], | ||
something: "else", | ||
}, | ||
dontAlterMe: function(arg) {}, | ||
}); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
zero: function() { | ||
a; | ||
simpleObj: function() { a }, | ||
promiseObj: ['$scope', '$timeout', function($scope, $timeout) { b }], | ||
translations: "translations", | ||
}, | ||
views: { | ||
viewa: { | ||
controller: ['$scope', 'myParam', function($scope, myParam) {}], | ||
controllerProvider: ['$stateParams', function($stateParams) {}], | ||
templateProvider: ['$scope', function($scope) {}], | ||
dontAlterMe: function(arg) {}, | ||
resolve: { | ||
myParam: ['$stateParams', function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
}] | ||
}, | ||
}, | ||
more: ['$scope', '$timeout', function($scope, $timeout) { | ||
b; | ||
}], | ||
something: "else", | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: ['$scope', function($scope) {}], | ||
controller: ['$scope', function($scope) {}], | ||
}, | ||
dontAlterMe: null, | ||
}, | ||
dontAlterMe: function(arg) {}, | ||
}); | ||
controller: ['$scope', 'simpleObj', 'promiseObj', 'translations', function($scope, simpleObj, promiseObj, translations) { c }], | ||
controllerProvider: ['$scope', function($scope) { g }], | ||
templateProvider: ['$scope', function($scope) { h }], | ||
onEnter: ['$scope', function($scope) { d }], | ||
onExit: ['$scope', function($scope) { e }], | ||
dontAlterMe: function(arg) { f }, | ||
}).state("myState2", { | ||
controller: ['$scope', function($scope) {}], | ||
}).state({ | ||
name: "myState3", | ||
controller: ['$scope', 'simpleObj', 'promiseObj', 'translations', function($scope, simpleObj, promiseObj, translations) { c }], | ||
}); | ||
$urlRouterProvider.when("/", ['$match', function($match) { a; }]); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", ['$location', function($location) { a; }]); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
simpleObj: function() { | ||
a; | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: ['$scope', function($scope) {}], | ||
resolve: { | ||
items: ['MyService', function(MyService) {}], | ||
data: ['a', 'b', function(a, b) {}], | ||
its: 42, | ||
}, | ||
donttouch: function(me) {}, | ||
}); | ||
}); | ||
promiseObj: ['$scope', '$timeout', function($scope, $timeout) { | ||
b; | ||
}], | ||
// none of the patterns below matches because they are not in an angular module context | ||
// this should be a straight copy of the code above, with identical copies in | ||
// with_annotations(_single).js | ||
foobar.irrespective("dontmatchthis", function() { | ||
translations: "translations", | ||
}, | ||
views: { | ||
viewa: { | ||
controller: ['$scope', 'myParam', function($scope, myParam) {}], | ||
templateProvider: ['$scope', function($scope) {}], | ||
dontAlterMe: function(arg) {}, | ||
// $httpProvider | ||
$httpProvider.interceptors.push(function($scope) { a }); | ||
$httpProvider.responseInterceptors.push(function($scope) { a }, function(a, b) { b }, function() { c }); | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: function($scope) { a } | ||
}).when("path2", { | ||
controller: function($scope) { b }, | ||
resolve: { | ||
myParam: ['$stateParams', function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
}] | ||
zero: function() { a }, | ||
more: function($scope, $timeout) { b }, | ||
something: "else", | ||
}, | ||
}, | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: ['$scope', function($scope) {}], | ||
controller: ['$scope', function($scope) {}], | ||
}); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
simpleObj: function() { a }, | ||
promiseObj: function($scope, $timeout) { b }, | ||
translations: "translations", | ||
}, | ||
dontAlterMe: null, | ||
}, | ||
controller: ['$scope', 'simpleObj', 'promiseObj', 'translations', function($scope, simpleObj, promiseObj, translations) { | ||
c; | ||
}], | ||
controllerProvider: ['$scope', function($scope) { | ||
g; | ||
}], | ||
templateProvider: ['$scope', function($scope) { | ||
h; | ||
}], | ||
onEnter: ['$scope', function($scope) { | ||
d; | ||
}], | ||
onExit: ['$scope', function($scope) { | ||
e; | ||
}], | ||
dontAlterMe: function(arg) { | ||
f; | ||
}, | ||
}).state("myState2", { | ||
controller: ['$scope', function($scope) {}], | ||
}).state({ | ||
name: "myState3", | ||
controller: ['$scope', 'simpleObj', 'promiseObj', 'translations', function($scope, simpleObj, promiseObj, translations) { | ||
c; | ||
}], | ||
}); | ||
$urlRouterProvider.when("/", ['$match', function($match) { a; }]); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", ['$location', function($location) { a; }]); | ||
views: { | ||
viewa: { | ||
controller: function($scope, myParam) {}, | ||
controllerProvider: function($stateParams) {}, | ||
templateProvider: function($scope) {}, | ||
dontAlterMe: function(arg) {}, | ||
resolve: { | ||
myParam: function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
} | ||
}, | ||
}, | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: function($scope) {}, | ||
controller: function($scope) {}, | ||
}, | ||
dontAlterMe: null, | ||
}, | ||
controller: function($scope, simpleObj, promiseObj, translations) { c }, | ||
controllerProvider: function($scope) { g }, | ||
templateProvider: function($scope) { h }, | ||
onEnter: function($scope) { d }, | ||
onExit: function($scope) { e }, | ||
dontAlterMe: function(arg) { f }, | ||
}).state("myState2", { | ||
controller: function($scope) {}, | ||
}).state({ | ||
name: "myState3", | ||
controller: function($scope, simpleObj, promiseObj, translations) { c }, | ||
}); | ||
$urlRouterProvider.when("/", function($match) { a; }); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", function($location) { a; }); | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: ['$scope', function($scope) {}], | ||
resolve: { | ||
items: ['MyService', function(MyService) {}], | ||
data: ['a', 'b', function(a, b) {}], | ||
its: 42, | ||
}, | ||
donttouch: function(me) {}, | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: function($scope) {}, | ||
resolve: { | ||
items: function(MyService) {}, | ||
data: function(a, b) {}, | ||
its: 42, | ||
}, | ||
donttouch: function(me) {}, | ||
}); | ||
}); | ||
@@ -300,1 +352,58 @@ | ||
foo.$injects = ['$scope']; | ||
// let's zip-zag indentation to make sure that the $injects array lines up properly | ||
// @ngInject | ||
function foo($scope) {} | ||
foo.$injects = ['$scope']; | ||
// @ngInject | ||
function foo($scope) { | ||
} | ||
foo.$injects = ['$scope']; | ||
/* @ngInject */ function foo($scope) {} | ||
foo.$injects = ['$scope']; | ||
/* @ngInject */ function foo($scope) { | ||
} | ||
foo.$injects = ['$scope']; | ||
// @ngInject | ||
var foo = function($scope) { | ||
}; | ||
foo.$injects = ['$scope']; | ||
// @ngInject | ||
var foo = function($scope) {}; | ||
foo.$injects = ['$scope']; | ||
// @ngInject | ||
var foo = function($scope) { | ||
} | ||
foo.$injects = ['$scope']; | ||
// @ngInject | ||
var foo = function($scope) {} | ||
foo.$injects = ['$scope']; | ||
/* @ngInject */ var foo = function($scope) { | ||
}; | ||
foo.$injects = ['$scope']; | ||
/* @ngInject */var foo = function($scope) {}; | ||
foo.$injects = ['$scope']; | ||
/* @ngInject */var foo = function($scope) { | ||
} | ||
foo.$injects = ['$scope']; | ||
/* @ngInject */var foo = function($scope) {} | ||
foo.$injects = ['$scope']; | ||
// adding an explicit annotation where it isn't needed should work fine | ||
myMod.controller("foo", /*@ngInject*/ ['$scope', '$timeout', function($scope, $timeout) { | ||
}]); | ||
// snippets that shouldn't fool ng-annotate into generating false positives, | ||
// whether we're inside an angular module or not | ||
myMod.controller("donttouchme", function() { | ||
// lo-dash regression that happened in the brief time frame when | ||
// notes (instad of "notes") would match. see issue #22 | ||
var notesForCurrentPage = _.filter(notes, function (note) { | ||
return note.page.uid === page.uid; | ||
}); | ||
}); |
@@ -153,101 +153,153 @@ "use strict"; | ||
// $httpProvider | ||
$httpProvider.interceptors.push(["$scope", function($scope) { a }]); | ||
$httpProvider.responseInterceptors.push(["$scope", function($scope) { a }], ["a", "b", function(a, b) { b }], function() { c }); | ||
var interceptor = /*@ngInject*/ ["$scope", function($scope) { a }]; | ||
$httpProvider.interceptors.push(interceptor); | ||
// all the patterns below matches only when we're inside a detected angular module | ||
angular.module("MyMod").directive("pleasematchthis", function() { | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: ["$scope", function($scope) { | ||
a; | ||
}] | ||
}).when("path2", { | ||
controller: ["$scope", function($scope) { | ||
b; | ||
}], | ||
// $httpProvider | ||
$httpProvider.interceptors.push(["$scope", function($scope) { a }]); | ||
$httpProvider.responseInterceptors.push(["$scope", function($scope) { a }], ["a", "b", function(a, b) { b }], function() { c }); | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: ["$scope", function($scope) { a }] | ||
}).when("path2", { | ||
controller: ["$scope", function($scope) { b }], | ||
resolve: { | ||
zero: function() { a }, | ||
more: ["$scope", "$timeout", function($scope, $timeout) { b }], | ||
something: "else", | ||
}, | ||
dontAlterMe: function(arg) {}, | ||
}); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
zero: function() { | ||
a; | ||
simpleObj: function() { a }, | ||
promiseObj: ["$scope", "$timeout", function($scope, $timeout) { b }], | ||
translations: "translations", | ||
}, | ||
views: { | ||
viewa: { | ||
controller: ["$scope", "myParam", function($scope, myParam) {}], | ||
controllerProvider: ["$stateParams", function($stateParams) {}], | ||
templateProvider: ["$scope", function($scope) {}], | ||
dontAlterMe: function(arg) {}, | ||
resolve: { | ||
myParam: ["$stateParams", function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
}] | ||
}, | ||
}, | ||
more: ["$scope", "$timeout", function($scope, $timeout) { | ||
b; | ||
}], | ||
something: "else", | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: ["$scope", function($scope) {}], | ||
controller: ["$scope", function($scope) {}], | ||
}, | ||
dontAlterMe: null, | ||
}, | ||
dontAlterMe: function(arg) {}, | ||
}); | ||
controller: ["$scope", "simpleObj", "promiseObj", "translations", function($scope, simpleObj, promiseObj, translations) { c }], | ||
controllerProvider: ["$scope", function($scope) { g }], | ||
templateProvider: ["$scope", function($scope) { h }], | ||
onEnter: ["$scope", function($scope) { d }], | ||
onExit: ["$scope", function($scope) { e }], | ||
dontAlterMe: function(arg) { f }, | ||
}).state("myState2", { | ||
controller: ["$scope", function($scope) {}], | ||
}).state({ | ||
name: "myState3", | ||
controller: ["$scope", "simpleObj", "promiseObj", "translations", function($scope, simpleObj, promiseObj, translations) { c }], | ||
}); | ||
$urlRouterProvider.when("/", ["$match", function($match) { a; }]); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", ["$location", function($location) { a; }]); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
simpleObj: function() { | ||
a; | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: ["$scope", function($scope) {}], | ||
resolve: { | ||
items: ["MyService", function(MyService) {}], | ||
data: ["a", "b", function(a, b) {}], | ||
its: 42, | ||
}, | ||
donttouch: function(me) {}, | ||
}); | ||
}); | ||
promiseObj: ["$scope", "$timeout", function($scope, $timeout) { | ||
b; | ||
}], | ||
// none of the patterns below matches because they are not in an angular module context | ||
// this should be a straight copy of the code above, with identical copies in | ||
// with_annotations(_single).js | ||
foobar.irrespective("dontmatchthis", function() { | ||
translations: "translations", | ||
}, | ||
views: { | ||
viewa: { | ||
controller: ["$scope", "myParam", function($scope, myParam) {}], | ||
templateProvider: ["$scope", function($scope) {}], | ||
dontAlterMe: function(arg) {}, | ||
// $httpProvider | ||
$httpProvider.interceptors.push(function($scope) { a }); | ||
$httpProvider.responseInterceptors.push(function($scope) { a }, function(a, b) { b }, function() { c }); | ||
// $routeProvider | ||
$routeProvider.when("path", { | ||
controller: function($scope) { a } | ||
}).when("path2", { | ||
controller: function($scope) { b }, | ||
resolve: { | ||
myParam: ["$stateParams", function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
}] | ||
zero: function() { a }, | ||
more: function($scope, $timeout) { b }, | ||
something: "else", | ||
}, | ||
}, | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: ["$scope", function($scope) {}], | ||
controller: ["$scope", function($scope) {}], | ||
}); | ||
// ui-router | ||
$stateProvider.state("myState", { | ||
resolve: { | ||
simpleObj: function() { a }, | ||
promiseObj: function($scope, $timeout) { b }, | ||
translations: "translations", | ||
}, | ||
dontAlterMe: null, | ||
}, | ||
controller: ["$scope", "simpleObj", "promiseObj", "translations", function($scope, simpleObj, promiseObj, translations) { | ||
c; | ||
}], | ||
controllerProvider: ["$scope", function($scope) { | ||
g; | ||
}], | ||
templateProvider: ["$scope", function($scope) { | ||
h; | ||
}], | ||
onEnter: ["$scope", function($scope) { | ||
d; | ||
}], | ||
onExit: ["$scope", function($scope) { | ||
e; | ||
}], | ||
dontAlterMe: function(arg) { | ||
f; | ||
}, | ||
}).state("myState2", { | ||
controller: ["$scope", function($scope) {}], | ||
}).state({ | ||
name: "myState3", | ||
controller: ["$scope", "simpleObj", "promiseObj", "translations", function($scope, simpleObj, promiseObj, translations) { | ||
c; | ||
}], | ||
}); | ||
$urlRouterProvider.when("/", ["$match", function($match) { a; }]); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", ["$location", function($location) { a; }]); | ||
views: { | ||
viewa: { | ||
controller: function($scope, myParam) {}, | ||
controllerProvider: function($stateParams) {}, | ||
templateProvider: function($scope) {}, | ||
dontAlterMe: function(arg) {}, | ||
resolve: { | ||
myParam: function($stateParams) { | ||
return $stateParams.paramFromDI; | ||
} | ||
}, | ||
}, | ||
viewb: { | ||
dontAlterMe: function(arg) {}, | ||
templateProvider: function($scope) {}, | ||
controller: function($scope) {}, | ||
}, | ||
dontAlterMe: null, | ||
}, | ||
controller: function($scope, simpleObj, promiseObj, translations) { c }, | ||
controllerProvider: function($scope) { g }, | ||
templateProvider: function($scope) { h }, | ||
onEnter: function($scope) { d }, | ||
onExit: function($scope) { e }, | ||
dontAlterMe: function(arg) { f }, | ||
}).state("myState2", { | ||
controller: function($scope) {}, | ||
}).state({ | ||
name: "myState3", | ||
controller: function($scope, simpleObj, promiseObj, translations) { c }, | ||
}); | ||
$urlRouterProvider.when("/", function($match) { a; }); | ||
$urlRouterProvider.otherwise("", function(a) { a; }); | ||
$urlRouterProvider.rule(function(a) { a; }).anything().when("/", function($location) { a; }); | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: ["$scope", function($scope) {}], | ||
resolve: { | ||
items: ["MyService", function(MyService) {}], | ||
data: ["a", "b", function(a, b) {}], | ||
its: 42, | ||
}, | ||
donttouch: function(me) {}, | ||
// angular ui / ui-bootstrap $modal | ||
$modal.open({ | ||
templateUrl: "str", | ||
controller: function($scope) {}, | ||
resolve: { | ||
items: function(MyService) {}, | ||
data: function(a, b) {}, | ||
its: 42, | ||
}, | ||
donttouch: function(me) {}, | ||
}); | ||
}); | ||
@@ -300,1 +352,58 @@ | ||
foo.$injects = ["$scope"]; | ||
// let's zip-zag indentation to make sure that the $injects array lines up properly | ||
// @ngInject | ||
function foo($scope) {} | ||
foo.$injects = ["$scope"]; | ||
// @ngInject | ||
function foo($scope) { | ||
} | ||
foo.$injects = ["$scope"]; | ||
/* @ngInject */ function foo($scope) {} | ||
foo.$injects = ["$scope"]; | ||
/* @ngInject */ function foo($scope) { | ||
} | ||
foo.$injects = ["$scope"]; | ||
// @ngInject | ||
var foo = function($scope) { | ||
}; | ||
foo.$injects = ["$scope"]; | ||
// @ngInject | ||
var foo = function($scope) {}; | ||
foo.$injects = ["$scope"]; | ||
// @ngInject | ||
var foo = function($scope) { | ||
} | ||
foo.$injects = ["$scope"]; | ||
// @ngInject | ||
var foo = function($scope) {} | ||
foo.$injects = ["$scope"]; | ||
/* @ngInject */ var foo = function($scope) { | ||
}; | ||
foo.$injects = ["$scope"]; | ||
/* @ngInject */var foo = function($scope) {}; | ||
foo.$injects = ["$scope"]; | ||
/* @ngInject */var foo = function($scope) { | ||
} | ||
foo.$injects = ["$scope"]; | ||
/* @ngInject */var foo = function($scope) {} | ||
foo.$injects = ["$scope"]; | ||
// adding an explicit annotation where it isn't needed should work fine | ||
myMod.controller("foo", /*@ngInject*/ ["$scope", "$timeout", function($scope, $timeout) { | ||
}]); | ||
// snippets that shouldn't fool ng-annotate into generating false positives, | ||
// whether we're inside an angular module or not | ||
myMod.controller("donttouchme", function() { | ||
// lo-dash regression that happened in the brief time frame when | ||
// notes (instad of "notes") would match. see issue #22 | ||
var notesForCurrentPage = _.filter(notes, function (note) { | ||
return note.page.uid === page.uid; | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
212623
5654