ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
63 lines (62 loc) • 2.16 kB
JavaScript
;
var __extends = (this && this.__extends)/* istanbul ignore next */ || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var Node_1 = require("./Node");
var Identifier = /** @class */ (function (_super) {
__extends(Identifier, _super);
function Identifier() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Gets the text for the identifier.
*/
Identifier.prototype.getText = function () {
return this.compilerNode.text;
};
/**
* Renames the identifier.
* @param newName - New name of the identifier.
*/
Identifier.prototype.rename = function (newName) {
this.global.languageService.renameNode(this, newName);
};
/**
* Finds all the references of this identifier.
*/
Identifier.prototype.findReferences = function () {
return this.global.languageService.findReferences(this);
};
/**
* Gets the definitions of the current identifier.
*
* This is similar to "go to definition."
*/
Identifier.prototype.getDefinitions = function () {
return this.global.languageService.getDefinitions(this);
};
/**
* Gets the implementations of the current identifier.
*
* This is similar to "go to implementation."
*/
Identifier.prototype.getImplementations = function () {
return this.global.languageService.getImplementations(this);
};
/**
* Gets the type of the identifier.
*/
Identifier.prototype.getType = function () {
return this.global.typeChecker.getTypeAtLocation(this);
};
return Identifier;
}(Node_1.Node));
exports.Identifier = Identifier;