@abaplint/cli 2.120.99 → 2.120.101

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 +465 -34
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -27839,6 +27839,167 @@ exports.Procedural = Procedural;
27839
27839
 
27840
27840
  /***/ },
27841
27841
 
27842
+ /***/ "../core/build/src/abap/5_syntax/_raise_message.js"
27843
+ /*!*********************************************************!*\
27844
+ !*** ../core/build/src/abap/5_syntax/_raise_message.js ***!
27845
+ \*********************************************************/
27846
+ (__unused_webpack_module, exports, __webpack_require__) {
27847
+
27848
+ "use strict";
27849
+
27850
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
27851
+ if (k2 === undefined) k2 = k;
27852
+ var desc = Object.getOwnPropertyDescriptor(m, k);
27853
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
27854
+ desc = { enumerable: true, get: function() { return m[k]; } };
27855
+ }
27856
+ Object.defineProperty(o, k2, desc);
27857
+ }) : (function(o, m, k, k2) {
27858
+ if (k2 === undefined) k2 = k;
27859
+ o[k2] = m[k];
27860
+ }));
27861
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
27862
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
27863
+ }) : function(o, v) {
27864
+ o["default"] = v;
27865
+ });
27866
+ var __importStar = (this && this.__importStar) || (function () {
27867
+ var ownKeys = function(o) {
27868
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27869
+ var ar = [];
27870
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27871
+ return ar;
27872
+ };
27873
+ return ownKeys(o);
27874
+ };
27875
+ return function (mod) {
27876
+ if (mod && mod.__esModule) return mod;
27877
+ var result = {};
27878
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
27879
+ __setModuleDefault(result, mod);
27880
+ return result;
27881
+ };
27882
+ })();
27883
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
27884
+ exports.RaiseMessage = void 0;
27885
+ const Expressions = __importStar(__webpack_require__(/*! ../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
27886
+ const nodes_1 = __webpack_require__(/*! ../nodes */ "../core/build/src/abap/nodes/index.js");
27887
+ const _syntax_input_1 = __webpack_require__(/*! ./_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
27888
+ const T100_INTERFACES = new Set(["IF_T100_MESSAGE", "IF_T100_DYN_MSG"]);
27889
+ // the root exception classes, they implement IF_MESSAGE and IF_SERIALIZABLE_OBJECT, but not the T100 interfaces
27890
+ const ROOT_EXCEPTIONS = new Set(["CX_ROOT", "CX_STATIC_CHECK", "CX_DYNAMIC_CHECK", "CX_NO_CHECK"]);
27891
+ /** RAISE EXCEPTION TYPE cx MESSAGE ... and THROW cx( MESSAGE ... ) require the exception class to implement
27892
+ * IF_T100_MESSAGE or IF_T100_DYN_MSG, and with RAISE EXCEPTION the constructor parameter TEXTID cannot be
27893
+ * passed in addition to MESSAGE, see the ABAP keyword documentation for RAISE EXCEPTION, MESSAGE.
27894
+ * The interface check only reports when the full class hierarchy is known, void classes and void interfaces
27895
+ * in the hierarchy are skipped, except for the root exception classes. */
27896
+ class RaiseMessage {
27897
+ static checkRaise(node, input) {
27898
+ var _a, _b, _c;
27899
+ var _d;
27900
+ const classTok = (_a = node.findDirectExpression(Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
27901
+ if (classTok === undefined || RaiseMessage.hasMessage(node) === false) {
27902
+ return;
27903
+ }
27904
+ for (const p of (_d = (_b = node.findDirectExpression(Expressions.ParameterListS)) === null || _b === void 0 ? void 0 : _b.findDirectExpressions(Expressions.ParameterS)) !== null && _d !== void 0 ? _d : []) {
27905
+ const name = (_c = p.findDirectExpression(Expressions.ParameterName)) === null || _c === void 0 ? void 0 : _c.getFirstToken();
27906
+ if ((name === null || name === void 0 ? void 0 : name.getStr().toUpperCase()) === "TEXTID") {
27907
+ const message = "RAISE EXCEPTION with MESSAGE, TEXTID cannot be passed";
27908
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, name, message));
27909
+ return;
27910
+ }
27911
+ }
27912
+ RaiseMessage.checkClass(classTok.getStr(), input, classTok);
27913
+ }
27914
+ static checkThrow(node, input) {
27915
+ var _a;
27916
+ const classTok = (_a = node.findDirectExpression(Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
27917
+ if (classTok === undefined || node.findDirectExpression(Expressions.MessageSource) === undefined) {
27918
+ return;
27919
+ }
27920
+ RaiseMessage.checkClass(classTok.getStr(), input, classTok);
27921
+ }
27922
+ /** MESSAGE msg or MESSAGE ID, but not USING MESSAGE */
27923
+ static hasMessage(node) {
27924
+ const children = node.getChildren();
27925
+ for (let i = 0; i < children.length; i++) {
27926
+ const c = children[i];
27927
+ if (c instanceof nodes_1.TokenNode && c.getFirstToken().getStr().toUpperCase() === "MESSAGE") {
27928
+ const previous = children[i - 1];
27929
+ if (previous === undefined || previous.getFirstToken().getStr().toUpperCase() !== "USING") {
27930
+ return true;
27931
+ }
27932
+ }
27933
+ }
27934
+ return false;
27935
+ }
27936
+ static checkClass(className, input, classTok) {
27937
+ const def = input.scope.findClassDefinition(className);
27938
+ if (def === undefined) {
27939
+ return;
27940
+ }
27941
+ if (RaiseMessage.isT100(def, input.scope, new Set()) === false) {
27942
+ const message = "Exception class " + def.getName().toUpperCase() +
27943
+ " must implement IF_T100_MESSAGE or IF_T100_DYN_MSG to be raised with MESSAGE";
27944
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, classTok, message));
27945
+ }
27946
+ }
27947
+ /** true or false when known, undefined when the hierarchy contains void parts */
27948
+ static isT100(def, scope, visited) {
27949
+ var _a;
27950
+ const upper = def.getName().toUpperCase();
27951
+ if (visited.has(upper)) {
27952
+ return undefined;
27953
+ }
27954
+ visited.add(upper);
27955
+ let unknown = false;
27956
+ const interfaces = def.getImplementing().map(i => i.name.toUpperCase());
27957
+ const seen = new Set();
27958
+ while (interfaces.length > 0) {
27959
+ const name = interfaces.pop();
27960
+ if (seen.has(name)) {
27961
+ continue;
27962
+ }
27963
+ seen.add(name);
27964
+ if (T100_INTERFACES.has(name)) {
27965
+ return true;
27966
+ }
27967
+ const idef = scope.findInterfaceDefinition(name);
27968
+ if (idef === undefined) {
27969
+ unknown = true;
27970
+ }
27971
+ else {
27972
+ interfaces.push(...idef.getImplementing().map(i => i.name.toUpperCase()));
27973
+ }
27974
+ }
27975
+ const superName = (_a = def.getSuperClass()) === null || _a === void 0 ? void 0 : _a.toUpperCase();
27976
+ if (superName !== undefined) {
27977
+ const superDef = scope.findClassDefinition(superName);
27978
+ if (superDef !== undefined) {
27979
+ const res = RaiseMessage.isT100(superDef, scope, visited);
27980
+ if (res === true) {
27981
+ return true;
27982
+ }
27983
+ else if (res === undefined) {
27984
+ unknown = true;
27985
+ }
27986
+ }
27987
+ else if (ROOT_EXCEPTIONS.has(superName) === false) {
27988
+ unknown = true;
27989
+ }
27990
+ }
27991
+ else if (ROOT_EXCEPTIONS.has(upper) === false) {
27992
+ // not an exception class, reported elsewhere or not at all
27993
+ unknown = true;
27994
+ }
27995
+ return unknown ? undefined : false;
27996
+ }
27997
+ }
27998
+ exports.RaiseMessage = RaiseMessage;
27999
+ //# sourceMappingURL=_raise_message.js.map
28000
+
28001
+ /***/ },
28002
+
27842
28003
  /***/ "../core/build/src/abap/5_syntax/_reference.js"
27843
28004
  /*!*****************************************************!*\
27844
28005
  !*** ../core/build/src/abap/5_syntax/_reference.js ***!
@@ -30618,7 +30779,14 @@ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/bui
30618
30779
  // a syntax error. Other types, a dynamic offset or length and "*" (undefined) are left alone, as is
30619
30780
  // length 0. The offset is applied first, so the length is compared to what remains after the offset.
30620
30781
  // A substring of a date, time or numeric text field has type n; its bounds are not checked.
30782
+ // An offset or length on a numeric field (i, int8, p, f, decfloat) is a syntax error, whatever its value.
30621
30783
  function substringType(context, offset, length, node, input) {
30784
+ const numericName = numericTypeName(context);
30785
+ if (numericName !== undefined) {
30786
+ const message = `Offset or length specification not possible on a field of numeric type "${numericName}"`;
30787
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
30788
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
30789
+ }
30622
30790
  if (context instanceof basic_1.DateType || context instanceof basic_1.TimeType || context instanceof basic_1.NumericType) {
30623
30791
  return numericSubstringType(context, offset, length);
30624
30792
  }
@@ -30644,6 +30812,30 @@ function substringType(context, offset, length, node, input) {
30644
30812
  }
30645
30813
  return context;
30646
30814
  }
30815
+ function numericTypeName(context) {
30816
+ if (context instanceof basic_1.IntegerType) {
30817
+ return "I";
30818
+ }
30819
+ else if (context instanceof basic_1.Integer8Type) {
30820
+ return "INT8";
30821
+ }
30822
+ else if (context instanceof basic_1.PackedType) {
30823
+ return "P";
30824
+ }
30825
+ else if (context instanceof basic_1.FloatType || context instanceof basic_1.FloatingPointType) {
30826
+ return "F";
30827
+ }
30828
+ else if (context instanceof basic_1.DecFloat16Type) {
30829
+ return "DECFLOAT16";
30830
+ }
30831
+ else if (context instanceof basic_1.DecFloat34Type) {
30832
+ return "DECFLOAT34";
30833
+ }
30834
+ else if (context instanceof basic_1.DecFloatType) {
30835
+ return "DECFLOAT";
30836
+ }
30837
+ return undefined;
30838
+ }
30647
30839
  function numericSubstringType(context, offset, length) {
30648
30840
  const hasOffset = offset !== undefined && offset > 0;
30649
30841
  const hasLength = length !== undefined && length > 0;
@@ -31783,6 +31975,7 @@ const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expr
31783
31975
  const source_1 = __webpack_require__(/*! ./source */ "../core/build/src/abap/5_syntax/expressions/source.js");
31784
31976
  const let_1 = __webpack_require__(/*! ./let */ "../core/build/src/abap/5_syntax/expressions/let.js");
31785
31977
  const cond_1 = __webpack_require__(/*! ./cond */ "../core/build/src/abap/5_syntax/expressions/cond.js");
31978
+ const _raise_message_1 = __webpack_require__(/*! ../_raise_message */ "../core/build/src/abap/5_syntax/_raise_message.js");
31786
31979
  class CondBody {
31787
31980
  static runSyntax(node, input, targetType) {
31788
31981
  if (node === undefined) {
@@ -31793,6 +31986,9 @@ class CondBody {
31793
31986
  if (l) {
31794
31987
  scoped = let_1.Let.runSyntax(l, input);
31795
31988
  }
31989
+ for (const t of node.findDirectExpressions(Expressions.Throw)) {
31990
+ _raise_message_1.RaiseMessage.checkThrow(t, input);
31991
+ }
31796
31992
  for (const s of node.findDirectExpressions(Expressions.Cond)) {
31797
31993
  cond_1.Cond.runSyntax(s, input);
31798
31994
  }
@@ -35457,6 +35653,7 @@ var __importStar = (this && this.__importStar) || (function () {
35457
35653
  Object.defineProperty(exports, "__esModule", ({ value: true }));
35458
35654
  exports.Select = void 0;
35459
35655
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
35656
+ const nodes_1 = __webpack_require__(/*! ../../nodes */ "../core/build/src/abap/nodes/index.js");
35460
35657
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/abap/types/basic/index.js");
35461
35658
  const inline_data_1 = __webpack_require__(/*! ./inline_data */ "../core/build/src/abap/5_syntax/expressions/inline_data.js");
35462
35659
  const target_1 = __webpack_require__(/*! ./target */ "../core/build/src/abap/5_syntax/expressions/target.js");
@@ -35472,6 +35669,8 @@ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/bui
35472
35669
  const version_1 = __webpack_require__(/*! ../../../version */ "../core/build/src/version.js");
35473
35670
  const _check_database_fields_1 = __webpack_require__(/*! ./_check_database_fields */ "../core/build/src/abap/5_syntax/expressions/_check_database_fields.js");
35474
35671
  const isSimple = /^\w+$/;
35672
+ // SQL functions where the result has the same type as the first argument
35673
+ const sameTypeAsFirstArgument = new Set(["UPPER", "LOWER", "LTRIM", "RTRIM"]);
35475
35674
  class Select {
35476
35675
  static runSyntax(node, input, skipImplicitInto = false, selectLoop = false) {
35477
35676
  var _a;
@@ -35677,7 +35876,7 @@ class Select {
35677
35876
  if (intoStructure) {
35678
35877
  const inlineList = intoStructure.findAllExpressions(Expressions.InlineData);
35679
35878
  if (inlineList.length === 1) {
35680
- inline_data_1.InlineData.runSyntax(inlineList[0], input, this.buildStructureType(fields, dbSources, input.scope));
35879
+ inline_data_1.InlineData.runSyntax(inlineList[0], input, this.buildStructureType(fields, dbSources, input.scope, from));
35681
35880
  }
35682
35881
  else {
35683
35882
  for (const inline of inlineList) {
@@ -35707,7 +35906,12 @@ class Select {
35707
35906
  return;
35708
35907
  }
35709
35908
  let type = basic_1.VoidType.get("SELECT_todo2");
35710
- if (isSimple.test(field.code)) {
35909
+ const fn = this.findFunctionColumn(field, false);
35910
+ if (fn) {
35911
+ const sourceInfos = this.buildDatabaseSourceInfos(from, dbSources);
35912
+ type = this.inferFunctionType(fn, code => this.findFieldType(code, sourceInfos, input.scope)) || type;
35913
+ }
35914
+ else if (isSimple.test(field.code)) {
35711
35915
  for (const dbSource of dbSources) {
35712
35916
  if (dbSource === undefined) {
35713
35917
  continue;
@@ -35739,7 +35943,7 @@ class Select {
35739
35943
  return basic_1.IntegerType.get();
35740
35944
  }
35741
35945
  }
35742
- static buildStructureType(fields, dbSources, scope) {
35946
+ static buildStructureType(fields, dbSources, scope, from) {
35743
35947
  var _a, _b, _c, _d, _e, _f;
35744
35948
  if (fields.length === 1 && dbSources.length === 1) {
35745
35949
  // COUNT( * ) yields an integer regardless of the (possibly dynamic) table
@@ -35775,10 +35979,16 @@ class Select {
35775
35979
  return basic_1.IntegerType.get();
35776
35980
  }
35777
35981
  }
35778
- else {
35779
- // todo: aggregated/calculated values
35780
- return basic_1.VoidType.get("SELECT_todo11");
35982
+ const fn = this.findFunctionColumn(fields[0], false);
35983
+ if (fn) {
35984
+ const sourceInfos = this.buildDatabaseSourceInfos(from, dbSources);
35985
+ const type = this.inferFunctionType(fn, code => this.findFieldType(code, sourceInfos, scope));
35986
+ if (type) {
35987
+ return type;
35988
+ }
35781
35989
  }
35990
+ // todo: aggregated/calculated values
35991
+ return basic_1.VoidType.get("SELECT_todo11");
35782
35992
  }
35783
35993
  else {
35784
35994
  return basic_1.VoidType.get("SELECT_todo10");
@@ -35799,15 +36009,10 @@ class Select {
35799
36009
  if (!(dbType instanceof basic_1.StructureType)) {
35800
36010
  return basic_1.VoidType.get("SELECT_todo14");
35801
36011
  }
35802
- const allFieldsSimple = fields.every(f => isSimple.test(f.code));
35803
- if (allFieldsSimple === true) {
35804
- const components = [];
35805
- for (const field of fields) {
35806
- const type = dbType.getComponentByName(field.code);
35807
- if (type === undefined) {
35808
- return basic_1.VoidType.get("SELECT_todo9");
35809
- }
35810
- components.push({ name: field.as || field.code, type });
36012
+ if (this.allFieldsSupported(fields) === true) {
36013
+ const components = this.buildSingleSourceComponents(fields, dbType, from, dbSources, scope);
36014
+ if (components === undefined) {
36015
+ return basic_1.VoidType.get("SELECT_todo9");
35811
36016
  }
35812
36017
  return new basic_1.StructureType(components);
35813
36018
  }
@@ -35833,9 +36038,15 @@ class Select {
35833
36038
  }
35834
36039
  return new basic_1.TableType(new basic_1.StructureType(components), tableOptions, undefined);
35835
36040
  }
36041
+ const lookup = code => this.findFieldType(code, sourceInfos, scope);
35836
36042
  const components = [];
35837
36043
  for (const field of fields) {
35838
- const type = this.findFieldType(field.code, sourceInfos, scope);
36044
+ const fn = this.findFunctionColumn(field);
36045
+ if (fn) {
36046
+ components.push({ name: field.as, type: this.inferFunctionType(fn, lookup) || basic_1.VoidType.get("SELECT_function") });
36047
+ continue;
36048
+ }
36049
+ const type = lookup(field.code);
35839
36050
  if (type === undefined) {
35840
36051
  return basic_1.VoidType.get("SELECT_todo3");
35841
36052
  }
@@ -35858,20 +36069,101 @@ class Select {
35858
36069
  if (fields.length === 1 && fields[0].code === "*") {
35859
36070
  return new basic_1.TableType(dbType, tableOptions, undefined);
35860
36071
  }
35861
- const allFieldsSimple = fields.every(f => isSimple.test(f.code));
35862
- if (allFieldsSimple === true) {
35863
- const components = [];
35864
- for (const field of fields) {
35865
- const type = dbType.getComponentByName(field.code);
35866
- if (type === undefined) {
35867
- return basic_1.VoidType.get("SELECT_todo6");
35868
- }
35869
- components.push({ name: field.as || field.code, type });
36072
+ if (this.allFieldsSupported(fields) === true) {
36073
+ const components = this.buildSingleSourceComponents(fields, dbType, from, dbSources, scope);
36074
+ if (components === undefined) {
36075
+ return basic_1.VoidType.get("SELECT_todo6");
35870
36076
  }
35871
36077
  return new basic_1.TableType(new basic_1.StructureType(components), tableOptions, undefined);
35872
36078
  }
35873
36079
  return basic_1.VoidType.get("SELECT_todo7");
35874
36080
  }
36081
+ /** plain field names, or SQL function columns with an alias */
36082
+ static allFieldsSupported(fields) {
36083
+ return fields.every(f => isSimple.test(f.code) || this.findFunctionColumn(f) !== undefined);
36084
+ }
36085
+ /** returns undefined if a plain field is not found in the database table */
36086
+ static buildSingleSourceComponents(fields, dbType, from, dbSources, scope) {
36087
+ const sourceInfos = this.buildDatabaseSourceInfos(from, dbSources);
36088
+ const lookup = code => this.findFieldType(code, sourceInfos, scope);
36089
+ const components = [];
36090
+ for (const field of fields) {
36091
+ const fn = this.findFunctionColumn(field);
36092
+ if (fn) {
36093
+ components.push({ name: field.as, type: this.inferFunctionType(fn, lookup) || basic_1.VoidType.get("SELECT_function") });
36094
+ continue;
36095
+ }
36096
+ const type = dbType.getComponentByName(field.code);
36097
+ if (type === undefined) {
36098
+ return undefined;
36099
+ }
36100
+ components.push({ name: field.as || field.code, type });
36101
+ }
36102
+ return components;
36103
+ }
36104
+ /** returns the SQLFunction node if the field list entry is a single SQL function call */
36105
+ static findFunctionColumn(field, requireAlias = true) {
36106
+ if (requireAlias === true && field.as === "") {
36107
+ return undefined;
36108
+ }
36109
+ else if (!(field.expression.get() instanceof Expressions.SQLField)) {
36110
+ return undefined;
36111
+ }
36112
+ const children = field.expression.getChildren().filter(c => !(c.get() instanceof Expressions.SQLAsName) && c.concatTokens().toUpperCase() !== "AS");
36113
+ if (children.length === 1
36114
+ && children[0] instanceof nodes_1.ExpressionNode
36115
+ && children[0].get() instanceof Expressions.SQLFunction) {
36116
+ return children[0];
36117
+ }
36118
+ return undefined;
36119
+ }
36120
+ /** infers the result type of a SQL function, returns undefined if not possible */
36121
+ static inferFunctionType(fn, lookup) {
36122
+ const name = fn.getFirstToken().getStr().toUpperCase();
36123
+ const inputs = fn.findDirectExpressions(Expressions.SQLFunctionInput);
36124
+ if (inputs.length === 0) {
36125
+ return undefined;
36126
+ }
36127
+ if (name === "SUBSTRING" && inputs.length === 3) {
36128
+ const len = inputs[2].concatTokens();
36129
+ if (/^\d+$/.test(len) === false || parseInt(len, 10) <= 0) {
36130
+ return undefined;
36131
+ }
36132
+ const argType = this.inferFunctionInputType(inputs[0], lookup);
36133
+ if (argType instanceof basic_1.StringType) {
36134
+ return argType;
36135
+ }
36136
+ else if (argType instanceof basic_1.CharacterType
36137
+ || argType instanceof basic_1.NumericType
36138
+ || argType instanceof basic_1.DateType
36139
+ || argType instanceof basic_1.TimeType) {
36140
+ return new basic_1.CharacterType(parseInt(len, 10));
36141
+ }
36142
+ return undefined;
36143
+ }
36144
+ else if (sameTypeAsFirstArgument.has(name)) {
36145
+ const argType = this.inferFunctionInputType(inputs[0], lookup);
36146
+ if (argType instanceof basic_1.CharacterType || argType instanceof basic_1.StringType) {
36147
+ return argType;
36148
+ }
36149
+ return undefined;
36150
+ }
36151
+ return undefined;
36152
+ }
36153
+ static inferFunctionInputType(input, lookup) {
36154
+ const children = input.getChildren();
36155
+ if (children.length !== 1 || !(children[0] instanceof nodes_1.ExpressionNode)) {
36156
+ return undefined;
36157
+ }
36158
+ const child = children[0];
36159
+ if (child.get() instanceof Expressions.SQLFieldName || child.get() instanceof Expressions.SQLAliasField) {
36160
+ return lookup(child.concatTokens().toUpperCase());
36161
+ }
36162
+ else if (child.get() instanceof Expressions.SQLFunction) {
36163
+ return this.inferFunctionType(child, lookup);
36164
+ }
36165
+ return undefined;
36166
+ }
35875
36167
  static buildDatabaseSourceInfos(from, dbSources) {
35876
36168
  const fromSources = from.findAllExpressions(Expressions.SQLFromSource);
35877
36169
  return dbSources.map((source, index) => {
@@ -35906,16 +36198,20 @@ class Select {
35906
36198
  return undefined;
35907
36199
  }
35908
36200
  static findFields(node, input) {
35909
- var _a, _b;
35910
- const expr = node.findFirstExpression(Expressions.SQLFieldList);
36201
+ var _a, _b, _c;
36202
+ let expr = node.findFirstExpression(Expressions.SQLFieldList);
36203
+ // a single field can be wrapped in a nested SQLFieldList
36204
+ while (expr && expr.getChildren().length === 1 && ((_a = expr.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.SQLFieldList) {
36205
+ expr = expr.getFirstChild();
36206
+ }
35911
36207
  const ret = [];
35912
- if (((_a = expr === null || expr === void 0 ? void 0 : expr.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.Dynamic) {
36208
+ if (((_b = expr === null || expr === void 0 ? void 0 : expr.getFirstChild()) === null || _b === void 0 ? void 0 : _b.get()) instanceof Expressions.Dynamic) {
35913
36209
  dynamic_1.Dynamic.runSyntax(expr.getFirstChild(), input);
35914
36210
  }
35915
36211
  // eslint-disable-next-line max-len
35916
36212
  for (const field of (expr === null || expr === void 0 ? void 0 : expr.findDirectExpressionsMulti([Expressions.SQLField, Expressions.SQLFieldName, Expressions.SQLAggregation])) || []) {
35917
36213
  let code = field.concatTokens().toUpperCase();
35918
- const as = ((_b = field.findDirectExpression(Expressions.SQLAsName)) === null || _b === void 0 ? void 0 : _b.concatTokens()) || "";
36214
+ const as = ((_c = field.findDirectExpression(Expressions.SQLAsName)) === null || _c === void 0 ? void 0 : _c.concatTokens()) || "";
35919
36215
  if (as !== "") {
35920
36216
  code = code.replace(" AS " + as.toUpperCase(), "");
35921
36217
  }
@@ -36333,8 +36629,9 @@ class Source {
36333
36629
  /** The calculation type of an arithmetic expression is the most general of the
36334
36630
  * operand types. An operand of type c, n, d, t or string is converted into it and
36335
36631
  * never becomes the result: "lv_f * '0.25'" is a float, not a character field of
36336
- * length four. Returns undefined when neither operand is numeric, leaving the
36337
- * decision to the caller. */
36632
+ * length four. Date and time operands count as numbers of days and seconds, type i:
36633
+ * "lv_end - lv_start" is a number of days, not a date. Returns undefined when neither
36634
+ * operand is numeric, leaving the decision to the caller. */
36338
36635
  static calculationType(left, right) {
36339
36636
  if (left === undefined || right === undefined) {
36340
36637
  return undefined;
@@ -36346,12 +36643,27 @@ class Source {
36346
36643
  else if (right instanceof basic_1.VoidType || right instanceof unknown_type_1.UnknownType) {
36347
36644
  return right;
36348
36645
  }
36646
+ const dateOrTime = left instanceof basic_1.DateType || left instanceof basic_1.TimeType
36647
+ || right instanceof basic_1.DateType || right instanceof basic_1.TimeType;
36648
+ if (left instanceof basic_1.DateType || left instanceof basic_1.TimeType) {
36649
+ left = basic_1.IntegerType.get();
36650
+ }
36651
+ if (right instanceof basic_1.DateType || right instanceof basic_1.TimeType) {
36652
+ right = basic_1.IntegerType.get();
36653
+ }
36349
36654
  const leftRank = this.numericRank(left);
36350
36655
  const rightRank = this.numericRank(right);
36351
36656
  if (leftRank === undefined && rightRank === undefined) {
36352
36657
  return undefined;
36353
36658
  }
36354
- else if (rightRank === undefined) {
36659
+ // a character-like operand next to a date or time counts as p: "lv_date + '5'" is p
36660
+ if (leftRank === undefined && this.isCharacterLike(left) && dateOrTime) {
36661
+ return rightRank >= 3 ? right : new basic_1.PackedType(8, 0);
36662
+ }
36663
+ else if (rightRank === undefined && this.isCharacterLike(right) && dateOrTime) {
36664
+ return leftRank >= 3 ? left : new basic_1.PackedType(8, 0);
36665
+ }
36666
+ if (rightRank === undefined) {
36355
36667
  return left;
36356
36668
  }
36357
36669
  else if (leftRank === undefined) {
@@ -36359,6 +36671,9 @@ class Source {
36359
36671
  }
36360
36672
  return leftRank >= rightRank ? left : right;
36361
36673
  }
36674
+ static isCharacterLike(type) {
36675
+ return type instanceof basic_1.CharacterType || type instanceof basic_1.NumericType || type instanceof basic_1.StringType;
36676
+ }
36362
36677
  static numericRank(type) {
36363
36678
  if (type instanceof basic_1.DecFloat34Type) {
36364
36679
  return 6;
@@ -37266,6 +37581,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
37266
37581
  exports.SwitchBody = void 0;
37267
37582
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
37268
37583
  const source_1 = __webpack_require__(/*! ./source */ "../core/build/src/abap/5_syntax/expressions/source.js");
37584
+ const _raise_message_1 = __webpack_require__(/*! ../_raise_message */ "../core/build/src/abap/5_syntax/_raise_message.js");
37269
37585
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
37270
37586
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/abap/types/basic/index.js");
37271
37587
  class SwitchBody {
@@ -37273,6 +37589,9 @@ class SwitchBody {
37273
37589
  if (node === undefined) {
37274
37590
  return;
37275
37591
  }
37592
+ for (const t of node.findDirectExpressions(Expressions.Throw)) {
37593
+ _raise_message_1.RaiseMessage.checkThrow(t, input);
37594
+ }
37276
37595
  const thenSource = node.findExpressionAfterToken("THEN");
37277
37596
  if (!((thenSource === null || thenSource === void 0 ? void 0 : thenSource.get()) instanceof Expressions.Source)) {
37278
37597
  const message = "SwitchBody, unexpected";
@@ -45732,6 +46051,7 @@ const raise_with_1 = __webpack_require__(/*! ../expressions/raise_with */ "../co
45732
46051
  const _object_oriented_1 = __webpack_require__(/*! ../_object_oriented */ "../core/build/src/abap/5_syntax/_object_oriented.js");
45733
46052
  const method_parameters_1 = __webpack_require__(/*! ../expressions/method_parameters */ "../core/build/src/abap/5_syntax/expressions/method_parameters.js");
45734
46053
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
46054
+ const _raise_message_1 = __webpack_require__(/*! ../_raise_message */ "../core/build/src/abap/5_syntax/_raise_message.js");
45735
46055
  class Raise {
45736
46056
  runSyntax(node, input) {
45737
46057
  // todo
@@ -45791,6 +46111,7 @@ class Raise {
45791
46111
  if (param) {
45792
46112
  new method_parameters_1.MethodParameters().checkExporting(param, input, method, true);
45793
46113
  }
46114
+ _raise_message_1.RaiseMessage.checkRaise(node, input);
45794
46115
  for (const s of node.findDirectExpressions(Expressions.RaiseWith)) {
45795
46116
  raise_with_1.RaiseWith.runSyntax(s, input);
45796
46117
  }
@@ -49778,6 +50099,107 @@ exports.Statics = Statics;
49778
50099
 
49779
50100
  /***/ },
49780
50101
 
50102
+ /***/ "../core/build/src/abap/5_syntax/structures/try.js"
50103
+ /*!*********************************************************!*\
50104
+ !*** ../core/build/src/abap/5_syntax/structures/try.js ***!
50105
+ \*********************************************************/
50106
+ (__unused_webpack_module, exports, __webpack_require__) {
50107
+
50108
+ "use strict";
50109
+
50110
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
50111
+ if (k2 === undefined) k2 = k;
50112
+ var desc = Object.getOwnPropertyDescriptor(m, k);
50113
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
50114
+ desc = { enumerable: true, get: function() { return m[k]; } };
50115
+ }
50116
+ Object.defineProperty(o, k2, desc);
50117
+ }) : (function(o, m, k, k2) {
50118
+ if (k2 === undefined) k2 = k;
50119
+ o[k2] = m[k];
50120
+ }));
50121
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
50122
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
50123
+ }) : function(o, v) {
50124
+ o["default"] = v;
50125
+ });
50126
+ var __importStar = (this && this.__importStar) || (function () {
50127
+ var ownKeys = function(o) {
50128
+ ownKeys = Object.getOwnPropertyNames || function (o) {
50129
+ var ar = [];
50130
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
50131
+ return ar;
50132
+ };
50133
+ return ownKeys(o);
50134
+ };
50135
+ return function (mod) {
50136
+ if (mod && mod.__esModule) return mod;
50137
+ var result = {};
50138
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
50139
+ __setModuleDefault(result, mod);
50140
+ return result;
50141
+ };
50142
+ })();
50143
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
50144
+ exports.Try = void 0;
50145
+ const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
50146
+ const Statements = __importStar(__webpack_require__(/*! ../../2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
50147
+ const Structures = __importStar(__webpack_require__(/*! ../../3_structures/structures */ "../core/build/src/abap/3_structures/structures/index.js"));
50148
+ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
50149
+ // "special exceptions must be caught before general exceptions", a CATCH of a class that inherits
50150
+ // from a class named in an earlier CATCH of the same TRY can never be reached, this is a syntax error
50151
+ // only reported when the lineage of the later class is known up to the earlier class, void classes are skipped
50152
+ class Try {
50153
+ static runSyntax(node, input) {
50154
+ const caught = new Set();
50155
+ for (const catchStructure of node.findDirectStructures(Structures.Catch)) {
50156
+ const statement = catchStructure.findDirectStatement(Statements.Catch);
50157
+ if (statement === undefined) {
50158
+ continue;
50159
+ }
50160
+ const names = [];
50161
+ for (const c of statement.findDirectExpressions(Expressions.ClassName)) {
50162
+ const token = c.getFirstToken();
50163
+ const className = token.getStr().toUpperCase();
50164
+ names.push(className);
50165
+ if (caught.size === 0) {
50166
+ continue;
50167
+ }
50168
+ const superclass = this.findCaughtSuperclass(className, caught, input);
50169
+ if (superclass !== undefined) {
50170
+ const message = `CATCH of ${className} after the CATCH of its superclass ${superclass}`;
50171
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, token, message));
50172
+ return;
50173
+ }
50174
+ }
50175
+ for (const name of names) {
50176
+ caught.add(name);
50177
+ }
50178
+ }
50179
+ }
50180
+ static findCaughtSuperclass(className, caught, input) {
50181
+ var _a;
50182
+ const visited = new Set([className]);
50183
+ let current = input.scope.findClassDefinition(className);
50184
+ while (current !== undefined) {
50185
+ const superclass = (_a = current.getSuperClass()) === null || _a === void 0 ? void 0 : _a.toUpperCase();
50186
+ if (superclass === undefined || visited.has(superclass)) {
50187
+ return undefined;
50188
+ }
50189
+ else if (caught.has(superclass)) {
50190
+ return superclass;
50191
+ }
50192
+ visited.add(superclass);
50193
+ current = input.scope.findClassDefinition(superclass);
50194
+ }
50195
+ return undefined;
50196
+ }
50197
+ }
50198
+ exports.Try = Try;
50199
+ //# sourceMappingURL=try.js.map
50200
+
50201
+ /***/ },
50202
+
49781
50203
  /***/ "../core/build/src/abap/5_syntax/structures/type_enum.js"
49782
50204
  /*!***************************************************************!*\
49783
50205
  !*** ../core/build/src/abap/5_syntax/structures/type_enum.js ***!
@@ -50185,6 +50607,7 @@ const types_1 = __webpack_require__(/*! ./structures/types */ "../core/build/src
50185
50607
  const statics_1 = __webpack_require__(/*! ./structures/statics */ "../core/build/src/abap/5_syntax/structures/statics.js");
50186
50608
  const constants_1 = __webpack_require__(/*! ./structures/constants */ "../core/build/src/abap/5_syntax/structures/constants.js");
50187
50609
  const cleanup_1 = __webpack_require__(/*! ./structures/cleanup */ "../core/build/src/abap/5_syntax/structures/cleanup.js");
50610
+ const try_1 = __webpack_require__(/*! ./structures/try */ "../core/build/src/abap/5_syntax/structures/try.js");
50188
50611
  const class_definition_1 = __webpack_require__(/*! ../types/class_definition */ "../core/build/src/abap/types/class_definition.js");
50189
50612
  const interface_definition_1 = __webpack_require__(/*! ../types/interface_definition */ "../core/build/src/abap/types/interface_definition.js");
50190
50613
  const delete_memory_1 = __webpack_require__(/*! ./statements/delete_memory */ "../core/build/src/abap/5_syntax/statements/delete_memory.js");
@@ -50670,6 +51093,9 @@ class SyntaxLogic {
50670
51093
  else if (stru instanceof Structures.Cleanup) {
50671
51094
  cleanup_1.Cleanup.runSyntax(node, input);
50672
51095
  }
51096
+ else if (stru instanceof Structures.Try) {
51097
+ try_1.Try.runSyntax(node, input);
51098
+ }
50673
51099
  return false;
50674
51100
  }
50675
51101
  updateScopeStatement(node) {
@@ -73130,7 +73556,7 @@ class Registry {
73130
73556
  }
73131
73557
  static abaplintVersion() {
73132
73558
  // magic, see build script "version.js"
73133
- return "2.120.99";
73559
+ return "2.120.101";
73134
73560
  }
73135
73561
  getDDICReferences() {
73136
73562
  return this.ddicReferences;
@@ -90758,13 +91184,18 @@ class FullyTypeConstants extends _abap_rule_1.ABAPRule {
90758
91184
  if ((stat.get() instanceof Statements.Constant
90759
91185
  || (this.conf.checkData === true && stat.get() instanceof Statements.Data))
90760
91186
  && !this.isTyped(stat)) {
91187
+ if (stat.get() instanceof Statements.Data && stat.findDirectExpression(expressions_1.DataDefinition) === undefined) {
91188
+ // unnamed field, eg. "DATA (10)." inside DATA BEGIN OF, cannot be typed
91189
+ continue;
91190
+ }
90761
91191
  const type = stat.get() instanceof Statements.Constant ? "constant definition" : "data definition";
90762
91192
  let token = (_a = stat.findFirstExpression(expressions_1.NamespaceSimpleName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
90763
91193
  if (token === undefined) {
90764
91194
  token = (_b = stat.findFirstExpression(expressions_1.DefinitionName)) === null || _b === void 0 ? void 0 : _b.getFirstToken();
90765
91195
  }
90766
91196
  if (token === undefined) {
90767
- throw new Error("fully type constants, unexpected node");
91197
+ const start = stat.getFirstToken().getStart();
91198
+ throw new Error(`fully type constants: unexpected node, ${file.getFilename()}, row ${start.getRow()}, col ${start.getCol()}, statement "${stat.concatTokens()}"`);
90768
91199
  }
90769
91200
  issues.push(issue_1.Issue.atToken(file, token, this.getDescription(type), this.getMetadata().key, this.conf.severity));
90770
91201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.120.99",
3
+ "version": "2.120.101",
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.99",
42
+ "@abaplint/core": "^2.120.101",
43
43
  "@types/chai": "^4.3.20",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.10",