@abaplint/core 2.120.89 → 2.120.91

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.
@@ -73,6 +73,7 @@ class FieldChain {
73
73
  const children = node.getChildren();
74
74
  context = this.findTop(children[0], input, refType);
75
75
  let prev = children[0].concatTokens();
76
+ let afterTableExpression = false;
76
77
  for (let i = 1; i < children.length; i++) {
77
78
  const current = children[i];
78
79
  if (current === undefined) {
@@ -120,6 +121,9 @@ class FieldChain {
120
121
  }
121
122
  }
122
123
  else if (current.get() instanceof tokens_1.InstanceArrow) {
124
+ if (afterTableExpression && table_expression_1.TableExpression.checkArrowAfter(input, current.getFirstToken())) {
125
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
126
+ }
123
127
  if (!(context instanceof basic_1.ObjectReferenceType)
124
128
  && !(context instanceof basic_1.DataReference)
125
129
  && !(context instanceof basic_1.VoidType)) {
@@ -152,6 +156,7 @@ class FieldChain {
152
156
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
153
157
  }
154
158
  table_expression_1.TableExpression.runSyntax(current, input, context);
159
+ afterTableExpression = true;
155
160
  if (!(context instanceof basic_1.VoidType) && !(context instanceof basic_1.UnknownType)) {
156
161
  context = context.getRowType();
157
162
  }
@@ -46,6 +46,7 @@ const method_call_param_1 = require("./method_call_param");
46
46
  const _reference_1 = require("../_reference");
47
47
  const component_name_1 = require("./component_name");
48
48
  const attribute_name_1 = require("./attribute_name");
49
+ const table_expression_1 = require("./table_expression");
49
50
  const _syntax_input_1 = require("../_syntax_input");
50
51
  class MethodCallChain {
51
52
  static runSyntax(node, input, targetType) {
@@ -58,6 +59,13 @@ class MethodCallChain {
58
59
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
59
60
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
60
61
  }
62
+ // the field chain is followed by "->", eg. "itab[ 1 ]-ref->meth( )"
63
+ if (first instanceof nodes_1.ExpressionNode
64
+ && first.get() instanceof Expressions.FieldChain
65
+ && first.findDirectExpression(Expressions.TableExpression) !== undefined
66
+ && table_expression_1.TableExpression.checkArrowAfter(input, children[1].getFirstToken())) {
67
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
68
+ }
61
69
  let currentIndex = 1;
62
70
  let context = this.findTop(first, input, targetType);
63
71
  if (first.get() instanceof Expressions.MethodCall) {
@@ -88,6 +88,8 @@ class NewObject {
88
88
  }
89
89
  }
90
90
  else if (typeName === "#" && targetType) {
91
+ const tid = new _typed_identifier_1.TypedIdentifier(typeToken, input.filename, targetType);
92
+ input.scope.addReference(typeToken, tid, _reference_1.ReferenceType.InferredType, input.filename);
91
93
  ret = targetType;
92
94
  }
93
95
  else if (typeName === "#") {
@@ -37,9 +37,23 @@ exports.TableExpression = void 0;
37
37
  const nodes_1 = require("../../nodes");
38
38
  const Expressions = __importStar(require("../../2_statements/expressions"));
39
39
  const source_1 = require("./source");
40
+ const _syntax_input_1 = require("../_syntax_input");
40
41
  const basic_1 = require("../../types/basic");
41
42
  const component_chain_1 = require("./component_chain");
43
+ const version_1 = require("../../../version");
42
44
  class TableExpression {
45
+ /** below v750 the object component selector "->" cannot follow a table expression, eg. "itab[ 1 ]-ref->meth( )",
46
+ * returns true and adds an issue if not allowed */
47
+ static checkArrowAfter(input, arrow) {
48
+ if ((0, version_1.releaseAtLeast)(input.scope.getRelease(), version_1.Release.v750)
49
+ || input.scope.getLanguageVersion() === version_1.LanguageVersion.Cloud
50
+ || input.scope.getOpenABAP()) {
51
+ return false;
52
+ }
53
+ const message = "Object component selector \"->\" after table expression not possible below v750";
54
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, arrow, message));
55
+ return true;
56
+ }
43
57
  static runSyntax(node, input, rowType) {
44
58
  if (node === undefined) {
45
59
  return;
@@ -73,6 +73,7 @@ class Target {
73
73
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
74
74
  }
75
75
  let currentIndex = 1;
76
+ let afterTableExpression = false;
76
77
  while (currentIndex <= children.length) {
77
78
  const current = children[currentIndex];
78
79
  if (current === undefined) {
@@ -98,6 +99,9 @@ class Target {
98
99
  }
99
100
  }
100
101
  else if (current.get() instanceof tokens_1.InstanceArrow) {
102
+ if (afterTableExpression && table_expression_1.TableExpression.checkArrowAfter(input, current.getFirstToken())) {
103
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
104
+ }
101
105
  if (!(context instanceof basic_1.ObjectReferenceType)
102
106
  && !(context instanceof basic_1.DataReference)
103
107
  && !(context instanceof basic_1.VoidType)) {
@@ -146,6 +150,7 @@ class Target {
146
150
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
147
151
  }
148
152
  table_expression_1.TableExpression.runSyntax(current, input, context);
153
+ afterTableExpression = true;
149
154
  if (!(context instanceof basic_1.VoidType) && !(context instanceof unknown_type_1.UnknownType)) {
150
155
  context = context.getRowType();
151
156
  }
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DataDefinition = void 0;
4
+ const tokens_1 = require("../abap/1_lexer/tokens");
5
+ const combi_1 = require("../abap/2_statements/combi");
4
6
  const nodes_1 = require("../abap/nodes");
5
7
  const cds_determine_types_1 = require("../cds/cds_determine_types");
8
+ const cds_lexer_1 = require("../cds/cds_lexer");
9
+ const version_1 = require("../version");
6
10
  const cds_parser_1 = require("../cds/cds_parser");
7
11
  const expressions_1 = require("../cds/expressions");
8
12
  const _abstract_object_1 = require("./_abstract_object");
@@ -94,8 +98,8 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
94
98
  associations: [],
95
99
  tree: undefined,
96
100
  };
97
- this.findSQLViewName();
98
101
  this.parsedData.tree = new cds_parser_1.CDSParser().parse(this.findSourceFile());
102
+ this.findSQLViewName(this.parsedData.tree);
99
103
  if (this.parsedData.tree) {
100
104
  for (const c of ((_a = this.parsedData.tree) === null || _a === void 0 ? void 0 : _a.getChildren()) || []) {
101
105
  if (c.get() instanceof expressions_1.CDSAnnotation) {
@@ -120,11 +124,30 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
120
124
  return (_a = this.parsedData) === null || _a === void 0 ? void 0 : _a.tree;
121
125
  }
122
126
  //////////
123
- findSQLViewName() {
127
+ findSQLViewName(tree) {
124
128
  var _a;
125
- const match = (_a = this.findSourceFile()) === null || _a === void 0 ? void 0 : _a.getRaw().match(/@AbapCatalog\.sqlViewName: '([\w/]+)'/);
126
- if (match) {
127
- this.parsedData.sqlViewName = match[1].toUpperCase();
129
+ let annotations = tree === null || tree === void 0 ? void 0 : tree.findDirectExpressions(expressions_1.CDSAnnotation);
130
+ if (annotations === undefined) {
131
+ const file = this.findSourceFile();
132
+ if (file === undefined) {
133
+ return;
134
+ }
135
+ // Keep SQL view lookup available even when the view body cannot be parsed.
136
+ const tokens = cds_lexer_1.CDSLexer.run(file).filter(t => !(t instanceof tokens_1.Comment));
137
+ const leadingAnnotations = (0, combi_1.seq)((0, combi_1.starPrio)(expressions_1.CDSAnnotation), (0, combi_1.starPrio)((0, combi_1.regex)(/.*/)));
138
+ annotations = (_a = combi_1.Combi.run(leadingAnnotations, tokens, version_1.defaultRelease)) === null || _a === void 0 ? void 0 : _a.filter((n) => n instanceof nodes_1.ExpressionNode && n.get() instanceof expressions_1.CDSAnnotation);
139
+ }
140
+ for (const annotation of annotations || []) {
141
+ const tokens = annotation.getTokens().map(t => t.getStr());
142
+ const colon = tokens.indexOf(":");
143
+ if (tokens.slice(0, colon).join("") !== "@AbapCatalog.sqlViewName") {
144
+ continue;
145
+ }
146
+ const match = tokens.slice(colon + 1).join(" ").match(/^'([\w/]+)'$/);
147
+ if (match) {
148
+ this.parsedData.sqlViewName = match[1].toUpperCase();
149
+ return;
150
+ }
128
151
  }
129
152
  }
130
153
  findDescription() {
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.120.89";
78
+ return "2.120.91";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;
@@ -0,0 +1,133 @@
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.AbapdocShortLink = exports.AbapdocShortLinkConf = void 0;
37
+ const Statements = __importStar(require("../abap/2_statements/statements"));
38
+ const Expressions = __importStar(require("../abap/2_statements/expressions"));
39
+ const issue_1 = require("../issue");
40
+ const _abap_rule_1 = require("./_abap_rule");
41
+ const _basic_rule_config_1 = require("./_basic_rule_config");
42
+ const _irule_1 = require("./_irule");
43
+ const _statement_1 = require("../abap/2_statements/statements/_statement");
44
+ const position_1 = require("../position");
45
+ const edit_helper_1 = require("../edit_helper");
46
+ class AbapdocShortLinkConf extends _basic_rule_config_1.BasicRuleConfig {
47
+ }
48
+ exports.AbapdocShortLinkConf = AbapdocShortLinkConf;
49
+ class AbapdocShortLink extends _abap_rule_1.ABAPRule {
50
+ constructor() {
51
+ super(...arguments);
52
+ this.conf = new AbapdocShortLinkConf();
53
+ }
54
+ getMetadata() {
55
+ return {
56
+ key: "abapdoc_short_link",
57
+ title: "Use short form of ABAP Doc links",
58
+ shortDescription: `Reports ABAP Doc links to components of the current global class or interface which repeat the object name.`,
59
+ extendedInformation: `Links to components of the same repository object can omit the object name and start with a period,
60
+ {@link zif_foo.data:field} can be written as {@link .data:field}.
61
+
62
+ Only checks ABAP Doc inside the definition of the global class or interface.
63
+
64
+ https://github.com/SAP/abap-file-formats/issues/880`,
65
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
66
+ badExample: `INTERFACE zif_foo PUBLIC.
67
+ "! Same as {@link zif_foo.data:bar}
68
+ DATA foo TYPE string.
69
+ DATA bar TYPE string.
70
+ ENDINTERFACE.`,
71
+ goodExample: `INTERFACE zif_foo PUBLIC.
72
+ "! Same as {@link .data:bar}
73
+ DATA foo TYPE string.
74
+ DATA bar TYPE string.
75
+ ENDINTERFACE.`,
76
+ };
77
+ }
78
+ getConfig() {
79
+ return this.conf;
80
+ }
81
+ setConfig(conf) {
82
+ this.conf = conf;
83
+ }
84
+ runParsed(file, obj) {
85
+ var _a;
86
+ const issues = [];
87
+ const objectType = obj.getType();
88
+ if (objectType !== "CLAS" && objectType !== "INTF") {
89
+ return [];
90
+ }
91
+ const objectName = obj.getName().toLowerCase();
92
+ let definition = false;
93
+ for (const statement of file.getStatements()) {
94
+ const type = statement.get();
95
+ if (type instanceof Statements.ClassDefinition || type instanceof Statements.Interface) {
96
+ const name = (_a = statement.findFirstExpression(Expressions.ClassName)) !== null && _a !== void 0 ? _a : statement.findFirstExpression(Expressions.InterfaceName);
97
+ definition = (name === null || name === void 0 ? void 0 : name.getFirstToken().getStr().toLowerCase()) === objectName;
98
+ continue;
99
+ }
100
+ else if (type instanceof Statements.EndClass || type instanceof Statements.EndInterface) {
101
+ definition = false;
102
+ continue;
103
+ }
104
+ else if (definition === false || !(type instanceof _statement_1.Comment)) {
105
+ continue;
106
+ }
107
+ const token = statement.getFirstToken();
108
+ const str = token.getStr();
109
+ if (str.startsWith(`"!`) === false) {
110
+ continue;
111
+ }
112
+ const regex = /\{@link\s+((?:(\w+):)?([\w/]+))\./gi;
113
+ let match;
114
+ while ((match = regex.exec(str)) !== null) {
115
+ const kind = match[2];
116
+ if (match[3].toLowerCase() !== objectName
117
+ || (kind !== undefined && kind.toLowerCase() !== objectType.toLowerCase())) {
118
+ continue;
119
+ }
120
+ const row = token.getStart().getRow();
121
+ const col = token.getStart().getCol() + match.index + match[0].length - 1 - match[1].length;
122
+ const start = new position_1.Position(row, col);
123
+ const end = new position_1.Position(row, col + match[1].length);
124
+ const fix = edit_helper_1.EditHelper.deleteRange(file, start, end);
125
+ const message = `Use short form of ABAP Doc link, remove "${match[1]}"`;
126
+ issues.push(issue_1.Issue.atRange(file, start, end, message, this.getMetadata().key, this.conf.severity, fix));
127
+ }
128
+ }
129
+ return issues;
130
+ }
131
+ }
132
+ exports.AbapdocShortLink = AbapdocShortLink;
133
+ //# sourceMappingURL=abapdoc_short_link.js.map
@@ -3387,12 +3387,9 @@ ${indentation} output = ${uniqueName}.\n`;
3387
3387
  }
3388
3388
  }
3389
3389
  /** NEW into a data reference creates data, CREATE OBJECT cannot: "target = NEW #|type( [value] )"
3390
- * with a variable typed REF TO a data type becomes CREATE DATA plus the assignment of the value */
3390
+ * with a target typed REF TO a data type becomes CREATE DATA plus the assignment of the value */
3391
3391
  newDataReference(high, target, found, lowFile, highSyntax) {
3392
3392
  var _a, _b, _c;
3393
- if (target.getChildren().length !== 1 || !(((_a = target.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.TargetField)) {
3394
- return undefined;
3395
- }
3396
3393
  const children = found.getChildren();
3397
3394
  const value = found.findDirectExpression(Expressions.Source);
3398
3395
  // NEW, the type, "(", optionally one value, ")"
@@ -3400,12 +3397,23 @@ ${indentation} output = ${uniqueName}.\n`;
3400
3397
  return undefined;
3401
3398
  }
3402
3399
  const name = target.concatTokens();
3400
+ const typeExpr = found.findDirectExpression(Expressions.TypeNameOrInfer);
3401
+ const typeName = typeExpr === null || typeExpr === void 0 ? void 0 : typeExpr.concatTokens();
3403
3402
  const spag = highSyntax.spaghetti.lookupPosition(high.getFirstToken().getStart(), lowFile.getFilename());
3404
- const type = (_b = spag === null || spag === void 0 ? void 0 : spag.findVariable(name)) === null || _b === void 0 ? void 0 : _b.getType();
3403
+ let type = undefined;
3404
+ if (typeName === "#") {
3405
+ // the type of the target, as inferred by the syntax check
3406
+ const typeToken = typeExpr.getFirstToken();
3407
+ const resolved = (_a = spag === null || spag === void 0 ? void 0 : spag.getData().references.find(r => r.referenceType === _reference_1.ReferenceType.InferredType
3408
+ && r.position.getStart().equals(typeToken.getStart()))) === null || _a === void 0 ? void 0 : _a.resolved;
3409
+ type = resolved instanceof _typed_identifier_1.TypedIdentifier ? resolved.getType() : undefined;
3410
+ }
3411
+ else if (target.getChildren().length === 1 && ((_b = target.getFirstChild()) === null || _b === void 0 ? void 0 : _b.get()) instanceof Expressions.TargetField) {
3412
+ type = (_c = spag === null || spag === void 0 ? void 0 : spag.findVariable(name)) === null || _c === void 0 ? void 0 : _c.getType();
3413
+ }
3405
3414
  if (!(type instanceof basic_1.DataReference)) {
3406
3415
  return undefined;
3407
3416
  }
3408
- const typeName = (_c = found.findDirectExpression(Expressions.TypeNameOrInfer)) === null || _c === void 0 ? void 0 : _c.concatTokens();
3409
3417
  const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
3410
3418
  let abap = `CREATE DATA ${name}` + (typeName === "#" ? "" : ` TYPE ${typeName}`) + ".";
3411
3419
  if (value === undefined) {
@@ -3453,7 +3461,7 @@ ${indentation} output = ${uniqueName}.\n`;
3453
3461
  }
3454
3462
  }
3455
3463
  else {
3456
- throw new Error("newParameters, downport, unexpected");
3464
+ return undefined; // not an object, CREATE OBJECT does not apply
3457
3465
  }
3458
3466
  }
3459
3467
  if (cdef && cdef.getMethodDefinitions === undefined) {
@@ -0,0 +1,105 @@
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.ForbiddenKernelWrite = exports.ForbiddenKernelWriteConf = void 0;
37
+ const Expressions = __importStar(require("../abap/2_statements/expressions"));
38
+ const Statements = __importStar(require("../abap/2_statements/statements"));
39
+ const _abap_rule_1 = require("./_abap_rule");
40
+ const _basic_rule_config_1 = require("./_basic_rule_config");
41
+ const issue_1 = require("../issue");
42
+ const _irule_1 = require("./_irule");
43
+ class ForbiddenKernelWriteConf extends _basic_rule_config_1.BasicRuleConfig {
44
+ constructor() {
45
+ super(...arguments);
46
+ /** Objects allowed to use WRITE '@KERNEL', array of string regex matched against the object name.
47
+ * Empty, the default, allows every object
48
+ * @uniqueItems true
49
+ */
50
+ this.allow = [];
51
+ }
52
+ }
53
+ exports.ForbiddenKernelWriteConf = ForbiddenKernelWriteConf;
54
+ class ForbiddenKernelWrite extends _abap_rule_1.ABAPRule {
55
+ constructor() {
56
+ super(...arguments);
57
+ this.conf = new ForbiddenKernelWriteConf();
58
+ this.allow = [];
59
+ }
60
+ getMetadata() {
61
+ return {
62
+ key: "forbidden_kernel_write",
63
+ title: "Forbidden kernel WRITE",
64
+ shortDescription: `Forbid WRITE '@KERNEL' outside the listed objects`,
65
+ extendedInformation: `The transpiler emits the literal of WRITE '@KERNEL ...' as raw JavaScript,
66
+ which runs with the privileges of the host. Open-abap uses this for its kernel classes, code compiled by a host it did not write should not.
67
+
68
+ allow is a list of regex, case insensitive, matched against the object name, eg. ["^CL_", "^KERNEL_"].
69
+ An empty list, the default, allows every object. To forbid WRITE '@KERNEL' everywhere use a regex matching no name, eg. ["^$"].`,
70
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Security],
71
+ badExample: `WRITE '@KERNEL process.exit(1);'.`,
72
+ };
73
+ }
74
+ getConfig() {
75
+ return this.conf;
76
+ }
77
+ setConfig(conf) {
78
+ this.conf = conf;
79
+ if (this.conf.allow === undefined) {
80
+ this.conf.allow = [];
81
+ }
82
+ this.allow = this.conf.allow.map(a => new RegExp(a, "i"));
83
+ }
84
+ runParsed(file, obj) {
85
+ var _a;
86
+ if (this.allow.length === 0 || this.allow.some(a => a.test(obj.getName()))) {
87
+ return [];
88
+ }
89
+ const ret = [];
90
+ for (const s of file.getStatements()) {
91
+ if (!(s.get() instanceof Statements.Write)) {
92
+ continue;
93
+ }
94
+ // same check as the transpiler, statements/write.ts
95
+ const source = (_a = s.findDirectExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens();
96
+ if ((source === null || source === void 0 ? void 0 : source.startsWith("'@KERNEL ")) === true) {
97
+ const message = "WRITE '@KERNEL' not allowed in " + obj.getName();
98
+ ret.push(issue_1.Issue.atStatement(file, s, message, this.getMetadata().key, this.conf.severity));
99
+ }
100
+ }
101
+ return ret;
102
+ }
103
+ }
104
+ exports.ForbiddenKernelWrite = ForbiddenKernelWrite;
105
+ //# sourceMappingURL=forbidden_kernel_write.js.map
@@ -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_short_link"), exports);
22
23
  __exportStar(require("./abapdoc_shorttext_length"), exports);
23
24
  __exportStar(require("./add_test_attributes"), exports);
24
25
  __exportStar(require("./aff_and_xml"), exports);
@@ -93,6 +94,7 @@ __exportStar(require("./exporting"), exports);
93
94
  __exportStar(require("./final_newline"), exports);
94
95
  __exportStar(require("./fm_global_parameters_obsolete"), exports);
95
96
  __exportStar(require("./forbidden_identifier"), exports);
97
+ __exportStar(require("./forbidden_kernel_write"), exports);
96
98
  __exportStar(require("./forbidden_pseudo_and_pragma"), exports);
97
99
  __exportStar(require("./forbidden_void_type"), exports);
98
100
  __exportStar(require("./form_tables_obsolete"), exports);
@@ -69,6 +69,7 @@ class XMLConsistency {
69
69
  extendedInformation: `Checks:
70
70
  * XML is well-formed and parseable
71
71
  * Naming for CLAS and INTF objects
72
+ * CLAS and INTF objects do not contain fields that abapGit clears, eg. AUTHOR, CREATEDON and VERSION
72
73
  * QUAN fields in TABL objects have reference table and field values
73
74
  * Transparent TABL objects have delivery class and size category set
74
75
  * TABL fields with a built-in type carry the INTTYPE abapGit serializes for it, for the confirmed pairs
@@ -154,6 +155,22 @@ class XMLConsistency {
154
155
  else if (((_a = obj.getMainABAPFile()) === null || _a === void 0 ? void 0 : _a.getStructure()) !== undefined && obj.getClassDefinition() === undefined) {
155
156
  issues.push(issue_1.Issue.atRow(file, 1, "Class matching XML name not found in ABAP file", this.getMetadata().key, this.conf.severity));
156
157
  }
158
+ issues.push(...this.checkClearedFields(obj, file, "VSEOCLASS", XMLConsistency.clearedClassFields));
159
+ return issues;
160
+ }
161
+ checkClearedFields(obj, file, structure, fields) {
162
+ var _a, _b;
163
+ const issues = [];
164
+ const block = (_b = (_a = obj.getXML()) === null || _a === void 0 ? void 0 : _a.match(new RegExp(`<${structure}>([\\s\\S]*?)</${structure}>`))) === null || _b === void 0 ? void 0 : _b[1];
165
+ if (block === undefined) {
166
+ return issues;
167
+ }
168
+ for (const field of fields) {
169
+ if (block.match(new RegExp(`<${field}[\\s/>]`)) !== null) {
170
+ const message = `Field ${field} in ${structure} is cleared by abapGit and should not be in the XML`;
171
+ issues.push(issue_1.Issue.atRow(file, 1, message, this.getMetadata().key, this.conf.severity));
172
+ }
173
+ }
157
174
  return issues;
158
175
  }
159
176
  runTextPool(obj, file) {
@@ -187,6 +204,7 @@ class XMLConsistency {
187
204
  else if (obj.getDefinition() !== undefined && ((_a = obj.getDefinition()) === null || _a === void 0 ? void 0 : _a.getName().toUpperCase()) !== name.toUpperCase()) {
188
205
  issues.push(issue_1.Issue.atRow(file, 1, "Interface matching XML name not found in ABAP file", this.getMetadata().key, this.conf.severity));
189
206
  }
207
+ issues.push(...this.checkClearedFields(obj, file, "VSEOINTERF", XMLConsistency.clearedInterfaceFields));
190
208
  return issues;
191
209
  }
192
210
  checkTextLength(file, fieldName, text, maxLength, lang) {
@@ -367,6 +385,14 @@ class XMLConsistency {
367
385
  }
368
386
  }
369
387
  exports.XMLConsistency = XMLConsistency;
388
+ // fields abapGit clears before serializing, see ZCL_ABAPGIT_OO_CLASS and ZCL_ABAPGIT_OO_INTERFACE;
389
+ // abapGit omits initial fields, so any occurrence shows as a diff on every pull
390
+ XMLConsistency.clearedInterfaceFields = [
391
+ "UUID", "AUTHOR", "CREATEDON", "CHANGEDBY", "CHANGEDON", "CHGDANYBY", "CHGDANYON", "R3RELEASE", "VERSION",
392
+ ];
393
+ XMLConsistency.clearedClassFields = [
394
+ ...XMLConsistency.clearedInterfaceFields, "CLSFINAL", "CLSABSTRCT", "EXPOSURE",
395
+ ];
370
396
  // INTTYPE that abapGit serializes for a built-in DATATYPE, confirmed by exported tables;
371
397
  // a different value activates, but shows as a diff on every pull
372
398
  XMLConsistency.intTypes = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.120.89",
3
+ "version": "2.120.91",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",