@abaplint/core 2.120.23 → 2.120.25

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.
@@ -1260,7 +1260,7 @@ declare class ClassDefinition_3 extends Identifier implements IClassDefinition {
1260
1260
  private checkClassNameLength;
1261
1261
  private findSuper;
1262
1262
  private checkMethodNameLength;
1263
- private checkClassConstructorStatic;
1263
+ private checkClassConstructor;
1264
1264
  private checkInterfaceVisibility;
1265
1265
  private checkMethodsFromSuperClasses;
1266
1266
  private checkMethodNameConflicts;
@@ -4897,6 +4897,7 @@ declare class MethodParameters_2 implements IMethodParameters {
4897
4897
  getParameterDefault(parameter: string): ExpressionNode;
4898
4898
  private parse;
4899
4899
  private checkDuplicateNames;
4900
+ private checkNameLengths;
4900
4901
  private workaroundRAP;
4901
4902
  private add;
4902
4903
  private isPassByValue;
@@ -11,7 +11,7 @@ class ClassDefinition {
11
11
  const risk = (0, combi_1.seq)("RISK LEVEL", level);
12
12
  const time = (0, combi_1.altPrio)("LONG", "MEDIUM", "SHORT");
13
13
  const duration = (0, combi_1.seq)("DURATION", time);
14
- const blah = (0, combi_1.per)(expressions_1.ClassGlobal, expressions_1.ClassFinal, "ABSTRACT", (0, combi_1.seq)("INHERITING FROM", expressions_1.SuperClassName), create, "FOR TESTING", risk, "SHARED MEMORY ENABLED", duration, (0, combi_1.ver)(version_1.Release.v754, (0, combi_1.seq)("FOR BEHAVIOR OF", expressions_1.BehaviorDefinitionName), { also: combi_1.AlsoIn.OpenABAP }), expressions_1.ClassFriends);
14
+ const blah = (0, combi_1.per)(expressions_1.ClassGlobal, expressions_1.ClassFinal, "ABSTRACT", (0, combi_1.seq)("INHERITING FROM", expressions_1.SuperClassName), create, "FOR TESTING", risk, "SHARED MEMORY ENABLED", duration, (0, combi_1.ver)(version_1.Release.v754, (0, combi_1.seq)("FOR BEHAVIOR OF", expressions_1.BehaviorDefinitionName), { also: combi_1.AlsoIn.OpenABAP }), (0, combi_1.ver)(version_1.Release.v758, (0, combi_1.seq)("FOR EVENTS OF", expressions_1.BehaviorDefinitionName)), expressions_1.ClassFriends);
15
15
  const def = (0, combi_1.seq)("DEFINITION", (0, combi_1.optPrio)(blah));
16
16
  return (0, combi_1.seq)("CLASS", expressions_1.ClassName, def);
17
17
  }
@@ -4,6 +4,7 @@ exports.MethodDef = void 0;
4
4
  const version_1 = require("../../../version");
5
5
  const combi_1 = require("../combi");
6
6
  const expressions_1 = require("../expressions");
7
+ const tokens_1 = require("../../1_lexer/tokens");
7
8
  class MethodDef {
8
9
  getMatcher() {
9
10
  const def = (0, combi_1.ver)(version_1.Release.v740sp08, (0, combi_1.seq)("DEFAULT", (0, combi_1.altPrio)("FAIL", "IGNORE")), { also: combi_1.AlsoIn.OpenABAP });
@@ -17,6 +18,9 @@ class MethodDef {
17
18
  const modify = (0, combi_1.alt)((0, combi_1.seq)("FOR ACTION", expressions_1.TypeName, (0, combi_1.optPrio)(result)), (0, combi_1.seq)("FOR CREATE", (0, combi_1.alt)(expressions_1.TypeName, expressions_1.EntityAssociation)), (0, combi_1.seq)("FOR DELETE", expressions_1.TypeName), (0, combi_1.seq)("FOR UPDATE", expressions_1.TypeName));
18
19
  const forRead = (0, combi_1.seq)("FOR READ", (0, combi_1.alt)(expressions_1.TypeName, expressions_1.EntityAssociation), (0, combi_1.optPrio)(full), result, (0, combi_1.optPrio)(link));
19
20
  const forfunction = (0, combi_1.seq)("FOR FUNCTION", expressions_1.TypeName, result);
21
+ const entityEventReference = (0, combi_1.seq)("REFERENCE", (0, combi_1.tok)(tokens_1.ParenLeft), expressions_1.MethodParamName, (0, combi_1.tok)(tokens_1.ParenRightW));
22
+ const entityEventParameter = (0, combi_1.seq)((0, combi_1.altPrio)(entityEventReference, expressions_1.MethodParamName), "FOR", expressions_1.TypeName);
23
+ const entityEvent = (0, combi_1.seq)((0, combi_1.optPrio)("FINAL"), "FOR ENTITY EVENT", (0, combi_1.optPrio)("IMPORTING"), (0, combi_1.plus)(entityEventParameter));
20
24
  const behavior = (0, combi_1.altPrio)("DDL OBJECT OPTIONS CDS SESSION CLIENT REQUIRED", // todo, this is only from version something
21
25
  (0, combi_1.seq)("TABLE FUNCTION", expressions_1.NamespaceSimpleName), // todo, this is only from version something
22
26
  (0, combi_1.seq)("VALIDATE ON SAVE IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("MODIFY", (0, combi_1.opt)("IMPORTING"), (0, combi_1.plus)((0, combi_1.seq)(expressions_1.MethodParamName, modify))), (0, combi_1.seq)("PRECHECK IMPORTING", expressions_1.MethodParamName, modify), (0, combi_1.seq)("DETERMINATION", expressions_1.TypeName, "IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("VALIDATION", expressions_1.TypeName, "IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("NUMBERING IMPORTING", expressions_1.MethodParamName, modify), (0, combi_1.seq)("READ IMPORTING", expressions_1.MethodParamName, (0, combi_1.altPrio)(forRead, forfunction)), (0, combi_1.seq)("FEATURES IMPORTING", expressions_1.MethodParamName, "REQUEST", expressions_1.NamespaceSimpleName, "FOR", expressions_1.NamespaceSimpleName, result), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR CREATE", expressions_1.TypeName, expressions_1.MethodParamName, "FOR UPDATE", expressions_1.TypeName, expressions_1.MethodParamName, "FOR DELETE", expressions_1.TypeName), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR READ", expressions_1.TypeName, result), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR UPDATE", expressions_1.TypeName), (0, combi_1.seq)((0, combi_1.alt)("BEHAVIOR", "LOCK"), "IMPORTING", expressions_1.MethodParamName, "FOR LOCK", expressions_1.TypeName), (0, combi_1.seq)("DETERMINE", (0, combi_1.alt)("ON MODIFY", "ON SAVE"), "IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("GLOBAL AUTHORIZATION IMPORTING REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result), (0, combi_1.seq)("GLOBAL FEATURES IMPORTING REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result), (0, combi_1.seq)((0, combi_1.seq)((0, combi_1.opt)("INSTANCE"), "AUTHORIZATION IMPORTING"), expressions_1.MethodParamName, "REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result), (0, combi_1.seq)("INSTANCE FEATURES IMPORTING", expressions_1.MethodParamName, "REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result));
@@ -24,7 +28,9 @@ class MethodDef {
24
28
  // AMDP OPTIONS clause blocked in KeyUser
25
29
  const amdp = (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("AMDP OPTIONS", (0, combi_1.optPrio)("READ-ONLY"), "CDS SESSION CLIENT", (0, combi_1.alt)("CURRENT", "DEPENDENT"), (0, combi_1.optPrio)(expressions_1.MethodDefImporting), (0, combi_1.optPrio)(expressions_1.MethodDefExporting), (0, combi_1.optPrio)(expressions_1.MethodDefRaising)));
26
30
  // FOR DDL OBJECT / FOR TABLE FUNCTION / FOR SCALAR FUNCTION blocked in KeyUser
27
- const ret = (0, combi_1.seq)((0, combi_1.altPrio)("CLASS-METHODS", "METHODS"), expressions_1.MethodName, (0, combi_1.alt)((0, combi_1.seq)((0, combi_1.optPrio)(expressions_1.Abstract), (0, combi_1.optPrio)(def), expressions_1.EventHandler), parameters, testing, (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("FOR", behavior)), amdp, "NOT AT END OF MODE", (0, combi_1.optPrio)(expressions_1.Redefinition)));
31
+ const regular = (0, combi_1.seq)((0, combi_1.altPrio)("CLASS-METHODS", "METHODS"), expressions_1.MethodName, (0, combi_1.alt)((0, combi_1.seq)((0, combi_1.optPrio)(expressions_1.Abstract), (0, combi_1.optPrio)(def), expressions_1.EventHandler), parameters, testing, (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("FOR", behavior)), amdp, "NOT AT END OF MODE", (0, combi_1.optPrio)(expressions_1.Redefinition)));
32
+ // RAP event handlers are instance methods; CLASS-METHODS is not allowed.
33
+ const ret = (0, combi_1.alt)((0, combi_1.seq)("METHODS", expressions_1.MethodName, (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, entityEvent)), regular);
28
34
  return ret;
29
35
  }
30
36
  }
@@ -281,6 +281,12 @@ class TypeUtils {
281
281
  if (source2 instanceof basic_1.HexType && this.isCalculated(node2) && source1 instanceof basic_1.IntegerType) {
282
282
  return false;
283
283
  }
284
+ if (source1 instanceof basic_1.DateType && this.isCalculated(node2) && source2 instanceof basic_1.IntegerType) {
285
+ return false;
286
+ }
287
+ if (source2 instanceof basic_1.DateType && this.isCalculated(node1) && source1 instanceof basic_1.IntegerType) {
288
+ return false;
289
+ }
284
290
  return true;
285
291
  }
286
292
  structureContainsString(structure) {
@@ -39,6 +39,7 @@ const source_1 = require("./source");
39
39
  const method_call_chain_1 = require("./method_call_chain");
40
40
  const source_field_symbol_1 = require("./source_field_symbol");
41
41
  const _syntax_input_1 = require("../_syntax_input");
42
+ const basic_1 = require("../../types/basic");
42
43
  const _type_utils_1 = require("../_type_utils");
43
44
  class Compare {
44
45
  static runSyntax(node, input) {
@@ -56,7 +57,15 @@ class Compare {
56
57
  if (node.findDirectExpression(Expressions.CompareOperator)
57
58
  && new _type_utils_1.TypeUtils(input.scope).isCompareable(sourceTypes[0], sourceTypes[1], sources[0], sources[1]) === false
58
59
  && sourceTypes.length === 2) {
59
- const message = "Incompatible types for comparison";
60
+ let message = "Incompatible types for comparison";
61
+ if ((sourceTypes[0] instanceof basic_1.DateType
62
+ && sourceTypes[1] instanceof basic_1.IntegerType
63
+ && sources[1].findFirstExpression(Expressions.ArithOperator))
64
+ || (sourceTypes[1] instanceof basic_1.DateType
65
+ && sourceTypes[0] instanceof basic_1.IntegerType
66
+ && sources[0].findFirstExpression(Expressions.ArithOperator))) {
67
+ message = "Date cannot be compared with arithmetic result of type Integer";
68
+ }
60
69
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
61
70
  }
62
71
  }
@@ -43,7 +43,12 @@ const _syntax_input_1 = require("../_syntax_input");
43
43
  const _type_utils_1 = require("../_type_utils");
44
44
  class Catch {
45
45
  runSyntax(node, input) {
46
- var _a;
46
+ var _a, _b, _c;
47
+ const target = node.findDirectExpression(Expressions.Target);
48
+ const inlineTarget = (_b = (_a = target === null || target === void 0 ? void 0 : target.findDirectExpression(Expressions.InlineData)) === null || _a === void 0 ? void 0 : _a.findFirstExpression(Expressions.TargetField)) === null || _b === void 0 ? void 0 : _b.getFirstToken();
49
+ if (inlineTarget && inlineTarget.getStr().length > 30) {
50
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, inlineTarget, "Inline exception name longer than 30 characters"));
51
+ }
47
52
  const names = new Set();
48
53
  for (const c of node.findDirectExpressions(Expressions.ClassName)) {
49
54
  const token = c.getFirstToken();
@@ -67,9 +72,8 @@ class Catch {
67
72
  }
68
73
  names.add(className);
69
74
  }
70
- const target = node.findDirectExpression(Expressions.Target);
71
75
  if (target === null || target === void 0 ? void 0 : target.findDirectExpression(Expressions.InlineData)) {
72
- const token = (_a = target.findFirstExpression(Expressions.TargetField)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
76
+ const token = (_c = target.findFirstExpression(Expressions.TargetField)) === null || _c === void 0 ? void 0 : _c.getFirstToken();
73
77
  if (token) {
74
78
  const classNames = Array.from(names);
75
79
  const unknownClass = classNames.find(name => input.scope.findClassDefinition(name) === undefined);
@@ -44,6 +44,7 @@ const include_type_1 = require("../statements/include_type");
44
44
  const type_1 = require("../statements/type");
45
45
  const Basic = __importStar(require("../../types/basic"));
46
46
  const _scope_type_1 = require("../_scope_type");
47
+ const _syntax_input_1 = require("../_syntax_input");
47
48
  class Types {
48
49
  runSyntax(node, input, qualifiedNamePrefix) {
49
50
  const name = node.findFirstExpression(Expressions.NamespaceSimpleName).getFirstToken();
@@ -58,6 +59,9 @@ class Types {
58
59
  if (ctyp instanceof Statements.Type) {
59
60
  const found = new type_1.Type().runSyntax(c, input, qualifiedNamePrefix + name.getStr() + "-");
60
61
  if (found) {
62
+ if (found.getName().length > 30) {
63
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, found.getToken(), "Structure field name longer than 30 characters"));
64
+ }
61
65
  components.push({ name: found.getName(), type: found.getType() });
62
66
  }
63
67
  }
@@ -74,6 +78,9 @@ class Types {
74
78
  else if (c instanceof nodes_1.StructureNode && ctyp instanceof Structures.Types) {
75
79
  const found = new Types().runSyntax(c, input, qualifiedNamePrefix + name.getStr() + "-");
76
80
  if (found) {
81
+ if (found.getName().length > 30) {
82
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, found.getToken(), "Structure field name longer than 30 characters"));
83
+ }
77
84
  components.push({ name: found.getName(), type: found.getType() });
78
85
  }
79
86
  }
@@ -101,7 +101,7 @@ class ClassDefinition extends _identifier_1.Identifier {
101
101
  this.checkEventNameConflicts(input);
102
102
  this.checkClassNameLength(input);
103
103
  this.checkMethodNameLength(input);
104
- this.checkClassConstructorStatic(input);
104
+ this.checkClassConstructor(input);
105
105
  }
106
106
  getFriends() {
107
107
  return this.friends;
@@ -171,11 +171,17 @@ class ClassDefinition extends _identifier_1.Identifier {
171
171
  }
172
172
  }
173
173
  }
174
- checkClassConstructorStatic(input) {
174
+ checkClassConstructor(input) {
175
175
  for (const m of this.methodDefs.getAll()) {
176
- if (m.getName().toUpperCase() === "CLASS_CONSTRUCTOR" && m.isStatic() === false) {
176
+ if (m.getName().toUpperCase() !== "CLASS_CONSTRUCTOR") {
177
+ continue;
178
+ }
179
+ if (m.isStatic() === false) {
177
180
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, m.getToken(), "CLASS_CONSTRUCTOR must be static"));
178
181
  }
182
+ else if (m.getVisibility() !== visibility_1.Visibility.Public) {
183
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, m.getToken(), "CLASS_CONSTRUCTOR must be declared in the public section"));
184
+ }
179
185
  }
180
186
  }
181
187
  checkInterfaceVisibility(input, node) {
@@ -45,6 +45,7 @@ const _object_oriented_1 = require("../5_syntax/_object_oriented");
45
45
  const _reference_1 = require("../5_syntax/_reference");
46
46
  const identifier_1 = require("../1_lexer/tokens/identifier");
47
47
  const _scope_type_1 = require("../5_syntax/_scope_type");
48
+ const _syntax_input_1 = require("../5_syntax/_syntax_input");
48
49
  // todo:
49
50
  // this.exceptions = [];
50
51
  // also consider RAISING vs EXCEPTIONS
@@ -67,6 +68,7 @@ class MethodParameters {
67
68
  input.scope.push(_scope_type_1.ScopeType.MethodDefinition, "method definition", node.getStart(), input.filename);
68
69
  try {
69
70
  this.parse(node, input, parentName, abstractMethod);
71
+ this.checkNameLengths(input);
70
72
  this.checkDuplicateNames();
71
73
  }
72
74
  finally {
@@ -218,6 +220,13 @@ class MethodParameters {
218
220
  names.add(name);
219
221
  }
220
222
  }
223
+ checkNameLengths(input) {
224
+ for (const parameter of this.getAll()) {
225
+ if (parameter.getName().length > 30) {
226
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, parameter.getToken(), "Method parameter name longer than 30 characters"));
227
+ }
228
+ }
229
+ }
221
230
  workaroundRAP(node, input, parentName) {
222
231
  const resultName = node.findExpressionAfterToken("RESULT");
223
232
  const concat = node.concatTokens().toUpperCase();
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.120.23";
78
+ return "2.120.25";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.120.23",
3
+ "version": "2.120.25",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",