All files / src/abap/5_syntax _eml.ts

90.62% Statements 29/32
92.85% Branches 13/14
100% Functions 1/1
90.62% Lines 29/32

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 331x 1x 1x 1x 1x 1x 1x 7x 7x       7x 7x 7x 7x 5x 5x 2x 2x 5x 5x 2x 2x 7x 7x 7x 7x 1x 1x 7x 1x  
import * as Expressions from "../2_statements/expressions";
import {StatementNode} from "../nodes";
import {SyntaxInput, syntaxIssue} from "./_syntax_input";
 
/** checks the entities referenced in EML statements, eg. READ ENTITIES and MODIFY ENTITIES */
export class EML {
  public static checkEntities(node: StatementNode, input: SyntaxInput): void {
    const nameNode = node.findDirectExpression(Expressions.NamespaceSimpleName);
    if (nameNode === undefined) {
      // eg. dynamic "MODIFY ENTITIES OPERATIONS" or "ENTITY zentity\_association"
      return;
    }
    const name = nameNode.concatTokens();
    const scope = input.scope;
 
    if (node.findDirectTokenByText("ENTITIES") !== undefined) {
      // "ENTITIES OF" refers to the behavior definition
      if (scope.findBehaviorDefinitionByName(name) === undefined && scope.getDDIC().inErrorNamespace(name)) {
        input.issues.push(syntaxIssue(input, nameNode.getFirstToken(), `Behavior definition "${name}" not found`));
      }
      return;
    }
 
    // single "ENTITY", inside a behavior pool the alias defined in the BDEF can be used
    const entity = scope.findBehaviorDefinition()?.findEntityNameByAlias(name) ?? name;
    if (scope.getDDIC().inErrorNamespace(entity)
        && scope.findBehaviorDefinitionByName(entity) === undefined
        && scope.getDDIC().lookupDDLS(entity) === undefined) {
      input.issues.push(syntaxIssue(input, nameNode.getFirstToken(), `Entity "${name}" not found`));
    }
  }
}