@abaplint/core 2.85.6 → 2.85.10

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.
@@ -313,13 +313,19 @@ class StarPrioroity {
313
313
  res = this.sta.run(res);
314
314
  if (res.length === 0) {
315
315
  if (prev !== undefined) {
316
- result = prev;
316
+ // console.log("star length: " + prev.length);
317
+ let best = Number.MAX_SAFE_INTEGER;
318
+ for (const p of prev) {
319
+ if (p.remainingLength() < best) {
320
+ result = [p];
321
+ best = p.remainingLength();
322
+ }
323
+ }
317
324
  }
318
325
  break;
319
326
  }
320
327
  prev = res;
321
328
  }
322
- // console.dir(result);
323
329
  return result;
324
330
  }
325
331
  railroad() {
@@ -401,13 +407,17 @@ class Sequence {
401
407
  const result = [];
402
408
  for (const input of r) {
403
409
  let temp = [input];
410
+ let match = true;
404
411
  for (const sequence of this.list) {
405
412
  temp = sequence.run(temp);
406
413
  if (temp.length === 0) {
414
+ match = false;
407
415
  break;
408
416
  }
409
417
  }
410
- result.push(...temp);
418
+ if (match === true) {
419
+ result.push(...temp);
420
+ }
411
421
  }
412
422
  return result;
413
423
  }
@@ -702,7 +712,13 @@ class Combi {
702
712
  this.ver = version;
703
713
  const input = new result_1.Result(tokens, 0);
704
714
  const result = runnable.run([input]);
705
- // console.log("res: " + result.length);
715
+ /*
716
+ console.log("res: " + result.length);
717
+ for (const res of result) {
718
+ console.dir(res.getNodes().map(n => n.get().constructor.name));
719
+ console.dir(res.getNodes().map(n => n.concatTokens()));
720
+ }
721
+ */
706
722
  for (const res of result) {
707
723
  if (res.remainingLength() === 0) {
708
724
  return res.getNodes();
@@ -8,9 +8,10 @@ class MethodSource extends combi_1.Expression {
8
8
  getRunnable() {
9
9
  const mname = (0, combi_1.alt)(_1.MethodName, _1.Dynamic);
10
10
  const cname = (0, combi_1.alt)(_1.FieldChain, _1.MethodCallChain, _1.Dynamic);
11
- const stati = (0, combi_1.seq)(_1.ClassName, (0, combi_1.tok)(tokens_1.StaticArrow));
11
+ // this is a bit tricky, this part is required as FieldChain takes a AttributeName
12
+ const stati = (0, combi_1.seq)(_1.ClassName, (0, combi_1.tok)(tokens_1.StaticArrow), mname);
12
13
  const part1 = (0, combi_1.seq)(cname, (0, combi_1.alt)((0, combi_1.tok)(tokens_1.InstanceArrow), (0, combi_1.tok)(tokens_1.StaticArrow)));
13
- return (0, combi_1.seq)((0, combi_1.optPrio)(stati), (0, combi_1.starPrio)(part1), mname);
14
+ return (0, combi_1.alt)(stati, (0, combi_1.seq)((0, combi_1.starPrio)(part1), mname));
14
15
  }
15
16
  }
16
17
  exports.MethodSource = MethodSource;
@@ -5,7 +5,7 @@ const combi_1 = require("../combi");
5
5
  const _1 = require(".");
6
6
  class SimpleSource3 extends combi_1.Expression {
7
7
  getRunnable() {
8
- return (0, combi_1.alt)(_1.Constant, _1.TextElement, _1.FieldChain);
8
+ return (0, combi_1.altPrio)(_1.Constant, _1.TextElement, _1.FieldChain);
9
9
  }
10
10
  }
11
11
  exports.SimpleSource3 = SimpleSource3;
@@ -8,7 +8,7 @@ const field_chain_1 = require("./field_chain");
8
8
  class SQLCDSParameters extends combi_1.Expression {
9
9
  getRunnable() {
10
10
  const param = (0, combi_1.seq)(_1.Field, "=", (0, combi_1.alt)((0, combi_1.seq)((0, combi_1.tok)(tokens_1.WAt), field_chain_1.FieldChain), _1.Constant));
11
- return (0, combi_1.seq)("(", param, (0, combi_1.star)((0, combi_1.seq)(",", param)), ")");
11
+ return (0, combi_1.seq)("(", param, (0, combi_1.starPrio)((0, combi_1.seq)(",", param)), ")");
12
12
  }
13
13
  }
14
14
  exports.SQLCDSParameters = SQLCDSParameters;
@@ -10,15 +10,15 @@ class SQLCompare extends combi_1.Expression {
10
10
  const val = new _1.SQLSource();
11
11
  const list = (0, combi_1.seq)((0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.WParenLeft), (0, combi_1.tok)(tokens_1.WParenLeftW)), val, (0, combi_1.starPrio)((0, combi_1.seq)(",", val)), ")");
12
12
  const subSelect = (0, combi_1.seq)("(", _1.Select, ")");
13
- const inn = (0, combi_1.seq)((0, combi_1.optPrio)("NOT"), "IN", (0, combi_1.altPrio)(_1.SQLSource, list, subSelect));
14
- const between = (0, combi_1.seq)((0, combi_1.optPrio)("NOT"), "BETWEEN", _1.SQLSource, "AND", _1.SQLSource);
15
- const like = (0, combi_1.seq)((0, combi_1.optPrio)("NOT"), "LIKE", _1.SQLSource, (0, combi_1.optPrio)((0, combi_1.seq)("ESCAPE", _1.SQLSource)));
16
- const nul = (0, combi_1.seq)("IS", (0, combi_1.optPrio)("NOT"), (0, combi_1.alt)("NULL", (0, combi_1.ver)(version_1.Version.v753, "INITIAL")));
13
+ const inn = (0, combi_1.seq)("IN", (0, combi_1.altPrio)(_1.SQLSource, list, subSelect));
14
+ const between = (0, combi_1.seq)("BETWEEN", _1.SQLSource, "AND", _1.SQLSource);
15
+ const like = (0, combi_1.seq)("LIKE", _1.SQLSource, (0, combi_1.optPrio)((0, combi_1.seq)("ESCAPE", _1.SQLSource)));
16
+ const nul = (0, combi_1.seq)("IS", (0, combi_1.optPrio)("NOT"), (0, combi_1.altPrio)("NULL", (0, combi_1.ver)(version_1.Version.v753, "INITIAL")));
17
17
  const source = new _1.SQLSource();
18
18
  const sub = (0, combi_1.seq)((0, combi_1.optPrio)((0, combi_1.altPrio)("ALL", "ANY", "SOME")), subSelect);
19
- const builtin = (0, combi_1.ver)(version_1.Version.v751, (0, combi_1.seq)((0, combi_1.alt)("lower", "upper"), (0, combi_1.tok)(tokens_1.ParenLeftW), _1.SQLFieldName, (0, combi_1.tok)(tokens_1.WParenRightW)));
20
- const arith = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)(_1.SQLFieldName, (0, combi_1.plusPrio)((0, combi_1.seq)((0, combi_1.altPrio)("+", "-", "*", "/"), _1.SQLFieldName))));
21
- const rett = (0, combi_1.seq)((0, combi_1.altPrio)(builtin, arith, _1.SQLFieldName), (0, combi_1.altPrio)((0, combi_1.seq)(_1.SQLCompareOperator, (0, combi_1.altPrio)(sub, source)), inn, like, between, nul));
19
+ const builtin = (0, combi_1.ver)(version_1.Version.v751, (0, combi_1.seq)((0, combi_1.altPrio)("lower", "upper"), (0, combi_1.tok)(tokens_1.ParenLeftW), _1.SQLFieldName, (0, combi_1.tok)(tokens_1.WParenRightW)));
20
+ const arith = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.plusPrio)((0, combi_1.seq)((0, combi_1.altPrio)("+", "-", "*", "/"), _1.SQLFieldName)));
21
+ const rett = (0, combi_1.seq)((0, combi_1.altPrio)(builtin, (0, combi_1.seq)(_1.SQLFieldName, (0, combi_1.optPrio)(arith))), (0, combi_1.altPrio)((0, combi_1.seq)(_1.SQLCompareOperator, (0, combi_1.altPrio)(sub, source)), (0, combi_1.seq)((0, combi_1.optPrio)("NOT"), (0, combi_1.altPrio)(inn, like, between)), nul));
22
22
  const exists = (0, combi_1.seq)("EXISTS", subSelect);
23
23
  return (0, combi_1.altPrio)(exists, _1.Dynamic, rett);
24
24
  }
@@ -11,7 +11,7 @@ class SQLFromSource extends combi_1.Expression {
11
11
  // https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abennews-752-open_sql.htm#!ABAP_MODIFICATION_1@1@
12
12
  const tab = (0, combi_1.ver)(version_1.Version.v752, (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WAt), _1.FieldChain));
13
13
  const aas = (0, combi_1.seq)("AS", _1.SQLAsName);
14
- return (0, combi_1.seq)((0, combi_1.altPrio)(_1.Dynamic, with_name_1.WithName, (0, combi_1.seq)(_1.DatabaseTable, (0, combi_1.optPrio)(_1.SQLCDSParameters)), tab), (0, combi_1.optPrio)((0, combi_1.ver)(version_1.Version.v752, "WITH PRIVILEGED ACCESS")), (0, combi_1.optPrio)(aas));
14
+ return (0, combi_1.seq)((0, combi_1.altPrio)(with_name_1.WithName, (0, combi_1.seq)(_1.DatabaseTable, (0, combi_1.optPrio)(_1.SQLCDSParameters)), tab), (0, combi_1.optPrio)((0, combi_1.ver)(version_1.Version.v752, "WITH PRIVILEGED ACCESS")), (0, combi_1.optPrio)(aas));
15
15
  }
16
16
  }
17
17
  exports.SQLFromSource = SQLFromSource;
@@ -8,9 +8,8 @@ const _1 = require(".");
8
8
  class SQLSource extends combi_1.Expression {
9
9
  getRunnable() {
10
10
  const paren = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.ParenLeftW), _1.Source, (0, combi_1.tok)(tokens_1.WParenRightW));
11
- // todo, this Source must be a simple field?
12
- const at = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WAt), (0, combi_1.altPrio)(_1.Source, paren)));
13
- return (0, combi_1.alt)(_1.SQLAliasField, _1.Source, at);
11
+ const at = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WAt), (0, combi_1.altPrio)(_1.SimpleSource3, paren)));
12
+ return (0, combi_1.alt)(_1.SQLAliasField, _1.SimpleSource3, at);
14
13
  }
15
14
  }
16
15
  exports.SQLSource = SQLSource;
@@ -5,12 +5,12 @@ const combi_1 = require("../combi");
5
5
  const version_1 = require("../../../version");
6
6
  const tokens_1 = require("../../1_lexer/tokens");
7
7
  const _1 = require(".");
8
- const constant_string_1 = require("./constant_string");
8
+ // todo, delete this expression, its the same as SQLSource?
9
9
  class SQLSourceSimple extends combi_1.Expression {
10
10
  getRunnable() {
11
11
  const paren = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.ParenLeftW), _1.Source, (0, combi_1.tok)(tokens_1.WParenRightW));
12
- const at = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WAt), (0, combi_1.alt)(_1.FieldChain, paren)));
13
- return (0, combi_1.alt)(_1.FieldChain, at, constant_string_1.ConstantString);
12
+ const at = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WAt), (0, combi_1.alt)(_1.SimpleSource3, paren)));
13
+ return (0, combi_1.alt)(_1.SimpleSource3, at);
14
14
  }
15
15
  }
16
16
  exports.SQLSourceSimple = SQLSourceSimple;
@@ -9,7 +9,7 @@ class TypeTableKey extends combi_1.Expression {
9
9
  const uniqueness = (0, combi_1.alt)("NON-UNIQUE", "UNIQUE");
10
10
  const defaultKey = "DEFAULT KEY";
11
11
  const emptyKey = (0, combi_1.ver)(version_1.Version.v740sp02, "EMPTY KEY");
12
- const key = (0, combi_1.seq)("WITH", (0, combi_1.opt)(uniqueness), (0, combi_1.altPrio)(defaultKey, emptyKey, (0, combi_1.seq)((0, combi_1.opt)((0, combi_1.alt)("SORTED", "HASHED")), "KEY", (0, combi_1.alt)((0, combi_1.seq)(_1.Field, "COMPONENTS", (0, combi_1.plus)(_1.FieldSub)), (0, combi_1.plus)(_1.FieldSub)))));
12
+ const key = (0, combi_1.seq)("WITH", (0, combi_1.opt)(uniqueness), (0, combi_1.altPrio)(defaultKey, emptyKey, (0, combi_1.seq)((0, combi_1.opt)((0, combi_1.alt)("SORTED", "HASHED")), "KEY", (0, combi_1.alt)((0, combi_1.seq)(_1.Field, "COMPONENTS", (0, combi_1.plus)(_1.FieldSub)), (0, combi_1.plus)(_1.FieldSub)))), (0, combi_1.optPrio)("READ-ONLY"));
13
13
  return key;
14
14
  }
15
15
  }
@@ -53,8 +53,8 @@ class TypeUtils {
53
53
  }
54
54
  static isAssignable(source, target) {
55
55
  /*
56
- console.dir(source);
57
- console.dir(target);
56
+ console.dir(source);
57
+ console.dir(target);
58
58
  */
59
59
  if (target instanceof basic_1.TableType) {
60
60
  if (target.isWithHeader()) {
@@ -103,7 +103,8 @@ class TypeUtils {
103
103
  }
104
104
  return false;
105
105
  }
106
- else if (target instanceof basic_1.IntegerType) {
106
+ else if (target instanceof basic_1.IntegerType
107
+ || target instanceof basic_1.StringType) {
107
108
  if (source instanceof basic_1.DataReference
108
109
  || source instanceof basic_1.ObjectReferenceType
109
110
  || source instanceof basic_1.GenericObjectReferenceType
@@ -70,6 +70,9 @@ class FieldChain {
70
70
  context = new dereference_1.Dereference().runSyntax(context);
71
71
  }
72
72
  else if (current.get() instanceof Expressions.ComponentName) {
73
+ if (context instanceof basic_1.TableType && context.isWithHeader()) {
74
+ context = context.getRowType();
75
+ }
73
76
  context = new component_name_1.ComponentName().runSyntax(context, current);
74
77
  }
75
78
  else if (current instanceof nodes_1.ExpressionNode
@@ -45,6 +45,9 @@ class Select {
45
45
  for (const s of node.findAllExpressions(Expressions.Source)) {
46
46
  new source_1.Source().runSyntax(s, scope, filename);
47
47
  }
48
+ for (const s of node.findAllExpressions(Expressions.SimpleSource3)) {
49
+ new source_1.Source().runSyntax(s, scope, filename);
50
+ }
48
51
  if (scope.getType() === _scope_type_1.ScopeType.OpenSQL) {
49
52
  scope.pop(node.getLastToken().getEnd());
50
53
  }
@@ -6,7 +6,10 @@ const source_1 = require("./source");
6
6
  const basic_1 = require("../../types/basic");
7
7
  class SQLForAllEntries {
8
8
  runSyntax(node, scope, filename) {
9
- const s = node.findFirstExpression(Expressions.Source);
9
+ let s = node.findFirstExpression(Expressions.Source);
10
+ if (s === undefined) {
11
+ s = node.findFirstExpression(Expressions.SimpleSource3);
12
+ }
10
13
  if (s) {
11
14
  const type = new source_1.Source().runSyntax(s, scope, filename);
12
15
  if (type instanceof basic_1.VoidType) {
@@ -5,6 +5,7 @@ const Expressions = require("../../2_statements/expressions");
5
5
  const target_1 = require("../expressions/target");
6
6
  const source_1 = require("../expressions/source");
7
7
  const dynamic_1 = require("../expressions/dynamic");
8
+ const basic_types_1 = require("../basic_types");
8
9
  class CreateData {
9
10
  runSyntax(node, scope, filename) {
10
11
  for (const s of node.findDirectExpressions(Expressions.Source)) {
@@ -16,6 +17,10 @@ class CreateData {
16
17
  for (const t of node.findDirectExpressions(Expressions.Dynamic)) {
17
18
  new dynamic_1.Dynamic().runSyntax(t, scope, filename);
18
19
  }
20
+ const type = node.findDirectExpression(Expressions.TypeName);
21
+ if (type) {
22
+ new basic_types_1.BasicTypes(filename, scope).resolveTypeName(type);
23
+ }
19
24
  }
20
25
  }
21
26
  exports.CreateData = CreateData;
@@ -10,6 +10,9 @@ class DeleteDatabase {
10
10
  for (const s of node.findAllExpressions(Expressions.Source)) {
11
11
  new source_1.Source().runSyntax(s, scope, filename);
12
12
  }
13
+ for (const s of node.findAllExpressions(Expressions.SimpleSource3)) {
14
+ new source_1.Source().runSyntax(s, scope, filename);
15
+ }
13
16
  for (const d of node.findAllExpressions(Expressions.Dynamic)) {
14
17
  new dynamic_1.Dynamic().runSyntax(d, scope, filename);
15
18
  }
@@ -10,6 +10,9 @@ class InsertDatabase {
10
10
  for (const s of node.findAllExpressions(Expressions.Source)) {
11
11
  new source_1.Source().runSyntax(s, scope, filename);
12
12
  }
13
+ for (const s of node.findAllExpressions(Expressions.SimpleSource3)) {
14
+ new source_1.Source().runSyntax(s, scope, filename);
15
+ }
13
16
  for (const d of node.findAllExpressions(Expressions.Dynamic)) {
14
17
  new dynamic_1.Dynamic().runSyntax(d, scope, filename);
15
18
  }
@@ -4,6 +4,7 @@ exports.ModifyDatabase = void 0;
4
4
  const Expressions = require("../../2_statements/expressions");
5
5
  const dynamic_1 = require("../expressions/dynamic");
6
6
  const database_table_1 = require("../expressions/database_table");
7
+ const source_1 = require("../expressions/source");
7
8
  class ModifyDatabase {
8
9
  runSyntax(node, scope, filename) {
9
10
  for (const d of node.findAllExpressions(Expressions.Dynamic)) {
@@ -13,6 +14,12 @@ class ModifyDatabase {
13
14
  if (dbtab !== undefined) {
14
15
  new database_table_1.DatabaseTable().runSyntax(dbtab, scope, filename);
15
16
  }
17
+ for (const s of node.findAllExpressions(Expressions.Source)) {
18
+ new source_1.Source().runSyntax(s, scope, filename);
19
+ }
20
+ for (const s of node.findAllExpressions(Expressions.SimpleSource3)) {
21
+ new source_1.Source().runSyntax(s, scope, filename);
22
+ }
16
23
  }
17
24
  }
18
25
  exports.ModifyDatabase = ModifyDatabase;
@@ -32,6 +32,9 @@ class UpdateDatabase {
32
32
  for (const s of node.findAllExpressions(Expressions.Source)) {
33
33
  new source_1.Source().runSyntax(s, scope, filename);
34
34
  }
35
+ for (const s of node.findAllExpressions(Expressions.SimpleSource3)) {
36
+ new source_1.Source().runSyntax(s, scope, filename);
37
+ }
35
38
  for (const d of node.findAllExpressions(Expressions.Dynamic)) {
36
39
  new dynamic_1.Dynamic().runSyntax(d, scope, filename);
37
40
  }
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.85.6";
71
+ return "2.85.10";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -19,8 +19,8 @@ class IdenticalContents extends _abap_rule_1.ABAPRule {
19
19
  return {
20
20
  key: "identical_contents",
21
21
  title: "Identical contents",
22
- shortDescription: `Find identical contents in blocks inside IFs, both in the beginning and in the end.
23
-
22
+ shortDescription: `Find identical contents in blocks inside IFs, both in the beginning and in the end.`,
23
+ extendedInformation: `
24
24
  Prerequsites: code is pretty printed with identical cAsE
25
25
 
26
26
  Chained statments are ignored`,
@@ -6,6 +6,7 @@ const _abap_rule_1 = require("./_abap_rule");
6
6
  const _basic_rule_config_1 = require("./_basic_rule_config");
7
7
  const objects_1 = require("../objects");
8
8
  const _irule_1 = require("./_irule");
9
+ const version_1 = require("../version");
9
10
  class LocalTestclassLocationConf extends _basic_rule_config_1.BasicRuleConfig {
10
11
  }
11
12
  exports.LocalTestclassLocationConf = LocalTestclassLocationConf;
@@ -33,6 +34,10 @@ class LocalTestclassLocation extends _abap_rule_1.ABAPRule {
33
34
  }
34
35
  runParsed(file, obj) {
35
36
  const issues = [];
37
+ if (this.reg.getConfig().getVersion() === version_1.Version.v700) {
38
+ // 700 does not have testclass includes
39
+ return [];
40
+ }
36
41
  if (!(obj instanceof objects_1.Class)) {
37
42
  return [];
38
43
  }
@@ -73,7 +73,8 @@ class SQLEscapeHostVariables extends _abap_rule_1.ABAPRule {
73
73
  }
74
74
  for (const o of s.findAllExpressions(Expressions.SQLSource)) {
75
75
  const first = o.getFirstChild();
76
- if ((first === null || first === void 0 ? void 0 : first.get()) instanceof Expressions.Source && first.getChildren()[0].get() instanceof Expressions.FieldChain) {
76
+ if (((first === null || first === void 0 ? void 0 : first.get()) instanceof Expressions.Source && first.getChildren()[0].get() instanceof Expressions.FieldChain)
77
+ || ((first === null || first === void 0 ? void 0 : first.get()) instanceof Expressions.SimpleSource3 && first.getChildren()[0].get() instanceof Expressions.FieldChain)) {
77
78
  const message = "Escape SQL host variables";
78
79
  const issue = issue_1.Issue.atToken(file, first.getFirstToken(), message, this.getMetadata().key, this.conf.severity);
79
80
  issues.push(issue);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.85.6",
3
+ "version": "2.85.10",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -48,7 +48,7 @@
48
48
  "@microsoft/api-extractor": "^7.19.4",
49
49
  "@types/chai": "^4.3.0",
50
50
  "@types/mocha": "^9.1.0",
51
- "@types/node": "^17.0.13",
51
+ "@types/node": "^17.0.15",
52
52
  "chai": "^4.3.6",
53
53
  "eslint": "^8.8.0",
54
54
  "mocha": "^9.2.0",
@@ -58,7 +58,7 @@
58
58
  "typescript": "^4.5.5"
59
59
  },
60
60
  "dependencies": {
61
- "fast-xml-parser": "^4.0.1",
61
+ "fast-xml-parser": "^4.0.2",
62
62
  "json5": "^2.2.0",
63
63
  "vscode-languageserver-protocol": "^3.16.0",
64
64
  "vscode-languageserver-types": "^3.16.0"