@abaplint/core 2.98.2 → 2.99.0

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.
@@ -1966,6 +1966,7 @@ declare namespace Expressions {
1966
1966
  ComponentCondSub,
1967
1967
  ComponentCond,
1968
1968
  ComponentName,
1969
+ SQLFields,
1969
1970
  ConcatenatedConstant,
1970
1971
  CondBody,
1971
1972
  CondSub,
@@ -4040,6 +4041,7 @@ declare class MIMEObject extends AbstractObject {
4040
4041
  getType(): string;
4041
4042
  getURL(): string | undefined;
4042
4043
  getClass(): string | undefined;
4044
+ isFolder(): boolean;
4043
4045
  getAllowedNaming(): {
4044
4046
  maxLength: number;
4045
4047
  allowNamespace: boolean;
@@ -5278,6 +5280,10 @@ declare class SQLFieldName extends Expression {
5278
5280
  getRunnable(): IStatementRunnable;
5279
5281
  }
5280
5282
 
5283
+ declare class SQLFields extends Expression {
5284
+ getRunnable(): IStatementRunnable;
5285
+ }
5286
+
5281
5287
  declare class SQLForAllEntries extends Expression {
5282
5288
  getRunnable(): IStatementRunnable;
5283
5289
  }
@@ -43,6 +43,7 @@ __exportStar(require("./component_compare"), exports);
43
43
  __exportStar(require("./component_cond_sub"), exports);
44
44
  __exportStar(require("./component_cond"), exports);
45
45
  __exportStar(require("./component_name"), exports);
46
+ __exportStar(require("./sql_fields"), exports);
46
47
  __exportStar(require("./concatenated_constant"), exports);
47
48
  __exportStar(require("./cond_body"), exports);
48
49
  __exportStar(require("./cond_sub"), exports);
@@ -15,7 +15,7 @@ class Select extends combi_1.Expression {
15
15
  const where = (0, combi_1.seq)("WHERE", _1.SQLCond);
16
16
  const offset = (0, combi_1.ver)(version_1.Version.v751, (0, combi_1.seq)("OFFSET", _1.SQLSource));
17
17
  const bypass = (0, combi_1.str)("BYPASSING BUFFER");
18
- const fields = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("FIELDS", _1.SQLFieldList));
18
+ const fields = (0, combi_1.ver)(version_1.Version.v750, _1.SQLFields);
19
19
  const perm = (0, combi_1.per)(_1.SQLFrom, into, _1.SQLForAllEntries, where, _1.SQLOrderBy, sql_up_to_1.SQLUpTo, offset, _1.SQLClient, _1.SQLHaving, bypass, sql_group_by_1.SQLGroupBy, fields, _1.DatabaseConnection);
20
20
  const permSingle = (0, combi_1.per)(_1.SQLFrom, sql_into_structure_1.SQLIntoStructure, where, _1.SQLClient, bypass, fields, _1.DatabaseConnection);
21
21
  const paren = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeftW), sql_field_name_1.SQLFieldName, (0, combi_1.tok)(tokens_1.WParenRightW));
@@ -6,10 +6,10 @@ const _1 = require(".");
6
6
  const sql_order_by_1 = require("./sql_order_by");
7
7
  const sql_having_1 = require("./sql_having");
8
8
  const sql_into_structure_1 = require("./sql_into_structure");
9
- const sql_field_list_1 = require("./sql_field_list");
10
9
  const sql_hints_1 = require("./sql_hints");
11
10
  const sql_field_list_loop_1 = require("./sql_field_list_loop");
12
11
  const sql_up_to_1 = require("./sql_up_to");
12
+ const version_1 = require("../../../version");
13
13
  class SelectLoop extends combi_1.Expression {
14
14
  getRunnable() {
15
15
  const where = (0, combi_1.seq)("WHERE", _1.SQLCond);
@@ -18,7 +18,7 @@ class SelectLoop extends combi_1.Expression {
18
18
  const tab = (0, combi_1.seq)(_1.SQLIntoTable, (0, combi_1.alt)(pack, (0, combi_1.seq)(_1.SQLFrom, pack), (0, combi_1.seq)(pack, _1.SQLFrom)));
19
19
  const packTab = (0, combi_1.seq)(pack, _1.SQLIntoTable);
20
20
  const perm = (0, combi_1.per)(_1.SQLFrom, where, sql_up_to_1.SQLUpTo, sql_order_by_1.SQLOrderBy, sql_having_1.SQLHaving, _1.SQLClient, bypass, _1.SQLGroupBy, _1.SQLForAllEntries, (0, combi_1.alt)(tab, sql_into_structure_1.SQLIntoStructure, packTab));
21
- const strict = (0, combi_1.seq)(_1.SQLFrom, "FIELDS", sql_field_list_1.SQLFieldList, where, sql_into_structure_1.SQLIntoStructure, sql_up_to_1.SQLUpTo);
21
+ const strict = (0, combi_1.seq)(_1.SQLFrom, (0, combi_1.ver)(version_1.Version.v750, _1.SQLFields), where, sql_into_structure_1.SQLIntoStructure, sql_up_to_1.SQLUpTo);
22
22
  const ret = (0, combi_1.seq)("SELECT", (0, combi_1.altPrio)((0, combi_1.seq)((0, combi_1.optPrio)("DISTINCT"), sql_field_list_loop_1.SQLFieldListLoop, perm), strict), (0, combi_1.optPrio)(sql_hints_1.SQLHints));
23
23
  return ret;
24
24
  }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SQLFields = void 0;
4
+ const combi_1 = require("../combi");
5
+ const _1 = require(".");
6
+ class SQLFields extends combi_1.Expression {
7
+ getRunnable() {
8
+ return (0, combi_1.seq)("FIELDS", _1.SQLFieldList);
9
+ }
10
+ }
11
+ exports.SQLFields = SQLFields;
12
+ //# sourceMappingURL=sql_fields.js.map
@@ -16,6 +16,10 @@ class MIMEObject extends _abstract_object_1.AbstractObject {
16
16
  this.parse();
17
17
  return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.CLASS;
18
18
  }
19
+ isFolder() {
20
+ var _a;
21
+ return ((_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.FOLDER) === "X";
22
+ }
19
23
  getAllowedNaming() {
20
24
  return {
21
25
  maxLength: 32,
@@ -53,6 +57,7 @@ class MIMEObject extends _abstract_object_1.AbstractObject {
53
57
  }
54
58
  this.parsedXML.URL = parsed.abapGit["asx:abap"]["asx:values"].URL;
55
59
  this.parsedXML.CLASS = parsed.abapGit["asx:abap"]["asx:values"].CLASS;
60
+ this.parsedXML.FOLDER = parsed.abapGit["asx:abap"]["asx:values"].FOLDER;
56
61
  const end = Date.now();
57
62
  return { updated: true, runtime: end - start };
58
63
  }
@@ -63,7 +63,7 @@ class Registry {
63
63
  }
64
64
  static abaplintVersion() {
65
65
  // magic, see build script "version.sh"
66
- return "2.98.2";
66
+ return "2.99.0";
67
67
  }
68
68
  getDDICReferences() {
69
69
  return this.references;
@@ -428,6 +428,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
428
428
  return found;
429
429
  }
430
430
  }
431
+ found = this.downportSelectFields(low, high, lowFile, highSyntax);
432
+ if (found) {
433
+ return found;
434
+ }
431
435
  found = this.outlineSwitch(low, high, lowFile, highSyntax);
432
436
  if (found) {
433
437
  return found;
@@ -597,6 +601,27 @@ Only one transformation is applied to a statement at a time, so multiple steps m
597
601
  }
598
602
  return undefined;
599
603
  }
604
+ downportSelectFields(low, high, lowFile, _highSyntax) {
605
+ var _a;
606
+ if (!(low.get() instanceof _statement_1.Unknown)) {
607
+ return undefined;
608
+ }
609
+ else if (!(high.get() instanceof Statements.Select)) {
610
+ return undefined;
611
+ }
612
+ const fields = high.findFirstExpression(Expressions.SQLFields);
613
+ if (fields === undefined) {
614
+ return undefined;
615
+ }
616
+ const code = (_a = fields.getLastChild()) === null || _a === void 0 ? void 0 : _a.concatTokens();
617
+ if (code === undefined) {
618
+ return undefined;
619
+ }
620
+ const fix1 = edit_helper_1.EditHelper.deleteRange(lowFile, fields.getFirstToken().getStart(), fields.getLastToken().getEnd());
621
+ const fix2 = edit_helper_1.EditHelper.insertAt(lowFile, high.getFirstToken().getEnd(), " " + code);
622
+ const fix = edit_helper_1.EditHelper.merge(fix1, fix2);
623
+ return issue_1.Issue.atToken(lowFile, fields.getFirstToken(), "Replace FIELDS", this.getMetadata().key, this.conf.severity, fix);
624
+ }
600
625
  downportSelectSingleInline(low, high, lowFile, _highSyntax) {
601
626
  var _a, _b, _c, _d;
602
627
  if (!(low.get() instanceof _statement_1.Unknown)) {
@@ -138,6 +138,7 @@ __exportStar(require("./sequential_blank"), exports);
138
138
  __exportStar(require("./short_case"), exports);
139
139
  __exportStar(require("./sicf_consistency"), exports);
140
140
  __exportStar(require("./slow_parameter_passing"), exports);
141
+ __exportStar(require("./smim_consistency"), exports);
141
142
  __exportStar(require("./space_before_colon"), exports);
142
143
  __exportStar(require("./space_before_dot"), exports);
143
144
  __exportStar(require("./sql_escape_host_variables"), exports);
@@ -32,7 +32,9 @@ class OmitPrecedingZeros extends _abap_rule_1.ABAPRule {
32
32
  this.conf = conf;
33
33
  }
34
34
  runParsed(file) {
35
+ var _a;
35
36
  const issues = [];
37
+ const message = "Omit preceding zeros";
36
38
  for (const s of file.getStatements()) {
37
39
  for (const i of s.findAllExpressions(Expressions.Integer)) {
38
40
  const token = i.getLastToken();
@@ -41,7 +43,14 @@ class OmitPrecedingZeros extends _abap_rule_1.ABAPRule {
41
43
  if (s.get() instanceof statements_1.CallScreen || s.get() instanceof statements_1.SetScreen) {
42
44
  continue;
43
45
  }
44
- const message = "Omit preceding zeros";
46
+ const issue = issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.getConfig().severity);
47
+ issues.push(issue);
48
+ }
49
+ }
50
+ for (const i of s.findAllExpressions(Expressions.ParameterException)) {
51
+ const token = (_a = i.findDirectExpression(Expressions.SimpleName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
52
+ const str = token === null || token === void 0 ? void 0 : token.getStr();
53
+ if (token && str && str.length > 1 && str.startsWith("0")) {
45
54
  const issue = issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.getConfig().severity);
46
55
  issues.push(issue);
47
56
  }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SMIMConsistency = exports.SMIMConsistencyConf = void 0;
4
+ const issue_1 = require("../issue");
5
+ const _basic_rule_config_1 = require("./_basic_rule_config");
6
+ const objects_1 = require("../objects");
7
+ const position_1 = require("../position");
8
+ class SMIMConsistencyConf extends _basic_rule_config_1.BasicRuleConfig {
9
+ }
10
+ exports.SMIMConsistencyConf = SMIMConsistencyConf;
11
+ class SMIMConsistency {
12
+ constructor() {
13
+ this.conf = new SMIMConsistencyConf();
14
+ }
15
+ getMetadata() {
16
+ return {
17
+ key: "smim_consistency",
18
+ title: "SMIM consistency check",
19
+ shortDescription: `SMIM consistency check`,
20
+ extendedInformation: "Check folders exists",
21
+ };
22
+ }
23
+ getConfig() {
24
+ return this.conf;
25
+ }
26
+ setConfig(conf) {
27
+ this.conf = conf;
28
+ }
29
+ initialize(reg) {
30
+ this.reg = reg;
31
+ return this;
32
+ }
33
+ run(obj) {
34
+ const issues = [];
35
+ if (!(obj instanceof objects_1.MIMEObject)) {
36
+ return [];
37
+ }
38
+ const base = this.base(obj.getURL() || "");
39
+ if (base !== "" && this.findFolder(base) === false) {
40
+ const message = "Parent folder not found";
41
+ const position = new position_1.Position(1, 1);
42
+ const issue = issue_1.Issue.atPosition(obj.getFiles()[0], position, message, this.getMetadata().key, this.conf.severity);
43
+ issues.push(issue);
44
+ }
45
+ return issues;
46
+ }
47
+ base(full) {
48
+ const components = full.split("/");
49
+ components.pop();
50
+ return components.join("/");
51
+ }
52
+ findFolder(base) {
53
+ for (const smim of this.reg.getObjectsByType("SMIM")) {
54
+ if (base === smim.getURL()) {
55
+ return true;
56
+ }
57
+ }
58
+ return false;
59
+ }
60
+ }
61
+ exports.SMIMConsistency = SMIMConsistency;
62
+ //# sourceMappingURL=smim_consistency.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.98.2",
3
+ "version": "2.99.0",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -47,10 +47,10 @@
47
47
  },
48
48
  "homepage": "https://abaplint.org",
49
49
  "devDependencies": {
50
- "@microsoft/api-extractor": "^7.34.4",
50
+ "@microsoft/api-extractor": "^7.34.5",
51
51
  "@types/chai": "^4.3.4",
52
52
  "@types/mocha": "^10.0.1",
53
- "@types/node": "^18.16.1",
53
+ "@types/node": "^18.16.2",
54
54
  "chai": "^4.3.7",
55
55
  "eslint": "^8.39.0",
56
56
  "mocha": "^10.2.0",