All files / src/abap/5_syntax/statements form.ts

85.71% Statements 24/28
50% Branches 2/4
100% Functions 1/1
85.71% Lines 24/28

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 281x 1x 1x 1x 1x 1x 1x 1x 1x 241x 241x 241x         241x 1x 1x 1x 241x 241x 241x 241x 241x 241x 241x 1x
import {StatementNode} from "../../nodes";
import {FormDefinition} from "../../types/form_definition";
import {ScopeType} from "../_scope_type";
import {FormName} from "../../2_statements/expressions";
import {StatementSyntax} from "../_statement_syntax";
import {SyntaxInput, syntaxIssue} from "../_syntax_input";
 
export class Form implements StatementSyntax {
  public runSyntax(node: StatementNode, input: SyntaxInput): void {
    const nameExpression = node.findDirectExpression(FormName);
    const name = nameExpression?.concatTokens();
    if (nameExpression === undefined || name === undefined) {
      const message = "Form, could not find name";
      input.issues.push(syntaxIssue(input, node.getFirstToken(), message));
      return;
    }
    if (name.length > 30) {
      const message = "FORM name longer than 30 characters";
      input.issues.push(syntaxIssue(input, nameExpression.getFirstToken(), message));
    }
    input.scope.push(ScopeType.Form, name, node.getFirstToken().getStart(), input.filename);
 
    const form = new FormDefinition(node, input);
    input.scope.addList(form.getUsingParameters());
    input.scope.addList(form.getChangingParameters());
    input.scope.addList(form.getTablesParameters());
  }
}