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

83.87% Statements 26/31
50% Branches 3/6
100% Functions 1/1
83.87% Lines 26/31

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 311x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 87x 87x     87x 87x 1x 1x 1x 1x 86x 86x 86x 86x 86x 86x       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} from "../_syntax_input";
import {VoidType} from "../../types/basic";
 
export class FieldSymbol implements StatementSyntax {
  public runSyntax(node: StatementNode, input: SyntaxInput): void {
    const fsname = node.findFirstExpression(Expressions.FieldSymbol)?.getFirstToken();
    if (fsname === undefined) {
      return;
    }
 
    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")));
  }
}