@abaplint/core
Version:
abaplint - Core API
144 lines • 4.72 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Issue = void 0;
const position_1 = require("./position");
const virtual_position_1 = require("./virtual_position");
const severity_1 = require("./severity");
class Issue {
//////////////////////////
static atRow(file, row, message, key, severity) {
const start = new position_1.Position(row, 1);
const end = new position_1.Position(row, file.getRawRows()[row - 1].length + 1);
severity = severity !== null && severity !== void 0 ? severity : severity_1.Severity.Error;
return new Issue({
filename: file.getFilename(),
message,
key,
start,
end,
severity,
});
}
static atStatement(file, statement, message, key, severity, fix, alternativeFixes) {
return this.atRange(file, statement.getStart(), statement.getEnd(), message, key, severity, fix, alternativeFixes);
}
static atPosition(file, start, message, key, severity, fix) {
const row = start.getRow();
const end = new position_1.Position(row, file.getRawRows()[row - 1].length + 1);
severity = severity !== null && severity !== void 0 ? severity : severity_1.Severity.Error;
return new Issue({
filename: file.getFilename(),
message,
key,
start,
end,
defaultFix: fix,
severity,
});
}
static atRowRange(file, row, startCol, endCol, message, key, severity, fix) {
const start = new position_1.Position(row, startCol);
const end = new position_1.Position(row, endCol);
severity = severity !== null && severity !== void 0 ? severity : severity_1.Severity.Error;
return new Issue({
filename: file.getFilename(),
message,
key,
start,
end,
defaultFix: fix,
severity,
});
}
static atRange(file, start, end, message, key, severity, fix, alternativeFixes) {
severity = severity !== null && severity !== void 0 ? severity : severity_1.Severity.Error;
return new Issue({
filename: file.getFilename(),
message,
key,
start,
end,
defaultFix: fix,
severity,
alternativeFixes,
});
}
static atToken(file, token, message, key, severity, fix) {
severity = severity !== null && severity !== void 0 ? severity : severity_1.Severity.Error;
return new Issue({
filename: file.getFilename(),
message,
key,
start: token.getStart(),
end: token.getEnd(),
severity,
defaultFix: fix,
});
}
static atTokenFilename(filename, token, message, key, severity, fix) {
severity = severity !== null && severity !== void 0 ? severity : severity_1.Severity.Error;
return new Issue({
filename: filename,
message,
key,
start: token.getStart(),
end: token.getEnd(),
severity,
defaultFix: fix,
});
}
static atIdentifier(identifier, message, key, severity, fix) {
severity = severity !== null && severity !== void 0 ? severity : severity_1.Severity.Error;
return new Issue({
filename: identifier.getFilename(),
message,
key,
start: identifier.getStart(),
end: identifier.getEnd(),
severity,
defaultFix: fix,
});
}
constructor(data) {
this.data = data;
if (this.data.start instanceof virtual_position_1.VirtualPosition) {
// no quick fixes inside macros
this.data.defaultFix = undefined;
}
if (this.data.start.getCol() < 1) {
throw new Error("issue, start col < 1");
}
else if (this.data.end.getCol() < 1) {
throw new Error("issue, end col < 1");
}
}
getData() {
return this.data;
}
getMessage() {
return this.data.message;
}
getKey() {
return this.data.key;
}
getStart() {
return this.data.start;
}
getEnd() {
return this.data.end;
}
getFilename() {
return this.data.filename;
}
getDefaultFix() {
return this.data.defaultFix;
}
getAlternativeFixes() {
return this.data.alternativeFixes;
}
getSeverity() {
return this.data.severity;
}
}
exports.Issue = Issue;
//# sourceMappingURL=issue.js.map