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

93.33% Statements 28/30
85.71% Branches 6/7
100% Functions 1/1
93.33% Lines 28/30

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 301x 1x 1x 1x 1x 1x 1x 8x 8x 8x 5x 5x 5x 2x 2x 3x 3x 6x 6x 8x 1x 1x 1x     1x 1x 8x 8x 1x
import * as Expressions from "../../2_statements/expressions";
import {ExpressionNode} from "../../nodes";
import {CurrentScope} from "../_current_scope";
import {ReferenceType} from "../_reference";
 
export class FieldOffset {
  public runSyntax(node: ExpressionNode, scope: CurrentScope, filename: string): void {
 
    const field = node.findDirectExpression(Expressions.SourceField);
    if (field) {
      const token = field.getFirstToken();
      const found = scope.findVariable(token.getStr());
      if (found === undefined) {
        throw new Error("\"" + field.getFirstToken().getStr() + "\" not found, FieldOffset");
      }
      scope.addReference(token, found, ReferenceType.DataReadReference, filename);
    }
 
    const symbol = node.findDirectExpression(Expressions.SourceFieldSymbol);
    if (symbol) {
      const token = symbol.getFirstToken();
      const found = scope.findVariable(token.getStr());
      if (found === undefined) {
        throw new Error("\"" + symbol.getFirstToken().getStr() + "\" not found, FieldOffset");
      }
      scope.addReference(token, found, ReferenceType.DataReadReference, filename);
    }
 
  }
}