@abaplint/core 2.120.84 → 2.120.86

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.
@@ -2429,7 +2429,6 @@ declare abstract class Expression implements IStatementRunnable {
2429
2429
 
2430
2430
  declare class ExpressionNode extends AbstractNode<ExpressionNode | TokenNode> {
2431
2431
  private readonly expression;
2432
- private tokenCount;
2433
2432
  constructor(expression: IStatementRunnable);
2434
2433
  addChild(_n: ExpressionNode | TokenNode): void;
2435
2434
  get(): IStatementRunnable;
@@ -6402,7 +6401,7 @@ declare class Result {
6402
6401
  private static fromChain;
6403
6402
  peek(): Token;
6404
6403
  peekAt(offset: number): Token | undefined;
6405
- shift(node: ExpressionNode | TokenNode): Result;
6404
+ shift(node: TokenNode): Result;
6406
6405
  wrapConsumed(consumedTokens: number, node: ExpressionNode): Result;
6407
6406
  popNode(): ExpressionNode | TokenNode | undefined;
6408
6407
  getNodes(): (ExpressionNode | TokenNode)[];
@@ -25,23 +25,25 @@ class Result {
25
25
  return this.tokens[this.tokenIndex + offset];
26
26
  }
27
27
  shift(node) {
28
- return Result.fromChain(this.tokens, this.tokenIndex + 1, { node, previous: this.nodes }, this.nodeCount + 1);
28
+ return Result.fromChain(this.tokens, this.tokenIndex + 1, { node, tokenCount: 1, previous: this.nodes }, this.nodeCount + 1);
29
29
  }
30
30
  wrapConsumed(consumedTokens, node) {
31
31
  let current = this.nodes;
32
32
  let currentCount = this.nodeCount;
33
+ let tokenCount = 0;
33
34
  const children = [];
34
35
  while (consumedTokens > 0) {
35
36
  if (current === undefined) {
36
37
  break;
37
38
  }
38
39
  children.push(current.node);
39
- consumedTokens = consumedTokens - current.node.countTokens();
40
+ consumedTokens = consumedTokens - current.tokenCount;
41
+ tokenCount = tokenCount + current.tokenCount;
40
42
  current = current.previous;
41
43
  currentCount--;
42
44
  }
43
45
  node.setChildren(children.reverse());
44
- this.nodes = { node, previous: current };
46
+ this.nodes = { node, tokenCount, previous: current };
45
47
  this.nodeCount = currentCount + 1;
46
48
  return this;
47
49
  }
@@ -70,7 +72,7 @@ class Result {
70
72
  this.nodes = undefined;
71
73
  this.nodeCount = 0;
72
74
  for (const node of n) {
73
- this.nodes = { node, previous: this.nodes };
75
+ this.nodes = { node, tokenCount: node.countTokens(), previous: this.nodes };
74
76
  this.nodeCount++;
75
77
  }
76
78
  }
@@ -33,11 +33,15 @@ class Submit {
33
33
  const datasetExpiration = (0, combi_1.seq)("DATASET EXPIRATION", expressions_1.Source);
34
34
  const coverText = (0, combi_1.seq)("COVER TEXT", expressions_1.Source);
35
35
  const listName = (0, combi_1.seq)("LIST NAME", expressions_1.Source);
36
+ const listDataset = (0, combi_1.seq)("LIST DATASET", expressions_1.Source);
37
+ const listAuthority = (0, combi_1.seq)("LIST AUTHORITY", expressions_1.Source);
38
+ const coverPage = (0, combi_1.seq)("COVER PAGE", expressions_1.Source);
39
+ const department = (0, combi_1.seq)("DEPARTMENT", expressions_1.Source);
36
40
  const keep = (0, combi_1.seq)("KEEP IN SPOOL", expressions_1.Source);
37
41
  const imm = (0, combi_1.seq)("IMMEDIATELY", expressions_1.Source);
38
42
  const dest = (0, combi_1.seq)("DESTINATION", expressions_1.Source);
39
43
  const language = (0, combi_1.seq)("LANGUAGE", expressions_1.Source);
40
- const perm = (0, combi_1.per)((0, combi_1.plusPrio)(awith), selectionTable, (0, combi_1.plusPrio)(awith), (0, combi_1.plusPrio)(awith), spool, lineSize, lineCount, archive, archiveMode, receiver, user, sset, ssetp, keep, cover, imm, layout, dest, coverText, listName, language, free, newList, uss, copies, datasetExpiration, "TO SAP-SPOOL", "WITHOUT SPOOL DYNPRO", "VIA SELECTION-SCREEN", exporting, expressions_1.AndReturn, job);
44
+ const perm = (0, combi_1.per)((0, combi_1.plusPrio)(awith), selectionTable, (0, combi_1.plusPrio)(awith), (0, combi_1.plusPrio)(awith), spool, lineSize, lineCount, archive, archiveMode, receiver, user, sset, ssetp, keep, cover, imm, layout, dest, coverText, listName, listDataset, listAuthority, coverPage, department, language, free, newList, uss, copies, datasetExpiration, "TO SAP-SPOOL", "WITHOUT SPOOL DYNPRO", "VIA SELECTION-SCREEN", exporting, expressions_1.AndReturn, job);
41
45
  const ret = (0, combi_1.seq)("SUBMIT", prog, (0, combi_1.opt)(perm));
42
46
  return (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, ret);
43
47
  }
@@ -1071,6 +1071,10 @@ class BasicTypes {
1071
1071
  this.input.issues.push((0, _syntax_input_1.syntaxIssue)(this.input, chain.getFirstToken(), message));
1072
1072
  return undefined;
1073
1073
  }
1074
+ else if (concat === "SY-REPID" || concat === "SYST-REPID") {
1075
+ // predefined constant in every program, not a SYST component
1076
+ return undefined;
1077
+ }
1074
1078
  return this.resolveConstantValue(chain);
1075
1079
  }
1076
1080
  throw new Error("findValue, unexpected");
@@ -7,7 +7,6 @@ const _abstract_node_1 = require("./_abstract_node");
7
7
  class ExpressionNode extends _abstract_node_1.AbstractNode {
8
8
  constructor(expression) {
9
9
  super();
10
- this.tokenCount = 0;
11
10
  this.expression = expression;
12
11
  }
13
12
  addChild(_n) {
@@ -18,13 +17,15 @@ class ExpressionNode extends _abstract_node_1.AbstractNode {
18
17
  }
19
18
  setChildren(children) {
20
19
  super.setChildren(children);
21
- for (const child of this.getChildren()) {
22
- this.tokenCount = this.tokenCount + child.countTokens();
23
- }
24
20
  return this;
25
21
  }
22
+ // not stored on the node, saves a field per ExpressionNode, the statement parser tracks counts itself
26
23
  countTokens() {
27
- return this.tokenCount;
24
+ let count = 0;
25
+ for (const child of this.getChildren()) {
26
+ count = count + child.countTokens();
27
+ }
28
+ return count;
28
29
  }
29
30
  getFirstToken() {
30
31
  for (const child of this.getChildren()) {
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.120.84";
78
+ return "2.120.86";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AbapdocShorttextLength = exports.AbapdocShorttextLengthConf = void 0;
4
+ const issue_1 = require("../issue");
5
+ const _abap_rule_1 = require("./_abap_rule");
6
+ const _basic_rule_config_1 = require("./_basic_rule_config");
7
+ const _irule_1 = require("./_irule");
8
+ const _statement_1 = require("../abap/2_statements/statements/_statement");
9
+ class AbapdocShorttextLengthConf extends _basic_rule_config_1.BasicRuleConfig {
10
+ }
11
+ exports.AbapdocShorttextLengthConf = AbapdocShorttextLengthConf;
12
+ const MAX_LENGTH = 60;
13
+ class AbapdocShorttextLength extends _abap_rule_1.ABAPRule {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.conf = new AbapdocShorttextLengthConf();
17
+ }
18
+ getMetadata() {
19
+ return {
20
+ key: "abapdoc_shorttext_length",
21
+ title: "ABAP Doc shorttext too long",
22
+ shortDescription: `Reports ABAP Doc shorttexts longer than 60 characters.`,
23
+ extendedInformation: `A shorttext is written as <p class="shorttext">...</p> or
24
+ <p class="shorttext synchronized">...</p>, the system warns "Shorttext must not exceed 60 characters."
25
+ if the text is longer.
26
+
27
+ The text may span several "! lines, line breaks count as one blank. Leading and trailing blanks are not counted,
28
+ an entity like &lt; counts as one character.`,
29
+ tags: [_irule_1.RuleTag.SingleFile],
30
+ badExample: `INTERFACE zif_foo PUBLIC.
31
+ "! <p class="shorttext synchronized">Returns the name of the selected row in the table of the view</p>
32
+ METHODS name RETURNING VALUE(result) TYPE string.
33
+ ENDINTERFACE.`,
34
+ goodExample: `INTERFACE zif_foo PUBLIC.
35
+ "! <p class="shorttext synchronized">Returns the name of the selected row</p>
36
+ METHODS name RETURNING VALUE(result) TYPE string.
37
+ ENDINTERFACE.`,
38
+ };
39
+ }
40
+ getConfig() {
41
+ return this.conf;
42
+ }
43
+ setConfig(conf) {
44
+ this.conf = conf;
45
+ }
46
+ runParsed(file) {
47
+ const issues = [];
48
+ let block = [];
49
+ for (const statement of file.getStatements()) {
50
+ const token = statement.getFirstToken();
51
+ const doc = statement.get() instanceof _statement_1.Comment && token.getStr().startsWith(`"!`);
52
+ const previous = block[block.length - 1];
53
+ if (doc === false || (previous !== undefined && token.getStart().getRow() !== previous.getStart().getRow() + 1)) {
54
+ issues.push(...this.checkBlock(file, block));
55
+ block = [];
56
+ }
57
+ if (doc === true) {
58
+ block.push(token);
59
+ }
60
+ }
61
+ issues.push(...this.checkBlock(file, block));
62
+ return issues;
63
+ }
64
+ checkBlock(file, block) {
65
+ const issues = [];
66
+ if (block.length === 0) {
67
+ return issues;
68
+ }
69
+ const text = block.map(t => t.getStr().substring(2)).join("\n");
70
+ const regex = /<p\s[^>]*class\s*=\s*"shorttext(?:\s+synchronized)?"[^>]*>([\s\S]*?)<\/p>/gi;
71
+ let match;
72
+ while ((match = regex.exec(text)) !== null) {
73
+ const length = this.decode(match[1].replace(/\s+/g, " ").trim()).length;
74
+ if (length <= MAX_LENGTH) {
75
+ continue;
76
+ }
77
+ const token = block[text.substring(0, match.index).split("\n").length - 1];
78
+ const message = `Shorttext must not exceed ${MAX_LENGTH} characters, found ${length}`;
79
+ issues.push(issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity));
80
+ }
81
+ return issues;
82
+ }
83
+ decode(text) {
84
+ return text.replace(/&(#\d+|#x[0-9a-fA-F]+|[a-zA-Z]+);/g, "_");
85
+ }
86
+ }
87
+ exports.AbapdocShorttextLength = AbapdocShorttextLength;
88
+ //# sourceMappingURL=abapdoc_shorttext_length.js.map
@@ -89,8 +89,28 @@ TEST-SEAMS: https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md
89
89
 
90
90
  BREAK points`,
91
91
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
92
- badExample: `DESCRIBE TABLE items LINES count.`,
93
- goodExample: `count = lines( items ).`,
92
+ badExample: `DEFINE _hello.
93
+ WRITE 'hello'.
94
+ END-OF-DEFINITION.
95
+
96
+ STATICS count TYPE i.
97
+
98
+ TYPES ty_items TYPE STANDARD TABLE OF i WITH DEFAULT KEY.
99
+
100
+ BREAK-POINT.
101
+
102
+ TEST-SEAM seam_name.
103
+ count = 1.
104
+ END-TEST-SEAM.
105
+
106
+ DESCRIBE TABLE items LINES count.
107
+
108
+ EXPORT data = items TO MEMORY ID 'ZFOO'.
109
+
110
+ EXPORT data = items TO DATABASE indx(zz) ID 'ZFOO'.`,
111
+ goodExample: `count = lines( items ).
112
+
113
+ TYPES ty_items TYPE STANDARD TABLE OF i WITH EMPTY KEY.`,
94
114
  };
95
115
  }
96
116
  getDescription(statement) {
@@ -19,6 +19,7 @@ __exportStar(require("./abapdoc"), exports);
19
19
  __exportStar(require("./abapdoc_html_tag"), exports);
20
20
  __exportStar(require("./abapdoc_leading_at"), exports);
21
21
  __exportStar(require("./abapdoc_parameter_names"), exports);
22
+ __exportStar(require("./abapdoc_shorttext_length"), exports);
22
23
  __exportStar(require("./add_test_attributes"), exports);
23
24
  __exportStar(require("./aff_and_xml"), exports);
24
25
  __exportStar(require("./alias_never_reassigned"), exports);
@@ -173,6 +174,7 @@ __exportStar(require("./prefer_pragmas"), exports);
173
174
  __exportStar(require("./prefer_abap_bool"), exports);
174
175
  __exportStar(require("./prefer_abap_bool_values"), exports);
175
176
  __exportStar(require("./prefer_raise_exception_new"), exports);
177
+ __exportStar(require("./prefer_raise_message"), exports);
176
178
  __exportStar(require("./prefer_string_template"), exports);
177
179
  __exportStar(require("./prefer_returning_to_exporting"), exports);
178
180
  __exportStar(require("./prefer_xsdbool"), exports);
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.PreferRaiseMessage = exports.PreferRaiseMessageConf = void 0;
37
+ const issue_1 = require("../issue");
38
+ const _abap_rule_1 = require("./_abap_rule");
39
+ const _basic_rule_config_1 = require("./_basic_rule_config");
40
+ const _irule_1 = require("./_irule");
41
+ const Statements = __importStar(require("../abap/2_statements/statements"));
42
+ const Expressions = __importStar(require("../abap/2_statements/expressions"));
43
+ class PreferRaiseMessageConf extends _basic_rule_config_1.BasicRuleConfig {
44
+ constructor() {
45
+ super(...arguments);
46
+ /** List of exception class names to ignore, case insensitive */
47
+ this.ignoreExceptionClasses = [];
48
+ }
49
+ }
50
+ exports.PreferRaiseMessageConf = PreferRaiseMessageConf;
51
+ class PreferRaiseMessage extends _abap_rule_1.ABAPRule {
52
+ constructor() {
53
+ super(...arguments);
54
+ this.conf = new PreferRaiseMessageConf();
55
+ }
56
+ getMetadata() {
57
+ return {
58
+ key: "prefer_raise_message",
59
+ title: "Prefer RAISE EXCEPTION with MESSAGE",
60
+ shortDescription: `Prefer RAISE EXCEPTION with MESSAGE instead of supplying parameter TEXT or TEXTID`,
61
+ extendedInformation: `Reports RAISE EXCEPTION statements where parameter TEXT or TEXTID is supplied.
62
+
63
+ Use a message class instead, so the text is translatable and can be found via where-used.
64
+
65
+ Exception classes can be excluded via configuration "ignoreExceptionClasses".`,
66
+ tags: [_irule_1.RuleTag.SingleFile],
67
+ goodExample: `RAISE EXCEPTION TYPE zcx_error MESSAGE e001(zclass).`,
68
+ badExample: `RAISE EXCEPTION TYPE zcx_error
69
+ EXPORTING text = 'hello world'.`,
70
+ };
71
+ }
72
+ getConfig() {
73
+ return this.conf;
74
+ }
75
+ setConfig(conf) {
76
+ this.conf = conf;
77
+ }
78
+ runParsed(file) {
79
+ var _a, _b, _c, _d;
80
+ var _e;
81
+ const issues = [];
82
+ const ignore = ((_e = this.conf.ignoreExceptionClasses) !== null && _e !== void 0 ? _e : []).map(c => c.toUpperCase());
83
+ for (const statement of file.getStatements()) {
84
+ if (!(statement.get() instanceof Statements.Raise)) {
85
+ continue;
86
+ }
87
+ const concat = statement.concatTokens().toUpperCase();
88
+ if (!concat.startsWith("RAISE EXCEPTION ") && !concat.startsWith("RAISE RESUMABLE EXCEPTION ")) {
89
+ continue;
90
+ }
91
+ else if (concat.includes(" MESSAGE")) {
92
+ continue;
93
+ }
94
+ let className;
95
+ let parameters;
96
+ const newObject = (_b = (_a = statement.findDirectExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.MethodCallChain)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(Expressions.NewObject);
97
+ if (newObject) {
98
+ className = (_c = newObject.findDirectExpression(Expressions.TypeNameOrInfer)) === null || _c === void 0 ? void 0 : _c.concatTokens();
99
+ parameters = newObject.findDirectExpression(Expressions.ParameterListS);
100
+ }
101
+ else {
102
+ className = (_d = statement.findDirectExpression(Expressions.ClassName)) === null || _d === void 0 ? void 0 : _d.concatTokens();
103
+ parameters = statement.findDirectExpression(Expressions.ParameterListS);
104
+ }
105
+ if (className === undefined || ignore.includes(className.toUpperCase())) {
106
+ continue;
107
+ }
108
+ const name = parameters === null || parameters === void 0 ? void 0 : parameters.findDirectExpressions(Expressions.ParameterS).map(p => { var _a; return (_a = p.findDirectExpression(Expressions.ParameterName)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase(); }).find(n => n === "TEXT" || n === "TEXTID");
109
+ if (name) {
110
+ const message = "Prefer RAISE EXCEPTION with MESSAGE, " + className + " raised with parameter " + name;
111
+ issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
112
+ }
113
+ }
114
+ return issues;
115
+ }
116
+ }
117
+ exports.PreferRaiseMessage = PreferRaiseMessage;
118
+ //# sourceMappingURL=prefer_raise_message.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.120.84",
3
+ "version": "2.120.86",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",