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 30x 20x 20x 30x 30x 7x 7x 7x 6x 6x 5x 5x 6x 7x 6x 6x 6x 30x 23x 23x 23x 23x 21x 21x 23x 30x 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 runSyntax(node: ExpressionNode, input: SyntaxInput) {
    for (const f of node.findDirectExpressions(Expressions.Source)) {
      new 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);
      }
    }
  }
}