All files / src/objects program.ts

91.37% Statements 53/58
92.3% Branches 12/13
87.5% Functions 7/8
91.37% Lines 53/58

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 591x 1x 1x 1x 1x 1x 1x 1x 1x 1x 29477x 29477x 1x 1x 3716x 3716x     3716x 3716x 1x 1x       1x 1x 166x 166x 166x 166x 166x 1x 1x 7284x 7284x 7284x 1x 1x 3409x 3409x 3409x 1x 1x 165x 165x 165x 1x 1x 3574x 2407x 2407x 2407x 2407x 2407x 2407x 3574x 1x  
import {ABAPObject} from "./_abap_object";
import {ABAPFile} from "../abap/abap_file";
 
export class Program extends ABAPObject {
  private parsedXML: {
    isInclude: boolean,
    isModulePool: boolean,
  } | undefined;
 
  public getType(): string {
    return "PROG";
  }
 
  public getSequencedFiles(): readonly ABAPFile[] {
    const main = this.getMainABAPFile();
    if (main === undefined) {
      return [];
    }
    return [main];
  }
 
  public getDescription(): string | undefined {
    // todo
    return undefined;
  }
 
  public getAllowedNaming() {
    return {
      maxLength: 40,
      allowNamespace: true,
    };
  }
 
  public setDirty(): void {
    this.parsedXML = undefined;
    super.setDirty();
  }
 
  public isInclude(): boolean {
    this.parseXML();
    return this.parsedXML!.isInclude;
  }
 
  public isModulePool(): boolean {
    this.parseXML();
    return this.parsedXML!.isModulePool;
  }
 
  public parseXML() {
    if (this.parsedXML === undefined) {
      const file = this.getXMLFile();
      this.parsedXML = {
        isInclude: file ? file.getRaw().includes("<SUBC>I</SUBC>") : false,
        isModulePool: file ? file.getRaw().includes("<SUBC>M</SUBC>") : false,
      };
    }
  }
}