ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
51 lines (49 loc) • 1.99 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("./../../../utils");
const ReferenceEntry_1 = require("./ReferenceEntry");
const ReferencedSymbolDefinitionInfo_1 = require("./ReferencedSymbolDefinitionInfo");
/**
* Referenced symbol.
*/
class ReferencedSymbol {
/**
* @internal
*/
constructor(global, compilerObject) {
this.global = global;
this._compilerObject = compilerObject;
// it's important to store the references so that the nodes referenced inside will point
// to the right node in case the user does manipulation between getting this object and getting the references
this.references = this.compilerObject.references.map(r => new ReferenceEntry_1.ReferenceEntry(global, r));
}
/**
* Gets the compiler referenced symbol.
*/
get compilerObject() {
return this._compilerObject;
}
/**
* Gets the definition.
*/
getDefinition() {
return new ReferencedSymbolDefinitionInfo_1.ReferencedSymbolDefinitionInfo(this.global, this.compilerObject.definition);
}
/**
* Gets the references.
*/
getReferences() {
return this.references;
}
}
__decorate([
utils_1.Memoize
], ReferencedSymbol.prototype, "getDefinition", null);
exports.ReferencedSymbol = ReferencedSymbol;
//# sourceMappingURL=ReferencedSymbol.js.map