All files / src/abap/5_syntax/expressions component_chain.ts

75% Statements 9/12
50% Branches 3/6
100% Functions 1/1
75% Lines 9/12

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    1x 1x   1x   1x       1x       1x 1x 1x           1x      
import {INode} from "../../nodes/_inode";
import {AbstractType} from "../../types/basic/_abstract_type";
import {VoidType} from "../../types/basic/void_type";
import {StructureType} from "../../types/basic/structure_type";
 
export class ComponentChain {
  public runSyntax(context: AbstractType | undefined, node: INode): AbstractType | undefined {
    Iif (context instanceof VoidType) {
      return context;
    }
 
    Iif (!(context instanceof StructureType)) {
      throw new Error("ComponentChain, not a structure");
    }
 
    const name = node.getFirstToken().getStr();
    const ret = context.getComponentByName(name);
    Iif (ret === undefined) {
      throw new Error("Component \"" + name + "\" not found in structure");
    }
 
// todo, add more here
 
    return ret;
  }
 
}