All files / src/abap/5_syntax/expressions method_param.ts

84.21% Statements 16/19
62.5% Branches 5/8
100% Functions 1/1
84.21% Lines 16/19

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    1x 1x 1x 1x 1x   1x   85x 85x       85x 85x       85x 85x 6x     84x 84x 84x          
import {ExpressionNode} from "../../nodes";
import {CurrentScope} from "../_current_scope";
import {TypedIdentifier, IdentifierMeta} from "../../types/_typed_identifier";
import {UnknownType} from "../../types/basic";
import {BasicTypes} from "../basic_types";
import * as Expressions from "../../2_statements/expressions";
import {Default} from "./default";
 
export class MethodParam {
  public runSyntax(node: ExpressionNode, scope: CurrentScope, filename: string, meta: IdentifierMeta[]): TypedIdentifier {
    const name = node.findDirectExpression(Expressions.MethodParamName);
    Iif (name === undefined) {
      throw new Error("MethodParam, todo, handle pass by value and reference");
    }
 
    const type = node.findDirectExpression(Expressions.TypeParam);
    Iif (type === undefined) {
      throw new Error("MethodParam, unexpected structure");
    }
 
    const def = type.findDirectExpression(Expressions.Default);
    if (def) {
      new Default().runSyntax(def, scope, filename);
    }
 
    const found = new BasicTypes(filename, scope).parseType(type);
    Eif (found) {
      return new TypedIdentifier(name.getFirstToken(), filename, found, meta);
    } else {
      return new TypedIdentifier(name.getFirstToken(), filename, new UnknownType("method param, todo"), meta);
    }
  }
}