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

86.48% Statements 32/37
57.14% Branches 4/7
100% Functions 1/1
86.48% Lines 32/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 1x 1x 1x 1x 130x 130x 130x     130x 130x 1x 1x 1x 130x 130x 1x 1x 1x 1x 129x 129x 129x 129x 129x 129x       1x
import * as Expressions from "../../2_statements/expressions";
import {StatementNode} from "../../nodes";
import {TypedIdentifier} from "../../types/_typed_identifier";
import {BasicTypes} from "../basic_types";
import {UnknownType} from "../../types/basic/unknown_type";
import {StatementSyntax} from "../_statement_syntax";
import {SyntaxInput, syntaxIssue} from "../_syntax_input";
import {VoidType} from "../../types/basic";
 
export class FieldSymbol implements StatementSyntax {
  public runSyntax(node: StatementNode, input: SyntaxInput): void {
    const fs = node.findFirstExpression(Expressions.FieldSymbol);
    const fsname = fs?.getFirstToken();
    if (fs === undefined || fsname === undefined) {
      return;
    }
 
    if (fs.concatTokens().length > 30) {
      const message = "FIELD-SYMBOLS name too long, " + fs.concatTokens();
      input.issues.push(syntaxIssue(input, fsname, message));
    }
 
    if (node.getChildren().length === 5) {
      // no type specified
      input.scope.addIdentifier(new TypedIdentifier(fsname, input.filename, VoidType.get("FS-SIMPLE")));
      return;
    }
 
    const bfound = new BasicTypes(input).parseType(node);
    if (bfound) {
      input.scope.addIdentifier(new TypedIdentifier(fsname, input.filename, bfound));
      return;
    }

    input.scope.addIdentifier(new TypedIdentifier(fsname, input.filename, new UnknownType("Fieldsymbol, fallback")));
  }
}