walkerFactory.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. extendStatics(d, b);
  11. function __() { this.constructor = d; }
  12. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13. };
  14. })();
  15. Object.defineProperty(exports, "__esModule", { value: true });
  16. var ngWalker_1 = require("../angular/ngWalker");
  17. function allNgComponent() {
  18. return new NgComponentWalkerBuilder();
  19. }
  20. exports.allNgComponent = allNgComponent;
  21. var Failure = (function () {
  22. function Failure(node, message) {
  23. this.node = node;
  24. this.message = message;
  25. }
  26. return Failure;
  27. }());
  28. exports.Failure = Failure;
  29. var NgComponentWalkerBuilder = (function () {
  30. function NgComponentWalkerBuilder() {
  31. }
  32. NgComponentWalkerBuilder.prototype.where = function (validate) {
  33. this._where = validate;
  34. return this;
  35. };
  36. NgComponentWalkerBuilder.prototype.build = function (sourceFile, options) {
  37. var self = this;
  38. var e = (function (_super) {
  39. __extends(class_1, _super);
  40. function class_1() {
  41. return _super !== null && _super.apply(this, arguments) || this;
  42. }
  43. class_1.prototype.visitNgComponent = function (meta) {
  44. var _this = this;
  45. self._where(meta).fmap(function (failure) { return _this.addFailureAtNode(failure.node, failure.message); });
  46. _super.prototype.visitNgComponent.call(this, meta);
  47. };
  48. return class_1;
  49. }(ngWalker_1.NgWalker));
  50. return new e(sourceFile, options);
  51. };
  52. return NgComponentWalkerBuilder;
  53. }());