@abaplint/core
Version:
abaplint - Core API
58 lines • 2.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FormLengthStats = void 0;
const Statements = require("../abap/2_statements/statements");
const expressions_1 = require("../abap/2_statements/expressions");
const _abap_object_1 = require("../objects/_abap_object");
const _statement_1 = require("../abap/2_statements/statements/_statement");
class FormLengthStats {
static run(obj) {
const res = [];
let pos = undefined;
let name = "";
let count = 0;
let form = false;
if (!(obj instanceof _abap_object_1.ABAPObject)) {
return [];
}
for (const file of obj.getABAPFiles()) {
for (const stat of file.getStatements()) {
const type = stat.get();
if (type instanceof Statements.Form) {
pos = stat.getFirstToken().getStart();
name = this.findName(stat);
form = true;
count = 0;
}
else if (type instanceof Statements.EndForm) {
if (pos) {
res.push({ name: name, className: "", count, file, pos });
}
else {
continue;
}
form = false;
}
else if (form === true
&& !(type instanceof _statement_1.Comment)
&& !(type instanceof _statement_1.Empty)) {
count = count + 1;
}
}
}
return res;
}
static findName(stat) {
let name = "";
const nameExpr = stat.findFirstExpression(expressions_1.FormName);
if (nameExpr) {
name = nameExpr.getFirstToken().getStr();
}
else {
throw new Error("FormLength, findName, expected FormName");
}
return name;
}
}
exports.FormLengthStats = FormLengthStats;
//# sourceMappingURL=form_length_stats.js.map