@abaplint/core 2.83.21 → 2.83.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2529,13 +2529,20 @@ declare interface IBuiltinMethod {
2529
2529
  }
2530
2530
 
2531
2531
  declare class ICFService extends AbstractObject {
2532
+ private parsedXML;
2532
2533
  getType(): string;
2533
2534
  getAllowedNaming(): {
2534
2535
  maxLength: number;
2535
2536
  allowNamespace: boolean;
2536
2537
  };
2538
+ setDirty(): void;
2537
2539
  getDescription(): string | undefined;
2540
+ getURL(): string | undefined;
2538
2541
  getHandlerList(): string[] | undefined;
2542
+ parse(): {
2543
+ updated: boolean;
2544
+ runtime: number;
2545
+ };
2539
2546
  }
2540
2547
 
2541
2548
  export declare interface IClassDefinition extends IInterfaceDefinition {
@@ -3245,7 +3252,9 @@ declare interface IScopeData {
3245
3252
  [name: string]: TypedIdentifier;
3246
3253
  };
3247
3254
  deferred: Token[];
3248
- cdefs: IClassDefinition[];
3255
+ cdefs: {
3256
+ [name: string]: IClassDefinition;
3257
+ };
3249
3258
  idefs: IInterfaceDefinition[];
3250
3259
  forms: IFormDefinition[];
3251
3260
  references: IReference[];
@@ -10,11 +10,12 @@ class Compare extends combi_1.Expression {
10
10
  const val = (0, combi_1.altPrio)(_1.FieldSub, _1.Constant);
11
11
  const list = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeft), val, (0, combi_1.plus)((0, combi_1.seq)(",", val)), (0, combi_1.tok)(tokens_1.ParenRightW));
12
12
  const inn = (0, combi_1.seq)((0, combi_1.optPrio)("NOT"), "IN", (0, combi_1.altPrio)(_1.Source, list));
13
- const sopt = (0, combi_1.seq)("IS", (0, combi_1.optPrio)("NOT"), (0, combi_1.altPrio)("SUPPLIED", "BOUND", (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("INSTANCE OF", _1.ClassName)), "REQUESTED", "ASSIGNED", "INITIAL"));
13
+ const sopt = (0, combi_1.seq)("IS", (0, combi_1.optPrio)("NOT"), (0, combi_1.altPrio)("SUPPLIED", "BOUND", (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("INSTANCE OF", _1.ClassName)), "REQUESTED", "INITIAL"));
14
14
  const between = (0, combi_1.seq)((0, combi_1.optPrio)("NOT"), "BETWEEN", _1.Source, "AND", _1.Source);
15
15
  const predicate = (0, combi_1.ver)(version_1.Version.v740sp08, _1.MethodCallChain);
16
16
  const rett = (0, combi_1.seq)(_1.Source, (0, combi_1.altPrio)((0, combi_1.seq)(_1.CompareOperator, _1.Source), inn, between, sopt));
17
- const ret = (0, combi_1.seq)((0, combi_1.opt)("NOT"), (0, combi_1.altPrio)(rett, predicate));
17
+ const fsassign = (0, combi_1.seq)(_1.SourceFieldSymbol, "IS", (0, combi_1.optPrio)("NOT"), "ASSIGNED");
18
+ const ret = (0, combi_1.seq)((0, combi_1.opt)("NOT"), (0, combi_1.altPrio)(rett, predicate, fsassign));
18
19
  return ret;
19
20
  }
20
21
  }
@@ -74,8 +74,14 @@ class CurrentScope {
74
74
  this.current.getData().extraLikeTypes[upper] = type;
75
75
  }
76
76
  addClassDefinition(c) {
77
- var _a;
78
- (_a = this.current) === null || _a === void 0 ? void 0 : _a.getData().cdefs.push(c);
77
+ if (this.current === undefined) {
78
+ return;
79
+ }
80
+ const name = c.getName().toUpperCase();
81
+ if (this.current.getData().cdefs[name] !== undefined) {
82
+ throw new Error(`Class "${name}" already defined`);
83
+ }
84
+ this.current.getData().cdefs[name] = c;
79
85
  }
80
86
  addFormDefinitions(f) {
81
87
  if (this.current === undefined) {
@@ -6,10 +6,10 @@ const expressions_1 = require("../../2_statements/expressions");
6
6
  class Constant {
7
7
  runSyntax(node) {
8
8
  if (node.findDirectExpression(expressions_1.Integer)) {
9
- return new basic_1.IntegerType();
9
+ return new basic_1.IntegerType("I");
10
10
  }
11
11
  else {
12
- return new basic_1.StringType();
12
+ return new basic_1.StringType("STRING");
13
13
  }
14
14
  }
15
15
  }
@@ -19,6 +19,7 @@ class DatabaseTable {
19
19
  }
20
20
  else {
21
21
  scope.addReference(token, found.getIdentifier(), _reference_1.ReferenceType.TableReference, filename);
22
+ scope.getDDICReferences().addUsing(scope.getParentObj(), { object: found, token: token, filename: filename });
22
23
  }
23
24
  }
24
25
  }
@@ -58,12 +58,15 @@ class Source {
58
58
  const method = new _builtin_1.BuiltIn().searchBuiltin(tok);
59
59
  scope.addReference(token, method, _reference_1.ReferenceType.BuiltinMethodReference, filename);
60
60
  new cond_1.Cond().runSyntax(node.findDirectExpression(Expressions.Cond), scope, filename);
61
- return new basic_1.CharacterType(1);
61
+ return new basic_1.CharacterType(1, "ABAP_BOOL");
62
62
  }
63
63
  case "REDUCE":
64
64
  {
65
65
  const foundType = this.determineType(node, scope, filename, targetType);
66
66
  const bodyType = new reduce_body_1.ReduceBody().runSyntax(node.findDirectExpression(Expressions.ReduceBody), scope, filename);
67
+ if (foundType === undefined) {
68
+ this.addIfInferred(node, scope, filename, bodyType);
69
+ }
67
70
  return foundType ? foundType : bodyType;
68
71
  }
69
72
  case "SWITCH":
@@ -75,7 +78,11 @@ class Source {
75
78
  case "COND":
76
79
  {
77
80
  const foundType = this.determineType(node, scope, filename, targetType);
78
- return new cond_body_1.CondBody().runSyntax(node.findDirectExpression(Expressions.CondBody), scope, filename, foundType);
81
+ const bodyType = new cond_body_1.CondBody().runSyntax(node.findDirectExpression(Expressions.CondBody), scope, filename, foundType);
82
+ if (foundType === undefined) {
83
+ this.addIfInferred(node, scope, filename, bodyType);
84
+ }
85
+ return foundType ? foundType : bodyType;
79
86
  }
80
87
  case "CONV":
81
88
  {
@@ -155,6 +162,18 @@ class Source {
155
162
  return context;
156
163
  }
157
164
  ////////////////////////////////
165
+ addIfInferred(node, scope, filename, inferredType) {
166
+ const basic = new basic_types_1.BasicTypes(filename, scope);
167
+ const typeExpression = node.findFirstExpression(Expressions.TypeNameOrInfer);
168
+ const typeToken = typeExpression === null || typeExpression === void 0 ? void 0 : typeExpression.getFirstToken();
169
+ const typeName = typeToken === null || typeToken === void 0 ? void 0 : typeToken.getStr();
170
+ if (typeName === "#" && inferredType) {
171
+ const found = basic.lookupQualifiedName(inferredType.getQualifiedName());
172
+ if (found) {
173
+ scope.addReference(typeToken, found, _reference_1.ReferenceType.InferredType, filename);
174
+ }
175
+ }
176
+ }
158
177
  determineType(node, scope, filename, targetType) {
159
178
  const basic = new basic_types_1.BasicTypes(filename, scope);
160
179
  const typeExpression = node.findFirstExpression(Expressions.TypeNameOrInfer);
@@ -8,7 +8,7 @@ class ScopeData {
8
8
  constructor() {
9
9
  this.data = {
10
10
  vars: {},
11
- cdefs: [],
11
+ cdefs: {},
12
12
  idefs: [],
13
13
  forms: [],
14
14
  types: {},
@@ -68,10 +68,9 @@ class SpaghettiScopeNode extends ScopeData {
68
68
  let search = this;
69
69
  const upper = name.toUpperCase();
70
70
  while (search !== undefined) {
71
- for (const cdef of search.getData().cdefs) {
72
- if (cdef.getName().toUpperCase() === upper) {
73
- return cdef;
74
- }
71
+ const c = search.getData().cdefs[upper];
72
+ if (c !== undefined) {
73
+ return c;
75
74
  }
76
75
  search = search.getParent();
77
76
  }
@@ -44,6 +44,7 @@ class CreateObject {
44
44
  continue;
45
45
  }
46
46
  else if (!(found instanceof basic_1.ObjectReferenceType)
47
+ && !(found instanceof basic_1.AnyType)
47
48
  && !(found instanceof basic_1.GenericObjectReferenceType)) {
48
49
  throw new Error("Target must be a object reference");
49
50
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AbstractObject = void 0;
4
- const fastxmlparser = require("fast-xml-parser");
4
+ const fast_xml_parser_1 = require("fast-xml-parser");
5
5
  const _identifier_1 = require("../abap/4_file_information/_identifier");
6
6
  const identifier_1 = require("../abap/1_lexer/tokens/identifier");
7
7
  const position_1 = require("../position");
@@ -100,7 +100,7 @@ class AbstractObject {
100
100
  return undefined;
101
101
  }
102
102
  try {
103
- return fastxmlparser.parse(xml, { parseNodeValue: false, ignoreAttributes: true, trimValues: false });
103
+ return new fast_xml_parser_1.XMLParser({ parseTagValue: false, ignoreAttributes: true, trimValues: false }).parse(xml);
104
104
  }
105
105
  catch (_a) {
106
106
  return undefined;
@@ -4,7 +4,7 @@ exports.FunctionGroup = void 0;
4
4
  const _abap_object_1 = require("./_abap_object");
5
5
  const types_1 = require("../abap/types");
6
6
  const xml_utils_1 = require("../xml_utils");
7
- const fastxmlparser = require("fast-xml-parser");
7
+ const fast_xml_parser_1 = require("fast-xml-parser");
8
8
  class FunctionGroup extends _abap_object_1.ABAPObject {
9
9
  constructor() {
10
10
  super(...arguments);
@@ -123,7 +123,7 @@ class FunctionGroup extends _abap_object_1.ABAPObject {
123
123
  if (found === undefined) {
124
124
  return {};
125
125
  }
126
- const parsed = fastxmlparser.parse(found.getRaw(), { parseNodeValue: false, ignoreAttributes: true, trimValues: false });
126
+ const parsed = new fast_xml_parser_1.XMLParser({ parseTagValue: false, ignoreAttributes: true, trimValues: false }).parse(found.getRaw());
127
127
  this.findTexts(parsed);
128
128
  }
129
129
  return this.texts;
@@ -13,26 +13,46 @@ class ICFService extends _abstract_object_1.AbstractObject {
13
13
  allowNamespace: true,
14
14
  };
15
15
  }
16
+ setDirty() {
17
+ this.parsedXML = undefined;
18
+ super.setDirty();
19
+ }
16
20
  getDescription() {
17
21
  // todo
18
22
  return undefined;
19
23
  }
20
- // todo, cache parsed data
24
+ getURL() {
25
+ var _a;
26
+ this.parse();
27
+ return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.url;
28
+ }
21
29
  getHandlerList() {
22
- const ret = [];
23
- const parsed = this.parseRaw2();
30
+ var _a;
31
+ this.parse();
32
+ return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.handlers;
33
+ }
34
+ parse() {
35
+ if (this.parsedXML) {
36
+ return { updated: false, runtime: 0 };
37
+ }
38
+ const start = Date.now();
39
+ this.parsedXML = {};
40
+ const parsed = super.parseRaw2();
24
41
  if (parsed === undefined
25
42
  || parsed.abapGit === undefined
26
43
  || parsed.abapGit["asx:abap"]["asx:values"] === undefined) {
27
- return undefined;
44
+ return { updated: false, runtime: 0 };
28
45
  }
29
46
  const table = parsed.abapGit["asx:abap"]["asx:values"].ICFHANDLER_TABLE;
47
+ this.parsedXML.handlers = [];
30
48
  for (const h of (0, xml_utils_1.xmlToArray)(table)) {
31
49
  if (h.ICFHANDLER !== undefined) {
32
- ret.push(h.ICFHANDLER.ICFHANDLER);
50
+ this.parsedXML.handlers.push(h.ICFHANDLER.ICFHANDLER);
33
51
  }
34
52
  }
35
- return ret;
53
+ this.parsedXML.url = parsed.abapGit["asx:abap"]["asx:values"].URL;
54
+ const end = Date.now();
55
+ return { updated: true, runtime: end - start };
36
56
  }
37
57
  }
38
58
  exports.ICFService = ICFService;
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.83.21";
71
+ return "2.83.25";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -236,8 +236,12 @@ Only one transformation is applied to a statement at a time, so multiple steps m
236
236
  if (!(low.get() instanceof _statement_1.Unknown)) {
237
237
  return undefined;
238
238
  }
239
- // todo: update + modify + insert + delete + select loop
240
- if (!(high.get() instanceof Statements.Select)) {
239
+ // todo: select loop
240
+ if (!(high.get() instanceof Statements.Select)
241
+ && !(high.get() instanceof Statements.UpdateDatabase)
242
+ && !(high.get() instanceof Statements.ModifyDatabase)
243
+ && !(high.get() instanceof Statements.DeleteDatabase)
244
+ && !(high.get() instanceof Statements.InsertDatabase)) {
241
245
  return undefined;
242
246
  }
243
247
  let fix = undefined;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RemoveDescriptions = exports.RemoveDescriptionsConf = void 0;
4
4
  const issue_1 = require("../issue");
5
- const fastxmlparser = require("fast-xml-parser");
5
+ const fast_xml_parser_1 = require("fast-xml-parser");
6
6
  const Objects = require("../objects");
7
7
  const _basic_rule_config_1 = require("./_basic_rule_config");
8
8
  const position_1 = require("../position");
@@ -95,7 +95,7 @@ Consider using ABAP Doc for documentation.`,
95
95
  return this.checkXML(xml, file);
96
96
  }
97
97
  checkXML(xml, file) {
98
- const parsed = fastxmlparser.parse(xml, { parseNodeValue: false, ignoreAttributes: true, trimValues: false });
98
+ const parsed = new fast_xml_parser_1.XMLParser({ parseTagValue: false, ignoreAttributes: true, trimValues: false }).parse(xml);
99
99
  if (parsed === undefined || parsed.abapGit["asx:abap"]["asx:values"] === undefined) {
100
100
  return [];
101
101
  }
@@ -64,14 +64,15 @@ class UnknownTypes {
64
64
  traverse(node) {
65
65
  var _a;
66
66
  const ret = [];
67
- for (const r of node.getData().references) {
67
+ const nodeData = node.getData();
68
+ for (const r of nodeData.references) {
68
69
  if (r.referenceType === _reference_1.ReferenceType.ObjectOrientedUnknownReference && ((_a = r.extra) === null || _a === void 0 ? void 0 : _a.ooName)) {
69
70
  const message = r.extra.ooName + " unknown";
70
71
  ret.push(issue_1.Issue.atIdentifier(r.position, message, this.getMetadata().key, this.conf.severity));
71
72
  }
72
73
  }
73
74
  if (node.getIdentifier().stype !== _scope_type_1.ScopeType.ClassImplementation) {
74
- const vars = node.getData().vars;
75
+ const vars = nodeData.vars;
75
76
  for (const name in vars) {
76
77
  const identifier = vars[name];
77
78
  const found = this.containsUnknown(identifier.getType());
@@ -80,7 +81,7 @@ class UnknownTypes {
80
81
  ret.push(issue_1.Issue.atIdentifier(identifier, message, this.getMetadata().key, this.conf.severity));
81
82
  }
82
83
  }
83
- const types = node.getData().types;
84
+ const types = nodeData.types;
84
85
  for (const name in types) {
85
86
  const identifier = types[name];
86
87
  const found = this.containsUnknown(identifier.getType());
@@ -90,14 +91,15 @@ class UnknownTypes {
90
91
  }
91
92
  }
92
93
  }
93
- for (const v of node.getData().idefs) {
94
+ for (const v of nodeData.idefs) {
94
95
  const found = this.checkMethodParameters(v);
95
96
  if (found) {
96
97
  const message = "Contains unknown, " + found.found;
97
98
  ret.push(issue_1.Issue.atIdentifier(found.id, message, this.getMetadata().key, this.conf.severity));
98
99
  }
99
100
  }
100
- for (const v of node.getData().cdefs) {
101
+ for (const name in nodeData.cdefs) {
102
+ const v = nodeData.cdefs[name];
101
103
  const found = this.checkMethodParameters(v);
102
104
  if (found) {
103
105
  const message = "Contains unknown, " + found.found;
@@ -5,7 +5,7 @@ const issue_1 = require("../issue");
5
5
  const _irule_1 = require("./_irule");
6
6
  const Objects = require("../objects");
7
7
  const _basic_rule_config_1 = require("./_basic_rule_config");
8
- const fastxmlparser = require("fast-xml-parser");
8
+ const fast_xml_parser_1 = require("fast-xml-parser");
9
9
  class XMLConsistencyConf extends _basic_rule_config_1.BasicRuleConfig {
10
10
  }
11
11
  exports.XMLConsistencyConf = XMLConsistencyConf;
@@ -39,7 +39,7 @@ class XMLConsistency {
39
39
  }
40
40
  const xml = obj.getXML();
41
41
  if (xml) {
42
- const res = fastxmlparser.validate(xml);
42
+ const res = fast_xml_parser_1.XMLValidator.validate(xml);
43
43
  if (res !== true) {
44
44
  issues.push(issue_1.Issue.atRow(file, 1, "XML parser error: " + res.err.msg, this.getMetadata().key, this.conf.severity));
45
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.83.21",
3
+ "version": "2.83.25",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -45,20 +45,20 @@
45
45
  },
46
46
  "homepage": "https://abaplint.org",
47
47
  "devDependencies": {
48
- "@microsoft/api-extractor": "^7.19.3",
48
+ "@microsoft/api-extractor": "^7.19.4",
49
49
  "@types/chai": "^4.3.0",
50
50
  "@types/mocha": "^9.0.0",
51
- "@types/node": "^17.0.8",
51
+ "@types/node": "^17.0.9",
52
52
  "chai": "^4.3.4",
53
- "eslint": "^8.6.0",
54
- "mocha": "^9.1.3",
53
+ "eslint": "^8.7.0",
54
+ "mocha": "^9.1.4",
55
55
  "c8": "^7.11.0",
56
56
  "source-map-support": "^0.5.21",
57
57
  "ts-json-schema-generator": "^0.97.0",
58
58
  "typescript": "^4.5.4"
59
59
  },
60
60
  "dependencies": {
61
- "fast-xml-parser": "^3.21.1",
61
+ "fast-xml-parser": "^4.0.1",
62
62
  "json5": "^2.2.0",
63
63
  "vscode-languageserver-protocol": "^3.16.0",
64
64
  "vscode-languageserver-types": "^3.16.0"