@abaplint/cli 2.120.88 → 2.120.89

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.
Files changed (2) hide show
  1. package/build/cli.js +61 -11
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -28511,6 +28511,15 @@ class TypeUtils {
28511
28511
  }
28512
28512
  return this.isAssignable(source, target);
28513
28513
  }
28514
+ // character-like arguments of built-in functions must be elementary, flat character-like structures are not allowed
28515
+ isAssignableBuiltin(source, target, node) {
28516
+ if (target instanceof basic_1.CLikeType
28517
+ && (source instanceof basic_1.StructureType
28518
+ || (source instanceof basic_1.TableType && source.isWithHeader() && source.getRowType() instanceof basic_1.StructureType))) {
28519
+ return false;
28520
+ }
28521
+ return this.isAssignableStrict(source, target, node);
28522
+ }
28514
28523
  // Typing with the classic STRUCTURE addition, ie. "FORM foo USING bar STRUCTURE zkey",
28515
28524
  // is not a compatibility check: ABAP only checks the fragment view up to the end of the
28516
28525
  // formal structure, so the actual parameter is allowed to be longer. For TABLES parameters
@@ -33800,6 +33809,7 @@ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/bui
33800
33809
  const constant_1 = __webpack_require__(/*! ./constant */ "../core/build/src/abap/5_syntax/expressions/constant.js");
33801
33810
  const _check_offset_length_1 = __webpack_require__(/*! ./_check_offset_length */ "../core/build/src/abap/5_syntax/expressions/_check_offset_length.js");
33802
33811
  const _check_text_symbol_1 = __webpack_require__(/*! ./_check_text_symbol */ "../core/build/src/abap/5_syntax/expressions/_check_text_symbol.js");
33812
+ const _builtin_1 = __webpack_require__(/*! ../_builtin */ "../core/build/src/abap/5_syntax/_builtin.js");
33803
33813
  class MethodCallParam {
33804
33814
  /** returns the type of the unnamed argument, if any */
33805
33815
  static runSyntax(node, input, method) {
@@ -33876,7 +33886,7 @@ class MethodCallParam {
33876
33886
  else if ((0, _check_text_symbol_1.checkTextSymbol)(child, targetType, input)) {
33877
33887
  return;
33878
33888
  }
33879
- else if (new _type_utils_1.TypeUtils(input.scope).isAssignableStrict(sourceType, targetType, child) === false) {
33889
+ else if (this.isAssignable(sourceType, targetType, child, method, input) === false) {
33880
33890
  const message = "Method parameter type not compatible";
33881
33891
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
33882
33892
  return;
@@ -33896,6 +33906,12 @@ class MethodCallParam {
33896
33906
  }
33897
33907
  return undefined;
33898
33908
  }
33909
+ static isAssignable(sourceType, targetType, child, method, input) {
33910
+ const typeUtils = new _type_utils_1.TypeUtils(input.scope);
33911
+ return method instanceof _builtin_1.BuiltInMethod
33912
+ ? typeUtils.isAssignableBuiltin(sourceType, targetType, child)
33913
+ : typeUtils.isAssignableStrict(sourceType, targetType, child);
33914
+ }
33899
33915
  }
33900
33916
  exports.MethodCallParam = MethodCallParam;
33901
33917
  //# sourceMappingURL=method_call_param.js.map
@@ -34133,6 +34149,7 @@ const field_chain_1 = __webpack_require__(/*! ./field_chain */ "../core/build/sr
34133
34149
  const _reference_1 = __webpack_require__(/*! ../_reference */ "../core/build/src/abap/5_syntax/_reference.js");
34134
34150
  const _check_offset_length_1 = __webpack_require__(/*! ./_check_offset_length */ "../core/build/src/abap/5_syntax/expressions/_check_offset_length.js");
34135
34151
  const _check_text_symbol_1 = __webpack_require__(/*! ./_check_text_symbol */ "../core/build/src/abap/5_syntax/expressions/_check_text_symbol.js");
34152
+ const _builtin_1 = __webpack_require__(/*! ../_builtin */ "../core/build/src/abap/5_syntax/_builtin.js");
34136
34153
  function normalizeParameterName(name) {
34137
34154
  return name.replace(/^!/, "").toUpperCase();
34138
34155
  }
@@ -34280,6 +34297,10 @@ class MethodParameters {
34280
34297
  if (this.requiredParameters === undefined) {
34281
34298
  this.requiredParameters = new Set(method.getParameters().getRequiredParameters().map(i => i.getName().toUpperCase()));
34282
34299
  }
34300
+ const typeUtils = new _type_utils_1.TypeUtils(input.scope);
34301
+ const assignable = method instanceof _builtin_1.BuiltInMethod
34302
+ ? typeUtils.isAssignableBuiltin.bind(typeUtils)
34303
+ : typeUtils.isAssignableStrict.bind(typeUtils);
34283
34304
  for (const item of items) {
34284
34305
  const parameter = allImporting.find(p => p.getName().toUpperCase() === item.name);
34285
34306
  if (parameter === undefined) {
@@ -34290,7 +34311,7 @@ class MethodParameters {
34290
34311
  else if ((0, _check_text_symbol_1.checkTextSymbol)(item.source, parameter.getType(), input)) {
34291
34312
  return;
34292
34313
  }
34293
- else if (new _type_utils_1.TypeUtils(input.scope).isAssignableStrict(item.sourceType, parameter.getType(), item.source) === false) {
34314
+ else if (assignable(item.sourceType, parameter.getType(), item.source) === false) {
34294
34315
  const message = "Method parameter type not compatible, " + item.name;
34295
34316
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
34296
34317
  return;
@@ -56693,7 +56714,7 @@ const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "../core/build/sr
56693
56714
  const ddic_1 = __webpack_require__(/*! ../ddic */ "../core/build/src/ddic.js");
56694
56715
  class CDSDetermineTypes {
56695
56716
  parseType(reg, parsedData, ddlsName) {
56696
- var _a;
56717
+ var _a, _b;
56697
56718
  const ddic = new ddic_1.DDIC(reg);
56698
56719
  if ((parsedData === null || parsedData === void 0 ? void 0 : parsedData.fields.length) === 0) {
56699
56720
  return basic_1.VoidType.get("DDLS:todo");
@@ -56772,13 +56793,29 @@ class CDSDetermineTypes {
56772
56793
  else {
56773
56794
  components.push({
56774
56795
  name: f.name,
56775
- type: basic_1.VoidType.get("DDLS:fieldname:" + ddlsName),
56796
+ type: (_b = this.findInSources(ddic, parsedData, f.nameInSource)) !== null && _b !== void 0 ? _b : basic_1.VoidType.get("DDLS:fieldname:" + ddlsName),
56776
56797
  });
56777
56798
  }
56778
56799
  }
56779
56800
  return new basic_1.StructureType(components, parsedData.definitionName, parsedData.definitionName, parsedData.description);
56780
56801
  }
56781
56802
  }
56803
+ /** unprefixed field, take the type from the first source containing it, void or unknown sources are skipped */
56804
+ findInSources(ddic, parsedData, nameInSource) {
56805
+ if (nameInSource === undefined) {
56806
+ return undefined;
56807
+ }
56808
+ for (const source of parsedData.sources) {
56809
+ const lookup = ddic.lookupTableOrView(source.name);
56810
+ if (lookup.type instanceof basic_1.StructureType) {
56811
+ const type = lookup.type.getComponentByName(nameInSource);
56812
+ if (type) {
56813
+ return type;
56814
+ }
56815
+ }
56816
+ }
56817
+ return undefined;
56818
+ }
56782
56819
  }
56783
56820
  exports.CDSDetermineTypes = CDSDetermineTypes;
56784
56821
  //# sourceMappingURL=cds_determine_types.js.map
@@ -65493,12 +65530,16 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
65493
65530
  let found = (_a = e.findDirectExpression(expressions_1.CDSAs)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(expressions_1.CDSName);
65494
65531
  const list = (_b = e.findDirectExpression(expressions_1.CDSPrefixedName)) === null || _b === void 0 ? void 0 : _b.findAllExpressions(expressions_1.CDSName);
65495
65532
  if (list !== undefined) {
65496
- const redirected = list.length > 1 && e.concatTokens().toUpperCase().includes(" REDIRECTED TO ");
65533
+ const redirected = e.concatTokens().toUpperCase().includes(" REDIRECTED TO ");
65497
65534
  if (list.length > 1 && redirected === false) {
65498
65535
  // "prefix.field" is looked up as "field" in "prefix", also when aliased via "as"
65499
65536
  prefix = list[0].concatTokens();
65500
65537
  nameInSource = list[list.length - 1].concatTokens();
65501
65538
  }
65539
+ else if (list.length === 1 && redirected === false) {
65540
+ // unprefixed "field" is looked up in the sources, also when aliased via "as"
65541
+ nameInSource = list[0].concatTokens();
65542
+ }
65502
65543
  if (found === undefined) {
65503
65544
  found = redirected === true ? list[0] : list[list.length - 1];
65504
65545
  }
@@ -72681,7 +72722,7 @@ class Registry {
72681
72722
  }
72682
72723
  static abaplintVersion() {
72683
72724
  // magic, see build script "version.js"
72684
- return "2.120.88";
72725
+ return "2.120.89";
72685
72726
  }
72686
72727
  getDDICReferences() {
72687
72728
  return this.ddicReferences;
@@ -101943,7 +101984,7 @@ class PreferStringTemplate extends _abap_rule_1.ABAPRule {
101943
101984
  continue;
101944
101985
  }
101945
101986
  const operands = this.flattenChain(source);
101946
- if (!operands.some(op => { const c = op.getFirstToken().getStr()[0]; return c === "'" || c === "`"; })) {
101987
+ if (!operands.some(op => this.isLiteral(op))) {
101947
101988
  continue;
101948
101989
  }
101949
101990
  const template = this.buildTemplate(operands);
@@ -101968,10 +102009,11 @@ class PreferStringTemplate extends _abap_rule_1.ABAPRule {
101968
102009
  buildTemplate(operands) {
101969
102010
  let inner = "";
101970
102011
  for (const op of operands) {
101971
- const raw = op.getFirstToken().getStr();
101972
- const firstChar = raw[0];
101973
- if (firstChar === "'" || firstChar === "`") {
101974
- inner += raw.slice(1, -1);
102012
+ if (this.isLiteral(op)) {
102013
+ const raw = op.getFirstToken().getStr();
102014
+ const delimiter = raw[0];
102015
+ const value = raw.slice(1, -1).split(delimiter + delimiter).join(delimiter);
102016
+ inner += value.replace(/[\\|{}]/g, "\\$&");
101975
102017
  }
101976
102018
  else {
101977
102019
  inner += `{ ${op.concatTokens()} }`;
@@ -101979,6 +102021,14 @@ class PreferStringTemplate extends _abap_rule_1.ABAPRule {
101979
102021
  }
101980
102022
  return `|${inner}|`;
101981
102023
  }
102024
+ // plain character or string literal, ie. not text symbols or concatenated constants
102025
+ isLiteral(op) {
102026
+ if (op.getFirstToken() !== op.getLastToken()) {
102027
+ return false;
102028
+ }
102029
+ const firstChar = op.getFirstToken().getStr()[0];
102030
+ return firstChar === "'" || firstChar === "`";
102031
+ }
101982
102032
  }
101983
102033
  exports.PreferStringTemplate = PreferStringTemplate;
101984
102034
  //# sourceMappingURL=prefer_string_template.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.120.88",
3
+ "version": "2.120.89",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "homepage": "https://abaplint.org",
41
41
  "devDependencies": {
42
- "@abaplint/core": "^2.120.88",
42
+ "@abaplint/core": "^2.120.89",
43
43
  "@types/chai": "^4.3.20",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.10",