Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 349x 349x 349x 349x 349x 349x 349x 71x 71x 278x 349x 285x 1764x 1764x 5x 5x 5x 5x 1764x 5x 5x 5x 5x 1759x 1754x 1754x 8x 8x 1764x 285x 278x 278x 278x 1x 1x 5x 5x 5x 5x 5x 1x | import * as Statements from "../abap/2_statements/statements";
import * as Expressions from "../abap/2_statements/expressions";
import {Position} from "../position";
import {StatementNode} from "../abap/nodes";
import {IObject} from "../objects/_iobject";
import {ABAPObject} from "../objects/_abap_object";
import {Empty, Comment} from "../abap/2_statements/statements/_statement";
import {IMethodLengthResult} from "./method_length_stats";
export class FunctionLengthStats {
public static run(obj: IObject): IMethodLengthResult[] {
const res: IMethodLengthResult[] = [];
let pos: Position | undefined = undefined;
let name: string = "";
let count = 0;
let func: boolean = false;
if (!(obj instanceof ABAPObject)) {
return [];
}
for (const file of obj.getABAPFiles()) {
for (const stat of file.getStatements()) {
const type = stat.get();
if (type instanceof Statements.FunctionModule) {
pos = stat.getFirstToken().getStart();
name = this.findName(stat);
func = true;
count = 0;
} else if (type instanceof Statements.EndFunction) {
if (pos) {
res.push({name: name, className: "", count, file, pos});
} else {
continue;
}
func = false;
} else if (func === true
&& !(type instanceof Comment)
&& !(type instanceof Empty)) {
count = count + 1;
}
}
}
return res;
}
private static findName(stat: StatementNode): string {
const nameExpr = stat.findFirstExpression(Expressions.Field);
if (nameExpr) {
return nameExpr.getFirstToken().getStr();
} else {
throw new Error("FunctionLength, findName, expected Field");
}
}
}
|