@abaplint/core 2.120.88 → 2.120.90

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.
@@ -5608,7 +5608,7 @@ declare type ParsedDataDefinition = {
5608
5608
  sqlViewName: string | undefined;
5609
5609
  definitionName: string | undefined;
5610
5610
  description: string | undefined;
5611
- /** name is the name of the element, nameInSource the name in the prefixed source, if aliased via "as" */
5611
+ /** name is the name of the element, nameInSource the name in the source, if aliased via "as" */
5612
5612
  fields: {
5613
5613
  key: boolean;
5614
5614
  name: string;
@@ -599,6 +599,15 @@ class TypeUtils {
599
599
  }
600
600
  return this.isAssignable(source, target);
601
601
  }
602
+ // character-like arguments of built-in functions must be elementary, flat character-like structures are not allowed
603
+ isAssignableBuiltin(source, target, node) {
604
+ if (target instanceof basic_1.CLikeType
605
+ && (source instanceof basic_1.StructureType
606
+ || (source instanceof basic_1.TableType && source.isWithHeader() && source.getRowType() instanceof basic_1.StructureType))) {
607
+ return false;
608
+ }
609
+ return this.isAssignableStrict(source, target, node);
610
+ }
602
611
  // Typing with the classic STRUCTURE addition, ie. "FORM foo USING bar STRUCTURE zkey",
603
612
  // is not a compatibility check: ABAP only checks the fragment view up to the end of the
604
613
  // formal structure, so the actual parameter is allowed to be longer. For TABLES parameters
@@ -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) {
@@ -45,6 +45,7 @@ const _syntax_input_1 = require("../_syntax_input");
45
45
  const constant_1 = require("./constant");
46
46
  const _check_offset_length_1 = require("./_check_offset_length");
47
47
  const _check_text_symbol_1 = require("./_check_text_symbol");
48
+ const _builtin_1 = require("../_builtin");
48
49
  class MethodCallParam {
49
50
  /** returns the type of the unnamed argument, if any */
50
51
  static runSyntax(node, input, method) {
@@ -121,7 +122,7 @@ class MethodCallParam {
121
122
  else if ((0, _check_text_symbol_1.checkTextSymbol)(child, targetType, input)) {
122
123
  return;
123
124
  }
124
- else if (new _type_utils_1.TypeUtils(input.scope).isAssignableStrict(sourceType, targetType, child) === false) {
125
+ else if (this.isAssignable(sourceType, targetType, child, method, input) === false) {
125
126
  const message = "Method parameter type not compatible";
126
127
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
127
128
  return;
@@ -141,6 +142,12 @@ class MethodCallParam {
141
142
  }
142
143
  return undefined;
143
144
  }
145
+ static isAssignable(sourceType, targetType, child, method, input) {
146
+ const typeUtils = new _type_utils_1.TypeUtils(input.scope);
147
+ return method instanceof _builtin_1.BuiltInMethod
148
+ ? typeUtils.isAssignableBuiltin(sourceType, targetType, child)
149
+ : typeUtils.isAssignableStrict(sourceType, targetType, child);
150
+ }
144
151
  }
145
152
  exports.MethodCallParam = MethodCallParam;
146
153
  //# sourceMappingURL=method_call_param.js.map
@@ -47,6 +47,7 @@ const field_chain_1 = require("./field_chain");
47
47
  const _reference_1 = require("../_reference");
48
48
  const _check_offset_length_1 = require("./_check_offset_length");
49
49
  const _check_text_symbol_1 = require("./_check_text_symbol");
50
+ const _builtin_1 = require("../_builtin");
50
51
  function normalizeParameterName(name) {
51
52
  return name.replace(/^!/, "").toUpperCase();
52
53
  }
@@ -194,6 +195,10 @@ class MethodParameters {
194
195
  if (this.requiredParameters === undefined) {
195
196
  this.requiredParameters = new Set(method.getParameters().getRequiredParameters().map(i => i.getName().toUpperCase()));
196
197
  }
198
+ const typeUtils = new _type_utils_1.TypeUtils(input.scope);
199
+ const assignable = method instanceof _builtin_1.BuiltInMethod
200
+ ? typeUtils.isAssignableBuiltin.bind(typeUtils)
201
+ : typeUtils.isAssignableStrict.bind(typeUtils);
197
202
  for (const item of items) {
198
203
  const parameter = allImporting.find(p => p.getName().toUpperCase() === item.name);
199
204
  if (parameter === undefined) {
@@ -204,7 +209,7 @@ class MethodParameters {
204
209
  else if ((0, _check_text_symbol_1.checkTextSymbol)(item.source, parameter.getType(), input)) {
205
210
  return;
206
211
  }
207
- else if (new _type_utils_1.TypeUtils(input.scope).isAssignableStrict(item.sourceType, parameter.getType(), item.source) === false) {
212
+ else if (assignable(item.sourceType, parameter.getType(), item.source) === false) {
208
213
  const message = "Method parameter type not compatible, " + item.name;
209
214
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
210
215
  return;
@@ -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
  }
@@ -5,7 +5,7 @@ const basic_1 = require("../abap/types/basic");
5
5
  const ddic_1 = require("../ddic");
6
6
  class CDSDetermineTypes {
7
7
  parseType(reg, parsedData, ddlsName) {
8
- var _a;
8
+ var _a, _b;
9
9
  const ddic = new ddic_1.DDIC(reg);
10
10
  if ((parsedData === null || parsedData === void 0 ? void 0 : parsedData.fields.length) === 0) {
11
11
  return basic_1.VoidType.get("DDLS:todo");
@@ -84,13 +84,29 @@ class CDSDetermineTypes {
84
84
  else {
85
85
  components.push({
86
86
  name: f.name,
87
- type: basic_1.VoidType.get("DDLS:fieldname:" + ddlsName),
87
+ type: (_b = this.findInSources(ddic, parsedData, f.nameInSource)) !== null && _b !== void 0 ? _b : basic_1.VoidType.get("DDLS:fieldname:" + ddlsName),
88
88
  });
89
89
  }
90
90
  }
91
91
  return new basic_1.StructureType(components, parsedData.definitionName, parsedData.definitionName, parsedData.description);
92
92
  }
93
93
  }
94
+ /** unprefixed field, take the type from the first source containing it, void or unknown sources are skipped */
95
+ findInSources(ddic, parsedData, nameInSource) {
96
+ if (nameInSource === undefined) {
97
+ return undefined;
98
+ }
99
+ for (const source of parsedData.sources) {
100
+ const lookup = ddic.lookupTableOrView(source.name);
101
+ if (lookup.type instanceof basic_1.StructureType) {
102
+ const type = lookup.type.getComponentByName(nameInSource);
103
+ if (type) {
104
+ return type;
105
+ }
106
+ }
107
+ }
108
+ return undefined;
109
+ }
94
110
  }
95
111
  exports.CDSDetermineTypes = CDSDetermineTypes;
96
112
  //# sourceMappingURL=cds_determine_types.js.map
@@ -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() {
@@ -150,12 +173,16 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
150
173
  let found = (_a = e.findDirectExpression(expressions_1.CDSAs)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(expressions_1.CDSName);
151
174
  const list = (_b = e.findDirectExpression(expressions_1.CDSPrefixedName)) === null || _b === void 0 ? void 0 : _b.findAllExpressions(expressions_1.CDSName);
152
175
  if (list !== undefined) {
153
- const redirected = list.length > 1 && e.concatTokens().toUpperCase().includes(" REDIRECTED TO ");
176
+ const redirected = e.concatTokens().toUpperCase().includes(" REDIRECTED TO ");
154
177
  if (list.length > 1 && redirected === false) {
155
178
  // "prefix.field" is looked up as "field" in "prefix", also when aliased via "as"
156
179
  prefix = list[0].concatTokens();
157
180
  nameInSource = list[list.length - 1].concatTokens();
158
181
  }
182
+ else if (list.length === 1 && redirected === false) {
183
+ // unprefixed "field" is looked up in the sources, also when aliased via "as"
184
+ nameInSource = list[0].concatTokens();
185
+ }
159
186
  if (found === undefined) {
160
187
  found = redirected === true ? list[0] : list[list.length - 1];
161
188
  }
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.120.88";
78
+ return "2.120.90";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;
@@ -94,7 +94,7 @@ class PreferStringTemplate extends _abap_rule_1.ABAPRule {
94
94
  continue;
95
95
  }
96
96
  const operands = this.flattenChain(source);
97
- if (!operands.some(op => { const c = op.getFirstToken().getStr()[0]; return c === "'" || c === "`"; })) {
97
+ if (!operands.some(op => this.isLiteral(op))) {
98
98
  continue;
99
99
  }
100
100
  const template = this.buildTemplate(operands);
@@ -119,10 +119,11 @@ class PreferStringTemplate extends _abap_rule_1.ABAPRule {
119
119
  buildTemplate(operands) {
120
120
  let inner = "";
121
121
  for (const op of operands) {
122
- const raw = op.getFirstToken().getStr();
123
- const firstChar = raw[0];
124
- if (firstChar === "'" || firstChar === "`") {
125
- inner += raw.slice(1, -1);
122
+ if (this.isLiteral(op)) {
123
+ const raw = op.getFirstToken().getStr();
124
+ const delimiter = raw[0];
125
+ const value = raw.slice(1, -1).split(delimiter + delimiter).join(delimiter);
126
+ inner += value.replace(/[\\|{}]/g, "\\$&");
126
127
  }
127
128
  else {
128
129
  inner += `{ ${op.concatTokens()} }`;
@@ -130,6 +131,14 @@ class PreferStringTemplate extends _abap_rule_1.ABAPRule {
130
131
  }
131
132
  return `|${inner}|`;
132
133
  }
134
+ // plain character or string literal, ie. not text symbols or concatenated constants
135
+ isLiteral(op) {
136
+ if (op.getFirstToken() !== op.getLastToken()) {
137
+ return false;
138
+ }
139
+ const firstChar = op.getFirstToken().getStr()[0];
140
+ return firstChar === "'" || firstChar === "`";
141
+ }
133
142
  }
134
143
  exports.PreferStringTemplate = PreferStringTemplate;
135
144
  //# sourceMappingURL=prefer_string_template.js.map
@@ -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.88",
3
+ "version": "2.120.90",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",