All files / src/objects authorization_check_field.ts

88.88% Statements 72/81
68.42% Branches 13/19
85.71% Functions 6/7
88.88% Lines 72/81

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 821x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 69x 69x 1x 1x 2x 2x 2x 2x 2x 1x 1x 4x 4x 4x 1x 1x       1x 1x 1x 1x 1x 1x 1x 9x 9x 9x 9x 9x 9x 9x 9x 6x 6x 6x 9x 3x 3x     9x     9x 1x 1x 16x 12x 12x 4x 4x 4x 4x 4x 4x 4x 16x     4x 16x 16x 16x 16x 16x 1x  
import {UnknownType, VoidType} from "../abap/types/basic";
import {AbstractType} from "../abap/types/basic/_abstract_type";
import {DDIC} from "../ddic";
import {IObjectAndToken} from "../_iddic_references";
import {IRegistry} from "../_iregistry";
import {AbstractObject} from "./_abstract_object";
 
export class AuthorizationCheckField extends AbstractObject {
  private parsedXML: {
    rollname?: string,
  } | undefined;
 
  public getType(): string {
    return "AUTH";
  }
 
  public getAllowedNaming() {
    return {
      maxLength: 30,
      allowNamespace: true,
    };
  }
 
  public setDirty(): void {
    this.parsedXML = undefined;
    super.setDirty();
  }
 
  public getDescription(): string | undefined {
    // todo
    return undefined;
  }
 
  public getDataElementName(): string | undefined {
    this.parse();
    return this.parsedXML?.rollname;
  }
 
  public parseType(reg: IRegistry): AbstractType {
    this.parse();
 
    const references: IObjectAndToken[] = [];
    const ddic = new DDIC(reg);
 
    if (this.parsedXML?.rollname) {
      const found = ddic.lookupDataElement(this.parsedXML.rollname);
      if (found.object) {
        references.push({object: found.object});
        reg.getDDICReferences().setUsing(this, references);
        return found.type;
      } else if (ddic.inErrorNamespace(this.parsedXML.rollname)) {
        return new UnknownType(this.parsedXML.rollname + " not found");
      } else {
        return new VoidType(this.parsedXML.rollname);
      }
    } else {
      return new UnknownType("Parsing error");
    }
  }
 
  public parse() {
    if (this.parsedXML) {
      return {updated: false, runtime: 0};
    }
 
    const start = Date.now();
    this.parsedXML = {};
    const parsed = super.parseRaw2();
 
    if (parsed === undefined
        || parsed.abapGit === undefined
        || parsed.abapGit["asx:abap"]["asx:values"] === undefined) {
      return {updated: false, runtime: 0};
    }
 
    this.parsedXML.rollname = parsed.abapGit["asx:abap"]["asx:values"].AUTHX?.ROLLNAME;
 
    const end = Date.now();
    return {updated: true, runtime: end - start};
  }
}