@abaplint/cli 2.97.1 → 2.97.2
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 +2 -2
- package/package.json +2 -2
package/build/cli.js
CHANGED
|
@@ -6792,7 +6792,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
6792
6792
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
6793
6793
|
|
|
6794
6794
|
"use strict";
|
|
6795
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.BasicTypes = void 0;\n/* eslint-disable default-case */\nconst _typed_identifier_1 = __webpack_require__(/*! ../types/_typed_identifier */ \"./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js\");\nconst Expressions = __webpack_require__(/*! ../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\nconst Statements = __webpack_require__(/*! ../2_statements/statements */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js\");\nconst Types = __webpack_require__(/*! ../types/basic */ \"./node_modules/@abaplint/core/build/src/abap/types/basic/index.js\");\nconst _scope_type_1 = __webpack_require__(/*! ./_scope_type */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js\");\nconst _object_oriented_1 = __webpack_require__(/*! ./_object_oriented */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_object_oriented.js\");\nconst class_constant_1 = __webpack_require__(/*! ../types/class_constant */ \"./node_modules/@abaplint/core/build/src/abap/types/class_constant.js\");\nconst identifier_1 = __webpack_require__(/*! ../1_lexer/tokens/identifier */ \"./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/identifier.js\");\nconst _reference_1 = __webpack_require__(/*! ./_reference */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js\");\nconst basic_1 = __webpack_require__(/*! ../types/basic */ \"./node_modules/@abaplint/core/build/src/abap/types/basic/index.js\");\nconst field_chain_1 = __webpack_require__(/*! ./expressions/field_chain */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/field_chain.js\");\nconst types_1 = __webpack_require__(/*! ../types */ \"./node_modules/@abaplint/core/build/src/abap/types/index.js\");\nconst expressions_1 = __webpack_require__(/*! ../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\nconst _builtin_1 = __webpack_require__(/*! ./_builtin */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_builtin.js\");\nconst position_1 = __webpack_require__(/*! ../../position */ \"./node_modules/@abaplint/core/build/src/position.js\");\nclass BasicTypes {\n constructor(filename, scope) {\n this.filename = filename;\n this.scope = scope;\n }\n lookupQualifiedName(name) {\n var _a;\n // argh, todo, rewrite this entire method, more argh\n if (name === undefined) {\n return undefined;\n }\n const found = this.scope.findType(name);\n if (found) {\n return found;\n }\n if (name.includes(\"=>\")) {\n const split = name.split(\"=>\");\n const ooName = split[0];\n const typeName = split[1];\n const oo = this.scope.findObjectDefinition(ooName);\n if (oo) {\n if (typeName.includes(\"-\")) {\n const split = typeName.split(\"-\");\n const subTypeName = split[0];\n const fieldName = split[1];\n const stru = oo.getTypeDefinitions().getByName(subTypeName);\n const struType = stru === null || stru === void 0 ? void 0 : stru.getType();\n if (stru && struType instanceof basic_1.StructureType) {\n const f = struType.getComponentByName(fieldName);\n if (f) {\n return new _typed_identifier_1.TypedIdentifier(stru.getToken(), stru.getFilename(), f);\n }\n }\n }\n else {\n const f = oo.getTypeDefinitions().getByName(typeName);\n if (f) {\n return f;\n }\n }\n }\n }\n else if (name.includes(\"-\")) {\n const split = name.split(\"-\");\n const typeName = split[0];\n const fieldName = split[1];\n const type = this.scope.findType(typeName);\n if (type) {\n const stru = type.getType();\n if (stru instanceof basic_1.StructureType) {\n const f = stru.getComponentByName(fieldName);\n if (f) {\n return new _typed_identifier_1.TypedIdentifier(type.getToken(), type.getFilename(), f);\n }\n }\n }\n }\n const lookup = this.scope.getDDIC().lookupNoVoid(name);\n const id = (_a = lookup === null || lookup === void 0 ? void 0 : lookup.object) === null || _a === void 0 ? void 0 : _a.getIdentifier();\n if (id && (lookup === null || lookup === void 0 ? void 0 : lookup.type)) {\n return new _typed_identifier_1.TypedIdentifier(id.getToken(), id.getFilename(), lookup.type);\n }\n const builtin = this.scope.getDDIC().lookupBuiltinType(name);\n if (builtin) {\n return new _typed_identifier_1.TypedIdentifier(new identifier_1.Identifier(new position_1.Position(1, 1), name), _builtin_1.BuiltIn.filename, builtin);\n }\n const type = this.scope.findTypePoolType(name);\n if (type) {\n return type;\n }\n return undefined;\n }\n resolveLikeName(node, headerLogic = true) {\n var _a;\n if (node === undefined) {\n return undefined;\n }\n let chain = node.findFirstExpression(Expressions.FieldChain);\n if (chain === undefined) {\n chain = node.findFirstExpression(Expressions.TypeName);\n }\n if (chain === undefined) {\n chain = node.findFirstExpression(Expressions.FieldSub);\n }\n if (chain === undefined) {\n chain = node.findFirstExpression(Expressions.SimpleFieldChain);\n }\n if (chain === undefined) {\n throw new Error(\"resolveLikeName, chain undefined\");\n }\n const fullName = chain.concatTokens();\n const children = [...chain.getChildren()];\n if (children.length === 0) {\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + fullName + \"\\\", resolveLikeName1\");\n }\n let type = undefined;\n if (children[1] && (children[1].getFirstToken().getStr() === \"=>\" || children[1].getFirstToken().getStr() === \"->\")) {\n type = new field_chain_1.FieldChain().runSyntax(chain, this.scope, this.filename, _reference_1.ReferenceType.TypeReference);\n }\n else {\n const name = children.shift().getFirstToken().getStr();\n let found = this.scope.findVariable(name);\n type = found === null || found === void 0 ? void 0 : found.getType();\n if (found === undefined) {\n found = this.scope.findExtraLikeType(name);\n type = found === null || found === void 0 ? void 0 : found.getType();\n }\n if (found) {\n this.scope.addReference(chain === null || chain === void 0 ? void 0 : chain.getFirstToken(), found, _reference_1.ReferenceType.TypeReference, this.filename);\n }\n if (type === undefined) {\n type = (_a = this.scope.getDDIC().lookupNoVoid(name)) === null || _a === void 0 ? void 0 : _a.type;\n }\n if (type === undefined && this.scope.isOO() === false && this.scope.getDDIC().inErrorNamespace(name) === false) {\n this.scope.addReference(chain.getChildren()[0].getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\n return new Types.VoidType(name);\n }\n while (children.length > 0) {\n const child = children.shift();\n if (child.getFirstToken().getStr() === \"-\") {\n if (type instanceof Types.VoidType) {\n return type;\n }\n }\n else if (child.concatTokens() === \"[]\") {\n if (type instanceof Types.TableType) {\n type = new basic_1.TableType(type.getRowType(), { withHeader: false, keyType: Types.TableKeyType.default });\n }\n }\n else { // field name\n let sub = undefined;\n if (type instanceof Types.TableType) {\n type = type.getRowType();\n }\n if (type instanceof Types.StructureType) {\n sub = type.getComponentByName(child.getFirstToken().getStr());\n }\n if (sub === undefined) {\n return new Types.UnknownType(\"Type error, field not part of structure \" + fullName);\n }\n type = sub;\n }\n }\n if (type instanceof Types.VoidType) {\n return type;\n }\n else if (type instanceof basic_1.TableType\n && type.isWithHeader()\n && headerLogic === true) {\n type = type.getRowType();\n }\n else if (type instanceof Types.TableType\n && type.isWithHeader() === true\n && type.getRowType() instanceof Types.VoidType) {\n return type.getRowType();\n }\n }\n if (!type) {\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + fullName + \"\\\", resolveLikeName2\");\n }\n return type;\n }\n cloneType(type, qualifiedName) {\n // nested types(containing \"-\") will inherit the qualified names if possible\n // todo, this needs to be extended to all AbstractTypes instead of just CharacterType\n if (type instanceof basic_1.CharacterType\n && qualifiedName\n && qualifiedName.includes(\"-\") === false) {\n type = type.cloneType(qualifiedName);\n }\n return type;\n }\n resolveTypeName(typeName, length, decimals, qualifiedName) {\n var _a;\n if (typeName === undefined) {\n return undefined;\n }\n const chain = this.resolveTypeChain(typeName);\n if (chain) {\n return this.cloneType(chain, qualifiedName);\n }\n const chainText = typeName.concatTokens().toUpperCase();\n const f = this.scope.getDDIC().lookupBuiltinType(chainText, length, decimals, qualifiedName);\n if (f !== undefined) {\n return f;\n }\n const typ = this.scope.findType(chainText);\n if (typ) {\n const token = typeName.getFirstToken();\n if (chainText.includes(\"~\")) {\n const name = chainText.split(\"~\")[0];\n const idef = this.scope.findInterfaceDefinition(name);\n if (idef) {\n this.scope.addReference(token, idef, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: \"INTF\", ooName: name });\n }\n }\n this.scope.addReference(token, typ, _reference_1.ReferenceType.TypeReference, this.filename);\n return typ.getType();\n }\n const type = (_a = this.scope.findTypePoolType(chainText)) === null || _a === void 0 ? void 0 : _a.getType();\n if (type) {\n // this.scope.addReference(typeName.getFirstToken(), type, ReferenceType.TypeReference, this.filename);\n return type;\n }\n const ddic = this.scope.getDDIC().lookup(chainText);\n if (ddic) {\n this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), { object: ddic.object, token: typeName.getFirstToken(), filename: this.filename });\n if (ddic.type instanceof _typed_identifier_1.TypedIdentifier) {\n this.scope.addReference(typeName.getFirstToken(), ddic.type, _reference_1.ReferenceType.TypeReference, this.filename);\n }\n else if (ddic.type instanceof basic_1.VoidType) {\n this.scope.addReference(typeName.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\n }\n return this.cloneType(ddic.type, qualifiedName);\n }\n return undefined;\n }\n simpleType(node, qualifiedNamePrefix) {\n let nameExpr = node.findFirstExpression(Expressions.NamespaceSimpleName);\n if (nameExpr === undefined) {\n nameExpr = node.findFirstExpression(Expressions.DefinitionName);\n }\n if (nameExpr === undefined) {\n return undefined;\n }\n let name = nameExpr.getFirstToken();\n if (nameExpr.countTokens() > 1) { // workaround for names with dashes\n name = new identifier_1.Identifier(name.getStart(), nameExpr.concatTokens());\n }\n let qualifiedName = undefined;\n if (node.get() instanceof Statements.Type) {\n if (this.scope.isTypePool() === true) {\n qualifiedName = name.getStr();\n }\n else {\n qualifiedName = (qualifiedNamePrefix || \"\") + name.getStr();\n if (this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition\n || this.scope.getType() === _scope_type_1.ScopeType.Interface) {\n qualifiedName = this.scope.getName() + \"=>\" + qualifiedName;\n }\n }\n }\n else if (qualifiedNamePrefix) {\n qualifiedName = qualifiedNamePrefix + qualifiedName;\n }\n const found = this.parseType(node, qualifiedName);\n if (found) {\n return new _typed_identifier_1.TypedIdentifier(name, this.filename, found);\n }\n return undefined;\n }\n parseTable(node, name) {\n var _a, _b, _c;\n const typename = node.findFirstExpression(Expressions.TypeName);\n const text = (_a = node.findFirstExpression(Expressions.TypeTable)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();\n if (text === undefined) {\n return undefined;\n }\n let type = undefined;\n if (text.startsWith(\"TYPE STANDARD TABLE \")\n || text.startsWith(\"TYPE TABLE \")\n || text.startsWith(\"LIKE TABLE \")\n || text.startsWith(\"LIKE STANDARD TABLE \")) {\n type = basic_1.TableAccessType.standard;\n }\n else if (text.startsWith(\"TYPE SORTED TABLE \")\n || text.startsWith(\"LIKE SORTED TABLE \")) {\n type = basic_1.TableAccessType.sorted;\n }\n else if (text.startsWith(\"TYPE HASHED TABLE \")\n || text.startsWith(\"LIKE HASHED TABLE \")) {\n type = basic_1.TableAccessType.hashed;\n }\n const typeTableKeys = node.findAllExpressions(expressions_1.TypeTableKey);\n const firstKey = typeTableKeys[0];\n const isNamed = (firstKey === null || firstKey === void 0 ? void 0 : firstKey.findDirectExpression(expressions_1.Field)) !== undefined;\n const primaryKey = {\n name: \"primary_key\",\n type: type || basic_1.TableAccessType.standard,\n isUnique: isNamed ? false : (firstKey === null || firstKey === void 0 ? void 0 : firstKey.concatTokens().toUpperCase().includes(\"WITH UNIQUE \")) === true,\n keyFields: [],\n };\n let start = 1;\n if (isNamed === false) {\n for (const k of (firstKey === null || firstKey === void 0 ? void 0 : firstKey.findDirectExpressions(expressions_1.FieldSub)) || []) {\n primaryKey.keyFields.push(k.concatTokens().toUpperCase());\n }\n }\n else {\n start = 0;\n }\n const secondaryKeys = [];\n for (let i = start; i < typeTableKeys.length; i++) {\n const row = typeTableKeys[i];\n const name = (_b = row.findDirectExpression(expressions_1.Field)) === null || _b === void 0 ? void 0 : _b.concatTokens();\n if (name === undefined) {\n continue;\n }\n const secondary = {\n name: name,\n type: row.findDirectTokenByText(\"SORTED\") ? basic_1.TableAccessType.sorted : basic_1.TableAccessType.hashed,\n isUnique: (row === null || row === void 0 ? void 0 : row.concatTokens().toUpperCase().includes(\"WITH UNIQUE \")) === true,\n keyFields: [],\n };\n for (const k of (row === null || row === void 0 ? void 0 : row.findDirectExpressions(expressions_1.FieldSub)) || []) {\n secondary.keyFields.push(k.concatTokens().toUpperCase());\n }\n secondaryKeys.push(secondary);\n }\n let keyType = Types.TableKeyType.user;\n if (text.includes(\" EMPTY KEY\")) {\n keyType = Types.TableKeyType.empty;\n }\n else if (text.includes(\" DEFAULT KEY\")) {\n keyType = Types.TableKeyType.default;\n }\n const options = {\n withHeader: text.includes(\" WITH HEADER LINE\"),\n keyType: keyType,\n primaryKey: primaryKey,\n secondary: secondaryKeys,\n };\n let found = undefined;\n if (text.startsWith(\"TYPE TABLE OF REF TO \")\n || text.startsWith(\"TYPE STANDARD TABLE OF REF TO \")\n || text.startsWith(\"TYPE SORTED TABLE OF REF TO \")\n || text.startsWith(\"TYPE HASHED TABLE OF REF TO \")) {\n found = this.resolveTypeRef(typename);\n if (found) {\n return new Types.TableType(found, options, name);\n }\n }\n else if (text.startsWith(\"TYPE TABLE OF \")\n || text.startsWith(\"TYPE STANDARD TABLE OF \")\n || text.startsWith(\"TYPE SORTED TABLE OF \")\n || text.startsWith(\"TYPE HASHED TABLE OF \")) {\n found = this.resolveTypeName(typename);\n if (found) {\n return new Types.TableType(found, options, name);\n }\n }\n else if (text.startsWith(\"LIKE TABLE OF \")\n || text.startsWith(\"LIKE STANDARD TABLE OF \")\n || text.startsWith(\"LIKE SORTED TABLE OF \")\n || text.startsWith(\"LIKE HASHED TABLE OF \")) {\n found = this.resolveLikeName(node);\n if (found) {\n return new Types.TableType(found, options, name);\n }\n }\n else if (text === \"TYPE STANDARD TABLE\"\n || text === \"TYPE SORTED TABLE\"\n || text === \"TYPE HASHED TABLE\"\n || text === \"TYPE INDEX TABLE\"\n || text === \"TYPE ANY TABLE\") {\n return new Types.TableType(new Types.AnyType(), options);\n }\n else if (text.startsWith(\"TYPE RANGE OF \")) {\n const sub = node.findFirstExpression(Expressions.TypeName);\n found = this.resolveTypeName(sub);\n if (found === undefined) {\n return new Types.UnknownType(\"TYPE RANGE OF, could not resolve type\");\n }\n const structure = new Types.StructureType([\n { name: \"sign\", type: new Types.CharacterType(1) },\n { name: \"option\", type: new Types.CharacterType(2) },\n { name: \"low\", type: found },\n { name: \"high\", type: found },\n ]);\n options.primaryKey.type = basic_1.TableAccessType.standard;\n return new Types.TableType(structure, options, name);\n }\n else if (text.startsWith(\"LIKE RANGE OF \")) {\n const sub = node.findFirstExpression(Expressions.SimpleFieldChain);\n found = this.resolveLikeName(sub);\n if (found === undefined) {\n return new Types.UnknownType(\"LIKE RANGE OF, could not resolve type\");\n }\n const structure = new Types.StructureType([\n { name: \"sign\", type: new Types.CharacterType(1) },\n { name: \"option\", type: new Types.CharacterType(2) },\n { name: \"low\", type: found },\n { name: \"high\", type: found },\n ], name);\n options.primaryKey.type = basic_1.TableAccessType.standard;\n return new Types.TableType(structure, options);\n }\n else if (typename && (text.startsWith(\"TYPE TABLE FOR CREATE \")\n || text.startsWith(\"TYPE TABLE FOR UPDATE \"))) {\n const name = typename.concatTokens();\n const type = (_c = this.scope.getDDIC().lookupDDLS(name)) === null || _c === void 0 ? void 0 : _c.type;\n if (type) {\n return new Types.TableType(new basic_1.VoidType(\"RapTodo\"), options);\n }\n else if (this.scope.getDDIC().inErrorNamespace(name)) {\n return new Types.UnknownType(`DDLS ${name} not found`);\n }\n else {\n return new Types.VoidType(name);\n }\n }\n // fallback to old style syntax, OCCURS etc\n return this.parseType(node, name);\n }\n parseType(node, qualifiedName) {\n var _a, _b, _c, _d, _e, _f;\n const typeName = node.findFirstExpression(Expressions.TypeName);\n let text = (_a = node.findFirstExpression(Expressions.Type)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();\n if (text === undefined) {\n text = (_b = node.findFirstExpression(Expressions.TypeParam)) === null || _b === void 0 ? void 0 : _b.concatTokens().toUpperCase();\n }\n if (text === undefined) {\n text = (_c = node.findFirstExpression(Expressions.TypeTable)) === null || _c === void 0 ? void 0 : _c.concatTokens().toUpperCase();\n if ((text === null || text === void 0 ? void 0 : text.startsWith(\"TYPE\")) === false && (text === null || text === void 0 ? void 0 : text.startsWith(\"LIKE\")) === false) {\n text = \"TYPE\";\n }\n }\n if (text === undefined) {\n text = (_d = node.findFirstExpression(Expressions.FormParamType)) === null || _d === void 0 ? void 0 : _d.concatTokens().toUpperCase();\n }\n if (text === undefined\n && node.get() instanceof Statements.Parameter\n && node.findDirectTokenByText(\"LIKE\")) {\n text = \"LIKE \" + (typeName === null || typeName === void 0 ? void 0 : typeName.concatTokens());\n }\n if (text === undefined) {\n text = \"TYPE\";\n }\n let found = undefined;\n if (text.startsWith(\"LIKE LINE OF \")) {\n const name = (_e = node.findFirstExpression(Expressions.FieldChain)) === null || _e === void 0 ? void 0 : _e.concatTokens();\n let e = node.findFirstExpression(Expressions.Type);\n if (e === undefined) {\n e = node.findFirstExpression(Expressions.FormParamType);\n }\n if (e === undefined) {\n e = node.findFirstExpression(Expressions.FieldChain);\n }\n const type = this.resolveLikeName(e, false);\n if (type === undefined) {\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + name + \"\\\", parseType\");\n }\n else if (type instanceof Types.TableType) {\n return type.getRowType();\n }\n else if (type instanceof Types.VoidType) {\n return type;\n }\n else {\n return new Types.UnknownType(\"Type error, not a table type \" + name);\n }\n }\n else if (text.startsWith(\"LIKE REF TO \")) {\n const name = (_f = node.findFirstExpression(Expressions.FieldChain)) === null || _f === void 0 ? void 0 : _f.concatTokens();\n const type = this.resolveLikeName(node.findFirstExpression(Expressions.Type), false);\n if (type === undefined) {\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + name + \"\\\", parseType\");\n }\n return new Types.DataReference(type, name);\n }\n else if (text === \"TYPE STANDARD TABLE\"\n || text === \"TYPE SORTED TABLE\"\n || text === \"TYPE HASHED TABLE\"\n || text === \"TYPE INDEX TABLE\"\n || text === \"TYPE ANY TABLE\") {\n return new Types.TableType(new Types.AnyType(), { withHeader: node.concatTokens().toUpperCase().includes(\"WITH HEADER LINE\"), keyType: Types.TableKeyType.default });\n }\n else if (text.startsWith(\"LIKE \")) {\n let sub = node.findFirstExpression(Expressions.Type);\n if (sub === undefined) {\n sub = node.findFirstExpression(Expressions.FormParamType);\n }\n if (sub === undefined) {\n sub = node.findFirstExpression(Expressions.TypeParam);\n }\n if (sub === undefined) {\n sub = node.findFirstExpression(Expressions.FieldChain);\n }\n if (sub === undefined) {\n sub = node.findFirstExpression(Expressions.TypeName);\n }\n found = this.resolveLikeName(sub);\n if (found && this.isOccurs(node)) {\n found = new Types.TableType(found, { withHeader: text.includes(\"WITH HEADER LINE\"), keyType: Types.TableKeyType.default }, qualifiedName);\n }\n }\n else if (text.startsWith(\"TYPE LINE OF \")) {\n const sub = node.findFirstExpression(Expressions.TypeName);\n found = this.resolveTypeName(sub);\n if (found instanceof _typed_identifier_1.TypedIdentifier) {\n found = found.getType();\n }\n if (found instanceof Types.TableType) {\n return found.getRowType();\n }\n else if (found instanceof Types.VoidType) {\n return found;\n }\n else if (found instanceof Types.UnknownType) {\n return new Types.UnknownType(\"TYPE LINE OF, unknown type, \" + found.getError());\n }\n else {\n return new Types.UnknownType(\"TYPE LINE OF, unexpected type, \" + (found === null || found === void 0 ? void 0 : found.constructor.name));\n }\n }\n else if (text.startsWith(\"TYPE REF TO \")) {\n found = this.resolveTypeRef(typeName);\n }\n else if (text.startsWith(\"TYPE\")) {\n found = this.resolveTypeName(typeName, this.findLength(node), this.findDecimals(node), qualifiedName);\n const concat = node.concatTokens().toUpperCase();\n if (found && this.isOccurs(node)) {\n found = new Types.TableType(found, { withHeader: concat.includes(\" WITH HEADER LINE\"), keyType: Types.TableKeyType.default }, qualifiedName);\n }\n else if (found && concat.includes(\" WITH HEADER LINE\")) {\n if (found instanceof Types.VoidType) {\n found = new Types.TableType(found, { withHeader: true, keyType: Types.TableKeyType.default });\n }\n else if (!(found instanceof Types.TableType)) {\n throw new Error(\"WITH HEADER LINE can only be used with internal table\");\n }\n else {\n found = new Types.TableType(found.getRowType(), { withHeader: true, keyType: Types.TableKeyType.default });\n }\n }\n if (found === undefined && typeName === undefined) {\n let length = 1;\n const len = node.findDirectExpression(Expressions.ConstantFieldLength);\n if (len) {\n const int = len.findDirectExpression(Expressions.Integer);\n if (int) {\n length = parseInt(int.concatTokens(), 10);\n }\n }\n found = new Types.CharacterType(length, { qualifiedName: qualifiedName }); // fallback\n if (this.isOccurs(node)) {\n found = new Types.TableType(found, { withHeader: concat.includes(\" WITH HEADER LINE\"), keyType: Types.TableKeyType.default }, qualifiedName);\n }\n }\n }\n return found;\n }\n /////////////////////\n isOccurs(node) {\n var _a;\n if (node.findDirectTokenByText(\"OCCURS\")) {\n return true;\n }\n else if ((_a = node.findFirstExpression(Expressions.TypeTable)) === null || _a === void 0 ? void 0 : _a.findDirectTokenByText(\"OCCURS\")) {\n return true;\n }\n return false;\n }\n // todo, rewrite this method\n resolveTypeChain(expr) {\n var _a;\n const chainText = expr.concatTokens().toUpperCase();\n if (chainText.includes(\"=>\") === false && chainText.includes(\"-\") === false) {\n return undefined;\n }\n let className;\n let rest = chainText;\n if (chainText.includes(\"=>\")) {\n const split = chainText.split(\"=>\");\n className = split[0];\n rest = split[1];\n }\n else if (chainText.includes(\"->\")) {\n const split = chainText.split(\"->\");\n className = split[0];\n rest = split[1];\n }\n const subs = rest.split(\"-\");\n let foundType = undefined;\n if (className && chainText.includes(\"=>\")) {\n const split = chainText.split(\"=>\");\n const className = split[0];\n // the prefix might be itself\n if ((this.scope.getType() === _scope_type_1.ScopeType.Interface\n || this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition)\n && this.scope.getName().toUpperCase() === className.toUpperCase()) {\n const foundId = this.scope.findType(subs[0]);\n foundType = foundId === null || foundId === void 0 ? void 0 : foundId.getType();\n if (foundType === undefined) {\n return new Types.UnknownType(\"Could not resolve type \" + chainText);\n }\n this.scope.addReference(expr.getTokens()[2], foundId, _reference_1.ReferenceType.TypeReference, this.filename);\n }\n else {\n // lookup in local and global scope\n const obj = this.scope.findObjectDefinition(className);\n if (obj === undefined && this.scope.getDDIC().inErrorNamespace(className) === false) {\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, this.filename, { ooName: className.toUpperCase() });\n return new Types.VoidType(className);\n }\n else if (obj === undefined) {\n return new Types.UnknownType(\"Could not resolve top \" + className + \", resolveTypeChain\");\n }\n const type = obj instanceof types_1.ClassDefinition ? \"CLAS\" : \"INTF\";\n this.scope.addReference(expr.getFirstToken(), obj, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: type, ooName: className });\n const byName = new _object_oriented_1.ObjectOriented(this.scope).searchTypeName(obj, subs[0]);\n foundType = byName === null || byName === void 0 ? void 0 : byName.getType();\n if (byName === undefined || foundType === undefined) {\n return new Types.UnknownType(subs[0] + \" not found in class or interface\");\n }\n this.scope.addReference(expr.getTokens()[2], byName, _reference_1.ReferenceType.TypeReference, this.filename);\n }\n }\n else if (className && chainText.includes(\"->\")) {\n const varVar = this.scope.findVariable(className);\n const foo = varVar === null || varVar === void 0 ? void 0 : varVar.getType();\n if (foo instanceof basic_1.ObjectReferenceType) {\n const typeName = subs[0];\n let id = foo.getIdentifier();\n if (!(id instanceof types_1.ClassDefinition || id instanceof types_1.InterfaceDefinition)) {\n const found = this.scope.findObjectDefinition(foo.getIdentifierName());\n if (found) {\n id = found;\n }\n else {\n return new Types.UnknownType(foo.getIdentifierName() + \" not found in scope\");\n }\n }\n if (id instanceof types_1.ClassDefinition || id instanceof types_1.InterfaceDefinition) {\n const type = id instanceof types_1.ClassDefinition ? \"CLAS\" : \"INTF\";\n this.scope.addReference(expr.getFirstToken(), id, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: type, ooName: id.getName() });\n const byName = new _object_oriented_1.ObjectOriented(this.scope).searchTypeName(id, typeName);\n foundType = byName === null || byName === void 0 ? void 0 : byName.getType();\n if (byName === undefined || foundType === undefined) {\n return new Types.UnknownType(typeName + \" not found in class or interface\");\n }\n this.scope.addReference(expr.getTokens()[2], byName, _reference_1.ReferenceType.TypeReference, this.filename);\n }\n else {\n return new Types.UnknownType(\"Not an object reference, \" + className + \", \" + id.constructor.name);\n }\n }\n else if (foo === undefined) {\n return new Types.UnknownType(className + \" not found in scope\");\n }\n else {\n return new Types.UnknownType(\"Not an object reference, \" + className + \", \" + foo.constructor.name);\n }\n }\n else {\n const found = this.scope.findType(subs[0]);\n foundType = found === null || found === void 0 ? void 0 : found.getType();\n if (foundType === undefined) {\n const typePoolType = (_a = this.scope.findTypePoolType(subs[0])) === null || _a === void 0 ? void 0 : _a.getType();\n if (typePoolType) {\n // this.scope.addReference(typeName.getFirstToken(), typePoolType, ReferenceType.TypeReference, this.filename);\n foundType = typePoolType;\n }\n if (foundType === undefined) {\n const f = this.scope.getDDIC().lookupTableOrView(subs[0]);\n this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), { object: f.object, filename: this.filename, token: expr.getFirstToken() });\n if (f.type instanceof _typed_identifier_1.TypedIdentifier) {\n foundType = f.type.getType();\n }\n else {\n foundType = f.type;\n }\n }\n }\n else {\n this.scope.addReference(expr.getFirstToken(), found, _reference_1.ReferenceType.TypeReference, this.filename);\n }\n if (foundType === undefined && this.scope.getDDIC().inErrorNamespace(subs[0]) === false) {\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\n return new Types.VoidType(subs[0]);\n }\n else if (foundType instanceof Types.VoidType) {\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\n return foundType;\n }\n else if (foundType === undefined) {\n return new Types.UnknownType(\"Unknown type \" + subs[0]);\n }\n }\n subs.shift();\n while (subs.length > 0) {\n if (foundType instanceof Types.UnknownType\n || foundType instanceof Types.VoidType) {\n return foundType;\n }\n else if (!(foundType instanceof Types.StructureType)) {\n return new Types.UnknownType(\"Not a structured type\");\n }\n foundType = foundType.getComponentByName(subs[0]);\n if (foundType === undefined) {\n return new Types.UnknownType(`Field \"${subs[0]}\" not found in structure`);\n }\n subs.shift();\n }\n return foundType;\n }\n resolveConstantValue(expr) {\n var _a, _b;\n // todo: rewrite this method\n if (!(expr.get() instanceof Expressions.SimpleFieldChain)) {\n throw new Error(\"resolveConstantValue\");\n }\n const firstNode = expr.getFirstChild();\n const firstToken = firstNode.getFirstToken();\n const firstName = firstToken.getStr();\n if (firstNode.get() instanceof Expressions.Field) {\n const found = this.scope.findVariable(firstName);\n const val = found === null || found === void 0 ? void 0 : found.getValue();\n if (typeof val === \"string\") {\n this.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.filename);\n return val;\n }\n else if ((found === null || found === void 0 ? void 0 : found.getType()) instanceof basic_1.StructureType) {\n this.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.filename);\n }\n return undefined;\n }\n else if (firstNode.get() instanceof Expressions.ClassName\n && firstName.toLowerCase() === this.scope.getName().toLowerCase()\n && (this.scope.getType() === _scope_type_1.ScopeType.Interface\n || this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition)) {\n const children = expr.getChildren();\n const token = (_a = children[2]) === null || _a === void 0 ? void 0 : _a.getFirstToken();\n const found = this.scope.findVariable(token.getStr());\n const val = found === null || found === void 0 ? void 0 : found.getValue();\n if (typeof val === \"string\") {\n this.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.filename);\n return val;\n }\n return undefined;\n }\n else if (firstNode.get() instanceof Expressions.ClassName) {\n const obj = this.scope.findObjectDefinition(firstName);\n if (obj === undefined) {\n if (this.scope.existsObject(firstName).found === true) {\n return undefined;\n }\n else if (this.scope.getDDIC().inErrorNamespace(firstName) === true) {\n throw new Error(\"resolveConstantValue, not found: \" + firstName);\n }\n else {\n this.scope.addReference(firstNode.getFirstToken(), undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, this.filename, { ooName: firstName.toUpperCase() });\n return undefined;\n }\n }\n const children = expr.getChildren();\n const token = (_b = children[2]) === null || _b === void 0 ? void 0 : _b.getFirstToken();\n const attr = token.getStr();\n const c = new _object_oriented_1.ObjectOriented(this.scope).searchConstantName(obj, attr);\n if (c instanceof class_constant_1.ClassConstant) {\n this.scope.addReference(token, c, _reference_1.ReferenceType.DataReadReference, this.filename);\n const val = c.getValue();\n if (typeof val === \"string\") {\n return val;\n }\n else if (typeof val === \"object\" && children[4]) {\n const name = children[4].getFirstToken().getStr();\n if (val[name] !== undefined) {\n return val[name];\n }\n }\n return undefined;\n }\n throw new Error(\"resolveConstantValue, constant not found \" + attr);\n }\n else {\n throw new Error(\"resolveConstantValue, unexpected structure\");\n }\n }\n resolveTypeRef(chain) {\n var _a;\n if (chain === undefined) {\n return undefined;\n }\n const name = chain.getFirstToken().getStr();\n if (chain.getAllTokens().length === 1) {\n if (name.toUpperCase() === \"OBJECT\") {\n return new Types.GenericObjectReferenceType();\n }\n const search = this.scope.existsObject(name);\n if (search.found === true && search.id) {\n this.scope.addReference(chain.getFirstToken(), search.id, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: search.ooType, ooName: name });\n return new Types.ObjectReferenceType(search.id, name);\n }\n }\n const found = this.resolveTypeName(chain);\n if (found && !(found instanceof Types.UnknownType) && !(found instanceof Types.VoidType)) {\n return new Types.DataReference(found);\n }\n else if (chain.concatTokens().toUpperCase() === \"DATA\") {\n return new Types.DataReference(new Types.AnyType());\n }\n if (this.scope.isBadiDef(name) === true) {\n return new Types.VoidType(name);\n }\n if (((_a = this.scope.getDDIC()) === null || _a === void 0 ? void 0 : _a.inErrorNamespace(name)) === false) {\n // this.scope.addReference(chain.getFirstToken(), undefined, ReferenceType.VoidType, this.filename);\n return new Types.VoidType(name);\n }\n return new Types.UnknownType(\"REF, unable to resolve \" + name);\n }\n findValue(node) {\n const val = node.findFirstExpression(Expressions.Value);\n if (val === undefined) {\n throw new Error(\"VALUE missing in expression\");\n }\n if (val.concatTokens().toUpperCase() === \"VALUE IS INITIAL\") {\n return undefined;\n }\n const constant = val.findFirstExpression(Expressions.Constant);\n if (constant) {\n return constant.concatTokens();\n }\n const chain = val.findFirstExpression(Expressions.SimpleFieldChain);\n if (chain) {\n return this.resolveConstantValue(chain);\n }\n throw new Error(\"findValue, unexpected\");\n }\n findDecimals(node) {\n var _a, _b;\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();\n if (dec) {\n return parseInt(dec, 10);\n }\n return undefined;\n }\n findLength(node) {\n const val = node.findFirstExpression(Expressions.Length);\n const flen = node.findFirstExpression(Expressions.ConstantFieldLength);\n if (val && flen) {\n throw new Error(\"Only specify length once\");\n }\n if (flen) {\n const cintExpr = flen.findFirstExpression(Expressions.Integer);\n if (cintExpr) {\n return this.parseInt(cintExpr.concatTokens());\n }\n const cchain = flen.findFirstExpression(Expressions.SimpleFieldChain);\n if (cchain) {\n const val = this.resolveConstantValue(cchain);\n return this.parseInt(val);\n }\n }\n if (val === undefined) {\n return 1;\n }\n const intExpr = val.findFirstExpression(Expressions.Integer);\n if (intExpr) {\n return this.parseInt(intExpr.concatTokens());\n }\n const strExpr = val.findFirstExpression(Expressions.ConstantString);\n if (strExpr) {\n return this.parseInt(strExpr.concatTokens());\n }\n const chain = val.findFirstExpression(Expressions.SimpleFieldChain);\n if (chain) {\n const val = this.resolveConstantValue(chain);\n return this.parseInt(val);\n }\n throw new Error(\"Unexpected, findLength\");\n }\n parseInt(text) {\n if (text === undefined) {\n return undefined;\n }\n if (text.startsWith(\"'\")) {\n text = text.split(\"'\")[1];\n }\n else if (text.startsWith(\"`\")) {\n text = text.split(\"`\")[1];\n }\n return parseInt(text, 10);\n }\n}\nexports.BasicTypes = BasicTypes;\n//# sourceMappingURL=basic_types.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/abap/5_syntax/basic_types.js?");
|
|
6795
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.BasicTypes = void 0;\n/* eslint-disable default-case */\nconst _typed_identifier_1 = __webpack_require__(/*! ../types/_typed_identifier */ \"./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js\");\nconst Expressions = __webpack_require__(/*! ../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\nconst Statements = __webpack_require__(/*! ../2_statements/statements */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js\");\nconst Types = __webpack_require__(/*! ../types/basic */ \"./node_modules/@abaplint/core/build/src/abap/types/basic/index.js\");\nconst _scope_type_1 = __webpack_require__(/*! ./_scope_type */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js\");\nconst _object_oriented_1 = __webpack_require__(/*! ./_object_oriented */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_object_oriented.js\");\nconst class_constant_1 = __webpack_require__(/*! ../types/class_constant */ \"./node_modules/@abaplint/core/build/src/abap/types/class_constant.js\");\nconst identifier_1 = __webpack_require__(/*! ../1_lexer/tokens/identifier */ \"./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/identifier.js\");\nconst _reference_1 = __webpack_require__(/*! ./_reference */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js\");\nconst basic_1 = __webpack_require__(/*! ../types/basic */ \"./node_modules/@abaplint/core/build/src/abap/types/basic/index.js\");\nconst field_chain_1 = __webpack_require__(/*! ./expressions/field_chain */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/field_chain.js\");\nconst types_1 = __webpack_require__(/*! ../types */ \"./node_modules/@abaplint/core/build/src/abap/types/index.js\");\nconst expressions_1 = __webpack_require__(/*! ../2_statements/expressions */ \"./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js\");\nconst _builtin_1 = __webpack_require__(/*! ./_builtin */ \"./node_modules/@abaplint/core/build/src/abap/5_syntax/_builtin.js\");\nconst position_1 = __webpack_require__(/*! ../../position */ \"./node_modules/@abaplint/core/build/src/position.js\");\nclass BasicTypes {\n constructor(filename, scope) {\n this.filename = filename;\n this.scope = scope;\n }\n lookupQualifiedName(name) {\n var _a;\n // argh, todo, rewrite this entire method, more argh\n if (name === undefined) {\n return undefined;\n }\n const found = this.scope.findType(name);\n if (found) {\n return found;\n }\n if (name.includes(\"=>\")) {\n const split = name.split(\"=>\");\n const ooName = split[0];\n const typeName = split[1];\n const oo = this.scope.findObjectDefinition(ooName);\n if (oo) {\n if (typeName.includes(\"-\")) {\n const split = typeName.split(\"-\");\n const subTypeName = split[0];\n const fieldName = split[1];\n const stru = oo.getTypeDefinitions().getByName(subTypeName);\n const struType = stru === null || stru === void 0 ? void 0 : stru.getType();\n if (stru && struType instanceof basic_1.StructureType) {\n const f = struType.getComponentByName(fieldName);\n if (f) {\n return new _typed_identifier_1.TypedIdentifier(stru.getToken(), stru.getFilename(), f);\n }\n }\n }\n else {\n const f = oo.getTypeDefinitions().getByName(typeName);\n if (f) {\n return f;\n }\n }\n }\n }\n else if (name.includes(\"-\")) {\n const split = name.split(\"-\");\n const typeName = split[0];\n const fieldName = split[1];\n const type = this.scope.findType(typeName);\n if (type) {\n const stru = type.getType();\n if (stru instanceof basic_1.StructureType) {\n const f = stru.getComponentByName(fieldName);\n if (f) {\n return new _typed_identifier_1.TypedIdentifier(type.getToken(), type.getFilename(), f);\n }\n }\n }\n }\n const lookup = this.scope.getDDIC().lookupNoVoid(name);\n const id = (_a = lookup === null || lookup === void 0 ? void 0 : lookup.object) === null || _a === void 0 ? void 0 : _a.getIdentifier();\n if (id && (lookup === null || lookup === void 0 ? void 0 : lookup.type)) {\n return new _typed_identifier_1.TypedIdentifier(id.getToken(), id.getFilename(), lookup.type);\n }\n const builtin = this.scope.getDDIC().lookupBuiltinType(name);\n if (builtin) {\n return new _typed_identifier_1.TypedIdentifier(new identifier_1.Identifier(new position_1.Position(1, 1), name), _builtin_1.BuiltIn.filename, builtin);\n }\n const type = this.scope.findTypePoolType(name);\n if (type) {\n return type;\n }\n return undefined;\n }\n resolveLikeName(node, headerLogic = true) {\n var _a;\n if (node === undefined) {\n return undefined;\n }\n let chain = node.findFirstExpression(Expressions.FieldChain);\n if (chain === undefined) {\n chain = node.findFirstExpression(Expressions.TypeName);\n }\n if (chain === undefined) {\n chain = node.findFirstExpression(Expressions.FieldSub);\n }\n if (chain === undefined) {\n chain = node.findFirstExpression(Expressions.SimpleFieldChain);\n }\n if (chain === undefined) {\n throw new Error(\"resolveLikeName, chain undefined\");\n }\n const fullName = chain.concatTokens();\n const children = [...chain.getChildren()];\n if (children.length === 0) {\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + fullName + \"\\\", resolveLikeName1\");\n }\n let type = undefined;\n if (children[1] && (children[1].getFirstToken().getStr() === \"=>\" || children[1].getFirstToken().getStr() === \"->\")) {\n type = new field_chain_1.FieldChain().runSyntax(chain, this.scope, this.filename, _reference_1.ReferenceType.TypeReference);\n }\n else {\n const name = children.shift().getFirstToken().getStr();\n let found = this.scope.findVariable(name);\n type = found === null || found === void 0 ? void 0 : found.getType();\n if (found === undefined) {\n found = this.scope.findExtraLikeType(name);\n type = found === null || found === void 0 ? void 0 : found.getType();\n }\n if (found) {\n this.scope.addReference(chain === null || chain === void 0 ? void 0 : chain.getFirstToken(), found, _reference_1.ReferenceType.TypeReference, this.filename);\n }\n if (type === undefined) {\n type = (_a = this.scope.getDDIC().lookupNoVoid(name)) === null || _a === void 0 ? void 0 : _a.type;\n }\n if (type === undefined && this.scope.isOO() === false && this.scope.getDDIC().inErrorNamespace(name) === false) {\n this.scope.addReference(chain.getChildren()[0].getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\n return new Types.VoidType(name);\n }\n while (children.length > 0) {\n const child = children.shift();\n if (child.getFirstToken().getStr() === \"-\") {\n if (type instanceof Types.VoidType) {\n return type;\n }\n }\n else if (child.concatTokens() === \"[]\") {\n if (type instanceof Types.TableType) {\n type = new basic_1.TableType(type.getRowType(), { withHeader: false, keyType: Types.TableKeyType.default });\n }\n }\n else { // field name\n let sub = undefined;\n if (type instanceof Types.TableType) {\n type = type.getRowType();\n }\n if (type instanceof Types.StructureType) {\n sub = type.getComponentByName(child.getFirstToken().getStr());\n }\n if (sub === undefined) {\n return new Types.UnknownType(\"Type error, field not part of structure \" + fullName);\n }\n type = sub;\n }\n }\n if (type instanceof Types.VoidType) {\n return type;\n }\n else if (type instanceof basic_1.TableType\n && type.isWithHeader()\n && headerLogic === true) {\n type = type.getRowType();\n }\n else if (type instanceof Types.TableType\n && type.isWithHeader() === true\n && type.getRowType() instanceof Types.VoidType) {\n return type.getRowType();\n }\n }\n if (!type) {\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + fullName + \"\\\", resolveLikeName2\");\n }\n return type;\n }\n cloneType(type, qualifiedName) {\n // nested types(containing \"-\") will inherit the qualified names if possible\n // todo, this needs to be extended to all AbstractTypes instead of just CharacterType\n if (type instanceof basic_1.CharacterType\n && qualifiedName\n && qualifiedName.includes(\"-\") === false) {\n type = type.cloneType(qualifiedName);\n }\n return type;\n }\n resolveTypeName(typeName, length, decimals, qualifiedName) {\n var _a;\n if (typeName === undefined) {\n return undefined;\n }\n const chain = this.resolveTypeChain(typeName);\n if (chain) {\n return this.cloneType(chain, qualifiedName);\n }\n const chainText = typeName.concatTokens().toUpperCase();\n const f = this.scope.getDDIC().lookupBuiltinType(chainText, length, decimals, qualifiedName);\n if (f !== undefined) {\n return f;\n }\n const typ = this.scope.findType(chainText);\n if (typ) {\n const token = typeName.getFirstToken();\n if (chainText.includes(\"~\")) {\n const name = chainText.split(\"~\")[0];\n const idef = this.scope.findInterfaceDefinition(name);\n if (idef) {\n this.scope.addReference(token, idef, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: \"INTF\", ooName: name });\n }\n }\n this.scope.addReference(token, typ, _reference_1.ReferenceType.TypeReference, this.filename);\n return typ.getType();\n }\n const type = (_a = this.scope.findTypePoolType(chainText)) === null || _a === void 0 ? void 0 : _a.getType();\n if (type) {\n // this.scope.addReference(typeName.getFirstToken(), type, ReferenceType.TypeReference, this.filename);\n return type;\n }\n const ddic = this.scope.getDDIC().lookup(chainText);\n if (ddic) {\n this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), { object: ddic.object, token: typeName.getFirstToken(), filename: this.filename });\n if (ddic.type instanceof _typed_identifier_1.TypedIdentifier) {\n this.scope.addReference(typeName.getFirstToken(), ddic.type, _reference_1.ReferenceType.TypeReference, this.filename);\n }\n else if (ddic.type instanceof basic_1.VoidType) {\n this.scope.addReference(typeName.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\n }\n return this.cloneType(ddic.type, qualifiedName);\n }\n return undefined;\n }\n simpleType(node, qualifiedNamePrefix) {\n let nameExpr = node.findFirstExpression(Expressions.NamespaceSimpleName);\n if (nameExpr === undefined) {\n nameExpr = node.findFirstExpression(Expressions.DefinitionName);\n }\n if (nameExpr === undefined) {\n return undefined;\n }\n let name = nameExpr.getFirstToken();\n if (nameExpr.countTokens() > 1) { // workaround for names with dashes\n name = new identifier_1.Identifier(name.getStart(), nameExpr.concatTokens());\n }\n let qualifiedName = undefined;\n if (node.get() instanceof Statements.Type) {\n if (this.scope.isTypePool() === true) {\n qualifiedName = name.getStr();\n }\n else {\n qualifiedName = (qualifiedNamePrefix || \"\") + name.getStr();\n if (this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition\n || this.scope.getType() === _scope_type_1.ScopeType.Interface) {\n qualifiedName = this.scope.getName() + \"=>\" + qualifiedName;\n }\n }\n }\n else if (qualifiedNamePrefix) {\n qualifiedName = qualifiedNamePrefix + qualifiedName;\n }\n const found = this.parseType(node, qualifiedName);\n if (found) {\n return new _typed_identifier_1.TypedIdentifier(name, this.filename, found);\n }\n return undefined;\n }\n parseTable(node, name) {\n var _a, _b, _c, _d;\n const typename = node.findFirstExpression(Expressions.TypeName);\n const text = (_a = node.findFirstExpression(Expressions.TypeTable)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();\n if (text === undefined) {\n return undefined;\n }\n let type = undefined;\n if (text.startsWith(\"TYPE STANDARD TABLE \")\n || text.startsWith(\"TYPE TABLE \")\n || text.startsWith(\"LIKE TABLE \")\n || text.startsWith(\"LIKE STANDARD TABLE \")) {\n type = basic_1.TableAccessType.standard;\n }\n else if (text.startsWith(\"TYPE SORTED TABLE \")\n || text.startsWith(\"LIKE SORTED TABLE \")) {\n type = basic_1.TableAccessType.sorted;\n }\n else if (text.startsWith(\"TYPE HASHED TABLE \")\n || text.startsWith(\"LIKE HASHED TABLE \")) {\n type = basic_1.TableAccessType.hashed;\n }\n const typeTableKeys = node.findAllExpressions(expressions_1.TypeTableKey);\n const firstKey = typeTableKeys[0];\n const isNamed = (firstKey === null || firstKey === void 0 ? void 0 : firstKey.findDirectExpression(expressions_1.Field)) !== undefined\n && ((_b = firstKey === null || firstKey === void 0 ? void 0 : firstKey.findDirectExpression(expressions_1.Field)) === null || _b === void 0 ? void 0 : _b.concatTokens().toUpperCase()) !== \"PRIMARY_KEY\";\n const primaryKey = {\n name: \"primary_key\",\n type: type || basic_1.TableAccessType.standard,\n isUnique: isNamed ? false : (firstKey === null || firstKey === void 0 ? void 0 : firstKey.concatTokens().toUpperCase().includes(\"WITH UNIQUE \")) === true,\n keyFields: [],\n };\n let start = 1;\n if (isNamed === false) {\n for (const k of (firstKey === null || firstKey === void 0 ? void 0 : firstKey.findDirectExpressions(expressions_1.FieldSub)) || []) {\n primaryKey.keyFields.push(k.concatTokens().toUpperCase());\n }\n }\n else {\n start = 0;\n }\n const secondaryKeys = [];\n for (let i = start; i < typeTableKeys.length; i++) {\n const row = typeTableKeys[i];\n const name = (_c = row.findDirectExpression(expressions_1.Field)) === null || _c === void 0 ? void 0 : _c.concatTokens();\n if (name === undefined) {\n continue;\n }\n const secondary = {\n name: name,\n type: row.findDirectTokenByText(\"SORTED\") ? basic_1.TableAccessType.sorted : basic_1.TableAccessType.hashed,\n isUnique: (row === null || row === void 0 ? void 0 : row.concatTokens().toUpperCase().includes(\"WITH UNIQUE \")) === true,\n keyFields: [],\n };\n for (const k of (row === null || row === void 0 ? void 0 : row.findDirectExpressions(expressions_1.FieldSub)) || []) {\n secondary.keyFields.push(k.concatTokens().toUpperCase());\n }\n secondaryKeys.push(secondary);\n }\n let keyType = Types.TableKeyType.user;\n if (text.includes(\" EMPTY KEY\")) {\n keyType = Types.TableKeyType.empty;\n }\n else if (text.includes(\" DEFAULT KEY\")) {\n keyType = Types.TableKeyType.default;\n }\n const options = {\n withHeader: text.includes(\" WITH HEADER LINE\"),\n keyType: keyType,\n primaryKey: primaryKey,\n secondary: secondaryKeys,\n };\n let found = undefined;\n if (text.startsWith(\"TYPE TABLE OF REF TO \")\n || text.startsWith(\"TYPE STANDARD TABLE OF REF TO \")\n || text.startsWith(\"TYPE SORTED TABLE OF REF TO \")\n || text.startsWith(\"TYPE HASHED TABLE OF REF TO \")) {\n found = this.resolveTypeRef(typename);\n if (found) {\n return new Types.TableType(found, options, name);\n }\n }\n else if (text.startsWith(\"TYPE TABLE OF \")\n || text.startsWith(\"TYPE STANDARD TABLE OF \")\n || text.startsWith(\"TYPE SORTED TABLE OF \")\n || text.startsWith(\"TYPE HASHED TABLE OF \")) {\n found = this.resolveTypeName(typename);\n if (found) {\n return new Types.TableType(found, options, name);\n }\n }\n else if (text.startsWith(\"LIKE TABLE OF \")\n || text.startsWith(\"LIKE STANDARD TABLE OF \")\n || text.startsWith(\"LIKE SORTED TABLE OF \")\n || text.startsWith(\"LIKE HASHED TABLE OF \")) {\n found = this.resolveLikeName(node);\n if (found) {\n return new Types.TableType(found, options, name);\n }\n }\n else if (text === \"TYPE STANDARD TABLE\"\n || text === \"TYPE SORTED TABLE\"\n || text === \"TYPE HASHED TABLE\"\n || text === \"TYPE INDEX TABLE\"\n || text === \"TYPE ANY TABLE\") {\n return new Types.TableType(new Types.AnyType(), options);\n }\n else if (text.startsWith(\"TYPE RANGE OF \")) {\n const sub = node.findFirstExpression(Expressions.TypeName);\n found = this.resolveTypeName(sub);\n if (found === undefined) {\n return new Types.UnknownType(\"TYPE RANGE OF, could not resolve type\");\n }\n const structure = new Types.StructureType([\n { name: \"sign\", type: new Types.CharacterType(1) },\n { name: \"option\", type: new Types.CharacterType(2) },\n { name: \"low\", type: found },\n { name: \"high\", type: found },\n ]);\n options.primaryKey.type = basic_1.TableAccessType.standard;\n return new Types.TableType(structure, options, name);\n }\n else if (text.startsWith(\"LIKE RANGE OF \")) {\n const sub = node.findFirstExpression(Expressions.SimpleFieldChain);\n found = this.resolveLikeName(sub);\n if (found === undefined) {\n return new Types.UnknownType(\"LIKE RANGE OF, could not resolve type\");\n }\n const structure = new Types.StructureType([\n { name: \"sign\", type: new Types.CharacterType(1) },\n { name: \"option\", type: new Types.CharacterType(2) },\n { name: \"low\", type: found },\n { name: \"high\", type: found },\n ], name);\n options.primaryKey.type = basic_1.TableAccessType.standard;\n return new Types.TableType(structure, options);\n }\n else if (typename && (text.startsWith(\"TYPE TABLE FOR CREATE \")\n || text.startsWith(\"TYPE TABLE FOR UPDATE \"))) {\n const name = typename.concatTokens();\n const type = (_d = this.scope.getDDIC().lookupDDLS(name)) === null || _d === void 0 ? void 0 : _d.type;\n if (type) {\n return new Types.TableType(new basic_1.VoidType(\"RapTodo\"), options);\n }\n else if (this.scope.getDDIC().inErrorNamespace(name)) {\n return new Types.UnknownType(`DDLS ${name} not found`);\n }\n else {\n return new Types.VoidType(name);\n }\n }\n // fallback to old style syntax, OCCURS etc\n return this.parseType(node, name);\n }\n parseType(node, qualifiedName) {\n var _a, _b, _c, _d, _e, _f;\n const typeName = node.findFirstExpression(Expressions.TypeName);\n let text = (_a = node.findFirstExpression(Expressions.Type)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();\n if (text === undefined) {\n text = (_b = node.findFirstExpression(Expressions.TypeParam)) === null || _b === void 0 ? void 0 : _b.concatTokens().toUpperCase();\n }\n if (text === undefined) {\n text = (_c = node.findFirstExpression(Expressions.TypeTable)) === null || _c === void 0 ? void 0 : _c.concatTokens().toUpperCase();\n if ((text === null || text === void 0 ? void 0 : text.startsWith(\"TYPE\")) === false && (text === null || text === void 0 ? void 0 : text.startsWith(\"LIKE\")) === false) {\n text = \"TYPE\";\n }\n }\n if (text === undefined) {\n text = (_d = node.findFirstExpression(Expressions.FormParamType)) === null || _d === void 0 ? void 0 : _d.concatTokens().toUpperCase();\n }\n if (text === undefined\n && node.get() instanceof Statements.Parameter\n && node.findDirectTokenByText(\"LIKE\")) {\n text = \"LIKE \" + (typeName === null || typeName === void 0 ? void 0 : typeName.concatTokens());\n }\n if (text === undefined) {\n text = \"TYPE\";\n }\n let found = undefined;\n if (text.startsWith(\"LIKE LINE OF \")) {\n const name = (_e = node.findFirstExpression(Expressions.FieldChain)) === null || _e === void 0 ? void 0 : _e.concatTokens();\n let e = node.findFirstExpression(Expressions.Type);\n if (e === undefined) {\n e = node.findFirstExpression(Expressions.FormParamType);\n }\n if (e === undefined) {\n e = node.findFirstExpression(Expressions.FieldChain);\n }\n const type = this.resolveLikeName(e, false);\n if (type === undefined) {\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + name + \"\\\", parseType\");\n }\n else if (type instanceof Types.TableType) {\n return type.getRowType();\n }\n else if (type instanceof Types.VoidType) {\n return type;\n }\n else {\n return new Types.UnknownType(\"Type error, not a table type \" + name);\n }\n }\n else if (text.startsWith(\"LIKE REF TO \")) {\n const name = (_f = node.findFirstExpression(Expressions.FieldChain)) === null || _f === void 0 ? void 0 : _f.concatTokens();\n const type = this.resolveLikeName(node.findFirstExpression(Expressions.Type), false);\n if (type === undefined) {\n return new Types.UnknownType(\"Type error, could not resolve \\\"\" + name + \"\\\", parseType\");\n }\n return new Types.DataReference(type, name);\n }\n else if (text === \"TYPE STANDARD TABLE\"\n || text === \"TYPE SORTED TABLE\"\n || text === \"TYPE HASHED TABLE\"\n || text === \"TYPE INDEX TABLE\"\n || text === \"TYPE ANY TABLE\") {\n return new Types.TableType(new Types.AnyType(), { withHeader: node.concatTokens().toUpperCase().includes(\"WITH HEADER LINE\"), keyType: Types.TableKeyType.default });\n }\n else if (text.startsWith(\"LIKE \")) {\n let sub = node.findFirstExpression(Expressions.Type);\n if (sub === undefined) {\n sub = node.findFirstExpression(Expressions.FormParamType);\n }\n if (sub === undefined) {\n sub = node.findFirstExpression(Expressions.TypeParam);\n }\n if (sub === undefined) {\n sub = node.findFirstExpression(Expressions.FieldChain);\n }\n if (sub === undefined) {\n sub = node.findFirstExpression(Expressions.TypeName);\n }\n found = this.resolveLikeName(sub);\n if (found && this.isOccurs(node)) {\n found = new Types.TableType(found, { withHeader: text.includes(\"WITH HEADER LINE\"), keyType: Types.TableKeyType.default }, qualifiedName);\n }\n }\n else if (text.startsWith(\"TYPE LINE OF \")) {\n const sub = node.findFirstExpression(Expressions.TypeName);\n found = this.resolveTypeName(sub);\n if (found instanceof _typed_identifier_1.TypedIdentifier) {\n found = found.getType();\n }\n if (found instanceof Types.TableType) {\n return found.getRowType();\n }\n else if (found instanceof Types.VoidType) {\n return found;\n }\n else if (found instanceof Types.UnknownType) {\n return new Types.UnknownType(\"TYPE LINE OF, unknown type, \" + found.getError());\n }\n else {\n return new Types.UnknownType(\"TYPE LINE OF, unexpected type, \" + (found === null || found === void 0 ? void 0 : found.constructor.name));\n }\n }\n else if (text.startsWith(\"TYPE REF TO \")) {\n found = this.resolveTypeRef(typeName);\n }\n else if (text.startsWith(\"TYPE\")) {\n found = this.resolveTypeName(typeName, this.findLength(node), this.findDecimals(node), qualifiedName);\n const concat = node.concatTokens().toUpperCase();\n if (found && this.isOccurs(node)) {\n found = new Types.TableType(found, { withHeader: concat.includes(\" WITH HEADER LINE\"), keyType: Types.TableKeyType.default }, qualifiedName);\n }\n else if (found && concat.includes(\" WITH HEADER LINE\")) {\n if (found instanceof Types.VoidType) {\n found = new Types.TableType(found, { withHeader: true, keyType: Types.TableKeyType.default });\n }\n else if (!(found instanceof Types.TableType)) {\n throw new Error(\"WITH HEADER LINE can only be used with internal table\");\n }\n else {\n found = new Types.TableType(found.getRowType(), { withHeader: true, keyType: Types.TableKeyType.default });\n }\n }\n if (found === undefined && typeName === undefined) {\n let length = 1;\n const len = node.findDirectExpression(Expressions.ConstantFieldLength);\n if (len) {\n const int = len.findDirectExpression(Expressions.Integer);\n if (int) {\n length = parseInt(int.concatTokens(), 10);\n }\n }\n found = new Types.CharacterType(length, { qualifiedName: qualifiedName }); // fallback\n if (this.isOccurs(node)) {\n found = new Types.TableType(found, { withHeader: concat.includes(\" WITH HEADER LINE\"), keyType: Types.TableKeyType.default }, qualifiedName);\n }\n }\n }\n return found;\n }\n /////////////////////\n isOccurs(node) {\n var _a;\n if (node.findDirectTokenByText(\"OCCURS\")) {\n return true;\n }\n else if ((_a = node.findFirstExpression(Expressions.TypeTable)) === null || _a === void 0 ? void 0 : _a.findDirectTokenByText(\"OCCURS\")) {\n return true;\n }\n return false;\n }\n // todo, rewrite this method\n resolveTypeChain(expr) {\n var _a;\n const chainText = expr.concatTokens().toUpperCase();\n if (chainText.includes(\"=>\") === false && chainText.includes(\"-\") === false) {\n return undefined;\n }\n let className;\n let rest = chainText;\n if (chainText.includes(\"=>\")) {\n const split = chainText.split(\"=>\");\n className = split[0];\n rest = split[1];\n }\n else if (chainText.includes(\"->\")) {\n const split = chainText.split(\"->\");\n className = split[0];\n rest = split[1];\n }\n const subs = rest.split(\"-\");\n let foundType = undefined;\n if (className && chainText.includes(\"=>\")) {\n const split = chainText.split(\"=>\");\n const className = split[0];\n // the prefix might be itself\n if ((this.scope.getType() === _scope_type_1.ScopeType.Interface\n || this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition)\n && this.scope.getName().toUpperCase() === className.toUpperCase()) {\n const foundId = this.scope.findType(subs[0]);\n foundType = foundId === null || foundId === void 0 ? void 0 : foundId.getType();\n if (foundType === undefined) {\n return new Types.UnknownType(\"Could not resolve type \" + chainText);\n }\n this.scope.addReference(expr.getTokens()[2], foundId, _reference_1.ReferenceType.TypeReference, this.filename);\n }\n else {\n // lookup in local and global scope\n const obj = this.scope.findObjectDefinition(className);\n if (obj === undefined && this.scope.getDDIC().inErrorNamespace(className) === false) {\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, this.filename, { ooName: className.toUpperCase() });\n return new Types.VoidType(className);\n }\n else if (obj === undefined) {\n return new Types.UnknownType(\"Could not resolve top \" + className + \", resolveTypeChain\");\n }\n const type = obj instanceof types_1.ClassDefinition ? \"CLAS\" : \"INTF\";\n this.scope.addReference(expr.getFirstToken(), obj, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: type, ooName: className });\n const byName = new _object_oriented_1.ObjectOriented(this.scope).searchTypeName(obj, subs[0]);\n foundType = byName === null || byName === void 0 ? void 0 : byName.getType();\n if (byName === undefined || foundType === undefined) {\n return new Types.UnknownType(subs[0] + \" not found in class or interface\");\n }\n this.scope.addReference(expr.getTokens()[2], byName, _reference_1.ReferenceType.TypeReference, this.filename);\n }\n }\n else if (className && chainText.includes(\"->\")) {\n const varVar = this.scope.findVariable(className);\n const foo = varVar === null || varVar === void 0 ? void 0 : varVar.getType();\n if (foo instanceof basic_1.ObjectReferenceType) {\n const typeName = subs[0];\n let id = foo.getIdentifier();\n if (!(id instanceof types_1.ClassDefinition || id instanceof types_1.InterfaceDefinition)) {\n const found = this.scope.findObjectDefinition(foo.getIdentifierName());\n if (found) {\n id = found;\n }\n else {\n return new Types.UnknownType(foo.getIdentifierName() + \" not found in scope\");\n }\n }\n if (id instanceof types_1.ClassDefinition || id instanceof types_1.InterfaceDefinition) {\n const type = id instanceof types_1.ClassDefinition ? \"CLAS\" : \"INTF\";\n this.scope.addReference(expr.getFirstToken(), id, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: type, ooName: id.getName() });\n const byName = new _object_oriented_1.ObjectOriented(this.scope).searchTypeName(id, typeName);\n foundType = byName === null || byName === void 0 ? void 0 : byName.getType();\n if (byName === undefined || foundType === undefined) {\n return new Types.UnknownType(typeName + \" not found in class or interface\");\n }\n this.scope.addReference(expr.getTokens()[2], byName, _reference_1.ReferenceType.TypeReference, this.filename);\n }\n else {\n return new Types.UnknownType(\"Not an object reference, \" + className + \", \" + id.constructor.name);\n }\n }\n else if (foo === undefined) {\n return new Types.UnknownType(className + \" not found in scope\");\n }\n else {\n return new Types.UnknownType(\"Not an object reference, \" + className + \", \" + foo.constructor.name);\n }\n }\n else {\n const found = this.scope.findType(subs[0]);\n foundType = found === null || found === void 0 ? void 0 : found.getType();\n if (foundType === undefined) {\n const typePoolType = (_a = this.scope.findTypePoolType(subs[0])) === null || _a === void 0 ? void 0 : _a.getType();\n if (typePoolType) {\n // this.scope.addReference(typeName.getFirstToken(), typePoolType, ReferenceType.TypeReference, this.filename);\n foundType = typePoolType;\n }\n if (foundType === undefined) {\n const f = this.scope.getDDIC().lookupTableOrView(subs[0]);\n this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), { object: f.object, filename: this.filename, token: expr.getFirstToken() });\n if (f.type instanceof _typed_identifier_1.TypedIdentifier) {\n foundType = f.type.getType();\n }\n else {\n foundType = f.type;\n }\n }\n }\n else {\n this.scope.addReference(expr.getFirstToken(), found, _reference_1.ReferenceType.TypeReference, this.filename);\n }\n if (foundType === undefined && this.scope.getDDIC().inErrorNamespace(subs[0]) === false) {\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\n return new Types.VoidType(subs[0]);\n }\n else if (foundType instanceof Types.VoidType) {\n this.scope.addReference(expr.getFirstToken(), undefined, _reference_1.ReferenceType.VoidType, this.filename);\n return foundType;\n }\n else if (foundType === undefined) {\n return new Types.UnknownType(\"Unknown type \" + subs[0]);\n }\n }\n subs.shift();\n while (subs.length > 0) {\n if (foundType instanceof Types.UnknownType\n || foundType instanceof Types.VoidType) {\n return foundType;\n }\n else if (!(foundType instanceof Types.StructureType)) {\n return new Types.UnknownType(\"Not a structured type\");\n }\n foundType = foundType.getComponentByName(subs[0]);\n if (foundType === undefined) {\n return new Types.UnknownType(`Field \"${subs[0]}\" not found in structure`);\n }\n subs.shift();\n }\n return foundType;\n }\n resolveConstantValue(expr) {\n var _a, _b;\n // todo: rewrite this method\n if (!(expr.get() instanceof Expressions.SimpleFieldChain)) {\n throw new Error(\"resolveConstantValue\");\n }\n const firstNode = expr.getFirstChild();\n const firstToken = firstNode.getFirstToken();\n const firstName = firstToken.getStr();\n if (firstNode.get() instanceof Expressions.Field) {\n const found = this.scope.findVariable(firstName);\n const val = found === null || found === void 0 ? void 0 : found.getValue();\n if (typeof val === \"string\") {\n this.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.filename);\n return val;\n }\n else if ((found === null || found === void 0 ? void 0 : found.getType()) instanceof basic_1.StructureType) {\n this.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.filename);\n }\n return undefined;\n }\n else if (firstNode.get() instanceof Expressions.ClassName\n && firstName.toLowerCase() === this.scope.getName().toLowerCase()\n && (this.scope.getType() === _scope_type_1.ScopeType.Interface\n || this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition)) {\n const children = expr.getChildren();\n const token = (_a = children[2]) === null || _a === void 0 ? void 0 : _a.getFirstToken();\n const found = this.scope.findVariable(token.getStr());\n const val = found === null || found === void 0 ? void 0 : found.getValue();\n if (typeof val === \"string\") {\n this.scope.addReference(firstToken, found, _reference_1.ReferenceType.DataReadReference, this.filename);\n return val;\n }\n return undefined;\n }\n else if (firstNode.get() instanceof Expressions.ClassName) {\n const obj = this.scope.findObjectDefinition(firstName);\n if (obj === undefined) {\n if (this.scope.existsObject(firstName).found === true) {\n return undefined;\n }\n else if (this.scope.getDDIC().inErrorNamespace(firstName) === true) {\n throw new Error(\"resolveConstantValue, not found: \" + firstName);\n }\n else {\n this.scope.addReference(firstNode.getFirstToken(), undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, this.filename, { ooName: firstName.toUpperCase() });\n return undefined;\n }\n }\n const children = expr.getChildren();\n const token = (_b = children[2]) === null || _b === void 0 ? void 0 : _b.getFirstToken();\n const attr = token.getStr();\n const c = new _object_oriented_1.ObjectOriented(this.scope).searchConstantName(obj, attr);\n if (c instanceof class_constant_1.ClassConstant) {\n this.scope.addReference(token, c, _reference_1.ReferenceType.DataReadReference, this.filename);\n const val = c.getValue();\n if (typeof val === \"string\") {\n return val;\n }\n else if (typeof val === \"object\" && children[4]) {\n const name = children[4].getFirstToken().getStr();\n if (val[name] !== undefined) {\n return val[name];\n }\n }\n return undefined;\n }\n throw new Error(\"resolveConstantValue, constant not found \" + attr);\n }\n else {\n throw new Error(\"resolveConstantValue, unexpected structure\");\n }\n }\n resolveTypeRef(chain) {\n var _a;\n if (chain === undefined) {\n return undefined;\n }\n const name = chain.getFirstToken().getStr();\n if (chain.getAllTokens().length === 1) {\n if (name.toUpperCase() === \"OBJECT\") {\n return new Types.GenericObjectReferenceType();\n }\n const search = this.scope.existsObject(name);\n if (search.found === true && search.id) {\n this.scope.addReference(chain.getFirstToken(), search.id, _reference_1.ReferenceType.ObjectOrientedReference, this.filename, { ooType: search.ooType, ooName: name });\n return new Types.ObjectReferenceType(search.id, name);\n }\n }\n const found = this.resolveTypeName(chain);\n if (found && !(found instanceof Types.UnknownType) && !(found instanceof Types.VoidType)) {\n return new Types.DataReference(found);\n }\n else if (chain.concatTokens().toUpperCase() === \"DATA\") {\n return new Types.DataReference(new Types.AnyType());\n }\n if (this.scope.isBadiDef(name) === true) {\n return new Types.VoidType(name);\n }\n if (((_a = this.scope.getDDIC()) === null || _a === void 0 ? void 0 : _a.inErrorNamespace(name)) === false) {\n // this.scope.addReference(chain.getFirstToken(), undefined, ReferenceType.VoidType, this.filename);\n return new Types.VoidType(name);\n }\n return new Types.UnknownType(\"REF, unable to resolve \" + name);\n }\n findValue(node) {\n const val = node.findFirstExpression(Expressions.Value);\n if (val === undefined) {\n throw new Error(\"VALUE missing in expression\");\n }\n if (val.concatTokens().toUpperCase() === \"VALUE IS INITIAL\") {\n return undefined;\n }\n const constant = val.findFirstExpression(Expressions.Constant);\n if (constant) {\n return constant.concatTokens();\n }\n const chain = val.findFirstExpression(Expressions.SimpleFieldChain);\n if (chain) {\n return this.resolveConstantValue(chain);\n }\n throw new Error(\"findValue, unexpected\");\n }\n findDecimals(node) {\n var _a, _b;\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();\n if (dec) {\n return parseInt(dec, 10);\n }\n return undefined;\n }\n findLength(node) {\n const val = node.findFirstExpression(Expressions.Length);\n const flen = node.findFirstExpression(Expressions.ConstantFieldLength);\n if (val && flen) {\n throw new Error(\"Only specify length once\");\n }\n if (flen) {\n const cintExpr = flen.findFirstExpression(Expressions.Integer);\n if (cintExpr) {\n return this.parseInt(cintExpr.concatTokens());\n }\n const cchain = flen.findFirstExpression(Expressions.SimpleFieldChain);\n if (cchain) {\n const val = this.resolveConstantValue(cchain);\n return this.parseInt(val);\n }\n }\n if (val === undefined) {\n return 1;\n }\n const intExpr = val.findFirstExpression(Expressions.Integer);\n if (intExpr) {\n return this.parseInt(intExpr.concatTokens());\n }\n const strExpr = val.findFirstExpression(Expressions.ConstantString);\n if (strExpr) {\n return this.parseInt(strExpr.concatTokens());\n }\n const chain = val.findFirstExpression(Expressions.SimpleFieldChain);\n if (chain) {\n const val = this.resolveConstantValue(chain);\n return this.parseInt(val);\n }\n throw new Error(\"Unexpected, findLength\");\n }\n parseInt(text) {\n if (text === undefined) {\n return undefined;\n }\n if (text.startsWith(\"'\")) {\n text = text.split(\"'\")[1];\n }\n else if (text.startsWith(\"`\")) {\n text = text.split(\"`\")[1];\n }\n return parseInt(text, 10);\n }\n}\nexports.BasicTypes = BasicTypes;\n//# sourceMappingURL=basic_types.js.map\n\n//# sourceURL=webpack://@abaplint/cli/./node_modules/@abaplint/core/build/src/abap/5_syntax/basic_types.js?");
|
|
6796
6796
|
|
|
6797
6797
|
/***/ }),
|
|
6798
6798
|
|
|
@@ -11841,7 +11841,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
11841
11841
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
11842
11842
|
|
|
11843
11843
|
"use strict";
|
|
11844
|
-
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.97.0\";\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?");
|
|
11844
|
+
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.97.2\";\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?");
|
|
11845
11845
|
|
|
11846
11846
|
/***/ }),
|
|
11847
11847
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/cli",
|
|
3
|
-
"version": "2.97.
|
|
3
|
+
"version": "2.97.2",
|
|
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.97.
|
|
40
|
+
"@abaplint/core": "^2.97.2",
|
|
41
41
|
"@types/chai": "^4.3.4",
|
|
42
42
|
"@types/glob": "^7.2.0",
|
|
43
43
|
"@types/minimist": "^1.2.2",
|