ngast
Version:
Parsing tools for Angular. The project is an abstraction over the Angular compiler which provides friendly interface.
110 lines • 4.66 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { Symbol } from './symbol';
import { assertDeps, exists } from './utils';
var NgModuleSymbol = /** @class */ (function (_super) {
__extends(NgModuleSymbol, _super);
function NgModuleSymbol() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.annotation = 'NgModule';
return _this;
}
Object.defineProperty(NgModuleSymbol.prototype, "deps", {
/** @internal */
get: function () {
var _a;
return (_a = this.analysis) === null || _a === void 0 ? void 0 : _a.inj.deps;
},
enumerable: false,
configurable: true
});
Object.defineProperty(NgModuleSymbol.prototype, "metadata", {
get: function () {
var _a;
return (_a = this.analysis) === null || _a === void 0 ? void 0 : _a.mod;
},
enumerable: false,
configurable: true
});
Object.defineProperty(NgModuleSymbol.prototype, "scope", {
get: function () {
this.ensureAnalysis();
return this.workspace.scopeRegistry.getScopeOfModule(this.node);
},
enumerable: false,
configurable: true
});
/** Return dependencies injected in the constructor of the module */
NgModuleSymbol.prototype.getDependencies = function () {
var _this = this;
assertDeps(this.deps, this.name);
return this.deps.map(function (dep) { return _this.workspace.findSymbol(dep.token); }).filter(exists);
};
/** Get the providers of the module as InjectableSymbol */
NgModuleSymbol.prototype.getProviders = function () {
var _a;
return this.workspace.providerRegistry.getAllProviders((_a = this.analysis) === null || _a === void 0 ? void 0 : _a.providers);
};
/**
* Get all declaration class of the module as `ComponentSymbol | PipeSymbol | DirectiveSymbol`
* You can filter them using `declaration.isSymbol(name)` method:
* @example
* ```typescript
* const declarations = module.getDeclarations()
* const components = declarations.filter(declaration => declaration.isSymbol('Component'))
* ```
*/
NgModuleSymbol.prototype.getDeclarations = function () {
var _this = this;
var _a;
return (_a = this.analysis) === null || _a === void 0 ? void 0 : _a.declarations.map(function (ref) { return _this.workspace.getSymbol(ref.node); });
};
/**
* Get all modules imported by the current module.
* You can filter them using `imported.isDts()`
* @example
* ```typescript
* const imported = module.getImports();
* const externalImports = imported.filter(import => import.isDts());
* ```
*/
NgModuleSymbol.prototype.getImports = function () {
var _this = this;
var _a;
return (_a = this.analysis) === null || _a === void 0 ? void 0 : _a.imports.map(function (ref) { return _this.workspace.getSymbol(ref.node); });
};
/**
* Get all declaration class of the module as `ComponentSymbol | PipeSymbol | DirectiveSymbol`
* You can filter them using `exported.isSymbol(name)` method:
* @example
* ```typescript
* const exported = module.getExports()
* const components = exported.filter(export => export.isSymbol('Component'))
* ```
*/
NgModuleSymbol.prototype.getExports = function () {
var _this = this;
var _a;
return (_a = this.analysis) === null || _a === void 0 ? void 0 : _a.exports.map(function (ref) { return _this.workspace.getSymbol(ref.node); });
};
/** Get the list of components bootstraped by the module if any */
NgModuleSymbol.prototype.getBootstap = function () {
var _this = this;
var _a;
return (_a = this.metadata) === null || _a === void 0 ? void 0 : _a.bootstrap.map(function (ref) { return _this.workspace.findSymbol(ref.value); });
};
return NgModuleSymbol;
}(Symbol));
export { NgModuleSymbol };
//# sourceMappingURL=module.symbol.js.map