UNPKG

@abaplint/core

Version:
49 lines 2.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AttributeChain = void 0; const void_type_1 = require("../../types/basic/void_type"); const object_reference_type_1 = require("../../types/basic/object_reference_type"); const _object_oriented_1 = require("../_object_oriented"); const expressions_1 = require("../../2_statements/expressions"); const _syntax_input_1 = require("../_syntax_input"); class AttributeChain { static runSyntax(inputContext, node, input, type) { if (inputContext instanceof void_type_1.VoidType) { return inputContext; } else if (!(inputContext instanceof object_reference_type_1.ObjectReferenceType)) { input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), "Not an object reference(AttributeChain)")); return void_type_1.VoidType.get(_syntax_input_1.CheckSyntaxKey); } const first = node.getChildren()[0]; if (!(first.get() instanceof expressions_1.AttributeName)) { input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), "AttributeChain, unexpected first child")); return void_type_1.VoidType.get(_syntax_input_1.CheckSyntaxKey); } const def = input.scope.findObjectDefinition(inputContext.getIdentifierName()); if (def === undefined) { const message = "Definition for \"" + inputContext.getIdentifierName() + "\" not found in scope(AttributeChain)"; input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message)); return void_type_1.VoidType.get(_syntax_input_1.CheckSyntaxKey); } const nameToken = first.getFirstToken(); const name = nameToken.getStr(); const helper = new _object_oriented_1.ObjectOriented(input.scope); let context = helper.searchAttributeName(def, name); if (context === undefined) { context = helper.searchConstantName(def, name); } if (context === undefined) { const message = "Attribute or constant \"" + name + "\" not found in \"" + def.getName() + "\""; input.issues.push((0, _syntax_input_1.syntaxIssue)(input, nameToken, message)); return void_type_1.VoidType.get(_syntax_input_1.CheckSyntaxKey); } for (const t of type) { input.scope.addReference(nameToken, context, t, input.filename); } // todo, loop, handle ArrowOrDash, ComponentName, TableExpression return context.getType(); } } exports.AttributeChain = AttributeChain; //# sourceMappingURL=attribute_chain.js.map