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

100% Statements 34/34
68.42% Branches 13/19
100% Functions 1/1
100% Lines 34/34

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 341x 1x 1x 1x 1x 1x 1x 29x 20x 20x 29x 29x 7x 7x 7x 6x 6x 5x 5x 6x 7x 6x 6x 6x 29x 22x 22x 22x 22x 21x 21x 22x 29x 1x
import {ExpressionNode} from "../../nodes";
import {CurrentScope} from "../_current_scope";
import * as Expressions from "../../2_statements/expressions";
import {Source} from "./source";
 
export class MessageSource {
  public runSyntax(node: ExpressionNode, scope: CurrentScope, filename: string) {
    for (const f of node.findDirectExpressions(Expressions.Source)) {
      new Source().runSyntax(f, scope, filename);
    }
 
    if (node.getFirstToken().getStr().toUpperCase() === "ID") {
      const id = node.findExpressionAfterToken("ID")?.concatTokens();
      let number = node.findDirectExpression(Expressions.MessageNumber)?.concatTokens();
      if (number === undefined) {
        const num = node.findExpressionAfterToken("NUMBER")?.concatTokens();
        if (num?.startsWith("'")) {
          number = num.substring(1, num.length - 1).toUpperCase();
        }
      }
      if (id?.startsWith("'") && number) {
        const messageClass = id.substring(1, id.length - 1).toUpperCase();
        scope.getMSAGReferences().addUsing(filename, node.getFirstToken(), messageClass, number);
      }
    } else {
      const typeAndNumber = node.findDirectExpression(Expressions.MessageTypeAndNumber)?.concatTokens();
      const messageNumber = typeAndNumber?.substring(1);
      const messageClass = node.findDirectExpression(Expressions.MessageClass)?.concatTokens().toUpperCase();
      if (messageNumber && messageClass) {
        scope.getMSAGReferences().addUsing(filename, node.getFirstToken(), messageClass, messageNumber);
      }
    }
  }
}