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

100% Statements 24/24
100% Branches 5/5
100% Functions 1/1
100% Lines 24/24

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 241x 1x 1x 1x 1x 1x 1739x 1739x 1739x 1739x 108x 108x 1631x 1631x 1631x 1739x 4x 4x 4x 4x 4x 1631x 1631x 1x
import {ExpressionNode} from "../../nodes";
import {CurrentScope} from "../_current_scope";
import {ReferenceType} from "../_reference";
 
export class SourceField {
  public runSyntax(node: ExpressionNode, scope: CurrentScope, filename: string, type?: ReferenceType | ReferenceType[]) {
    const token = node.getFirstToken();
    const name = token.getStr();
    const found = scope.findVariable(name);
    if (found === undefined) {
      throw new Error("\"" + name + "\" not found, findTop");
    }
    if (type) {
      scope.addReference(token, found, type, filename);
    }
    if (name.includes("~")) {
      const idef = scope.findInterfaceDefinition(name.split("~")[0]);
      if (idef) {
        scope.addReference(token, idef, ReferenceType.ObjectOrientedReference, filename);
      }
    }
    return found.getType();
  }
}