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

94.59% Statements 35/37
65% Branches 13/20
100% Functions 1/1
94.59% Lines 35/37

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 371x 1x 1x 1x 1x 1x 1x 48x     48x 26x 26x 48x 48x 9x 9x 9x 8x 8x 7x 7x 8x 9x 8x 8x 8x 48x 39x 39x 39x 39x 37x 37x 39x 48x 1x
import {ExpressionNode} from "../../nodes";
import * as Expressions from "../../2_statements/expressions";
import {Source} from "./source";
import {SyntaxInput} from "../_syntax_input";
 
export class MessageSource {
  public static runSyntax(node: ExpressionNode, input: SyntaxInput) {
    for (const f of node.findDirectExpressions(Expressions.Source)) {
      Source.runSyntax(f, input);
    }
    for (const f of node.findDirectExpressions(Expressions.SimpleSource3)) {
      Source.runSyntax(f, input);
    }
 
    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();
        input.scope.getMSAGReferences().addUsing(input.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) {
        input.scope.getMSAGReferences().addUsing(input.filename, node.getFirstToken(), messageClass, messageNumber);
      }
    }
  }
}