UNPKG

@abaplint/core

Version:
47 lines 2.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MethodParam = void 0; const _typed_identifier_1 = require("../../types/_typed_identifier"); const basic_1 = require("../../types/basic"); const basic_types_1 = require("../basic_types"); const Expressions = require("../../2_statements/expressions"); const default_1 = require("./default"); const cgeneric_type_1 = require("../../types/basic/cgeneric_type"); const assert_error_1 = require("../assert_error"); class MethodParam { static runSyntax(node, input, meta) { const name = node.findDirectExpression(Expressions.MethodParamName); if (name === undefined) { throw new assert_error_1.AssertError("MethodParam, todo, handle pass by value and reference"); } const type = node.findDirectExpression(Expressions.TypeParam); if (type === undefined) { throw new assert_error_1.AssertError("MethodParam, unexpected structure"); } const def = type.findDirectExpression(Expressions.Default); if (def) { try { default_1.Default.runSyntax(def, input); } catch (e) { return new _typed_identifier_1.TypedIdentifier(name.getFirstToken(), input.filename, new basic_1.UnknownType(e.toString()), meta); } } const concat = type.concatTokens().toUpperCase(); if (concat === "TYPE C" || concat.startsWith("TYPE C ")) { return new _typed_identifier_1.TypedIdentifier(name.getFirstToken(), input.filename, cgeneric_type_1.CGenericType.get(), meta); } else if (concat === "TYPE X" || concat.startsWith("TYPE X ")) { return new _typed_identifier_1.TypedIdentifier(name.getFirstToken(), input.filename, basic_1.XGenericType.get(), meta); } const found = new basic_types_1.BasicTypes(input).parseType(type); if (found) { return new _typed_identifier_1.TypedIdentifier(name.getFirstToken(), input.filename, found, meta); } else { return new _typed_identifier_1.TypedIdentifier(name.getFirstToken(), input.filename, new basic_1.UnknownType("method param, todo"), meta); } } } exports.MethodParam = MethodParam; //# sourceMappingURL=method_param.js.map