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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 10262x 10262x 10262x 10262x 10262x 11x 11x 11x 11x 10262x 10251x 10251x 10251x 10251x 10251x 10262x 1x 1x 10251x 10251x 1x 1x 1x 10262x 10262x 10262x 10262x 10262x 10262x 10262x 10262x 10262x 10262x 10262x 10262x 10262x 10262x 10262x 10262x 10262x 10262x 10262x 10284x 10284x 10284x 10284x 10284x 10284x 10284x 10284x 10284x 10284x 10262x 10262x 10262x 10262x 10262x 10262x 10262x 10262x 10262x 10262x 1x 1x | import {ABAPFile} from "./abap_file";
import {ABAPFileInformation} from "./4_file_information/abap_file_information";
import {ABAPFileInformationParser} from "./4_file_information/abap_file_information_parser";
import {IABAPLexerResult} from "./1_lexer/lexer_result";
import {IFile} from "../files/_ifile";
import {IRegistry} from "../_iregistry";
import {Issue} from "../issue";
import {Lexer} from "./1_lexer/lexer";
import {StatementParser} from "./2_statements/statement_parser";
import {StructureParser} from "./3_structures/structure_parser";
import {ABAPRelease, LanguageVersion, defaultRelease} from "../version";
export interface IABAPParserResult {
issues: readonly Issue[],
output: readonly ABAPFile[],
/** runtime in milliseconds */
runtime: number,
runtimeExtra: {lexing: number, statements: number, structure: number},
}
export interface IABAPParserOptions {
release?: ABAPRelease;
languageVersion?: LanguageVersion;
globalMacros?: readonly string[];
reg?: IRegistry;
}
export class ABAPParser {
private readonly release: ABAPRelease;
private readonly languageVersion: LanguageVersion;
private readonly globalMacros: readonly string[];
private readonly reg?: IRegistry;
/** @deprecated Use `new ABAPParser(options)` instead */
public constructor(release: ABAPRelease, globalMacros?: readonly string[], reg?: IRegistry);
public constructor(options?: IABAPParserOptions);
public constructor(
optionsOrRelease?: IABAPParserOptions | ABAPRelease,
globalMacros?: readonly string[],
reg?: IRegistry,
) {
if (optionsOrRelease === undefined || ABAPParser.isRelease(optionsOrRelease)) {
this.release = optionsOrRelease ?? defaultRelease;
this.languageVersion = LanguageVersion.Normal;
this.globalMacros = globalMacros ?? [];
this.reg = reg;
} else {
this.release = optionsOrRelease.release ?? defaultRelease;
this.languageVersion = optionsOrRelease.languageVersion ?? LanguageVersion.Normal;
this.globalMacros = optionsOrRelease.globalMacros ?? [];
this.reg = optionsOrRelease.reg;
}
}
private static isRelease(o: IABAPParserOptions | ABAPRelease): o is ABAPRelease {
return typeof (o as ABAPRelease).ordinal === "number";
}
// files is input for a single object
public parse(files: readonly IFile[]): IABAPParserResult {
const issues: Issue[] = [];
const output: ABAPFile[] = [];
const start = Date.now();
// 1: lexing
const b1 = Date.now();
const lexerResult: readonly IABAPLexerResult[] = files.map(f => new Lexer().run(f));
const lexingRuntime = Date.now() - b1;
// 2: statements
const b2 = Date.now();
const statementResult = new StatementParser(this.release, this.reg, this.languageVersion)
.run(lexerResult, this.globalMacros);
const statementsRuntime = Date.now() - b2;
// 3: structures
const b3 = Date.now();
for (const f of statementResult) {
const result = StructureParser.run(f);
// 4: file information
const parser = new ABAPFileInformationParser(f.file.getFilename());
const parsed = parser.parse(result.node);
const info = new ABAPFileInformation(parsed);
output.push(new ABAPFile(f.file, f.tokens, f.statements, result.node, info));
issues.push(...result.issues);
}
const structuresRuntime = Date.now() - b3;
const end = Date.now();
return {issues,
output,
runtime: end - start,
runtimeExtra: {lexing: lexingRuntime, statements: statementsRuntime, structure: structuresRuntime},
};
}
} |