@abaplint/cli 2.94.23 → 2.94.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cli.js +17 -6
- package/package.json +3 -3
package/build/cli.js
CHANGED
|
@@ -1644,7 +1644,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
1644
1644
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1645
1645
|
|
|
1646
1646
|
"use strict";
|
|
1647
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.MethodSource = void 0;\r\nconst combi_1 = __webpack_require__(/*! ../combi */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/combi.js\");\r\nconst tokens_1 = __webpack_require__(/*! ../../1_lexer/tokens */ \"./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/index.js\");\r\nconst _1 = __webpack_require__(/*! . */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nclass MethodSource extends combi_1.Expression {\r\n getRunnable() {\r\n const
|
|
1647
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.MethodSource = void 0;\r\nconst combi_1 = __webpack_require__(/*! ../combi */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/combi.js\");\r\nconst tokens_1 = __webpack_require__(/*! ../../1_lexer/tokens */ \"./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/index.js\");\r\nconst _1 = __webpack_require__(/*! . */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nclass MethodSource extends combi_1.Expression {\r\n getRunnable() {\r\n // note: AttributeName can be both an attribute and a method name, the syntax check will tell\r\n // note: its allowed to end with MethodCall, however if this is done it will give a syntax error via syntax check\r\n const afterArrow = (0, combi_1.alt)(_1.AttributeName, _1.MethodCall, _1.Dynamic);\r\n const arrow = (0, combi_1.alt)((0, combi_1.tok)(tokens_1.InstanceArrow), (0, combi_1.tok)(tokens_1.StaticArrow));\r\n const attr = (0, combi_1.seq)(arrow, afterArrow);\r\n const comp = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.Dash), _1.ComponentName);\r\n const attrOrComp = (0, combi_1.alt)(attr, comp);\r\n const staticClass = (0, combi_1.seq)(_1.ClassName, (0, combi_1.tok)(tokens_1.StaticArrow));\r\n const clas = (0, combi_1.seq)(staticClass, afterArrow);\r\n const start = (0, combi_1.seq)((0, combi_1.altPrio)(clas, _1.SourceField, _1.SourceFieldSymbol, _1.Dynamic), (0, combi_1.star)(attrOrComp));\r\n return start;\r\n }\r\n}\r\nexports.MethodSource = MethodSource;\r\n//# sourceMappingURL=method_source.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/method_source.js?");
|
|
1648
1648
|
|
|
1649
1649
|
/***/ }),
|
|
1650
1650
|
|
|
@@ -6748,7 +6748,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
6748
6748
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
6749
6749
|
|
|
6750
6750
|
"use strict";
|
|
6751
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.BasicTypes = void 0;\r\n/* eslint-disable default-case */\r\nconst _typed_identifier_1 = __webpack_require__(/*! ../types/_typed_identifier */ \"./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js\");\r\nconst Expressions = __webpack_require__(/*! ../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst Statements = __webpack_require__(/*! ../2_statements/statements */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js\");\r\nconst Types = __webpack_require__(/*! ../types/basic */ \"./node_modules/@abaplint/core/build/src/abap/types/basic/index.js\");\r\nconst _scope_type_1 = __webpack_require__(/*! ./_scope_type */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js\");\r\nconst _object_oriented_1 = __webpack_require__(/*! ./_object_oriented */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_object_oriented.js\");\r\nconst class_constant_1 = __webpack_require__(/*! ../types/class_constant */ \"./node_modules/@abaplint/core/build/src/abap/types/class_constant.js\");\r\nconst identifier_1 = __webpack_require__(/*! ../1_lexer/tokens/identifier */ \"./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/identifier.js\");\r\nconst _reference_1 = __webpack_require__(/*! ./_reference */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js\");\r\nconst basic_1 = __webpack_require__(/*! ../types/basic */ \"./node_modules/@abaplint/core/build/src/abap/types/basic/index.js\");\r\nconst field_chain_1 = __webpack_require__(/*! ./expressions/field_chain */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/field_chain.js\");\r\nconst types_1 = __webpack_require__(/*! ../types */ \"./node_modules/@abaplint/core/build/src/abap/types/index.js\");\r\nconst expressions_1 = __webpack_require__(/*! ../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst _builtin_1 = __webpack_require__(/*! ./_builtin */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_builtin.js\");\r\nconst position_1 = __webpack_require__(/*! ../../position */ \"./node_modules/@abaplint/core/build/src/position.js\");\r\nclass BasicTypes {\r\n constructor(filename, scope) {\r\n this.filename = filename;\r\n this.scope = scope;\r\n }\r\n lookupQualifiedName(name) {\r\n var _a;\r\n // argh, todo, rewrite this entire method, more argh\r\n if (name === undefined) {\r\n return undefined;\r\n }\r\n const found = this.scope.findType(name);\r\n if (found) {\r\n return found;\r\n }\r\n if (name.includes(\"=>\")) {\r\n const split = name.split(\"=>\");\r\n const ooName = split[0];\r\n const typeName = split[1];\r\n const oo = this.scope.findObjectDefinition(ooName);\r\n if (oo) {\r\n if (typeName.includes(\"-\")) {\r\n const split = typeName.split(\"-\");\r\n const subTypeName = split[0];\r\n const fieldName = split[1];\r\n const stru = oo.getTypeDefinitions().getByName(subTypeName);\r\n const struType = stru === null || stru === void 0 ? void 0 : stru.getType();\r\n if (stru && struType instanceof basic_1.StructureType) {\r\n const f = struType.getComponentByName(fieldName);\r\n if (f) {\r\n return new _typed_identifier_1.TypedIdentifier(stru.getToken(), stru.getFilename(), f);\r\n }\r\n }\r\n }\r\n else {\r\n const f = oo.getTypeDefinitions().getByName(typeName);\r\n if (f) {\r\n return f;\r\n }\r\n }\r\n }\r\n }\r\n else if (name.includes(\"-\")) {\r\n const split = name.split(\"-\");\r\n const typeName = split[0];\r\n const fieldName = split[1];\r\n const type = this.scope.findType(typeName);\r\n if (type) {\r\n const stru = type.getType();\r\n if (stru instanceof basic_1.StructureType) {\r\n const f = stru.getComponentByName(fieldName);\r\n if (f) {\r\n return new _typed_identifier_1.TypedIdentifier(type.getToken(), type.getFilename(), f);\r\n }\r\n }\r\n }\r\n }\r\n const lookup = this.scope.getDDIC().lookupNoVoid(name);\r\n const id = (_a = lookup === null || lookup === void 0 ? void 0 : lookup.object) === null || _a === void 0 ? void 0 : _a.getIdentifier();\r\n if (id && (lookup === null || lookup === void 0 ? void 0 : lookup.type)) {\r\n return new _typed_identifier_1.TypedIdentifier(id.getToken(), id.getFilename(), lookup.type);\r\n }\r\n const builtin = this.scope.getDDIC().lookupBuiltinType(name);\r\n if (builtin) {\r\n return new _typed_identifier_1.TypedIdentifier(new identifier_1.Identifier(new position_1.Position(1, 1), name), _builtin_1.BuiltIn.filename, builtin);\r\n }\r\n const type = this.scope.findTypePoolType(name);\r\n if (type) {\r\n return type;\r\n }\r\n return undefined;\r\n }\r\n resolveLikeName(node, headerLogic = true) {\r\n var _a;\r\n if (node === undefined) {\r\n return undefined;\r\n }\r\n let chain = node.findFirstExpression(Expressions.FieldChain);\r\n if (chain === undefined) {\r\n chain = node.findFirstExpression(Expressions.TypeName);\r\n }\r\n if (chain === undefined) {\r\n chain = node.findFirstExpression(Expressions.FieldSub);\r\n }\r\n if (chain === undefined) {\r\n chain = node.findFirstExpression(Expressions.SimpleFieldChain);\r\n }\r\n if (chain === undefined) {\r\n throw new Error(\"resolveLikeName, chain undefined\");\r\n }\r\n const fullName = chain.concatTokens();\r\n const children = [...chain.getChildren()];\r\n if (children.length === 0) {\r\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + fullName + \"\\\", resolveLikeName1\");\r\n }\r\n let type = undefined;\r\n if (children[1] && (children[1].getFirstToken().getStr() === \"=>\" || children[1].getFirstToken().getStr() === \"->\")) {\r\n type = new field_chain_1.FieldChain().runSyntax(chain, this.scope, this.filename, _reference_1.ReferenceType.TypeReference);\r\n }\r\n else {\r\n const name = children.shift().getFirstToken().getStr();\r\n let found = this.scope.findVariable(name);\r\n type = found === null || found === void 0 ? void 0 : found.getType();\r\n if (found === undefined) {\r\n found = this.scope.findExtraLikeType(name);\r\n type = found === null || found === void 0 ? void 0 : found.getType();\r\n }\r\n if (found) {\r\n this.scope.addReference(chain === null || chain === void 0 ? void 0 : chain.getFirstToken(), found, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n if (type === undefined) {\r\n type = (_a = this.scope.getDDIC().lookupNoVoid(name)) === null || _a === void 0 ? void 0 : _a.type;\r\n }\r\n if (type === undefined && this.scope.isOO() === false && this.scope.getDDIC().inErrorNamespace(name) === false) {\r\n this.scope.addReference(chain.getChildren()[0].getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\r\n return new Types.VoidType(name);\r\n }\r\n while (children.length > 0) {\r\n const child = children.shift();\r\n if (child.getFirstToken().getStr() === \"-\") {\r\n if (type instanceof Types.VoidType) {\r\n return type;\r\n }\r\n }\r\n else if (child.concatTokens() === \"[]\") {\r\n if (type instanceof Types.TableType) {\r\n type = new basic_1.TableType(type.getRowType(), { withHeader: false });\r\n }\r\n }\r\n else { // field name\r\n let sub = undefined;\r\n if (type instanceof Types.TableType) {\r\n type = type.getRowType();\r\n }\r\n if (type instanceof Types.StructureType) {\r\n sub = type.getComponentByName(child.getFirstToken().getStr());\r\n }\r\n if (sub === undefined) {\r\n return new Types.UnknownType(\"Type error, field not part of structure \" + fullName);\r\n }\r\n type = sub;\r\n }\r\n }\r\n if (type instanceof Types.VoidType) {\r\n return type;\r\n }\r\n else if (type instanceof basic_1.TableType\r\n && type.isWithHeader()\r\n && headerLogic === true) {\r\n type = type.getRowType();\r\n }\r\n else if (type instanceof Types.TableType\r\n && type.isWithHeader() === true\r\n && type.getRowType() instanceof Types.VoidType) {\r\n return type.getRowType();\r\n }\r\n }\r\n if (!type) {\r\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + fullName + \"\\\", resolveLikeName2\");\r\n }\r\n return type;\r\n }\r\n resolveTypeName(typeName, length, decimals, qualifiedName) {\r\n var _a;\r\n if (typeName === undefined) {\r\n return undefined;\r\n }\r\n let chain = this.resolveTypeChain(typeName);\r\n if (chain) {\r\n if (chain instanceof basic_1.CharacterType && qualifiedName) {\r\n chain = chain.cloneType(qualifiedName);\r\n }\r\n return chain;\r\n }\r\n const chainText = typeName.concatTokens().toUpperCase();\r\n const f = this.scope.getDDIC().lookupBuiltinType(chainText, length, decimals, qualifiedName);\r\n if (f !== undefined) {\r\n return f;\r\n }\r\n const typ = this.scope.findType(chainText);\r\n if (typ) {\r\n const token = typeName.getFirstToken();\r\n if (chainText.includes(\"~\")) {\r\n const name = chainText.split(\"~\")[0];\r\n const idef = this.scope.findInterfaceDefinition(name);\r\n if (idef) {\r\n this.scope.addReference(token, idef, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: \"INTF\", ooName: name });\r\n }\r\n }\r\n this.scope.addReference(token, typ, _reference_1.ReferenceType.TypeReference, this.filename);\r\n return typ.getType();\r\n }\r\n const type = (_a = this.scope.findTypePoolType(chainText)) === null || _a === void 0 ? void 0 : _a.getType();\r\n if (type) {\r\n // this.scope.addReference(typeName.getFirstToken(), type, ReferenceType.TypeReference, this.filename);\r\n return type;\r\n }\r\n const ddic = this.scope.getDDIC().lookup(chainText);\r\n if (ddic) {\r\n this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), { object: ddic.object, token: typeName.getFirstToken(), filename: this.filename });\r\n if (ddic.type instanceof _typed_identifier_1.TypedIdentifier) {\r\n this.scope.addReference(typeName.getFirstToken(), ddic.type, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n else if (ddic.type instanceof basic_1.VoidType) {\r\n this.scope.addReference(typeName.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\r\n }\r\n return ddic.type;\r\n }\r\n return undefined;\r\n }\r\n simpleType(node, qualifiedNamePrefix) {\r\n let nameExpr = node.findFirstExpression(Expressions.NamespaceSimpleName);\r\n if (nameExpr === undefined) {\r\n nameExpr = node.findFirstExpression(Expressions.DefinitionName);\r\n }\r\n if (nameExpr === undefined) {\r\n return undefined;\r\n }\r\n let name = nameExpr.getFirstToken();\r\n if (nameExpr.countTokens() > 1) { // workaround for names with dashes\r\n name = new identifier_1.Identifier(name.getStart(), nameExpr.concatTokens());\r\n }\r\n let qualifiedName = undefined;\r\n if (node.get() instanceof Statements.Type) {\r\n if (this.scope.isTypePool() === true) {\r\n qualifiedName = name.getStr();\r\n }\r\n else {\r\n qualifiedName = (qualifiedNamePrefix || \"\") + name.getStr();\r\n if (this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition\r\n || this.scope.getType() === _scope_type_1.ScopeType.Interface) {\r\n qualifiedName = this.scope.getName() + \"=>\" + qualifiedName;\r\n }\r\n }\r\n }\r\n else if (qualifiedNamePrefix) {\r\n qualifiedName = qualifiedNamePrefix + qualifiedName;\r\n }\r\n const found = this.parseType(node, qualifiedName);\r\n if (found) {\r\n return new _typed_identifier_1.TypedIdentifier(name, this.filename, found);\r\n }\r\n return undefined;\r\n }\r\n parseTable(node, name) {\r\n var _a, _b, _c;\r\n const typename = node.findFirstExpression(Expressions.TypeName);\r\n const text = (_a = node.findFirstExpression(Expressions.TypeTable)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();\r\n if (text === undefined) {\r\n return undefined;\r\n }\r\n let type = undefined;\r\n if (text.startsWith(\"TYPE STANDARD TABLE \") || text.startsWith(\"LIKE STANDARD TABLE \")) {\r\n type = basic_1.TableAccessType.standard;\r\n }\r\n else if (text.startsWith(\"TYPE SORTED TABLE \") || text.startsWith(\"LIKE SORTED TABLE \")) {\r\n type = basic_1.TableAccessType.sorted;\r\n }\r\n else if (text.startsWith(\"TYPE HASHED TABLE \") || text.startsWith(\"LIKE HASHED TABLE \")) {\r\n type = basic_1.TableAccessType.hashed;\r\n }\r\n const typeTableKeys = node.findAllExpressions(expressions_1.TypeTableKey);\r\n const firstKey = typeTableKeys[0];\r\n const primaryKey = {\r\n name: \"primary_key\",\r\n type: type,\r\n isUnique: (firstKey === null || firstKey === void 0 ? void 0 : firstKey.concatTokens().toUpperCase().includes(\"WITH UNIQUE \")) === true,\r\n keyFields: [],\r\n };\r\n for (const k of (firstKey === null || firstKey === void 0 ? void 0 : firstKey.findDirectExpressions(expressions_1.FieldSub)) || []) {\r\n primaryKey.keyFields.push(k.concatTokens().toUpperCase());\r\n }\r\n const secondaryKeys = [];\r\n for (let i = 1; i < typeTableKeys.length; i++) {\r\n const row = typeTableKeys[i];\r\n const name = (_b = row.findDirectExpression(expressions_1.Field)) === null || _b === void 0 ? void 0 : _b.concatTokens();\r\n if (name === undefined) {\r\n continue;\r\n }\r\n const secondary = {\r\n name: name,\r\n type: row.findDirectTokenByText(\"SORTED\") ? basic_1.TableAccessType.sorted : basic_1.TableAccessType.hashed,\r\n isUnique: (row === null || row === void 0 ? void 0 : row.concatTokens().toUpperCase().includes(\"WITH UNIQUE \")) === true,\r\n keyFields: [],\r\n };\r\n for (const k of (row === null || row === void 0 ? void 0 : row.findDirectExpressions(expressions_1.FieldSub)) || []) {\r\n secondary.keyFields.push(k.concatTokens().toUpperCase());\r\n }\r\n secondaryKeys.push(secondary);\r\n }\r\n const options = {\r\n withHeader: text.includes(\" WITH HEADER LINE\"),\r\n primaryKey: primaryKey,\r\n secondary: secondaryKeys,\r\n };\r\n let found = undefined;\r\n if (text.startsWith(\"TYPE TABLE OF REF TO \")\r\n || text.startsWith(\"TYPE STANDARD TABLE OF REF TO \")\r\n || text.startsWith(\"TYPE SORTED TABLE OF REF TO \")\r\n || text.startsWith(\"TYPE HASHED TABLE OF REF TO \")) {\r\n found = this.resolveTypeRef(typename);\r\n if (found) {\r\n return new Types.TableType(found, options, name);\r\n }\r\n }\r\n else if (text.startsWith(\"TYPE TABLE OF \")\r\n || text.startsWith(\"TYPE STANDARD TABLE OF \")\r\n || text.startsWith(\"TYPE SORTED TABLE OF \")\r\n || text.startsWith(\"TYPE HASHED TABLE OF \")) {\r\n found = this.resolveTypeName(typename);\r\n if (found) {\r\n return new Types.TableType(found, options, name);\r\n }\r\n }\r\n else if (text.startsWith(\"LIKE TABLE OF \")\r\n || text.startsWith(\"LIKE STANDARD TABLE OF \")\r\n || text.startsWith(\"LIKE SORTED TABLE OF \")\r\n || text.startsWith(\"LIKE HASHED TABLE OF \")) {\r\n found = this.resolveLikeName(node);\r\n if (found) {\r\n return new Types.TableType(found, options, name);\r\n }\r\n }\r\n else if (text === \"TYPE STANDARD TABLE\"\r\n || text === \"TYPE SORTED TABLE\"\r\n || text === \"TYPE HASHED TABLE\"\r\n || text === \"TYPE INDEX TABLE\"\r\n || text === \"TYPE ANY TABLE\") {\r\n return new Types.TableType(new Types.AnyType(), options);\r\n }\r\n else if (text.startsWith(\"TYPE RANGE OF \")) {\r\n const sub = node.findFirstExpression(Expressions.TypeName);\r\n found = this.resolveTypeName(sub);\r\n if (found === undefined) {\r\n return new Types.UnknownType(\"TYPE RANGE OF, could not resolve type\");\r\n }\r\n const structure = new Types.StructureType([\r\n { name: \"sign\", type: new Types.CharacterType(1) },\r\n { name: \"option\", type: new Types.CharacterType(2) },\r\n { name: \"low\", type: found },\r\n { name: \"high\", type: found },\r\n ]);\r\n return new Types.TableType(structure, options, name);\r\n }\r\n else if (text.startsWith(\"LIKE RANGE OF \")) {\r\n const sub = node.findFirstExpression(Expressions.SimpleFieldChain);\r\n found = this.resolveLikeName(sub);\r\n if (found === undefined) {\r\n return new Types.UnknownType(\"LIKE RANGE OF, could not resolve type\");\r\n }\r\n const structure = new Types.StructureType([\r\n { name: \"sign\", type: new Types.CharacterType(1) },\r\n { name: \"option\", type: new Types.CharacterType(2) },\r\n { name: \"low\", type: found },\r\n { name: \"high\", type: found },\r\n ], name);\r\n return new Types.TableType(structure, options);\r\n }\r\n else if (typename && (text.startsWith(\"TYPE TABLE FOR CREATE \")\r\n || text.startsWith(\"TYPE TABLE FOR UPDATE \"))) {\r\n const name = typename.concatTokens();\r\n const type = (_c = this.scope.getDDIC().lookupDDLS(name)) === null || _c === void 0 ? void 0 : _c.type;\r\n if (type) {\r\n return new Types.TableType(new basic_1.VoidType(\"RapTodo\"), options);\r\n }\r\n else if (this.scope.getDDIC().inErrorNamespace(name)) {\r\n return new Types.UnknownType(`DDLS ${name} not found`);\r\n }\r\n else {\r\n return new Types.VoidType(name);\r\n }\r\n }\r\n // fallback to old style syntax, OCCURS etc\r\n return this.parseType(node, name);\r\n }\r\n parseType(node, qualifiedName) {\r\n var _a, _b, _c, _d, _e, _f;\r\n const typeName = node.findFirstExpression(Expressions.TypeName);\r\n let text = (_a = node.findFirstExpression(Expressions.Type)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();\r\n if (text === undefined) {\r\n text = (_b = node.findFirstExpression(Expressions.TypeParam)) === null || _b === void 0 ? void 0 : _b.concatTokens().toUpperCase();\r\n }\r\n if (text === undefined) {\r\n text = (_c = node.findFirstExpression(Expressions.TypeTable)) === null || _c === void 0 ? void 0 : _c.concatTokens().toUpperCase();\r\n if ((text === null || text === void 0 ? void 0 : text.startsWith(\"TYPE\")) === false && (text === null || text === void 0 ? void 0 : text.startsWith(\"LIKE\")) === false) {\r\n text = \"TYPE\";\r\n }\r\n }\r\n if (text === undefined) {\r\n text = (_d = node.findFirstExpression(Expressions.FormParamType)) === null || _d === void 0 ? void 0 : _d.concatTokens().toUpperCase();\r\n }\r\n if (text === undefined) {\r\n text = \"TYPE\";\r\n }\r\n let found = undefined;\r\n if (text.startsWith(\"LIKE LINE OF \")) {\r\n const name = (_e = node.findFirstExpression(Expressions.FieldChain)) === null || _e === void 0 ? void 0 : _e.concatTokens();\r\n let e = node.findFirstExpression(Expressions.Type);\r\n if (e === undefined) {\r\n e = node.findFirstExpression(Expressions.FormParamType);\r\n }\r\n if (e === undefined) {\r\n e = node.findFirstExpression(Expressions.FieldChain);\r\n }\r\n const type = this.resolveLikeName(e, false);\r\n if (type === undefined) {\r\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + name + \"\\\", parseType\");\r\n }\r\n else if (type instanceof Types.TableType) {\r\n return type.getRowType();\r\n }\r\n else if (type instanceof Types.VoidType) {\r\n return type;\r\n }\r\n else {\r\n return new Types.UnknownType(\"Type error, not a table type \" + name);\r\n }\r\n }\r\n else if (text.startsWith(\"LIKE REF TO \")) {\r\n const name = (_f = node.findFirstExpression(Expressions.FieldChain)) === null || _f === void 0 ? void 0 : _f.concatTokens();\r\n const type = this.resolveLikeName(node.findFirstExpression(Expressions.Type), false);\r\n if (type === undefined) {\r\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + name + \"\\\", parseType\");\r\n }\r\n return new Types.DataReference(type, name);\r\n }\r\n else if (text === \"TYPE STANDARD TABLE\"\r\n || text === \"TYPE SORTED TABLE\"\r\n || text === \"TYPE HASHED TABLE\"\r\n || text === \"TYPE INDEX TABLE\"\r\n || text === \"TYPE ANY TABLE\") {\r\n return new Types.TableType(new Types.AnyType(), { withHeader: node.concatTokens().toUpperCase().includes(\"WITH HEADER LINE\") });\r\n }\r\n else if (text.startsWith(\"LIKE \")) {\r\n let sub = node.findFirstExpression(Expressions.Type);\r\n if (sub === undefined) {\r\n sub = node.findFirstExpression(Expressions.FormParamType);\r\n }\r\n if (sub === undefined) {\r\n sub = node.findFirstExpression(Expressions.TypeParam);\r\n }\r\n if (sub === undefined) {\r\n sub = node.findFirstExpression(Expressions.FieldChain);\r\n }\r\n found = this.resolveLikeName(sub);\r\n if (found && this.isOccurs(node)) {\r\n found = new Types.TableType(found, { withHeader: text.includes(\"WITH HEADER LINE\") }, qualifiedName);\r\n }\r\n }\r\n else if (text.startsWith(\"TYPE LINE OF \")) {\r\n const sub = node.findFirstExpression(Expressions.TypeName);\r\n found = this.resolveTypeName(sub);\r\n if (found instanceof _typed_identifier_1.TypedIdentifier) {\r\n found = found.getType();\r\n }\r\n if (found instanceof Types.TableType) {\r\n return found.getRowType();\r\n }\r\n else if (found instanceof Types.VoidType) {\r\n return found;\r\n }\r\n else if (found instanceof Types.UnknownType) {\r\n return new Types.UnknownType(\"TYPE LINE OF, unknown type, \" + found.getError());\r\n }\r\n else {\r\n return new Types.UnknownType(\"TYPE LINE OF, unexpected type, \" + (found === null || found === void 0 ? void 0 : found.constructor.name));\r\n }\r\n }\r\n else if (text.startsWith(\"TYPE REF TO \")) {\r\n found = this.resolveTypeRef(typeName);\r\n }\r\n else if (text.startsWith(\"TYPE\")) {\r\n found = this.resolveTypeName(typeName, this.findLength(node), this.findDecimals(node), qualifiedName);\r\n const concat = node.concatTokens().toUpperCase();\r\n if (found && this.isOccurs(node)) {\r\n found = new Types.TableType(found, { withHeader: concat.includes(\" WITH HEADER LINE\") }, qualifiedName);\r\n }\r\n else if (found && concat.includes(\" WITH HEADER LINE\")) {\r\n if (found instanceof Types.VoidType) {\r\n found = new Types.TableType(found, { withHeader: true });\r\n }\r\n else if (!(found instanceof Types.TableType)) {\r\n throw new Error(\"WITH HEADER LINE can only be used with internal table\");\r\n }\r\n else {\r\n found = new Types.TableType(found.getRowType(), { withHeader: true });\r\n }\r\n }\r\n if (found === undefined && typeName === undefined) {\r\n let length = 1;\r\n const len = node.findDirectExpression(Expressions.ConstantFieldLength);\r\n if (len) {\r\n const int = len.findDirectExpression(Expressions.Integer);\r\n if (int) {\r\n length = parseInt(int.concatTokens(), 10);\r\n }\r\n }\r\n found = new Types.CharacterType(length, { qualifiedName: qualifiedName }); // fallback\r\n if (this.isOccurs(node)) {\r\n found = new Types.TableType(found, { withHeader: concat.includes(\" WITH HEADER LINE\") }, qualifiedName);\r\n }\r\n }\r\n }\r\n return found;\r\n }\r\n /////////////////////\r\n isOccurs(node) {\r\n var _a;\r\n if (node.findDirectTokenByText(\"OCCURS\")) {\r\n return true;\r\n }\r\n else if ((_a = node.findFirstExpression(Expressions.TypeTable)) === null || _a === void 0 ? void 0 : _a.findDirectTokenByText(\"OCCURS\")) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n // todo, rewrite this method\r\n resolveTypeChain(expr) {\r\n var _a;\r\n const chainText = expr.concatTokens().toUpperCase();\r\n if (chainText.includes(\"=>\") === false && chainText.includes(\"-\") === false) {\r\n return undefined;\r\n }\r\n let className;\r\n let rest = chainText;\r\n if (chainText.includes(\"=>\")) {\r\n const split = chainText.split(\"=>\");\r\n className = split[0];\r\n rest = split[1];\r\n }\r\n else if (chainText.includes(\"->\")) {\r\n const split = chainText.split(\"->\");\r\n className = split[0];\r\n rest = split[1];\r\n }\r\n const subs = rest.split(\"-\");\r\n let foundType = undefined;\r\n if (className && chainText.includes(\"=>\")) {\r\n const split = chainText.split(\"=>\");\r\n const className = split[0];\r\n // the prefix might be itself\r\n if ((this.scope.getType() === _scope_type_1.ScopeType.Interface\r\n || this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition)\r\n && this.scope.getName().toUpperCase() === className.toUpperCase()) {\r\n const foundId = this.scope.findType(subs[0]);\r\n foundType = foundId === null || foundId === void 0 ? void 0 : foundId.getType();\r\n if (foundType === undefined) {\r\n return new Types.UnknownType(\"Could not resolve type \" + chainText);\r\n }\r\n this.scope.addReference(expr.getTokens()[2], foundId, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n else {\r\n // lookup in local and global scope\r\n const obj = this.scope.findObjectDefinition(className);\r\n if (obj === undefined && this.scope.getDDIC().inErrorNamespace(className) === false) {\r\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, this.filename, { ooName: className.toUpperCase() });\r\n return new Types.VoidType(className);\r\n }\r\n else if (obj === undefined) {\r\n return new Types.UnknownType(\"Could not resolve top \" + className + \", resolveTypeChain\");\r\n }\r\n const type = obj instanceof types_1.ClassDefinition ? \"CLAS\" : \"INTF\";\r\n this.scope.addReference(expr.getFirstToken(), obj, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: type, ooName: className });\r\n const byName = new _object_oriented_1.ObjectOriented(this.scope).searchTypeName(obj, subs[0]);\r\n foundType = byName === null || byName === void 0 ? void 0 : byName.getType();\r\n if (byName === undefined || foundType === undefined) {\r\n return new Types.UnknownType(subs[0] + \" not found in class or interface\");\r\n }\r\n this.scope.addReference(expr.getTokens()[2], byName, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n }\r\n else if (className && chainText.includes(\"->\")) {\r\n const varVar = this.scope.findVariable(className);\r\n const foo = varVar === null || varVar === void 0 ? void 0 : varVar.getType();\r\n if (foo instanceof basic_1.ObjectReferenceType) {\r\n const typeName = subs[0];\r\n let id = foo.getIdentifier();\r\n if (!(id instanceof types_1.ClassDefinition || id instanceof types_1.InterfaceDefinition)) {\r\n const found = this.scope.findObjectDefinition(foo.getIdentifierName());\r\n if (found) {\r\n id = found;\r\n }\r\n else {\r\n return new Types.UnknownType(foo.getIdentifierName() + \" not found in scope\");\r\n }\r\n }\r\n if (id instanceof types_1.ClassDefinition || id instanceof types_1.InterfaceDefinition) {\r\n const type = id instanceof types_1.ClassDefinition ? \"CLAS\" : \"INTF\";\r\n this.scope.addReference(expr.getFirstToken(), id, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: type, ooName: id.getName() });\r\n const byName = new _object_oriented_1.ObjectOriented(this.scope).searchTypeName(id, typeName);\r\n foundType = byName === null || byName === void 0 ? void 0 : byName.getType();\r\n if (byName === undefined || foundType === undefined) {\r\n return new Types.UnknownType(typeName + \" not found in class or interface\");\r\n }\r\n this.scope.addReference(expr.getTokens()[2], byName, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n else {\r\n return new Types.UnknownType(\"Not an object reference, \" + className + \", \" + id.constructor.name);\r\n }\r\n }\r\n else if (foo === undefined) {\r\n return new Types.UnknownType(className + \" not found in scope\");\r\n }\r\n else {\r\n return new Types.UnknownType(\"Not an object reference, \" + className + \", \" + foo.constructor.name);\r\n }\r\n }\r\n else {\r\n const found = this.scope.findType(subs[0]);\r\n foundType = found === null || found === void 0 ? void 0 : found.getType();\r\n if (foundType === undefined) {\r\n const typePoolType = (_a = this.scope.findTypePoolType(subs[0])) === null || _a === void 0 ? void 0 : _a.getType();\r\n if (typePoolType) {\r\n // this.scope.addReference(typeName.getFirstToken(), typePoolType, ReferenceType.TypeReference, this.filename);\r\n foundType = typePoolType;\r\n }\r\n if (foundType === undefined) {\r\n const f = this.scope.getDDIC().lookupTableOrView(subs[0]);\r\n this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), { object: f.object, filename: this.filename, token: expr.getFirstToken() });\r\n if (f.type instanceof _typed_identifier_1.TypedIdentifier) {\r\n foundType = f.type.getType();\r\n }\r\n else {\r\n foundType = f.type;\r\n }\r\n }\r\n }\r\n else {\r\n this.scope.addReference(expr.getFirstToken(), found, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n if (foundType === undefined && this.scope.getDDIC().inErrorNamespace(subs[0]) === false) {\r\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\r\n return new Types.VoidType(subs[0]);\r\n }\r\n else if (foundType instanceof Types.VoidType) {\r\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\r\n return foundType;\r\n }\r\n else if (foundType === undefined) {\r\n return new Types.UnknownType(\"Unknown type \" + subs[0]);\r\n }\r\n }\r\n subs.shift();\r\n while (subs.length > 0) {\r\n if (foundType instanceof Types.UnknownType\r\n || foundType instanceof Types.VoidType) {\r\n return foundType;\r\n }\r\n else if (!(foundType instanceof Types.StructureType)) {\r\n return new Types.UnknownType(\"Not a structured type\");\r\n }\r\n foundType = foundType.getComponentByName(subs[0]);\r\n subs.shift();\r\n }\r\n return foundType;\r\n }\r\n resolveConstantValue(expr) {\r\n var _a, _b;\r\n // todo: rewrite this method\r\n if (!(expr.get() instanceof Expressions.SimpleFieldChain)) {\r\n throw new Error(\"resolveConstantValue\");\r\n }\r\n const firstNode = expr.getFirstChild();\r\n const firstToken = firstNode.getFirstToken();\r\n const firstName = firstToken.getStr();\r\n if (firstNode.get() instanceof Expressions.Field) {\r\n const found = this.scope.findVariable(firstName);\r\n const val = found === null || found === void 0 ? void 0 : found.getValue();\r\n if (typeof val === \"string\") {\r\n this.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.filename);\r\n return val;\r\n }\r\n else if ((found === null || found === void 0 ? void 0 : found.getType()) instanceof basic_1.StructureType) {\r\n this.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.filename);\r\n }\r\n return undefined;\r\n }\r\n else if (firstNode.get() instanceof Expressions.ClassName\r\n && firstName.toLowerCase() === this.scope.getName().toLowerCase()\r\n && (this.scope.getType() === _scope_type_1.ScopeType.Interface\r\n || this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition)) {\r\n const children = expr.getChildren();\r\n const token = (_a = children[2]) === null || _a === void 0 ? void 0 : _a.getFirstToken();\r\n const found = this.scope.findVariable(token.getStr());\r\n const val = found === null || found === void 0 ? void 0 : found.getValue();\r\n if (typeof val === \"string\") {\r\n this.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.filename);\r\n return val;\r\n }\r\n return undefined;\r\n }\r\n else if (firstNode.get() instanceof Expressions.ClassName) {\r\n const obj = this.scope.findObjectDefinition(firstName);\r\n if (obj === undefined) {\r\n if (this.scope.existsObject(firstName).found === true) {\r\n return undefined;\r\n }\r\n else if (this.scope.getDDIC().inErrorNamespace(firstName) === true) {\r\n throw new Error(\"resolveConstantValue, not found: \" + firstName);\r\n }\r\n else {\r\n this.scope.addReference(firstNode.getFirstToken(), undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, this.filename, { ooName: firstName.toUpperCase() });\r\n return undefined;\r\n }\r\n }\r\n const children = expr.getChildren();\r\n const token = (_b = children[2]) === null || _b === void 0 ? void 0 : _b.getFirstToken();\r\n const attr = token.getStr();\r\n const c = new _object_oriented_1.ObjectOriented(this.scope).searchConstantName(obj, attr);\r\n if (c instanceof class_constant_1.ClassConstant) {\r\n this.scope.addReference(token, c, _reference_1.ReferenceType.DataReadReference, this.filename);\r\n const val = c.getValue();\r\n if (typeof val === \"string\") {\r\n return val;\r\n }\r\n else if (typeof val === \"object\" && children[4]) {\r\n const name = children[4].getFirstToken().getStr();\r\n if (val[name] !== undefined) {\r\n return val[name];\r\n }\r\n }\r\n return undefined;\r\n }\r\n throw new Error(\"resolveConstantValue, constant not found \" + attr);\r\n }\r\n else {\r\n throw new Error(\"resolveConstantValue, unexpected structure\");\r\n }\r\n }\r\n resolveTypeRef(chain) {\r\n var _a;\r\n if (chain === undefined) {\r\n return undefined;\r\n }\r\n const name = chain.getFirstToken().getStr();\r\n if (chain.getAllTokens().length === 1) {\r\n if (name.toUpperCase() === \"OBJECT\") {\r\n return new Types.GenericObjectReferenceType();\r\n }\r\n const search = this.scope.existsObject(name);\r\n if (search.found === true && search.id) {\r\n this.scope.addReference(chain.getFirstToken(), search.id, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: search.ooType, ooName: name });\r\n return new Types.ObjectReferenceType(search.id, name);\r\n }\r\n }\r\n const found = this.resolveTypeName(chain);\r\n if (found && !(found instanceof Types.UnknownType) && !(found instanceof Types.VoidType)) {\r\n return new Types.DataReference(found);\r\n }\r\n else if (chain.concatTokens().toUpperCase() === \"DATA\") {\r\n return new Types.DataReference(new Types.AnyType());\r\n }\r\n if (this.scope.isBadiDef(name) === true) {\r\n return new Types.VoidType(name);\r\n }\r\n if (((_a = this.scope.getDDIC()) === null || _a === void 0 ? void 0 : _a.inErrorNamespace(name)) === false) {\r\n // this.scope.addReference(chain.getFirstToken(), undefined, ReferenceType.VoidType, this.filename);\r\n return new Types.VoidType(name);\r\n }\r\n return new Types.UnknownType(\"REF, unable to resolve \" + name);\r\n }\r\n findValue(node) {\r\n const val = node.findFirstExpression(Expressions.Value);\r\n if (val === undefined) {\r\n throw new Error(\"VALUE missing in expression\");\r\n }\r\n if (val.concatTokens().toUpperCase() === \"VALUE IS INITIAL\") {\r\n return undefined;\r\n }\r\n const constant = val.findFirstExpression(Expressions.Constant);\r\n if (constant) {\r\n return constant.concatTokens();\r\n }\r\n const chain = val.findFirstExpression(Expressions.SimpleFieldChain);\r\n if (chain) {\r\n return this.resolveConstantValue(chain);\r\n }\r\n throw new Error(\"findValue, unexpected\");\r\n }\r\n findDecimals(node) {\r\n var _a, _b;\r\n const dec = (_b = (_a = node.findDirectExpression(Expressions.Decimals)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Integer)) === null || _b === void 0 ? void 0 : _b.concatTokens();\r\n if (dec) {\r\n return parseInt(dec, 10);\r\n }\r\n return undefined;\r\n }\r\n findLength(node) {\r\n const val = node.findFirstExpression(Expressions.Length);\r\n const flen = node.findFirstExpression(Expressions.ConstantFieldLength);\r\n if (val && flen) {\r\n throw new Error(\"Only specify length once\");\r\n }\r\n if (flen) {\r\n const cintExpr = flen.findFirstExpression(Expressions.Integer);\r\n if (cintExpr) {\r\n return this.parseInt(cintExpr.concatTokens());\r\n }\r\n const cchain = flen.findFirstExpression(Expressions.SimpleFieldChain);\r\n if (cchain) {\r\n const val = this.resolveConstantValue(cchain);\r\n return this.parseInt(val);\r\n }\r\n }\r\n if (val === undefined) {\r\n return 1;\r\n }\r\n const intExpr = val.findFirstExpression(Expressions.Integer);\r\n if (intExpr) {\r\n return this.parseInt(intExpr.concatTokens());\r\n }\r\n const strExpr = val.findFirstExpression(Expressions.ConstantString);\r\n if (strExpr) {\r\n return this.parseInt(strExpr.concatTokens());\r\n }\r\n const chain = val.findFirstExpression(Expressions.SimpleFieldChain);\r\n if (chain) {\r\n const val = this.resolveConstantValue(chain);\r\n return this.parseInt(val);\r\n }\r\n throw new Error(\"Unexpected, findLength\");\r\n }\r\n parseInt(text) {\r\n if (text === undefined) {\r\n return undefined;\r\n }\r\n if (text.startsWith(\"'\")) {\r\n text = text.split(\"'\")[1];\r\n }\r\n else if (text.startsWith(\"`\")) {\r\n text = text.split(\"`\")[1];\r\n }\r\n return parseInt(text, 10);\r\n }\r\n}\r\nexports.BasicTypes = BasicTypes;\r\n//# sourceMappingURL=basic_types.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/abap/5_syntax/basic_types.js?");
|
|
6751
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.BasicTypes = void 0;\r\n/* eslint-disable default-case */\r\nconst _typed_identifier_1 = __webpack_require__(/*! ../types/_typed_identifier */ \"./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js\");\r\nconst Expressions = __webpack_require__(/*! ../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst Statements = __webpack_require__(/*! ../2_statements/statements */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js\");\r\nconst Types = __webpack_require__(/*! ../types/basic */ \"./node_modules/@abaplint/core/build/src/abap/types/basic/index.js\");\r\nconst _scope_type_1 = __webpack_require__(/*! ./_scope_type */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js\");\r\nconst _object_oriented_1 = __webpack_require__(/*! ./_object_oriented */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_object_oriented.js\");\r\nconst class_constant_1 = __webpack_require__(/*! ../types/class_constant */ \"./node_modules/@abaplint/core/build/src/abap/types/class_constant.js\");\r\nconst identifier_1 = __webpack_require__(/*! ../1_lexer/tokens/identifier */ \"./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/identifier.js\");\r\nconst _reference_1 = __webpack_require__(/*! ./_reference */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js\");\r\nconst basic_1 = __webpack_require__(/*! ../types/basic */ \"./node_modules/@abaplint/core/build/src/abap/types/basic/index.js\");\r\nconst field_chain_1 = __webpack_require__(/*! ./expressions/field_chain */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/field_chain.js\");\r\nconst types_1 = __webpack_require__(/*! ../types */ \"./node_modules/@abaplint/core/build/src/abap/types/index.js\");\r\nconst expressions_1 = __webpack_require__(/*! ../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst _builtin_1 = __webpack_require__(/*! ./_builtin */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_builtin.js\");\r\nconst position_1 = __webpack_require__(/*! ../../position */ \"./node_modules/@abaplint/core/build/src/position.js\");\r\nclass BasicTypes {\r\n constructor(filename, scope) {\r\n this.filename = filename;\r\n this.scope = scope;\r\n }\r\n lookupQualifiedName(name) {\r\n var _a;\r\n // argh, todo, rewrite this entire method, more argh\r\n if (name === undefined) {\r\n return undefined;\r\n }\r\n const found = this.scope.findType(name);\r\n if (found) {\r\n return found;\r\n }\r\n if (name.includes(\"=>\")) {\r\n const split = name.split(\"=>\");\r\n const ooName = split[0];\r\n const typeName = split[1];\r\n const oo = this.scope.findObjectDefinition(ooName);\r\n if (oo) {\r\n if (typeName.includes(\"-\")) {\r\n const split = typeName.split(\"-\");\r\n const subTypeName = split[0];\r\n const fieldName = split[1];\r\n const stru = oo.getTypeDefinitions().getByName(subTypeName);\r\n const struType = stru === null || stru === void 0 ? void 0 : stru.getType();\r\n if (stru && struType instanceof basic_1.StructureType) {\r\n const f = struType.getComponentByName(fieldName);\r\n if (f) {\r\n return new _typed_identifier_1.TypedIdentifier(stru.getToken(), stru.getFilename(), f);\r\n }\r\n }\r\n }\r\n else {\r\n const f = oo.getTypeDefinitions().getByName(typeName);\r\n if (f) {\r\n return f;\r\n }\r\n }\r\n }\r\n }\r\n else if (name.includes(\"-\")) {\r\n const split = name.split(\"-\");\r\n const typeName = split[0];\r\n const fieldName = split[1];\r\n const type = this.scope.findType(typeName);\r\n if (type) {\r\n const stru = type.getType();\r\n if (stru instanceof basic_1.StructureType) {\r\n const f = stru.getComponentByName(fieldName);\r\n if (f) {\r\n return new _typed_identifier_1.TypedIdentifier(type.getToken(), type.getFilename(), f);\r\n }\r\n }\r\n }\r\n }\r\n const lookup = this.scope.getDDIC().lookupNoVoid(name);\r\n const id = (_a = lookup === null || lookup === void 0 ? void 0 : lookup.object) === null || _a === void 0 ? void 0 : _a.getIdentifier();\r\n if (id && (lookup === null || lookup === void 0 ? void 0 : lookup.type)) {\r\n return new _typed_identifier_1.TypedIdentifier(id.getToken(), id.getFilename(), lookup.type);\r\n }\r\n const builtin = this.scope.getDDIC().lookupBuiltinType(name);\r\n if (builtin) {\r\n return new _typed_identifier_1.TypedIdentifier(new identifier_1.Identifier(new position_1.Position(1, 1), name), _builtin_1.BuiltIn.filename, builtin);\r\n }\r\n const type = this.scope.findTypePoolType(name);\r\n if (type) {\r\n return type;\r\n }\r\n return undefined;\r\n }\r\n resolveLikeName(node, headerLogic = true) {\r\n var _a;\r\n if (node === undefined) {\r\n return undefined;\r\n }\r\n let chain = node.findFirstExpression(Expressions.FieldChain);\r\n if (chain === undefined) {\r\n chain = node.findFirstExpression(Expressions.TypeName);\r\n }\r\n if (chain === undefined) {\r\n chain = node.findFirstExpression(Expressions.FieldSub);\r\n }\r\n if (chain === undefined) {\r\n chain = node.findFirstExpression(Expressions.SimpleFieldChain);\r\n }\r\n if (chain === undefined) {\r\n throw new Error(\"resolveLikeName, chain undefined\");\r\n }\r\n const fullName = chain.concatTokens();\r\n const children = [...chain.getChildren()];\r\n if (children.length === 0) {\r\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + fullName + \"\\\", resolveLikeName1\");\r\n }\r\n let type = undefined;\r\n if (children[1] && (children[1].getFirstToken().getStr() === \"=>\" || children[1].getFirstToken().getStr() === \"->\")) {\r\n type = new field_chain_1.FieldChain().runSyntax(chain, this.scope, this.filename, _reference_1.ReferenceType.TypeReference);\r\n }\r\n else {\r\n const name = children.shift().getFirstToken().getStr();\r\n let found = this.scope.findVariable(name);\r\n type = found === null || found === void 0 ? void 0 : found.getType();\r\n if (found === undefined) {\r\n found = this.scope.findExtraLikeType(name);\r\n type = found === null || found === void 0 ? void 0 : found.getType();\r\n }\r\n if (found) {\r\n this.scope.addReference(chain === null || chain === void 0 ? void 0 : chain.getFirstToken(), found, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n if (type === undefined) {\r\n type = (_a = this.scope.getDDIC().lookupNoVoid(name)) === null || _a === void 0 ? void 0 : _a.type;\r\n }\r\n if (type === undefined && this.scope.isOO() === false && this.scope.getDDIC().inErrorNamespace(name) === false) {\r\n this.scope.addReference(chain.getChildren()[0].getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\r\n return new Types.VoidType(name);\r\n }\r\n while (children.length > 0) {\r\n const child = children.shift();\r\n if (child.getFirstToken().getStr() === \"-\") {\r\n if (type instanceof Types.VoidType) {\r\n return type;\r\n }\r\n }\r\n else if (child.concatTokens() === \"[]\") {\r\n if (type instanceof Types.TableType) {\r\n type = new basic_1.TableType(type.getRowType(), { withHeader: false });\r\n }\r\n }\r\n else { // field name\r\n let sub = undefined;\r\n if (type instanceof Types.TableType) {\r\n type = type.getRowType();\r\n }\r\n if (type instanceof Types.StructureType) {\r\n sub = type.getComponentByName(child.getFirstToken().getStr());\r\n }\r\n if (sub === undefined) {\r\n return new Types.UnknownType(\"Type error, field not part of structure \" + fullName);\r\n }\r\n type = sub;\r\n }\r\n }\r\n if (type instanceof Types.VoidType) {\r\n return type;\r\n }\r\n else if (type instanceof basic_1.TableType\r\n && type.isWithHeader()\r\n && headerLogic === true) {\r\n type = type.getRowType();\r\n }\r\n else if (type instanceof Types.TableType\r\n && type.isWithHeader() === true\r\n && type.getRowType() instanceof Types.VoidType) {\r\n return type.getRowType();\r\n }\r\n }\r\n if (!type) {\r\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + fullName + \"\\\", resolveLikeName2\");\r\n }\r\n return type;\r\n }\r\n resolveTypeName(typeName, length, decimals, qualifiedName) {\r\n var _a;\r\n if (typeName === undefined) {\r\n return undefined;\r\n }\r\n let chain = this.resolveTypeChain(typeName);\r\n if (chain) {\r\n if (chain instanceof basic_1.CharacterType && qualifiedName) {\r\n chain = chain.cloneType(qualifiedName);\r\n }\r\n return chain;\r\n }\r\n const chainText = typeName.concatTokens().toUpperCase();\r\n const f = this.scope.getDDIC().lookupBuiltinType(chainText, length, decimals, qualifiedName);\r\n if (f !== undefined) {\r\n return f;\r\n }\r\n const typ = this.scope.findType(chainText);\r\n if (typ) {\r\n const token = typeName.getFirstToken();\r\n if (chainText.includes(\"~\")) {\r\n const name = chainText.split(\"~\")[0];\r\n const idef = this.scope.findInterfaceDefinition(name);\r\n if (idef) {\r\n this.scope.addReference(token, idef, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: \"INTF\", ooName: name });\r\n }\r\n }\r\n this.scope.addReference(token, typ, _reference_1.ReferenceType.TypeReference, this.filename);\r\n return typ.getType();\r\n }\r\n const type = (_a = this.scope.findTypePoolType(chainText)) === null || _a === void 0 ? void 0 : _a.getType();\r\n if (type) {\r\n // this.scope.addReference(typeName.getFirstToken(), type, ReferenceType.TypeReference, this.filename);\r\n return type;\r\n }\r\n const ddic = this.scope.getDDIC().lookup(chainText);\r\n if (ddic) {\r\n this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), { object: ddic.object, token: typeName.getFirstToken(), filename: this.filename });\r\n if (ddic.type instanceof _typed_identifier_1.TypedIdentifier) {\r\n this.scope.addReference(typeName.getFirstToken(), ddic.type, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n else if (ddic.type instanceof basic_1.VoidType) {\r\n this.scope.addReference(typeName.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\r\n }\r\n return ddic.type;\r\n }\r\n return undefined;\r\n }\r\n simpleType(node, qualifiedNamePrefix) {\r\n let nameExpr = node.findFirstExpression(Expressions.NamespaceSimpleName);\r\n if (nameExpr === undefined) {\r\n nameExpr = node.findFirstExpression(Expressions.DefinitionName);\r\n }\r\n if (nameExpr === undefined) {\r\n return undefined;\r\n }\r\n let name = nameExpr.getFirstToken();\r\n if (nameExpr.countTokens() > 1) { // workaround for names with dashes\r\n name = new identifier_1.Identifier(name.getStart(), nameExpr.concatTokens());\r\n }\r\n let qualifiedName = undefined;\r\n if (node.get() instanceof Statements.Type) {\r\n if (this.scope.isTypePool() === true) {\r\n qualifiedName = name.getStr();\r\n }\r\n else {\r\n qualifiedName = (qualifiedNamePrefix || \"\") + name.getStr();\r\n if (this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition\r\n || this.scope.getType() === _scope_type_1.ScopeType.Interface) {\r\n qualifiedName = this.scope.getName() + \"=>\" + qualifiedName;\r\n }\r\n }\r\n }\r\n else if (qualifiedNamePrefix) {\r\n qualifiedName = qualifiedNamePrefix + qualifiedName;\r\n }\r\n const found = this.parseType(node, qualifiedName);\r\n if (found) {\r\n return new _typed_identifier_1.TypedIdentifier(name, this.filename, found);\r\n }\r\n return undefined;\r\n }\r\n parseTable(node, name) {\r\n var _a, _b, _c;\r\n const typename = node.findFirstExpression(Expressions.TypeName);\r\n const text = (_a = node.findFirstExpression(Expressions.TypeTable)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();\r\n if (text === undefined) {\r\n return undefined;\r\n }\r\n let type = undefined;\r\n if (text.startsWith(\"TYPE STANDARD TABLE \") || text.startsWith(\"LIKE STANDARD TABLE \")) {\r\n type = basic_1.TableAccessType.standard;\r\n }\r\n else if (text.startsWith(\"TYPE SORTED TABLE \") || text.startsWith(\"LIKE SORTED TABLE \")) {\r\n type = basic_1.TableAccessType.sorted;\r\n }\r\n else if (text.startsWith(\"TYPE HASHED TABLE \") || text.startsWith(\"LIKE HASHED TABLE \")) {\r\n type = basic_1.TableAccessType.hashed;\r\n }\r\n const typeTableKeys = node.findAllExpressions(expressions_1.TypeTableKey);\r\n const firstKey = typeTableKeys[0];\r\n const primaryKey = {\r\n name: \"primary_key\",\r\n type: type,\r\n isUnique: (firstKey === null || firstKey === void 0 ? void 0 : firstKey.concatTokens().toUpperCase().includes(\"WITH UNIQUE \")) === true,\r\n keyFields: [],\r\n };\r\n for (const k of (firstKey === null || firstKey === void 0 ? void 0 : firstKey.findDirectExpressions(expressions_1.FieldSub)) || []) {\r\n primaryKey.keyFields.push(k.concatTokens().toUpperCase());\r\n }\r\n const secondaryKeys = [];\r\n for (let i = 1; i < typeTableKeys.length; i++) {\r\n const row = typeTableKeys[i];\r\n const name = (_b = row.findDirectExpression(expressions_1.Field)) === null || _b === void 0 ? void 0 : _b.concatTokens();\r\n if (name === undefined) {\r\n continue;\r\n }\r\n const secondary = {\r\n name: name,\r\n type: row.findDirectTokenByText(\"SORTED\") ? basic_1.TableAccessType.sorted : basic_1.TableAccessType.hashed,\r\n isUnique: (row === null || row === void 0 ? void 0 : row.concatTokens().toUpperCase().includes(\"WITH UNIQUE \")) === true,\r\n keyFields: [],\r\n };\r\n for (const k of (row === null || row === void 0 ? void 0 : row.findDirectExpressions(expressions_1.FieldSub)) || []) {\r\n secondary.keyFields.push(k.concatTokens().toUpperCase());\r\n }\r\n secondaryKeys.push(secondary);\r\n }\r\n const options = {\r\n withHeader: text.includes(\" WITH HEADER LINE\"),\r\n primaryKey: primaryKey,\r\n secondary: secondaryKeys,\r\n };\r\n let found = undefined;\r\n if (text.startsWith(\"TYPE TABLE OF REF TO \")\r\n || text.startsWith(\"TYPE STANDARD TABLE OF REF TO \")\r\n || text.startsWith(\"TYPE SORTED TABLE OF REF TO \")\r\n || text.startsWith(\"TYPE HASHED TABLE OF REF TO \")) {\r\n found = this.resolveTypeRef(typename);\r\n if (found) {\r\n return new Types.TableType(found, options, name);\r\n }\r\n }\r\n else if (text.startsWith(\"TYPE TABLE OF \")\r\n || text.startsWith(\"TYPE STANDARD TABLE OF \")\r\n || text.startsWith(\"TYPE SORTED TABLE OF \")\r\n || text.startsWith(\"TYPE HASHED TABLE OF \")) {\r\n found = this.resolveTypeName(typename);\r\n if (found) {\r\n return new Types.TableType(found, options, name);\r\n }\r\n }\r\n else if (text.startsWith(\"LIKE TABLE OF \")\r\n || text.startsWith(\"LIKE STANDARD TABLE OF \")\r\n || text.startsWith(\"LIKE SORTED TABLE OF \")\r\n || text.startsWith(\"LIKE HASHED TABLE OF \")) {\r\n found = this.resolveLikeName(node);\r\n if (found) {\r\n return new Types.TableType(found, options, name);\r\n }\r\n }\r\n else if (text === \"TYPE STANDARD TABLE\"\r\n || text === \"TYPE SORTED TABLE\"\r\n || text === \"TYPE HASHED TABLE\"\r\n || text === \"TYPE INDEX TABLE\"\r\n || text === \"TYPE ANY TABLE\") {\r\n return new Types.TableType(new Types.AnyType(), options);\r\n }\r\n else if (text.startsWith(\"TYPE RANGE OF \")) {\r\n const sub = node.findFirstExpression(Expressions.TypeName);\r\n found = this.resolveTypeName(sub);\r\n if (found === undefined) {\r\n return new Types.UnknownType(\"TYPE RANGE OF, could not resolve type\");\r\n }\r\n const structure = new Types.StructureType([\r\n { name: \"sign\", type: new Types.CharacterType(1) },\r\n { name: \"option\", type: new Types.CharacterType(2) },\r\n { name: \"low\", type: found },\r\n { name: \"high\", type: found },\r\n ]);\r\n return new Types.TableType(structure, options, name);\r\n }\r\n else if (text.startsWith(\"LIKE RANGE OF \")) {\r\n const sub = node.findFirstExpression(Expressions.SimpleFieldChain);\r\n found = this.resolveLikeName(sub);\r\n if (found === undefined) {\r\n return new Types.UnknownType(\"LIKE RANGE OF, could not resolve type\");\r\n }\r\n const structure = new Types.StructureType([\r\n { name: \"sign\", type: new Types.CharacterType(1) },\r\n { name: \"option\", type: new Types.CharacterType(2) },\r\n { name: \"low\", type: found },\r\n { name: \"high\", type: found },\r\n ], name);\r\n return new Types.TableType(structure, options);\r\n }\r\n else if (typename && (text.startsWith(\"TYPE TABLE FOR CREATE \")\r\n || text.startsWith(\"TYPE TABLE FOR UPDATE \"))) {\r\n const name = typename.concatTokens();\r\n const type = (_c = this.scope.getDDIC().lookupDDLS(name)) === null || _c === void 0 ? void 0 : _c.type;\r\n if (type) {\r\n return new Types.TableType(new basic_1.VoidType(\"RapTodo\"), options);\r\n }\r\n else if (this.scope.getDDIC().inErrorNamespace(name)) {\r\n return new Types.UnknownType(`DDLS ${name} not found`);\r\n }\r\n else {\r\n return new Types.VoidType(name);\r\n }\r\n }\r\n // fallback to old style syntax, OCCURS etc\r\n return this.parseType(node, name);\r\n }\r\n parseType(node, qualifiedName) {\r\n var _a, _b, _c, _d, _e, _f;\r\n const typeName = node.findFirstExpression(Expressions.TypeName);\r\n let text = (_a = node.findFirstExpression(Expressions.Type)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();\r\n if (text === undefined) {\r\n text = (_b = node.findFirstExpression(Expressions.TypeParam)) === null || _b === void 0 ? void 0 : _b.concatTokens().toUpperCase();\r\n }\r\n if (text === undefined) {\r\n text = (_c = node.findFirstExpression(Expressions.TypeTable)) === null || _c === void 0 ? void 0 : _c.concatTokens().toUpperCase();\r\n if ((text === null || text === void 0 ? void 0 : text.startsWith(\"TYPE\")) === false && (text === null || text === void 0 ? void 0 : text.startsWith(\"LIKE\")) === false) {\r\n text = \"TYPE\";\r\n }\r\n }\r\n if (text === undefined) {\r\n text = (_d = node.findFirstExpression(Expressions.FormParamType)) === null || _d === void 0 ? void 0 : _d.concatTokens().toUpperCase();\r\n }\r\n if (text === undefined\r\n && node.get() instanceof Statements.Parameter\r\n && node.findDirectTokenByText(\"LIKE\")) {\r\n text = \"LIKE \" + (typeName === null || typeName === void 0 ? void 0 : typeName.concatTokens());\r\n }\r\n if (text === undefined) {\r\n text = \"TYPE\";\r\n }\r\n let found = undefined;\r\n if (text.startsWith(\"LIKE LINE OF \")) {\r\n const name = (_e = node.findFirstExpression(Expressions.FieldChain)) === null || _e === void 0 ? void 0 : _e.concatTokens();\r\n let e = node.findFirstExpression(Expressions.Type);\r\n if (e === undefined) {\r\n e = node.findFirstExpression(Expressions.FormParamType);\r\n }\r\n if (e === undefined) {\r\n e = node.findFirstExpression(Expressions.FieldChain);\r\n }\r\n const type = this.resolveLikeName(e, false);\r\n if (type === undefined) {\r\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + name + \"\\\", parseType\");\r\n }\r\n else if (type instanceof Types.TableType) {\r\n return type.getRowType();\r\n }\r\n else if (type instanceof Types.VoidType) {\r\n return type;\r\n }\r\n else {\r\n return new Types.UnknownType(\"Type error, not a table type \" + name);\r\n }\r\n }\r\n else if (text.startsWith(\"LIKE REF TO \")) {\r\n const name = (_f = node.findFirstExpression(Expressions.FieldChain)) === null || _f === void 0 ? void 0 : _f.concatTokens();\r\n const type = this.resolveLikeName(node.findFirstExpression(Expressions.Type), false);\r\n if (type === undefined) {\r\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + name + \"\\\", parseType\");\r\n }\r\n return new Types.DataReference(type, name);\r\n }\r\n else if (text === \"TYPE STANDARD TABLE\"\r\n || text === \"TYPE SORTED TABLE\"\r\n || text === \"TYPE HASHED TABLE\"\r\n || text === \"TYPE INDEX TABLE\"\r\n || text === \"TYPE ANY TABLE\") {\r\n return new Types.TableType(new Types.AnyType(), { withHeader: node.concatTokens().toUpperCase().includes(\"WITH HEADER LINE\") });\r\n }\r\n else if (text.startsWith(\"LIKE \")) {\r\n let sub = node.findFirstExpression(Expressions.Type);\r\n if (sub === undefined) {\r\n sub = node.findFirstExpression(Expressions.FormParamType);\r\n }\r\n if (sub === undefined) {\r\n sub = node.findFirstExpression(Expressions.TypeParam);\r\n }\r\n if (sub === undefined) {\r\n sub = node.findFirstExpression(Expressions.FieldChain);\r\n }\r\n if (sub === undefined) {\r\n sub = node.findFirstExpression(Expressions.TypeName);\r\n }\r\n found = this.resolveLikeName(sub);\r\n if (found && this.isOccurs(node)) {\r\n found = new Types.TableType(found, { withHeader: text.includes(\"WITH HEADER LINE\") }, qualifiedName);\r\n }\r\n }\r\n else if (text.startsWith(\"TYPE LINE OF \")) {\r\n const sub = node.findFirstExpression(Expressions.TypeName);\r\n found = this.resolveTypeName(sub);\r\n if (found instanceof _typed_identifier_1.TypedIdentifier) {\r\n found = found.getType();\r\n }\r\n if (found instanceof Types.TableType) {\r\n return found.getRowType();\r\n }\r\n else if (found instanceof Types.VoidType) {\r\n return found;\r\n }\r\n else if (found instanceof Types.UnknownType) {\r\n return new Types.UnknownType(\"TYPE LINE OF, unknown type, \" + found.getError());\r\n }\r\n else {\r\n return new Types.UnknownType(\"TYPE LINE OF, unexpected type, \" + (found === null || found === void 0 ? void 0 : found.constructor.name));\r\n }\r\n }\r\n else if (text.startsWith(\"TYPE REF TO \")) {\r\n found = this.resolveTypeRef(typeName);\r\n }\r\n else if (text.startsWith(\"TYPE\")) {\r\n found = this.resolveTypeName(typeName, this.findLength(node), this.findDecimals(node), qualifiedName);\r\n const concat = node.concatTokens().toUpperCase();\r\n if (found && this.isOccurs(node)) {\r\n found = new Types.TableType(found, { withHeader: concat.includes(\" WITH HEADER LINE\") }, qualifiedName);\r\n }\r\n else if (found && concat.includes(\" WITH HEADER LINE\")) {\r\n if (found instanceof Types.VoidType) {\r\n found = new Types.TableType(found, { withHeader: true });\r\n }\r\n else if (!(found instanceof Types.TableType)) {\r\n throw new Error(\"WITH HEADER LINE can only be used with internal table\");\r\n }\r\n else {\r\n found = new Types.TableType(found.getRowType(), { withHeader: true });\r\n }\r\n }\r\n if (found === undefined && typeName === undefined) {\r\n let length = 1;\r\n const len = node.findDirectExpression(Expressions.ConstantFieldLength);\r\n if (len) {\r\n const int = len.findDirectExpression(Expressions.Integer);\r\n if (int) {\r\n length = parseInt(int.concatTokens(), 10);\r\n }\r\n }\r\n found = new Types.CharacterType(length, { qualifiedName: qualifiedName }); // fallback\r\n if (this.isOccurs(node)) {\r\n found = new Types.TableType(found, { withHeader: concat.includes(\" WITH HEADER LINE\") }, qualifiedName);\r\n }\r\n }\r\n }\r\n return found;\r\n }\r\n /////////////////////\r\n isOccurs(node) {\r\n var _a;\r\n if (node.findDirectTokenByText(\"OCCURS\")) {\r\n return true;\r\n }\r\n else if ((_a = node.findFirstExpression(Expressions.TypeTable)) === null || _a === void 0 ? void 0 : _a.findDirectTokenByText(\"OCCURS\")) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n // todo, rewrite this method\r\n resolveTypeChain(expr) {\r\n var _a;\r\n const chainText = expr.concatTokens().toUpperCase();\r\n if (chainText.includes(\"=>\") === false && chainText.includes(\"-\") === false) {\r\n return undefined;\r\n }\r\n let className;\r\n let rest = chainText;\r\n if (chainText.includes(\"=>\")) {\r\n const split = chainText.split(\"=>\");\r\n className = split[0];\r\n rest = split[1];\r\n }\r\n else if (chainText.includes(\"->\")) {\r\n const split = chainText.split(\"->\");\r\n className = split[0];\r\n rest = split[1];\r\n }\r\n const subs = rest.split(\"-\");\r\n let foundType = undefined;\r\n if (className && chainText.includes(\"=>\")) {\r\n const split = chainText.split(\"=>\");\r\n const className = split[0];\r\n // the prefix might be itself\r\n if ((this.scope.getType() === _scope_type_1.ScopeType.Interface\r\n || this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition)\r\n && this.scope.getName().toUpperCase() === className.toUpperCase()) {\r\n const foundId = this.scope.findType(subs[0]);\r\n foundType = foundId === null || foundId === void 0 ? void 0 : foundId.getType();\r\n if (foundType === undefined) {\r\n return new Types.UnknownType(\"Could not resolve type \" + chainText);\r\n }\r\n this.scope.addReference(expr.getTokens()[2], foundId, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n else {\r\n // lookup in local and global scope\r\n const obj = this.scope.findObjectDefinition(className);\r\n if (obj === undefined && this.scope.getDDIC().inErrorNamespace(className) === false) {\r\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, this.filename, { ooName: className.toUpperCase() });\r\n return new Types.VoidType(className);\r\n }\r\n else if (obj === undefined) {\r\n return new Types.UnknownType(\"Could not resolve top \" + className + \", resolveTypeChain\");\r\n }\r\n const type = obj instanceof types_1.ClassDefinition ? \"CLAS\" : \"INTF\";\r\n this.scope.addReference(expr.getFirstToken(), obj, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: type, ooName: className });\r\n const byName = new _object_oriented_1.ObjectOriented(this.scope).searchTypeName(obj, subs[0]);\r\n foundType = byName === null || byName === void 0 ? void 0 : byName.getType();\r\n if (byName === undefined || foundType === undefined) {\r\n return new Types.UnknownType(subs[0] + \" not found in class or interface\");\r\n }\r\n this.scope.addReference(expr.getTokens()[2], byName, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n }\r\n else if (className && chainText.includes(\"->\")) {\r\n const varVar = this.scope.findVariable(className);\r\n const foo = varVar === null || varVar === void 0 ? void 0 : varVar.getType();\r\n if (foo instanceof basic_1.ObjectReferenceType) {\r\n const typeName = subs[0];\r\n let id = foo.getIdentifier();\r\n if (!(id instanceof types_1.ClassDefinition || id instanceof types_1.InterfaceDefinition)) {\r\n const found = this.scope.findObjectDefinition(foo.getIdentifierName());\r\n if (found) {\r\n id = found;\r\n }\r\n else {\r\n return new Types.UnknownType(foo.getIdentifierName() + \" not found in scope\");\r\n }\r\n }\r\n if (id instanceof types_1.ClassDefinition || id instanceof types_1.InterfaceDefinition) {\r\n const type = id instanceof types_1.ClassDefinition ? \"CLAS\" : \"INTF\";\r\n this.scope.addReference(expr.getFirstToken(), id, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: type, ooName: id.getName() });\r\n const byName = new _object_oriented_1.ObjectOriented(this.scope).searchTypeName(id, typeName);\r\n foundType = byName === null || byName === void 0 ? void 0 : byName.getType();\r\n if (byName === undefined || foundType === undefined) {\r\n return new Types.UnknownType(typeName + \" not found in class or interface\");\r\n }\r\n this.scope.addReference(expr.getTokens()[2], byName, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n else {\r\n return new Types.UnknownType(\"Not an object reference, \" + className + \", \" + id.constructor.name);\r\n }\r\n }\r\n else if (foo === undefined) {\r\n return new Types.UnknownType(className + \" not found in scope\");\r\n }\r\n else {\r\n return new Types.UnknownType(\"Not an object reference, \" + className + \", \" + foo.constructor.name);\r\n }\r\n }\r\n else {\r\n const found = this.scope.findType(subs[0]);\r\n foundType = found === null || found === void 0 ? void 0 : found.getType();\r\n if (foundType === undefined) {\r\n const typePoolType = (_a = this.scope.findTypePoolType(subs[0])) === null || _a === void 0 ? void 0 : _a.getType();\r\n if (typePoolType) {\r\n // this.scope.addReference(typeName.getFirstToken(), typePoolType, ReferenceType.TypeReference, this.filename);\r\n foundType = typePoolType;\r\n }\r\n if (foundType === undefined) {\r\n const f = this.scope.getDDIC().lookupTableOrView(subs[0]);\r\n this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), { object: f.object, filename: this.filename, token: expr.getFirstToken() });\r\n if (f.type instanceof _typed_identifier_1.TypedIdentifier) {\r\n foundType = f.type.getType();\r\n }\r\n else {\r\n foundType = f.type;\r\n }\r\n }\r\n }\r\n else {\r\n this.scope.addReference(expr.getFirstToken(), found, _reference_1.ReferenceType.TypeReference, this.filename);\r\n }\r\n if (foundType === undefined && this.scope.getDDIC().inErrorNamespace(subs[0]) === false) {\r\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\r\n return new Types.VoidType(subs[0]);\r\n }\r\n else if (foundType instanceof Types.VoidType) {\r\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\r\n return foundType;\r\n }\r\n else if (foundType === undefined) {\r\n return new Types.UnknownType(\"Unknown type \" + subs[0]);\r\n }\r\n }\r\n subs.shift();\r\n while (subs.length > 0) {\r\n if (foundType instanceof Types.UnknownType\r\n || foundType instanceof Types.VoidType) {\r\n return foundType;\r\n }\r\n else if (!(foundType instanceof Types.StructureType)) {\r\n return new Types.UnknownType(\"Not a structured type\");\r\n }\r\n foundType = foundType.getComponentByName(subs[0]);\r\n subs.shift();\r\n }\r\n return foundType;\r\n }\r\n resolveConstantValue(expr) {\r\n var _a, _b;\r\n // todo: rewrite this method\r\n if (!(expr.get() instanceof Expressions.SimpleFieldChain)) {\r\n throw new Error(\"resolveConstantValue\");\r\n }\r\n const firstNode = expr.getFirstChild();\r\n const firstToken = firstNode.getFirstToken();\r\n const firstName = firstToken.getStr();\r\n if (firstNode.get() instanceof Expressions.Field) {\r\n const found = this.scope.findVariable(firstName);\r\n const val = found === null || found === void 0 ? void 0 : found.getValue();\r\n if (typeof val === \"string\") {\r\n this.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.filename);\r\n return val;\r\n }\r\n else if ((found === null || found === void 0 ? void 0 : found.getType()) instanceof basic_1.StructureType) {\r\n this.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.filename);\r\n }\r\n return undefined;\r\n }\r\n else if (firstNode.get() instanceof Expressions.ClassName\r\n && firstName.toLowerCase() === this.scope.getName().toLowerCase()\r\n && (this.scope.getType() === _scope_type_1.ScopeType.Interface\r\n || this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition)) {\r\n const children = expr.getChildren();\r\n const token = (_a = children[2]) === null || _a === void 0 ? void 0 : _a.getFirstToken();\r\n const found = this.scope.findVariable(token.getStr());\r\n const val = found === null || found === void 0 ? void 0 : found.getValue();\r\n if (typeof val === \"string\") {\r\n this.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.filename);\r\n return val;\r\n }\r\n return undefined;\r\n }\r\n else if (firstNode.get() instanceof Expressions.ClassName) {\r\n const obj = this.scope.findObjectDefinition(firstName);\r\n if (obj === undefined) {\r\n if (this.scope.existsObject(firstName).found === true) {\r\n return undefined;\r\n }\r\n else if (this.scope.getDDIC().inErrorNamespace(firstName) === true) {\r\n throw new Error(\"resolveConstantValue, not found: \" + firstName);\r\n }\r\n else {\r\n this.scope.addReference(firstNode.getFirstToken(), undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, this.filename, { ooName: firstName.toUpperCase() });\r\n return undefined;\r\n }\r\n }\r\n const children = expr.getChildren();\r\n const token = (_b = children[2]) === null || _b === void 0 ? void 0 : _b.getFirstToken();\r\n const attr = token.getStr();\r\n const c = new _object_oriented_1.ObjectOriented(this.scope).searchConstantName(obj, attr);\r\n if (c instanceof class_constant_1.ClassConstant) {\r\n this.scope.addReference(token, c, _reference_1.ReferenceType.DataReadReference, this.filename);\r\n const val = c.getValue();\r\n if (typeof val === \"string\") {\r\n return val;\r\n }\r\n else if (typeof val === \"object\" && children[4]) {\r\n const name = children[4].getFirstToken().getStr();\r\n if (val[name] !== undefined) {\r\n return val[name];\r\n }\r\n }\r\n return undefined;\r\n }\r\n throw new Error(\"resolveConstantValue, constant not found \" + attr);\r\n }\r\n else {\r\n throw new Error(\"resolveConstantValue, unexpected structure\");\r\n }\r\n }\r\n resolveTypeRef(chain) {\r\n var _a;\r\n if (chain === undefined) {\r\n return undefined;\r\n }\r\n const name = chain.getFirstToken().getStr();\r\n if (chain.getAllTokens().length === 1) {\r\n if (name.toUpperCase() === \"OBJECT\") {\r\n return new Types.GenericObjectReferenceType();\r\n }\r\n const search = this.scope.existsObject(name);\r\n if (search.found === true && search.id) {\r\n this.scope.addReference(chain.getFirstToken(), search.id, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: search.ooType, ooName: name });\r\n return new Types.ObjectReferenceType(search.id, name);\r\n }\r\n }\r\n const found = this.resolveTypeName(chain);\r\n if (found && !(found instanceof Types.UnknownType) && !(found instanceof Types.VoidType)) {\r\n return new Types.DataReference(found);\r\n }\r\n else if (chain.concatTokens().toUpperCase() === \"DATA\") {\r\n return new Types.DataReference(new Types.AnyType());\r\n }\r\n if (this.scope.isBadiDef(name) === true) {\r\n return new Types.VoidType(name);\r\n }\r\n if (((_a = this.scope.getDDIC()) === null || _a === void 0 ? void 0 : _a.inErrorNamespace(name)) === false) {\r\n // this.scope.addReference(chain.getFirstToken(), undefined, ReferenceType.VoidType, this.filename);\r\n return new Types.VoidType(name);\r\n }\r\n return new Types.UnknownType(\"REF, unable to resolve \" + name);\r\n }\r\n findValue(node) {\r\n const val = node.findFirstExpression(Expressions.Value);\r\n if (val === undefined) {\r\n throw new Error(\"VALUE missing in expression\");\r\n }\r\n if (val.concatTokens().toUpperCase() === \"VALUE IS INITIAL\") {\r\n return undefined;\r\n }\r\n const constant = val.findFirstExpression(Expressions.Constant);\r\n if (constant) {\r\n return constant.concatTokens();\r\n }\r\n const chain = val.findFirstExpression(Expressions.SimpleFieldChain);\r\n if (chain) {\r\n return this.resolveConstantValue(chain);\r\n }\r\n throw new Error(\"findValue, unexpected\");\r\n }\r\n findDecimals(node) {\r\n var _a, _b;\r\n const dec = (_b = (_a = node.findDirectExpression(Expressions.Decimals)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Integer)) === null || _b === void 0 ? void 0 : _b.concatTokens();\r\n if (dec) {\r\n return parseInt(dec, 10);\r\n }\r\n return undefined;\r\n }\r\n findLength(node) {\r\n const val = node.findFirstExpression(Expressions.Length);\r\n const flen = node.findFirstExpression(Expressions.ConstantFieldLength);\r\n if (val && flen) {\r\n throw new Error(\"Only specify length once\");\r\n }\r\n if (flen) {\r\n const cintExpr = flen.findFirstExpression(Expressions.Integer);\r\n if (cintExpr) {\r\n return this.parseInt(cintExpr.concatTokens());\r\n }\r\n const cchain = flen.findFirstExpression(Expressions.SimpleFieldChain);\r\n if (cchain) {\r\n const val = this.resolveConstantValue(cchain);\r\n return this.parseInt(val);\r\n }\r\n }\r\n if (val === undefined) {\r\n return 1;\r\n }\r\n const intExpr = val.findFirstExpression(Expressions.Integer);\r\n if (intExpr) {\r\n return this.parseInt(intExpr.concatTokens());\r\n }\r\n const strExpr = val.findFirstExpression(Expressions.ConstantString);\r\n if (strExpr) {\r\n return this.parseInt(strExpr.concatTokens());\r\n }\r\n const chain = val.findFirstExpression(Expressions.SimpleFieldChain);\r\n if (chain) {\r\n const val = this.resolveConstantValue(chain);\r\n return this.parseInt(val);\r\n }\r\n throw new Error(\"Unexpected, findLength\");\r\n }\r\n parseInt(text) {\r\n if (text === undefined) {\r\n return undefined;\r\n }\r\n if (text.startsWith(\"'\")) {\r\n text = text.split(\"'\")[1];\r\n }\r\n else if (text.startsWith(\"`\")) {\r\n text = text.split(\"`\")[1];\r\n }\r\n return parseInt(text, 10);\r\n }\r\n}\r\nexports.BasicTypes = BasicTypes;\r\n//# sourceMappingURL=basic_types.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/abap/5_syntax/basic_types.js?");
|
|
6752
6752
|
|
|
6753
6753
|
/***/ }),
|
|
6754
6754
|
|
|
@@ -6979,7 +6979,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
6979
6979
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
6980
6980
|
|
|
6981
6981
|
"use strict";
|
|
6982
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.FieldChain = void 0;\r\nconst nodes_1 = __webpack_require__(/*! ../../nodes */ \"./node_modules/@abaplint/core/build/src/abap/nodes/index.js\");\r\nconst Expressions = __webpack_require__(/*! ../../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst tokens_1 = __webpack_require__(/*! ../../1_lexer/tokens */ \"./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/index.js\");\r\nconst basic_1 = __webpack_require__(/*! ../../types/basic */ \"./node_modules/@abaplint/core/build/src/abap/types/basic/index.js\");\r\nconst component_name_1 = __webpack_require__(/*! ./component_name */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/component_name.js\");\r\nconst attribute_name_1 = __webpack_require__(/*! ./attribute_name */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/attribute_name.js\");\r\nconst _reference_1 = __webpack_require__(/*! ../_reference */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js\");\r\nconst field_offset_1 = __webpack_require__(/*! ./field_offset */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/field_offset.js\");\r\nconst field_length_1 = __webpack_require__(/*! ./field_length */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/field_length.js\");\r\nconst table_expression_1 = __webpack_require__(/*! ./table_expression */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/table_expression.js\");\r\nconst expressions_1 = __webpack_require__(/*! ../../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst dereference_1 = __webpack_require__(/*! ./dereference */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/dereference.js\");\r\nconst source_field_symbol_1 = __webpack_require__(/*! ./source_field_symbol */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source_field_symbol.js\");\r\nclass FieldChain {\r\n runSyntax(node, scope, filename, refType) {\r\n const concat = node.concatTokens();\r\n if (concat.includes(\"-\")) {\r\n // workaround for names with dashes\r\n const found = scope.findVariable(concat);\r\n if (found) {\r\n if (refType) {\r\n scope.addReference(node.getFirstToken(), found, refType, filename);\r\n }\r\n return found.getType();\r\n }\r\n }\r\n const children = node.getChildren().slice();\r\n let contextName = children[0].concatTokens();\r\n let context = this.findTop(children.shift(), scope, filename, refType);\r\n while (children.length > 0) {\r\n contextName += children[0].concatTokens();\r\n const current = children.shift();\r\n if (current === undefined) {\r\n break;\r\n }\r\n if (current.get() instanceof tokens_1.DashW) {\r\n throw new Error(\"Ending with dash\");\r\n }\r\n else if (current.get() instanceof tokens_1.Dash) {\r\n if (context instanceof basic_1.UnknownType) {\r\n throw new Error(\"Not a structure, type unknown, FieldChain\");\r\n }\r\n else if (!(context instanceof basic_1.StructureType)\r\n && !(context instanceof basic_1.TableType && context.isWithHeader())\r\n && !(context instanceof basic_1.VoidType)) {\r\n if (context instanceof basic_1.TableType && context.isWithHeader() === false) {\r\n if (scope.isAllowHeaderUse(contextName.substring(0, contextName.length - 1))) {\r\n // FOR ALL ENTRIES workaround\r\n context = context.getRowType();\r\n if (!(context instanceof basic_1.StructureType) && !(context instanceof basic_1.VoidType)) {\r\n context = new basic_1.StructureType([{ name: \"TABLE_LINE\", type: context }]);\r\n }\r\n }\r\n else {\r\n throw new Error(\"Table without header, cannot access fields, \" + contextName);\r\n }\r\n }\r\n else {\r\n throw new Error(\"Not a structure, FieldChain\");\r\n }\r\n }\r\n }\r\n else if (current.get() instanceof tokens_1.InstanceArrow) {\r\n if (!(context instanceof basic_1.ObjectReferenceType)\r\n && !(context instanceof basic_1.DataReference)\r\n && !(context instanceof basic_1.VoidType)) {\r\n throw new Error(\"Not an object reference, field chain\");\r\n }\r\n }\r\n else if (current.get() instanceof expressions_1.Dereference) {\r\n context = new dereference_1.Dereference().runSyntax(context);\r\n }\r\n else if (current.get() instanceof Expressions.ComponentName) {\r\n if (context instanceof basic_1.TableType && context.isWithHeader()) {\r\n context = context.getRowType();\r\n }\r\n context = new component_name_1.ComponentName().runSyntax(context, current);\r\n }\r\n else if (current instanceof nodes_1.ExpressionNode\r\n && current.get() instanceof Expressions.TableExpression) {\r\n if (!(context instanceof basic_1.TableType) && !(context instanceof basic_1.VoidType)) {\r\n throw new Error(\"Table expression, expected table\");\r\n }\r\n new table_expression_1.TableExpression().runSyntax(current, scope, filename);\r\n if (!(context instanceof basic_1.VoidType)) {\r\n context = context.getRowType();\r\n }\r\n }\r\n else if (current.get() instanceof Expressions.AttributeName) {\r\n context = new attribute_name_1.AttributeName().runSyntax(context, current, scope, filename, refType);\r\n }\r\n else if (current.get() instanceof Expressions.FieldOffset && current instanceof nodes_1.ExpressionNode) {\r\n new field_offset_1.FieldOffset().runSyntax(current, scope, filename);\r\n }\r\n else if (current.get() instanceof Expressions.FieldLength && current instanceof nodes_1.ExpressionNode) {\r\n new field_length_1.FieldLength().runSyntax(current, scope, filename);\r\n }\r\n }\r\n return context;\r\n }\r\n ////////////////\r\n findTop(node, scope, filename, type) {\r\n if (node === undefined) {\r\n return undefined;\r\n }\r\n if (node instanceof nodes_1.ExpressionNode\r\n && node.get() instanceof Expressions.SourceFieldSymbol) {\r\n return new source_field_symbol_1.SourceFieldSymbol().runSyntax(node, scope, filename);\r\n }\r\n else if (node
|
|
6982
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.FieldChain = void 0;\r\nconst nodes_1 = __webpack_require__(/*! ../../nodes */ \"./node_modules/@abaplint/core/build/src/abap/nodes/index.js\");\r\nconst Expressions = __webpack_require__(/*! ../../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst tokens_1 = __webpack_require__(/*! ../../1_lexer/tokens */ \"./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/index.js\");\r\nconst basic_1 = __webpack_require__(/*! ../../types/basic */ \"./node_modules/@abaplint/core/build/src/abap/types/basic/index.js\");\r\nconst component_name_1 = __webpack_require__(/*! ./component_name */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/component_name.js\");\r\nconst attribute_name_1 = __webpack_require__(/*! ./attribute_name */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/attribute_name.js\");\r\nconst _reference_1 = __webpack_require__(/*! ../_reference */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js\");\r\nconst field_offset_1 = __webpack_require__(/*! ./field_offset */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/field_offset.js\");\r\nconst field_length_1 = __webpack_require__(/*! ./field_length */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/field_length.js\");\r\nconst table_expression_1 = __webpack_require__(/*! ./table_expression */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/table_expression.js\");\r\nconst expressions_1 = __webpack_require__(/*! ../../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst dereference_1 = __webpack_require__(/*! ./dereference */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/dereference.js\");\r\nconst source_field_symbol_1 = __webpack_require__(/*! ./source_field_symbol */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source_field_symbol.js\");\r\nconst source_field_1 = __webpack_require__(/*! ./source_field */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source_field.js\");\r\nclass FieldChain {\r\n runSyntax(node, scope, filename, refType) {\r\n const concat = node.concatTokens();\r\n if (concat.includes(\"-\")) {\r\n // workaround for names with dashes\r\n const found = scope.findVariable(concat);\r\n if (found) {\r\n if (refType) {\r\n scope.addReference(node.getFirstToken(), found, refType, filename);\r\n }\r\n return found.getType();\r\n }\r\n }\r\n const children = node.getChildren().slice();\r\n let contextName = children[0].concatTokens();\r\n let context = this.findTop(children.shift(), scope, filename, refType);\r\n while (children.length > 0) {\r\n contextName += children[0].concatTokens();\r\n const current = children.shift();\r\n if (current === undefined) {\r\n break;\r\n }\r\n if (current.get() instanceof tokens_1.DashW) {\r\n throw new Error(\"Ending with dash\");\r\n }\r\n else if (current.get() instanceof tokens_1.Dash) {\r\n if (context instanceof basic_1.UnknownType) {\r\n throw new Error(\"Not a structure, type unknown, FieldChain\");\r\n }\r\n else if (!(context instanceof basic_1.StructureType)\r\n && !(context instanceof basic_1.TableType && context.isWithHeader())\r\n && !(context instanceof basic_1.VoidType)) {\r\n if (context instanceof basic_1.TableType && context.isWithHeader() === false) {\r\n if (scope.isAllowHeaderUse(contextName.substring(0, contextName.length - 1))) {\r\n // FOR ALL ENTRIES workaround\r\n context = context.getRowType();\r\n if (!(context instanceof basic_1.StructureType) && !(context instanceof basic_1.VoidType)) {\r\n context = new basic_1.StructureType([{ name: \"TABLE_LINE\", type: context }]);\r\n }\r\n }\r\n else {\r\n throw new Error(\"Table without header, cannot access fields, \" + contextName);\r\n }\r\n }\r\n else {\r\n throw new Error(\"Not a structure, FieldChain\");\r\n }\r\n }\r\n }\r\n else if (current.get() instanceof tokens_1.InstanceArrow) {\r\n if (!(context instanceof basic_1.ObjectReferenceType)\r\n && !(context instanceof basic_1.DataReference)\r\n && !(context instanceof basic_1.VoidType)) {\r\n throw new Error(\"Not an object reference, field chain\");\r\n }\r\n }\r\n else if (current.get() instanceof expressions_1.Dereference) {\r\n context = new dereference_1.Dereference().runSyntax(context);\r\n }\r\n else if (current.get() instanceof Expressions.ComponentName) {\r\n if (context instanceof basic_1.TableType && context.isWithHeader()) {\r\n context = context.getRowType();\r\n }\r\n context = new component_name_1.ComponentName().runSyntax(context, current);\r\n }\r\n else if (current instanceof nodes_1.ExpressionNode\r\n && current.get() instanceof Expressions.TableExpression) {\r\n if (!(context instanceof basic_1.TableType) && !(context instanceof basic_1.VoidType)) {\r\n throw new Error(\"Table expression, expected table\");\r\n }\r\n new table_expression_1.TableExpression().runSyntax(current, scope, filename);\r\n if (!(context instanceof basic_1.VoidType)) {\r\n context = context.getRowType();\r\n }\r\n }\r\n else if (current.get() instanceof Expressions.AttributeName) {\r\n context = new attribute_name_1.AttributeName().runSyntax(context, current, scope, filename, refType);\r\n }\r\n else if (current.get() instanceof Expressions.FieldOffset && current instanceof nodes_1.ExpressionNode) {\r\n new field_offset_1.FieldOffset().runSyntax(current, scope, filename);\r\n }\r\n else if (current.get() instanceof Expressions.FieldLength && current instanceof nodes_1.ExpressionNode) {\r\n new field_length_1.FieldLength().runSyntax(current, scope, filename);\r\n }\r\n }\r\n return context;\r\n }\r\n ////////////////\r\n findTop(node, scope, filename, type) {\r\n if (node === undefined) {\r\n return undefined;\r\n }\r\n if (node instanceof nodes_1.ExpressionNode\r\n && node.get() instanceof Expressions.SourceFieldSymbol) {\r\n return new source_field_symbol_1.SourceFieldSymbol().runSyntax(node, scope, filename);\r\n }\r\n else if (node instanceof nodes_1.ExpressionNode\r\n && node.get() instanceof Expressions.SourceField) {\r\n return new source_field_1.SourceField().runSyntax(node, scope, filename, type);\r\n }\r\n else if (node.get() instanceof Expressions.ClassName) {\r\n const classTok = node.getFirstToken();\r\n const classNam = classTok.getStr();\r\n if (classNam.toUpperCase() === \"OBJECT\") {\r\n return new basic_1.GenericObjectReferenceType();\r\n }\r\n const found = scope.existsObject(classNam);\r\n if (found.found === true && found.id) {\r\n scope.addReference(classTok, found.id, found.type, filename);\r\n return new basic_1.ObjectReferenceType(found.id);\r\n }\r\n else if (scope.getDDIC().inErrorNamespace(classNam) === false) {\r\n scope.addReference(classTok, undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, filename, { ooName: classNam.toUpperCase() });\r\n return new basic_1.VoidType(classNam);\r\n }\r\n else {\r\n throw new Error(\"Unknown class \" + classNam);\r\n }\r\n }\r\n return undefined;\r\n }\r\n}\r\nexports.FieldChain = FieldChain;\r\n//# sourceMappingURL=field_chain.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/field_chain.js?");
|
|
6983
6983
|
|
|
6984
6984
|
/***/ }),
|
|
6985
6985
|
|
|
@@ -7199,7 +7199,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
7199
7199
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
7200
7200
|
|
|
7201
7201
|
"use strict";
|
|
7202
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.MethodSource = void 0;\r\nconst Expressions = __webpack_require__(/*! ../../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst nodes_1 = __webpack_require__(/*! ../../nodes */ \"./node_modules/@abaplint/core/build/src/abap/nodes/index.js\");\r\nconst dynamic_1 = __webpack_require__(/*! ./dynamic */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/dynamic.js\");\r\nconst
|
|
7202
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.MethodSource = void 0;\r\nconst Expressions = __webpack_require__(/*! ../../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst nodes_1 = __webpack_require__(/*! ../../nodes */ \"./node_modules/@abaplint/core/build/src/abap/nodes/index.js\");\r\nconst dynamic_1 = __webpack_require__(/*! ./dynamic */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/dynamic.js\");\r\nconst basic_1 = __webpack_require__(/*! ../../types/basic */ \"./node_modules/@abaplint/core/build/src/abap/types/basic/index.js\");\r\nconst _reference_1 = __webpack_require__(/*! ../_reference */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js\");\r\nconst _object_oriented_1 = __webpack_require__(/*! ../_object_oriented */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_object_oriented.js\");\r\nconst _abstract_type_1 = __webpack_require__(/*! ../../types/basic/_abstract_type */ \"./node_modules/@abaplint/core/build/src/abap/types/basic/_abstract_type.js\");\r\nconst source_field_symbol_1 = __webpack_require__(/*! ./source_field_symbol */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source_field_symbol.js\");\r\nconst source_field_1 = __webpack_require__(/*! ./source_field */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source_field.js\");\r\nconst tokens_1 = __webpack_require__(/*! ../../1_lexer/tokens */ \"./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/index.js\");\r\nconst attribute_name_1 = __webpack_require__(/*! ./attribute_name */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/attribute_name.js\");\r\nconst component_name_1 = __webpack_require__(/*! ./component_name */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/component_name.js\");\r\nconst types_1 = __webpack_require__(/*! ../../types */ \"./node_modules/@abaplint/core/build/src/abap/types/index.js\");\r\nclass MethodSource {\r\n runSyntax(node, scope, filename) {\r\n var _a;\r\n const helper = new _object_oriented_1.ObjectOriented(scope);\r\n const children = node.getChildren().slice();\r\n const first = children.shift();\r\n if (first === undefined) {\r\n throw new Error(\"MethodSource, first child expected\");\r\n }\r\n let context = this.findTop(first, scope, filename);\r\n if (context === undefined) {\r\n context = (_a = scope.findVariable(\"me\")) === null || _a === void 0 ? void 0 : _a.getType();\r\n children.unshift(first);\r\n }\r\n if (context instanceof basic_1.VoidType) {\r\n // todo, if there are more dynamic with variables, the references for the variables are not added?\r\n return context;\r\n }\r\n while (children.length > 0) {\r\n const current = children.shift();\r\n if (current === undefined) {\r\n break;\r\n }\r\n if (current.get() instanceof tokens_1.Dash) {\r\n if (context instanceof basic_1.UnknownType) {\r\n throw new Error(\"Not a structure, type unknown, MethodSource\");\r\n }\r\n else if (!(context instanceof basic_1.StructureType)) {\r\n throw new Error(\"Not a structure, MethodSource\");\r\n }\r\n }\r\n else if (current.get() instanceof tokens_1.InstanceArrow\r\n || current.get() instanceof tokens_1.StaticArrow) {\r\n // todo, handling static vs instance\r\n }\r\n else if (current.get() instanceof Expressions.AttributeName\r\n || current.get() instanceof Expressions.SourceField) {\r\n try {\r\n if (context instanceof _abstract_type_1.AbstractType) {\r\n const attr = new attribute_name_1.AttributeName().runSyntax(context, current, scope, filename, _reference_1.ReferenceType.DataReadReference);\r\n context = attr;\r\n continue;\r\n }\r\n }\r\n catch (_b) {\r\n // ignore\r\n }\r\n // try looking for method name\r\n const className = context instanceof basic_1.ObjectReferenceType ? context.getIdentifierName() : undefined;\r\n const methodToken = current.getFirstToken();\r\n const methodName = methodToken === null || methodToken === void 0 ? void 0 : methodToken.getStr();\r\n const def = scope.findObjectDefinition(className);\r\n // eslint-disable-next-line prefer-const\r\n let { method, def: foundDef } = helper.searchMethodName(def, methodName);\r\n if (method === undefined && (methodName === null || methodName === void 0 ? void 0 : methodName.toUpperCase()) === \"CONSTRUCTOR\") {\r\n context = new basic_1.VoidType(\"CONSTRUCTOR\"); // todo, this is a workaround, constructors always exists\r\n }\r\n else if (method === undefined && !(context instanceof basic_1.VoidType)) {\r\n throw new Error(\"Method or attribute \\\"\" + methodName + \"\\\" not found, MethodSource\");\r\n }\r\n else if (method) {\r\n const extra = {\r\n ooName: foundDef === null || foundDef === void 0 ? void 0 : foundDef.getName(),\r\n ooType: foundDef instanceof types_1.ClassDefinition ? \"CLAS\" : \"INTF\"\r\n };\r\n scope.addReference(methodToken, method, _reference_1.ReferenceType.MethodReference, filename, extra);\r\n context = method;\r\n }\r\n }\r\n else if (current.get() instanceof Expressions.ComponentName && context instanceof _abstract_type_1.AbstractType) {\r\n if (context instanceof basic_1.TableType && context.isWithHeader()) {\r\n context = context.getRowType();\r\n }\r\n context = new component_name_1.ComponentName().runSyntax(context, current);\r\n }\r\n else if (current instanceof nodes_1.ExpressionNode && current.get() instanceof Expressions.Dynamic) {\r\n new dynamic_1.Dynamic().runSyntax(current, scope, filename);\r\n context = new basic_1.VoidType(\"Dynamic\");\r\n }\r\n }\r\n if (context instanceof _abstract_type_1.AbstractType && !(context instanceof basic_1.VoidType)) {\r\n throw new Error(\"Not a method, MethodSource\");\r\n }\r\n else if (context === undefined) {\r\n throw new Error(\"Not found, MethodSource\");\r\n }\r\n return context;\r\n }\r\n //////////////////////////////////////\r\n findTop(first, scope, filename) {\r\n if (first.get() instanceof Expressions.ClassName) {\r\n // todo, refactor this part to new expression handler,\r\n const token = first.getFirstToken();\r\n const className = token.getStr();\r\n const classDefinition = scope.findObjectDefinition(className);\r\n if (classDefinition === undefined && scope.getDDIC().inErrorNamespace(className) === false) {\r\n const extra = { ooName: className, ooType: \"Void\" };\r\n scope.addReference(token, undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, filename, extra);\r\n return new basic_1.VoidType(className);\r\n }\r\n else if (classDefinition === undefined) {\r\n throw new Error(\"Class \" + className + \" not found\");\r\n }\r\n scope.addReference(first.getFirstToken(), classDefinition, _reference_1.ReferenceType.ObjectOrientedReference, filename);\r\n return new basic_1.ObjectReferenceType(classDefinition);\r\n }\r\n else if (first instanceof nodes_1.ExpressionNode && first.get() instanceof Expressions.SourceField) {\r\n try {\r\n return new source_field_1.SourceField().runSyntax(first, scope, filename, _reference_1.ReferenceType.DataReadReference);\r\n }\r\n catch (_a) {\r\n return undefined;\r\n }\r\n }\r\n else if (first instanceof nodes_1.ExpressionNode && first.get() instanceof Expressions.SourceFieldSymbol) {\r\n return new source_field_symbol_1.SourceFieldSymbol().runSyntax(first, scope, filename);\r\n }\r\n else if (first instanceof nodes_1.ExpressionNode && first.get() instanceof Expressions.Dynamic) {\r\n new dynamic_1.Dynamic().runSyntax(first, scope, filename);\r\n return new basic_1.VoidType(\"Dynamic\");\r\n }\r\n return undefined;\r\n }\r\n}\r\nexports.MethodSource = MethodSource;\r\n//# sourceMappingURL=method_source.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/method_source.js?");
|
|
7203
7203
|
|
|
7204
7204
|
/***/ }),
|
|
7205
7205
|
|
|
@@ -7280,6 +7280,17 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
7280
7280
|
|
|
7281
7281
|
/***/ }),
|
|
7282
7282
|
|
|
7283
|
+
/***/ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source_field.js":
|
|
7284
|
+
/*!*****************************************************************************************!*\
|
|
7285
|
+
!*** ./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source_field.js ***!
|
|
7286
|
+
\*****************************************************************************************/
|
|
7287
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
7288
|
+
|
|
7289
|
+
"use strict";
|
|
7290
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.SourceField = void 0;\r\nconst _reference_1 = __webpack_require__(/*! ../_reference */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js\");\r\nclass SourceField {\r\n runSyntax(node, scope, filename, type) {\r\n const token = node.getFirstToken();\r\n const name = token.getStr();\r\n const found = scope.findVariable(name);\r\n if (found === undefined) {\r\n throw new Error(\"\\\"\" + name + \"\\\" not found, findTop\");\r\n }\r\n if (type) {\r\n scope.addReference(token, found, type, filename);\r\n }\r\n if (name.includes(\"~\")) {\r\n const idef = scope.findInterfaceDefinition(name.split(\"~\")[0]);\r\n if (idef) {\r\n scope.addReference(token, idef, _reference_1.ReferenceType.ObjectOrientedReference, filename);\r\n }\r\n }\r\n return found.getType();\r\n }\r\n}\r\nexports.SourceField = SourceField;\r\n//# sourceMappingURL=source_field.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source_field.js?");
|
|
7291
|
+
|
|
7292
|
+
/***/ }),
|
|
7293
|
+
|
|
7283
7294
|
/***/ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source_field_symbol.js":
|
|
7284
7295
|
/*!************************************************************************************************!*\
|
|
7285
7296
|
!*** ./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source_field_symbol.js ***!
|
|
@@ -10169,7 +10180,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
10169
10180
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
10170
10181
|
|
|
10171
10182
|
"use strict";
|
|
10172
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.LSPLookup = void 0;\r\nconst LServer = __webpack_require__(/*! vscode-languageserver-types */ \"./node_modules/vscode-languageserver-types/lib/esm/main.js\");\r\nconst Statements = __webpack_require__(/*! ../abap/2_statements/statements */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js\");\r\nconst Expressions = __webpack_require__(/*! ../abap/2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/syntax.js\");\r\nconst _lsp_utils_1 = __webpack_require__(/*! ./_lsp_utils */ \"./node_modules/@abaplint/core/build/src/lsp/_lsp_utils.js\");\r\nconst _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ \"./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js\");\r\nconst _reference_1 = __webpack_require__(/*! ../abap/5_syntax/_reference */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js\");\r\nconst _builtin_1 = __webpack_require__(/*! ../abap/5_syntax/_builtin */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_builtin.js\");\r\nconst _scope_type_1 = __webpack_require__(/*! ../abap/5_syntax/_scope_type */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js\");\r\nclass LSPLookup {\r\n static lookup(cursor, reg, obj) {\r\n const inc = this.findInclude(cursor, reg);\r\n if (inc) {\r\n const found = this.ABAPFileResult(inc);\r\n return { hover: \"Include\", definition: found, implementation: found };\r\n }\r\n const fm = this.findFunctionModule(cursor);\r\n if (fm) {\r\n return { hover: \"Function Module \" + fm };\r\n }\r\n const bottomScope = new syntax_1.SyntaxLogic(reg, obj).run().spaghetti.lookupPosition(cursor.identifier.getStart(), cursor.identifier.getFilename());\r\n if (bottomScope === undefined) {\r\n return undefined;\r\n }\r\n const clas = bottomScope.findClassDefinition(cursor.token.getStr());\r\n if (clas && clas.getStart().equals(cursor.token.getStart())) {\r\n const found = _lsp_utils_1.LSPUtils.identiferToLocation(clas);\r\n return {\r\n hover: \"Class Definition, \" + cursor.token.getStr(),\r\n definition: found,\r\n definitionId: clas,\r\n implementation: undefined,\r\n scope: bottomScope,\r\n };\r\n }\r\n const intf = bottomScope.findInterfaceDefinition(cursor.token.getStr());\r\n if (intf && intf.getStart().equals(cursor.token.getStart())) {\r\n const found = _lsp_utils_1.LSPUtils.identiferToLocation(intf);\r\n return {\r\n hover: \"Interface Definition, \" + cursor.token.getStr(),\r\n definition: found,\r\n definitionId: intf,\r\n implementation: undefined,\r\n scope: bottomScope,\r\n };\r\n }\r\n const type = bottomScope.findType(cursor.token.getStr());\r\n if (type !== undefined && type.getStart().equals(cursor.token.getStart())) {\r\n const found = _lsp_utils_1.LSPUtils.identiferToLocation(type);\r\n const hover = \"Type Definition, \" + cursor.token.getStr() + \"\\n\\n\" + this.dumpType(type);\r\n return { hover, definition: found, definitionId: type, scope: bottomScope };\r\n }\r\n const method = this.findMethodDefinition(cursor, bottomScope);\r\n if (method !== undefined && method.getStart().equals(cursor.token.getStart())) {\r\n const found = _lsp_utils_1.LSPUtils.identiferToLocation(method);\r\n const hover = \"Method Definition \\\"\" + method.getName() + \"\\\"\";\r\n return { hover, definition: found, definitionId: method, scope: bottomScope };\r\n }\r\n const variable = bottomScope.findVariable(cursor.token.getStr());\r\n if (variable !== undefined && variable.getStart().equals(cursor.token.getStart())) {\r\n const hover = \"Variable Definition\\n\\n\" + this.dumpType(variable);\r\n let location = undefined;\r\n if (variable.getMeta().includes(\"built-in\" /* IdentifierMeta.BuiltIn */) === false) {\r\n location = _lsp_utils_1.LSPUtils.identiferToLocation(variable);\r\n }\r\n return { hover, definition: location, implementation: location, definitionId: variable, scope: bottomScope };\r\n }\r\n let hoverValue = \"\";\r\n const ddicRefs = reg.getDDICReferences().listByFilename(cursor.identifier.getFilename(), cursor.identifier.getStart().getRow());\r\n for (const d of ddicRefs) {\r\n if (d.object && d.token && d.token.getStart().equals(cursor.identifier.getStart())) {\r\n hoverValue += `DDIC: ${d.object.getType()} ${d.object.getName()}`;\r\n }\r\n }\r\n const refs = this.searchReferences(bottomScope, cursor.token);\r\n if (refs.length > 0) {\r\n for (const ref of refs) {\r\n if (hoverValue !== \"\") {\r\n hoverValue += \"\\n_________________\\n\";\r\n }\r\n hoverValue += this.referenceHover(ref, bottomScope, reg);\r\n }\r\n let definition = undefined;\r\n if (refs[0].resolved) {\r\n definition = _lsp_utils_1.LSPUtils.identiferToLocation(refs[0].resolved);\r\n if (definition.uri === _builtin_1.BuiltIn.filename) {\r\n definition = undefined;\r\n }\r\n }\r\n return { hover: hoverValue, definition, definitionId: refs[0].resolved, scope: bottomScope };\r\n }\r\n if (hoverValue !== \"\") {\r\n return { hover: hoverValue, scope: bottomScope };\r\n }\r\n return undefined;\r\n }\r\n ////////////////////////////////////////////\r\n static dumpType(variable) {\r\n let value = variable.toText() + \"\\n\\nType: \" + variable.getType().toText(0);\r\n if (variable.getValue()) {\r\n value += \"\\n\\nValue: ```\" + variable.getValue() + \"```\";\r\n }\r\n if (variable.getMeta().length > 0) {\r\n value += \"\\n\\nMeta: \" + variable.getMeta().join(\", \");\r\n }\r\n if (variable.getType().containsVoid() === true) {\r\n value += \"\\n\\nContains Void types\";\r\n }\r\n if (variable.getType().getQualifiedName()) {\r\n value += \"\\n\\nQualified Type Name: ```\" + variable.getType().getQualifiedName() + \"```\";\r\n }\r\n if (variable.getType().isGeneric() === true) {\r\n value += \"\\n\\nIs Generic Type\";\r\n }\r\n if (variable.getType().getConversionExit() !== undefined) {\r\n value += \"\\n\\nConversion Exit: ```\" + variable.getType().getConversionExit() + \"```\";\r\n }\r\n if (variable.getType().getDDICName() !== undefined) {\r\n value += \"\\n\\nDDIC Name: ```\" + variable.getType().getDDICName() + \"```\";\r\n }\r\n return value;\r\n }\r\n static referenceHover(ref, scope, reg) {\r\n var _a, _b, _c, _d, _e;\r\n let name = \"\";\r\n if (ref.resolved) {\r\n name = \"```\" + ref.resolved.getName() + \"```\";\r\n }\r\n let ret = `${ref.referenceType} ${name}`;\r\n if (ref.referenceType === _reference_1.ReferenceType.MethodReference && ((_a = ref.extra) === null || _a === void 0 ? void 0 : _a.ooName)) {\r\n let cdef = scope.findClassDefinition(ref.extra.ooName);\r\n if (cdef === undefined) {\r\n cdef = scope.findInterfaceDefinition(ref.extra.ooName);\r\n }\r\n if (cdef === undefined) {\r\n cdef = (_b = reg.getObject(\"CLAS\", ref.extra.ooName)) === null || _b === void 0 ? void 0 : _b.getDefinition();\r\n }\r\n if (cdef === undefined) {\r\n cdef = (_c = reg.getObject(\"INTF\", ref.extra.ooName)) === null || _c === void 0 ? void 0 : _c.getDefinition();\r\n }\r\n ret += \"\\n\\n\" + this.hoverMethod(ref.position.getName(), cdef);\r\n }\r\n else if (ref.resolved instanceof _typed_identifier_1.TypedIdentifier) {\r\n ret += \"\\n\\n\" + this.dumpType(ref.resolved);\r\n }\r\n else if (ref.referenceType === _reference_1.ReferenceType.BuiltinMethodReference) {\r\n const builtinDef = new _builtin_1.BuiltIn().searchBuiltin((_e = (_d = ref.resolved) === null || _d === void 0 ? void 0 : _d.getName()) === null || _e === void 0 ? void 0 : _e.toUpperCase());\r\n if (builtinDef === undefined) {\r\n return \"Error: builtin method signature not found\";\r\n }\r\n ret += \"\\n\\n\" + this.methodParameters(builtinDef);\r\n }\r\n if (ref.resolved) {\r\n ret += \"\\n\\n(Resolved)\";\r\n }\r\n if (ref.extra !== undefined && Object.keys(ref.extra).length > 0) {\r\n ret += \"\\n\\nExtra: \" + JSON.stringify(ref.extra);\r\n }\r\n return ret;\r\n }\r\n static hoverMethod(method, classDef) {\r\n if (classDef === undefined) {\r\n return \"class not found\";\r\n }\r\n const methodDef = classDef.getMethodDefinitions().getByName(method);\r\n if (methodDef === undefined) {\r\n return \"method not found in definition\";\r\n }\r\n return this.methodParameters(methodDef);\r\n }\r\n static methodParameters(methodDef) {\r\n let ret = \"\";\r\n const parameters = methodDef.getParameters();\r\n const importing = parameters.getImporting();\r\n if (importing.length > 0) {\r\n ret += \"IMPORTING\\n\";\r\n for (const p of importing) {\r\n ret += this.singleParameter(p);\r\n }\r\n }\r\n const exporting = parameters.getExporting();\r\n if (exporting.length > 0) {\r\n ret += \"EXPORTING\\n\";\r\n for (const p of exporting) {\r\n ret += this.singleParameter(p);\r\n }\r\n }\r\n const changing = parameters.getChanging();\r\n if (changing.length > 0) {\r\n ret += \"CHANGING\\n\";\r\n for (const p of changing) {\r\n ret += this.singleParameter(p);\r\n }\r\n }\r\n const r = parameters.getReturning();\r\n if (r) {\r\n ret += \"RETURNING\\n\" + this.singleParameter(r);\r\n }\r\n if (methodDef.getRaising().length > 0) {\r\n ret += \"RAISING\\n\";\r\n for (const p of methodDef.getRaising()) {\r\n ret += \"* \" + p + \"\\n\";\r\n }\r\n }\r\n return ret;\r\n }\r\n static singleParameter(p) {\r\n let extra = p.getMeta().join(\", \");\r\n if (extra !== \"\") {\r\n extra = \"(Meta: \" + extra + \")\";\r\n }\r\n return \"* \" + p.getName() + extra + \" TYPE \" + p.getType().toText(1) + \"\\n\\n\";\r\n }\r\n static searchReferences(scope, token) {\r\n const ret = [];\r\n for (const r of scope.getData().references) {\r\n if (r.position.getStart().equals(token.getStart())) {\r\n ret.push(r);\r\n }\r\n }\r\n const parent = scope.getParent();\r\n if (parent) {\r\n ret.push(...this.searchReferences(parent, token));\r\n }\r\n return ret;\r\n }\r\n static ABAPFileResult(abap) {\r\n return {\r\n uri: abap.getFilename(),\r\n range: LServer.Range.create(0, 0, 0, 0),\r\n };\r\n }\r\n static findMethodDefinition(found, scope) {\r\n var _a, _b, _c, _d;\r\n if (scope.getIdentifier().stype !== _scope_type_1.ScopeType.ClassDefinition\r\n || !(found.snode.get() instanceof Statements.MethodDef)) {\r\n return undefined;\r\n }\r\n const nameToken = (_a = found.snode.findFirstExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();\r\n if (nameToken === undefined) {\r\n return undefined;\r\n }\r\n if (found.snode.findFirstExpression(Expressions.Redefinition)) {\r\n return undefined;\r\n }\r\n // check the cursor is at the right token\r\n if (nameToken.getStart().getCol() !== found.token.getStart().getCol()\r\n || nameToken.getStart().getRow() !== found.token.getStart().getRow()) {\r\n return undefined;\r\n }\r\n const def = (_d = (_c = (_b = scope.getParent()) === null || _b === void 0 ? void 0 : _b.findClassDefinition(scope.getIdentifier().sname)) === null || _c === void 0 ? void 0 : _c.getMethodDefinitions()) === null || _d === void 0 ? void 0 : _d.getByName(nameToken.getStr());\r\n return def;\r\n }\r\n static findFunctionModule(found) {\r\n if (!(found.snode.get() instanceof Statements.CallFunction)) {\r\n return undefined;\r\n }\r\n const name = found.snode.findFirstExpression(Expressions.FunctionName);\r\n if (name === undefined) {\r\n return undefined;\r\n }\r\n // check the cursor is at the right token\r\n const token = name.getFirstToken();\r\n if (token.getStart().getCol() !== found.token.getStart().getCol()\r\n || token.getStart().getRow() !== found.token.getStart().getRow()) {\r\n return undefined;\r\n }\r\n return token.getStr();\r\n }\r\n static findInclude(found, reg) {\r\n if (!(found.snode.get() instanceof Statements.Include)) {\r\n return;\r\n }\r\n const name = found.snode.findFirstExpression(Expressions.IncludeName);\r\n if (name === undefined) {\r\n return undefined;\r\n }\r\n // check the cursor is at the right token\r\n const token = name.getFirstToken();\r\n if (token.getStart().getCol() !== found.token.getStart().getCol()\r\n || token.getStart().getRow() !== found.token.getStart().getRow()) {\r\n return undefined;\r\n }\r\n const obj = reg.getObject(\"PROG\", token.getStr());\r\n if (obj) {\r\n return obj.getABAPFiles()[0];\r\n }\r\n return undefined;\r\n }\r\n}\r\nexports.LSPLookup = LSPLookup;\r\n//# sourceMappingURL=_lookup.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/lsp/_lookup.js?");
|
|
10183
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.LSPLookup = void 0;\r\nconst LServer = __webpack_require__(/*! vscode-languageserver-types */ \"./node_modules/vscode-languageserver-types/lib/esm/main.js\");\r\nconst Statements = __webpack_require__(/*! ../abap/2_statements/statements */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js\");\r\nconst Expressions = __webpack_require__(/*! ../abap/2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\r\nconst syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/syntax.js\");\r\nconst _lsp_utils_1 = __webpack_require__(/*! ./_lsp_utils */ \"./node_modules/@abaplint/core/build/src/lsp/_lsp_utils.js\");\r\nconst _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ \"./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js\");\r\nconst _reference_1 = __webpack_require__(/*! ../abap/5_syntax/_reference */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js\");\r\nconst _builtin_1 = __webpack_require__(/*! ../abap/5_syntax/_builtin */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_builtin.js\");\r\nconst _scope_type_1 = __webpack_require__(/*! ../abap/5_syntax/_scope_type */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js\");\r\nconst types_1 = __webpack_require__(/*! ../abap/types */ \"./node_modules/@abaplint/core/build/src/abap/types/index.js\");\r\nclass LSPLookup {\r\n static lookup(cursor, reg, obj) {\r\n const inc = this.findInclude(cursor, reg);\r\n if (inc) {\r\n const found = this.ABAPFileResult(inc);\r\n return { hover: \"Include\", definition: found, implementation: found };\r\n }\r\n const fm = this.findFunctionModule(cursor);\r\n if (fm) {\r\n return { hover: \"Function Module \" + fm };\r\n }\r\n const bottomScope = new syntax_1.SyntaxLogic(reg, obj).run().spaghetti.lookupPosition(cursor.identifier.getStart(), cursor.identifier.getFilename());\r\n if (bottomScope === undefined) {\r\n return undefined;\r\n }\r\n const clas = bottomScope.findClassDefinition(cursor.token.getStr());\r\n if (clas && clas.getStart().equals(cursor.token.getStart())) {\r\n const found = _lsp_utils_1.LSPUtils.identiferToLocation(clas);\r\n return {\r\n hover: \"Class Definition, \" + cursor.token.getStr(),\r\n definition: found,\r\n definitionId: clas,\r\n implementation: undefined,\r\n scope: bottomScope,\r\n };\r\n }\r\n const intf = bottomScope.findInterfaceDefinition(cursor.token.getStr());\r\n if (intf && intf.getStart().equals(cursor.token.getStart())) {\r\n const found = _lsp_utils_1.LSPUtils.identiferToLocation(intf);\r\n return {\r\n hover: \"Interface Definition, \" + cursor.token.getStr(),\r\n definition: found,\r\n definitionId: intf,\r\n implementation: undefined,\r\n scope: bottomScope,\r\n };\r\n }\r\n const type = bottomScope.findType(cursor.token.getStr());\r\n if (type !== undefined && type.getStart().equals(cursor.token.getStart())) {\r\n const found = _lsp_utils_1.LSPUtils.identiferToLocation(type);\r\n const hover = \"Type Definition, \" + cursor.token.getStr() + \"\\n\\n\" + this.dumpType(type);\r\n return { hover, definition: found, definitionId: type, scope: bottomScope };\r\n }\r\n const method = this.findMethodDefinition(cursor, bottomScope);\r\n if (method !== undefined && method.getStart().equals(cursor.token.getStart())) {\r\n const found = _lsp_utils_1.LSPUtils.identiferToLocation(method);\r\n const hover = \"Method Definition \\\"\" + method.getName() + \"\\\"\";\r\n return { hover, definition: found, definitionId: method, scope: bottomScope };\r\n }\r\n const variable = bottomScope.findVariable(cursor.token.getStr());\r\n if (variable !== undefined && variable.getStart().equals(cursor.token.getStart())) {\r\n const hover = \"Variable Definition\\n\\n\" + this.dumpType(variable);\r\n let location = undefined;\r\n if (variable.getMeta().includes(\"built-in\" /* IdentifierMeta.BuiltIn */) === false) {\r\n location = _lsp_utils_1.LSPUtils.identiferToLocation(variable);\r\n }\r\n return { hover, definition: location, implementation: location, definitionId: variable, scope: bottomScope };\r\n }\r\n let hoverValue = \"\";\r\n const ddicRefs = reg.getDDICReferences().listByFilename(cursor.identifier.getFilename(), cursor.identifier.getStart().getRow());\r\n for (const d of ddicRefs) {\r\n if (d.object && d.token && d.token.getStart().equals(cursor.identifier.getStart())) {\r\n hoverValue += `DDIC: ${d.object.getType()} ${d.object.getName()}`;\r\n }\r\n }\r\n const refs = this.searchReferences(bottomScope, cursor.token);\r\n if (refs.length > 0) {\r\n for (const ref of refs) {\r\n if (hoverValue !== \"\") {\r\n hoverValue += \"\\n_________________\\n\";\r\n }\r\n hoverValue += this.referenceHover(ref, bottomScope, reg);\r\n }\r\n let definition = undefined;\r\n let implementation = undefined;\r\n if (refs[0].resolved) {\r\n definition = _lsp_utils_1.LSPUtils.identiferToLocation(refs[0].resolved);\r\n if (definition.uri === _builtin_1.BuiltIn.filename) {\r\n definition = undefined;\r\n }\r\n if (refs[0].resolved instanceof types_1.FormDefinition) {\r\n implementation = definition;\r\n }\r\n }\r\n return {\r\n hover: hoverValue,\r\n definition: definition,\r\n implementation: implementation,\r\n definitionId: refs[0].resolved,\r\n scope: bottomScope,\r\n };\r\n }\r\n if (hoverValue !== \"\") {\r\n return { hover: hoverValue, scope: bottomScope };\r\n }\r\n return undefined;\r\n }\r\n ////////////////////////////////////////////\r\n static dumpType(variable) {\r\n let value = variable.toText() + \"\\n\\nType: \" + variable.getType().toText(0);\r\n if (variable.getValue()) {\r\n value += \"\\n\\nValue: ```\" + variable.getValue() + \"```\";\r\n }\r\n if (variable.getMeta().length > 0) {\r\n value += \"\\n\\nMeta: \" + variable.getMeta().join(\", \");\r\n }\r\n if (variable.getType().containsVoid() === true) {\r\n value += \"\\n\\nContains Void types\";\r\n }\r\n if (variable.getType().getQualifiedName()) {\r\n value += \"\\n\\nQualified Type Name: ```\" + variable.getType().getQualifiedName() + \"```\";\r\n }\r\n if (variable.getType().isGeneric() === true) {\r\n value += \"\\n\\nIs Generic Type\";\r\n }\r\n if (variable.getType().getConversionExit() !== undefined) {\r\n value += \"\\n\\nConversion Exit: ```\" + variable.getType().getConversionExit() + \"```\";\r\n }\r\n if (variable.getType().getDDICName() !== undefined) {\r\n value += \"\\n\\nDDIC Name: ```\" + variable.getType().getDDICName() + \"```\";\r\n }\r\n return value;\r\n }\r\n static referenceHover(ref, scope, reg) {\r\n var _a, _b, _c, _d, _e;\r\n let name = \"\";\r\n if (ref.resolved) {\r\n name = \"```\" + ref.resolved.getName() + \"```\";\r\n }\r\n let ret = `${ref.referenceType} ${name}`;\r\n if (ref.referenceType === _reference_1.ReferenceType.MethodReference && ((_a = ref.extra) === null || _a === void 0 ? void 0 : _a.ooName)) {\r\n let cdef = scope.findClassDefinition(ref.extra.ooName);\r\n if (cdef === undefined) {\r\n cdef = scope.findInterfaceDefinition(ref.extra.ooName);\r\n }\r\n if (cdef === undefined) {\r\n cdef = (_b = reg.getObject(\"CLAS\", ref.extra.ooName)) === null || _b === void 0 ? void 0 : _b.getDefinition();\r\n }\r\n if (cdef === undefined) {\r\n cdef = (_c = reg.getObject(\"INTF\", ref.extra.ooName)) === null || _c === void 0 ? void 0 : _c.getDefinition();\r\n }\r\n ret += \"\\n\\n\" + this.hoverMethod(ref.position.getName(), cdef);\r\n }\r\n else if (ref.resolved instanceof _typed_identifier_1.TypedIdentifier) {\r\n ret += \"\\n\\n\" + this.dumpType(ref.resolved);\r\n }\r\n else if (ref.referenceType === _reference_1.ReferenceType.BuiltinMethodReference) {\r\n const builtinDef = new _builtin_1.BuiltIn().searchBuiltin((_e = (_d = ref.resolved) === null || _d === void 0 ? void 0 : _d.getName()) === null || _e === void 0 ? void 0 : _e.toUpperCase());\r\n if (builtinDef === undefined) {\r\n return \"Error: builtin method signature not found\";\r\n }\r\n ret += \"\\n\\n\" + this.methodParameters(builtinDef);\r\n }\r\n if (ref.resolved) {\r\n ret += \"\\n\\n(Resolved)\";\r\n }\r\n if (ref.extra !== undefined && Object.keys(ref.extra).length > 0) {\r\n ret += \"\\n\\nExtra: \" + JSON.stringify(ref.extra);\r\n }\r\n return ret;\r\n }\r\n static hoverMethod(method, classDef) {\r\n if (classDef === undefined) {\r\n return \"class not found\";\r\n }\r\n const methodDef = classDef.getMethodDefinitions().getByName(method);\r\n if (methodDef === undefined) {\r\n return \"method not found in definition\";\r\n }\r\n return this.methodParameters(methodDef);\r\n }\r\n static methodParameters(methodDef) {\r\n let ret = \"\";\r\n const parameters = methodDef.getParameters();\r\n const importing = parameters.getImporting();\r\n if (importing.length > 0) {\r\n ret += \"IMPORTING\\n\";\r\n for (const p of importing) {\r\n ret += this.singleParameter(p);\r\n }\r\n }\r\n const exporting = parameters.getExporting();\r\n if (exporting.length > 0) {\r\n ret += \"EXPORTING\\n\";\r\n for (const p of exporting) {\r\n ret += this.singleParameter(p);\r\n }\r\n }\r\n const changing = parameters.getChanging();\r\n if (changing.length > 0) {\r\n ret += \"CHANGING\\n\";\r\n for (const p of changing) {\r\n ret += this.singleParameter(p);\r\n }\r\n }\r\n const r = parameters.getReturning();\r\n if (r) {\r\n ret += \"RETURNING\\n\" + this.singleParameter(r);\r\n }\r\n if (methodDef.getRaising().length > 0) {\r\n ret += \"RAISING\\n\";\r\n for (const p of methodDef.getRaising()) {\r\n ret += \"* \" + p + \"\\n\";\r\n }\r\n }\r\n return ret;\r\n }\r\n static singleParameter(p) {\r\n let extra = p.getMeta().join(\", \");\r\n if (extra !== \"\") {\r\n extra = \"(Meta: \" + extra + \")\";\r\n }\r\n return \"* \" + p.getName() + extra + \" TYPE \" + p.getType().toText(1) + \"\\n\\n\";\r\n }\r\n static searchReferences(scope, token) {\r\n const ret = [];\r\n for (const r of scope.getData().references) {\r\n if (r.position.getStart().equals(token.getStart())) {\r\n ret.push(r);\r\n }\r\n }\r\n const parent = scope.getParent();\r\n if (parent) {\r\n ret.push(...this.searchReferences(parent, token));\r\n }\r\n return ret;\r\n }\r\n static ABAPFileResult(abap) {\r\n return {\r\n uri: abap.getFilename(),\r\n range: LServer.Range.create(0, 0, 0, 0),\r\n };\r\n }\r\n static findMethodDefinition(found, scope) {\r\n var _a, _b, _c, _d;\r\n if (scope.getIdentifier().stype !== _scope_type_1.ScopeType.ClassDefinition\r\n || !(found.snode.get() instanceof Statements.MethodDef)) {\r\n return undefined;\r\n }\r\n const nameToken = (_a = found.snode.findFirstExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();\r\n if (nameToken === undefined) {\r\n return undefined;\r\n }\r\n if (found.snode.findFirstExpression(Expressions.Redefinition)) {\r\n return undefined;\r\n }\r\n // check the cursor is at the right token\r\n if (nameToken.getStart().getCol() !== found.token.getStart().getCol()\r\n || nameToken.getStart().getRow() !== found.token.getStart().getRow()) {\r\n return undefined;\r\n }\r\n const def = (_d = (_c = (_b = scope.getParent()) === null || _b === void 0 ? void 0 : _b.findClassDefinition(scope.getIdentifier().sname)) === null || _c === void 0 ? void 0 : _c.getMethodDefinitions()) === null || _d === void 0 ? void 0 : _d.getByName(nameToken.getStr());\r\n return def;\r\n }\r\n static findFunctionModule(found) {\r\n if (!(found.snode.get() instanceof Statements.CallFunction)) {\r\n return undefined;\r\n }\r\n const name = found.snode.findFirstExpression(Expressions.FunctionName);\r\n if (name === undefined) {\r\n return undefined;\r\n }\r\n // check the cursor is at the right token\r\n const token = name.getFirstToken();\r\n if (token.getStart().getCol() !== found.token.getStart().getCol()\r\n || token.getStart().getRow() !== found.token.getStart().getRow()) {\r\n return undefined;\r\n }\r\n return token.getStr();\r\n }\r\n static findInclude(found, reg) {\r\n if (!(found.snode.get() instanceof Statements.Include)) {\r\n return;\r\n }\r\n const name = found.snode.findFirstExpression(Expressions.IncludeName);\r\n if (name === undefined) {\r\n return undefined;\r\n }\r\n // check the cursor is at the right token\r\n const token = name.getFirstToken();\r\n if (token.getStart().getCol() !== found.token.getStart().getCol()\r\n || token.getStart().getRow() !== found.token.getStart().getRow()) {\r\n return undefined;\r\n }\r\n const obj = reg.getObject(\"PROG\", token.getStr());\r\n if (obj) {\r\n return obj.getABAPFiles()[0];\r\n }\r\n return undefined;\r\n }\r\n}\r\nexports.LSPLookup = LSPLookup;\r\n//# sourceMappingURL=_lookup.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/lsp/_lookup.js?");
|
|
10173
10184
|
|
|
10174
10185
|
/***/ }),
|
|
10175
10186
|
|
|
@@ -11775,7 +11786,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
11775
11786
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
11776
11787
|
|
|
11777
11788
|
"use strict";
|
|
11778
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Registry = void 0;\nconst config_1 = __webpack_require__(/*! ./config */ \"./node_modules/@abaplint/core/build/src/config.js\");\nconst artifacts_objects_1 = __webpack_require__(/*! ./artifacts_objects */ \"./node_modules/@abaplint/core/build/src/artifacts_objects.js\");\nconst find_global_definitions_1 = __webpack_require__(/*! ./abap/5_syntax/global_definitions/find_global_definitions */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/global_definitions/find_global_definitions.js\");\nconst excludeHelper_1 = __webpack_require__(/*! ./utils/excludeHelper */ \"./node_modules/@abaplint/core/build/src/utils/excludeHelper.js\");\nconst ddic_references_1 = __webpack_require__(/*! ./ddic_references */ \"./node_modules/@abaplint/core/build/src/ddic_references.js\");\nconst rules_runner_1 = __webpack_require__(/*! ./rules_runner */ \"./node_modules/@abaplint/core/build/src/rules_runner.js\");\n// todo, this should really be an instance in case there are multiple Registry'ies\nclass ParsingPerformance {\n static clear() {\n this.results = [];\n this.lexing = 0;\n this.statements = 0;\n this.structure = 0;\n }\n static push(obj, result) {\n if (result.runtimeExtra) {\n this.lexing += result.runtimeExtra.lexing;\n this.statements += result.runtimeExtra.statements;\n this.structure += result.runtimeExtra.structure;\n }\n if (result.runtime < 100) {\n return;\n }\n if (this.results === undefined) {\n this.results = [];\n }\n let extra = \"\";\n if (result.runtimeExtra) {\n extra = `\\t(lexing: ${result.runtimeExtra.lexing}ms, statements: ${result.runtimeExtra.statements}ms, structure: ${result.runtimeExtra.structure}ms)`;\n }\n this.results.push({\n runtime: result.runtime,\n extra,\n name: obj.getType() + \" \" + obj.getName(),\n });\n }\n static output() {\n const MAX = 10;\n this.results.sort((a, b) => { return b.runtime - a.runtime; });\n for (let i = 0; i < MAX; i++) {\n const row = this.results[i];\n if (row === undefined) {\n break;\n }\n process.stderr.write(`\\t${row.runtime}ms\\t${row.name} ${row.extra}\\n`);\n }\n process.stderr.write(`\\tTotal lexing: ${this.lexing}ms\\n`);\n process.stderr.write(`\\tTotal statements: ${this.statements}ms\\n`);\n process.stderr.write(`\\tTotal structure: ${this.structure}ms\\n`);\n }\n}\n///////////////////////////////////////////////////////////////////////////////////////////////\nclass Registry {\n constructor(conf) {\n this.objects = {};\n this.objectsByType = {};\n this.dependencies = {};\n this.conf = conf ? conf : config_1.Config.getDefault();\n this.references = new ddic_references_1.DDICReferences();\n }\n static abaplintVersion() {\n // magic, see build script \"version.sh\"\n return \"2.94.23\";\n }\n getDDICReferences() {\n return this.references;\n }\n *getObjects() {\n for (const name in this.objects) {\n for (const type in this.objects[name]) {\n yield this.objects[name][type];\n }\n }\n }\n *getObjectsByType(type) {\n for (const name in this.objectsByType[type] || []) {\n yield this.objectsByType[type][name];\n }\n }\n *getFiles() {\n for (const obj of this.getObjects()) {\n for (const file of obj.getFiles()) {\n yield file;\n }\n }\n }\n getFirstObject() {\n for (const name in this.objects) {\n for (const type in this.objects[name]) {\n return this.objects[name][type];\n }\n }\n return undefined;\n }\n getObjectCount(skipDependencies = true) {\n let res = 0;\n for (const o of this.getObjects()) {\n if (skipDependencies === true && this.isDependency(o)) {\n continue;\n }\n res = res + 1;\n }\n return res;\n }\n getFileByName(filename) {\n const upper = filename.toUpperCase();\n for (const o of this.getObjects()) {\n for (const f of o.getFiles()) {\n if (f.getFilename().toUpperCase() === upper) {\n return f;\n }\n }\n }\n return undefined;\n }\n getObject(type, name) {\n if (type === undefined || name === undefined) {\n return undefined;\n }\n const searchName = name.toUpperCase();\n if (this.objects[searchName]) {\n return this.objects[searchName][type];\n }\n return undefined;\n }\n getConfig() {\n return this.conf;\n }\n // assumption: Config is immutable, and can only be changed via this method\n setConfig(conf) {\n for (const obj of this.getObjects()) {\n obj.setDirty();\n }\n this.conf = conf;\n return this;\n }\n inErrorNamespace(name) {\n // todo: performance? cache regexp?\n const reg = new RegExp(this.getConfig().getSyntaxSetttings().errorNamespace, \"i\");\n return reg.test(name);\n }\n addFile(file) {\n return this.addFiles([file]);\n }\n updateFile(file) {\n const obj = this.find(file.getObjectName(), file.getObjectType());\n obj.updateFile(file);\n return this;\n }\n removeFile(file) {\n const obj = this.find(file.getObjectName(), file.getObjectType());\n obj.removeFile(file);\n if (obj.getFiles().length === 0) {\n this.references.clear(obj);\n this.removeObject(obj);\n }\n return this;\n }\n _addFiles(files, dependency) {\n var _a;\n const globalExclude = ((_a = this.conf.getGlobal().exclude) !== null && _a !== void 0 ? _a : [])\n .map(pattern => new RegExp(pattern, \"i\"));\n for (const f of files) {\n const filename = f.getFilename();\n const isNotAbapgitFile = filename.split(\".\").length <= 2;\n if (isNotAbapgitFile || excludeHelper_1.ExcludeHelper.isExcluded(filename, globalExclude)) {\n continue;\n }\n let found = this.findOrCreate(f.getObjectName(), f.getObjectType());\n if (dependency === false && found && this.isDependency(found)) {\n this.removeDependency(found);\n found = this.findOrCreate(f.getObjectName(), f.getObjectType());\n }\n found.addFile(f);\n }\n return this;\n }\n addFiles(files) {\n this._addFiles(files, false);\n return this;\n }\n addDependencies(files) {\n for (const f of files) {\n this.addDependency(f);\n }\n return this;\n }\n addDependency(file) {\n var _a;\n const type = (_a = file.getObjectType()) === null || _a === void 0 ? void 0 : _a.toUpperCase();\n if (type === undefined) {\n return this;\n }\n const name = file.getObjectName().toUpperCase();\n if (this.dependencies[type] === undefined) {\n this.dependencies[type] = {};\n }\n this.dependencies[type][name] = true;\n this._addFiles([file], true);\n return this;\n }\n removeDependency(obj) {\n var _a;\n (_a = this.dependencies[obj.getType()]) === null || _a === void 0 ? true : delete _a[obj.getName()];\n this.removeObject(obj);\n }\n isDependency(obj) {\n var _a;\n return ((_a = this.dependencies[obj.getType()]) === null || _a === void 0 ? void 0 : _a[obj.getName()]) === true;\n }\n isFileDependency(filename) {\n var _a, _b;\n const f = this.getFileByName(filename);\n if (f === undefined) {\n return false;\n }\n const type = (_a = f.getObjectType()) === null || _a === void 0 ? void 0 : _a.toUpperCase();\n if (type === undefined) {\n return false;\n }\n const name = f.getObjectName().toUpperCase();\n return ((_b = this.dependencies[type]) === null || _b === void 0 ? void 0 : _b[name]) === true;\n }\n // assumption: the file is already in the registry\n findObjectForFile(file) {\n const filename = file.getFilename();\n for (const obj of this.getObjects()) {\n for (const ofile of obj.getFiles()) {\n if (ofile.getFilename() === filename) {\n return obj;\n }\n }\n }\n return undefined;\n }\n // todo, this will be changed to async sometime\n findIssues(input) {\n if (this.isDirty() === true) {\n this.parse();\n }\n return new rules_runner_1.RulesRunner(this).runRules(this.getObjects(), input);\n }\n // todo, this will be changed to async sometime\n findIssuesObject(iobj) {\n if (this.isDirty() === true) {\n this.parse();\n }\n return new rules_runner_1.RulesRunner(this).runRules([iobj]);\n }\n // todo, this will be changed to async sometime\n parse() {\n if (this.isDirty() === false) {\n return this;\n }\n ParsingPerformance.clear();\n for (const o of this.getObjects()) {\n this.parsePrivate(o);\n }\n new find_global_definitions_1.FindGlobalDefinitions(this).run();\n return this;\n }\n async parseAsync(input) {\n var _a, _b;\n if (this.isDirty() === false) {\n return this;\n }\n ParsingPerformance.clear();\n (_a = input === null || input === void 0 ? void 0 : input.progress) === null || _a === void 0 ? void 0 : _a.set(this.getObjectCount(false), \"Lexing and parsing\");\n for (const o of this.getObjects()) {\n await ((_b = input === null || input === void 0 ? void 0 : input.progress) === null || _b === void 0 ? void 0 : _b.tick(\"Lexing and parsing(\" + this.conf.getVersion() + \") - \" + o.getType() + \" \" + o.getName()));\n this.parsePrivate(o);\n }\n if ((input === null || input === void 0 ? void 0 : input.outputPerformance) === true) {\n ParsingPerformance.output();\n }\n new find_global_definitions_1.FindGlobalDefinitions(this).run(input === null || input === void 0 ? void 0 : input.progress);\n return this;\n }\n //////////////////////////////////////////\n // todo, refactor, this is a mess, see where-used, a lot of the code should be in this method instead\n parsePrivate(input) {\n const config = this.getConfig();\n const result = input.parse(config.getVersion(), config.getSyntaxSetttings().globalMacros, this);\n ParsingPerformance.push(input, result);\n }\n isDirty() {\n for (const o of this.getObjects()) {\n const dirty = o.isDirty();\n if (dirty === true) {\n return true;\n }\n }\n return false;\n }\n findOrCreate(name, type) {\n try {\n return this.find(name, type);\n }\n catch (_a) {\n const newName = name.toUpperCase();\n const newType = type ? type : \"UNKNOWN\";\n const add = artifacts_objects_1.ArtifactsObjects.newObject(newName, newType);\n if (this.objects[newName] === undefined) {\n this.objects[newName] = {};\n }\n this.objects[newName][newType] = add;\n if (this.objectsByType[newType] === undefined) {\n this.objectsByType[newType] = {};\n }\n this.objectsByType[newType][newName] = add;\n return add;\n }\n }\n removeObject(remove) {\n if (remove === undefined) {\n return;\n }\n if (this.objects[remove.getName()][remove.getType()] === undefined) {\n throw new Error(\"removeObject: object not found\");\n }\n if (Object.keys(this.objects[remove.getName()]).length === 1) {\n delete this.objects[remove.getName()];\n }\n else {\n delete this.objects[remove.getName()][remove.getType()];\n }\n if (Object.keys(this.objectsByType[remove.getType()]).length === 1) {\n delete this.objectsByType[remove.getType()];\n }\n else {\n delete this.objectsByType[remove.getType()][remove.getName()];\n }\n }\n find(name, type) {\n const searchType = type ? type : \"UNKNOWN\";\n const searchName = name.toUpperCase();\n if (this.objects[searchName] !== undefined\n && this.objects[searchName][searchType]) {\n return this.objects[searchName][searchType];\n }\n throw new Error(\"find: object not found, \" + type + \" \" + name);\n }\n}\nexports.Registry = Registry;\n//# sourceMappingURL=registry.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/registry.js?");
|
|
11789
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Registry = void 0;\nconst config_1 = __webpack_require__(/*! ./config */ \"./node_modules/@abaplint/core/build/src/config.js\");\nconst artifacts_objects_1 = __webpack_require__(/*! ./artifacts_objects */ \"./node_modules/@abaplint/core/build/src/artifacts_objects.js\");\nconst find_global_definitions_1 = __webpack_require__(/*! ./abap/5_syntax/global_definitions/find_global_definitions */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/global_definitions/find_global_definitions.js\");\nconst excludeHelper_1 = __webpack_require__(/*! ./utils/excludeHelper */ \"./node_modules/@abaplint/core/build/src/utils/excludeHelper.js\");\nconst ddic_references_1 = __webpack_require__(/*! ./ddic_references */ \"./node_modules/@abaplint/core/build/src/ddic_references.js\");\nconst rules_runner_1 = __webpack_require__(/*! ./rules_runner */ \"./node_modules/@abaplint/core/build/src/rules_runner.js\");\n// todo, this should really be an instance in case there are multiple Registry'ies\nclass ParsingPerformance {\n static clear() {\n this.results = [];\n this.lexing = 0;\n this.statements = 0;\n this.structure = 0;\n }\n static push(obj, result) {\n if (result.runtimeExtra) {\n this.lexing += result.runtimeExtra.lexing;\n this.statements += result.runtimeExtra.statements;\n this.structure += result.runtimeExtra.structure;\n }\n if (result.runtime < 100) {\n return;\n }\n if (this.results === undefined) {\n this.results = [];\n }\n let extra = \"\";\n if (result.runtimeExtra) {\n extra = `\\t(lexing: ${result.runtimeExtra.lexing}ms, statements: ${result.runtimeExtra.statements}ms, structure: ${result.runtimeExtra.structure}ms)`;\n }\n this.results.push({\n runtime: result.runtime,\n extra,\n name: obj.getType() + \" \" + obj.getName(),\n });\n }\n static output() {\n const MAX = 10;\n this.results.sort((a, b) => { return b.runtime - a.runtime; });\n for (let i = 0; i < MAX; i++) {\n const row = this.results[i];\n if (row === undefined) {\n break;\n }\n process.stderr.write(`\\t${row.runtime}ms\\t${row.name} ${row.extra}\\n`);\n }\n process.stderr.write(`\\tTotal lexing: ${this.lexing}ms\\n`);\n process.stderr.write(`\\tTotal statements: ${this.statements}ms\\n`);\n process.stderr.write(`\\tTotal structure: ${this.structure}ms\\n`);\n }\n}\n///////////////////////////////////////////////////////////////////////////////////////////////\nclass Registry {\n constructor(conf) {\n this.objects = {};\n this.objectsByType = {};\n this.dependencies = {};\n this.conf = conf ? conf : config_1.Config.getDefault();\n this.references = new ddic_references_1.DDICReferences();\n }\n static abaplintVersion() {\n // magic, see build script \"version.sh\"\n return \"2.94.25\";\n }\n getDDICReferences() {\n return this.references;\n }\n *getObjects() {\n for (const name in this.objects) {\n for (const type in this.objects[name]) {\n yield this.objects[name][type];\n }\n }\n }\n *getObjectsByType(type) {\n for (const name in this.objectsByType[type] || []) {\n yield this.objectsByType[type][name];\n }\n }\n *getFiles() {\n for (const obj of this.getObjects()) {\n for (const file of obj.getFiles()) {\n yield file;\n }\n }\n }\n getFirstObject() {\n for (const name in this.objects) {\n for (const type in this.objects[name]) {\n return this.objects[name][type];\n }\n }\n return undefined;\n }\n getObjectCount(skipDependencies = true) {\n let res = 0;\n for (const o of this.getObjects()) {\n if (skipDependencies === true && this.isDependency(o)) {\n continue;\n }\n res = res + 1;\n }\n return res;\n }\n getFileByName(filename) {\n const upper = filename.toUpperCase();\n for (const o of this.getObjects()) {\n for (const f of o.getFiles()) {\n if (f.getFilename().toUpperCase() === upper) {\n return f;\n }\n }\n }\n return undefined;\n }\n getObject(type, name) {\n if (type === undefined || name === undefined) {\n return undefined;\n }\n const searchName = name.toUpperCase();\n if (this.objects[searchName]) {\n return this.objects[searchName][type];\n }\n return undefined;\n }\n getConfig() {\n return this.conf;\n }\n // assumption: Config is immutable, and can only be changed via this method\n setConfig(conf) {\n for (const obj of this.getObjects()) {\n obj.setDirty();\n }\n this.conf = conf;\n return this;\n }\n inErrorNamespace(name) {\n // todo: performance? cache regexp?\n const reg = new RegExp(this.getConfig().getSyntaxSetttings().errorNamespace, \"i\");\n return reg.test(name);\n }\n addFile(file) {\n return this.addFiles([file]);\n }\n updateFile(file) {\n const obj = this.find(file.getObjectName(), file.getObjectType());\n obj.updateFile(file);\n return this;\n }\n removeFile(file) {\n const obj = this.find(file.getObjectName(), file.getObjectType());\n obj.removeFile(file);\n if (obj.getFiles().length === 0) {\n this.references.clear(obj);\n this.removeObject(obj);\n }\n return this;\n }\n _addFiles(files, dependency) {\n var _a;\n const globalExclude = ((_a = this.conf.getGlobal().exclude) !== null && _a !== void 0 ? _a : [])\n .map(pattern => new RegExp(pattern, \"i\"));\n for (const f of files) {\n const filename = f.getFilename();\n const isNotAbapgitFile = filename.split(\".\").length <= 2;\n if (isNotAbapgitFile || excludeHelper_1.ExcludeHelper.isExcluded(filename, globalExclude)) {\n continue;\n }\n let found = this.findOrCreate(f.getObjectName(), f.getObjectType());\n if (dependency === false && found && this.isDependency(found)) {\n this.removeDependency(found);\n found = this.findOrCreate(f.getObjectName(), f.getObjectType());\n }\n found.addFile(f);\n }\n return this;\n }\n addFiles(files) {\n this._addFiles(files, false);\n return this;\n }\n addDependencies(files) {\n for (const f of files) {\n this.addDependency(f);\n }\n return this;\n }\n addDependency(file) {\n var _a;\n const type = (_a = file.getObjectType()) === null || _a === void 0 ? void 0 : _a.toUpperCase();\n if (type === undefined) {\n return this;\n }\n const name = file.getObjectName().toUpperCase();\n if (this.dependencies[type] === undefined) {\n this.dependencies[type] = {};\n }\n this.dependencies[type][name] = true;\n this._addFiles([file], true);\n return this;\n }\n removeDependency(obj) {\n var _a;\n (_a = this.dependencies[obj.getType()]) === null || _a === void 0 ? true : delete _a[obj.getName()];\n this.removeObject(obj);\n }\n isDependency(obj) {\n var _a;\n return ((_a = this.dependencies[obj.getType()]) === null || _a === void 0 ? void 0 : _a[obj.getName()]) === true;\n }\n isFileDependency(filename) {\n var _a, _b;\n const f = this.getFileByName(filename);\n if (f === undefined) {\n return false;\n }\n const type = (_a = f.getObjectType()) === null || _a === void 0 ? void 0 : _a.toUpperCase();\n if (type === undefined) {\n return false;\n }\n const name = f.getObjectName().toUpperCase();\n return ((_b = this.dependencies[type]) === null || _b === void 0 ? void 0 : _b[name]) === true;\n }\n // assumption: the file is already in the registry\n findObjectForFile(file) {\n const filename = file.getFilename();\n for (const obj of this.getObjects()) {\n for (const ofile of obj.getFiles()) {\n if (ofile.getFilename() === filename) {\n return obj;\n }\n }\n }\n return undefined;\n }\n // todo, this will be changed to async sometime\n findIssues(input) {\n if (this.isDirty() === true) {\n this.parse();\n }\n return new rules_runner_1.RulesRunner(this).runRules(this.getObjects(), input);\n }\n // todo, this will be changed to async sometime\n findIssuesObject(iobj) {\n if (this.isDirty() === true) {\n this.parse();\n }\n return new rules_runner_1.RulesRunner(this).runRules([iobj]);\n }\n // todo, this will be changed to async sometime\n parse() {\n if (this.isDirty() === false) {\n return this;\n }\n ParsingPerformance.clear();\n for (const o of this.getObjects()) {\n this.parsePrivate(o);\n }\n new find_global_definitions_1.FindGlobalDefinitions(this).run();\n return this;\n }\n async parseAsync(input) {\n var _a, _b;\n if (this.isDirty() === false) {\n return this;\n }\n ParsingPerformance.clear();\n (_a = input === null || input === void 0 ? void 0 : input.progress) === null || _a === void 0 ? void 0 : _a.set(this.getObjectCount(false), \"Lexing and parsing\");\n for (const o of this.getObjects()) {\n await ((_b = input === null || input === void 0 ? void 0 : input.progress) === null || _b === void 0 ? void 0 : _b.tick(\"Lexing and parsing(\" + this.conf.getVersion() + \") - \" + o.getType() + \" \" + o.getName()));\n this.parsePrivate(o);\n }\n if ((input === null || input === void 0 ? void 0 : input.outputPerformance) === true) {\n ParsingPerformance.output();\n }\n new find_global_definitions_1.FindGlobalDefinitions(this).run(input === null || input === void 0 ? void 0 : input.progress);\n return this;\n }\n //////////////////////////////////////////\n // todo, refactor, this is a mess, see where-used, a lot of the code should be in this method instead\n parsePrivate(input) {\n const config = this.getConfig();\n const result = input.parse(config.getVersion(), config.getSyntaxSetttings().globalMacros, this);\n ParsingPerformance.push(input, result);\n }\n isDirty() {\n for (const o of this.getObjects()) {\n const dirty = o.isDirty();\n if (dirty === true) {\n return true;\n }\n }\n return false;\n }\n findOrCreate(name, type) {\n try {\n return this.find(name, type);\n }\n catch (_a) {\n const newName = name.toUpperCase();\n const newType = type ? type : \"UNKNOWN\";\n const add = artifacts_objects_1.ArtifactsObjects.newObject(newName, newType);\n if (this.objects[newName] === undefined) {\n this.objects[newName] = {};\n }\n this.objects[newName][newType] = add;\n if (this.objectsByType[newType] === undefined) {\n this.objectsByType[newType] = {};\n }\n this.objectsByType[newType][newName] = add;\n return add;\n }\n }\n removeObject(remove) {\n if (remove === undefined) {\n return;\n }\n if (this.objects[remove.getName()][remove.getType()] === undefined) {\n throw new Error(\"removeObject: object not found\");\n }\n if (Object.keys(this.objects[remove.getName()]).length === 1) {\n delete this.objects[remove.getName()];\n }\n else {\n delete this.objects[remove.getName()][remove.getType()];\n }\n if (Object.keys(this.objectsByType[remove.getType()]).length === 1) {\n delete this.objectsByType[remove.getType()];\n }\n else {\n delete this.objectsByType[remove.getType()][remove.getName()];\n }\n }\n find(name, type) {\n const searchType = type ? type : \"UNKNOWN\";\n const searchName = name.toUpperCase();\n if (this.objects[searchName] !== undefined\n && this.objects[searchName][searchType]) {\n return this.objects[searchName][searchType];\n }\n throw new Error(\"find: object not found, \" + type + \" \" + name);\n }\n}\nexports.Registry = Registry;\n//# sourceMappingURL=registry.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/registry.js?");
|
|
11779
11790
|
|
|
11780
11791
|
/***/ }),
|
|
11781
11792
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/cli",
|
|
3
|
-
"version": "2.94.
|
|
3
|
+
"version": "2.94.25",
|
|
4
4
|
"description": "abaplint - Command Line Interface",
|
|
5
5
|
"bin": {
|
|
6
6
|
"abaplint": "./abaplint"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://abaplint.org",
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@abaplint/core": "^2.94.
|
|
40
|
+
"@abaplint/core": "^2.94.25",
|
|
41
41
|
"@types/chai": "^4.3.4",
|
|
42
42
|
"@types/glob": "^7.2.0",
|
|
43
43
|
"@types/minimist": "^1.2.2",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@types/progress": "^2.0.5",
|
|
47
47
|
"chai": "^4.3.7",
|
|
48
48
|
"chalk": "^5.2.0",
|
|
49
|
-
"eslint": "^8.
|
|
49
|
+
"eslint": "^8.32.0",
|
|
50
50
|
"glob": "^7.2.3",
|
|
51
51
|
"json5": "^2.2.3",
|
|
52
52
|
"memfs": "^3.4.13",
|