ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
71 lines (70 loc) • 1.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Diagnostic.
*/
var Diagnostic = /** @class */ (function () {
/** @internal */
function Diagnostic(global, compilerObject) {
this.global = global;
this._compilerObject = compilerObject;
}
Object.defineProperty(Diagnostic.prototype, "compilerObject", {
/**
* Gets the underlying compiler diagnostic.
*/
get: function () {
return this._compilerObject;
},
enumerable: true,
configurable: true
});
/**
* Gets the source file.
*/
Diagnostic.prototype.getSourceFile = function () {
var file = this.compilerObject.file;
return file == null ? undefined : this.global.compilerFactory.getSourceFile(file);
};
/**
* Gets the message text.
*/
Diagnostic.prototype.getMessageText = function () {
var messageText = this._compilerObject.messageText;
if (typeof messageText === "string")
return messageText;
return this.global.compilerFactory.getDiagnosticMessageChain(messageText);
};
/**
* Gets the start.
*/
Diagnostic.prototype.getStart = function () {
return this.compilerObject.start;
};
/**
* Gets the length.
*/
Diagnostic.prototype.getLength = function () {
return this.compilerObject.length;
};
/**
* Gets the diagnostic category.
*/
Diagnostic.prototype.getCategory = function () {
return this.compilerObject.category;
};
/**
* Gets the code of the diagnostic.
*/
Diagnostic.prototype.getCode = function () {
return this.compilerObject.code;
};
/**
* Gets the source.
*/
Diagnostic.prototype.getSource = function () {
return this.compilerObject.source;
};
return Diagnostic;
}());
exports.Diagnostic = Diagnostic;