All files / src/objects interface.ts

95.4% Statements 83/87
69.04% Branches 29/42
100% Functions 12/12
95.4% Lines 83/87

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 881x 1x 1x 1x 1x 1x 154x 154x 154x 154x 154x 2067x 2067x 154x 154x 185x 185x 154x 154x 67x 67x     67x 67x 154x 154x 690x 690x 154x 154x 57x 57x 154x 154x 57x 57x 154x 154x 29x 29x 29x 29x 29x 154x 154x 212x 212x 212x 212x 154x 154x 8x 8x 8x 154x 154x 82x 82x 82x 154x 154x 154x 154x 90x 60x 60x 30x 30x 30x 30x 30x 90x 21x 21x 9x 90x 90x     90x 9x 9x 9x 90x 154x 154x  
import {ABAPObject} from "./_abap_object";
import {IInterfaceDefinition} from "../abap/types/_interface_definition";
import {ABAPFile} from "../abap/abap_file";
import {InfoInterfaceDefinition} from "../abap/4_file_information/_abap_file_information";
import {Identifier} from "../abap/4_file_information/_identifier";
 
export class Interface extends ABAPObject {
  private def: IInterfaceDefinition | undefined = undefined;
  private parsedXML: {name?: string, description?: string} | undefined = undefined;
 
  public getType(): string {
    return "INTF";
  }
 
  public setDefinition(def: IInterfaceDefinition | undefined): void {
    this.def = def;
  }
 
  public getSequencedFiles(): readonly ABAPFile[] {
    const main = this.getMainABAPFile();
    if (main === undefined) {
      return [];
    }
    return [main];
  }
 
  public getDefinition(): IInterfaceDefinition | undefined {
    return this.def;
  }
 
  public getInterface(): InfoInterfaceDefinition | undefined {
    return this.getMainABAPFile()?.getInfo().getInterfaceDefinitionByName(this.getName());
  }
 
  public getIdentifier(): Identifier | undefined {
    return this.getInterface()?.identifier;
  }
 
  public getAllowedNaming() {
    return {
      maxLength: 30,
      allowNamespace: true,
    };
  }
 
  public setDirty(): void {
    this.def = undefined;
    this.parsedXML = undefined;
    super.setDirty();
  }
 
  public getNameFromXML(): string | undefined {
    this.parseXML();
    return this.parsedXML?.name;
  }
 
  public getDescription(): string | undefined {
    this.parseXML();
    return this.parsedXML?.description;
  }
 
/////////////////////////
 
  private parseXML() {
    if (this.parsedXML !== undefined) {
      return;
    }
 
    this.parsedXML = {};
 
    const parsed = super.parseRaw2();
    if (parsed === undefined
        || parsed?.abapGit?.["asx:abap"]?.["asx:values"] === undefined) {
      return;
    }
 
    const vseo = parsed?.abapGit?.["asx:abap"]?.["asx:values"]?.VSEOINTERF;
    if (vseo === undefined) {
      this.parsedXML.description = "";
      this.parsedXML.name = "";
    } else {
      this.parsedXML.description = vseo.DESCRIPT ? vseo.DESCRIPT : "";
      this.parsedXML.name = vseo.CLSNAME ? vseo.CLSNAME : "";
    }
  }
 
}