@abaplint/core 2.102.45 → 2.102.47

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.
@@ -475,6 +475,10 @@ declare class BehaviorDefinition extends AbstractObject {
475
475
  getDescription(): string | undefined;
476
476
  }
477
477
 
478
+ declare class BehaviorDefinitionName extends Expression {
479
+ getRunnable(): IStatementRunnable;
480
+ }
481
+
478
482
  declare class BlockName extends Expression {
479
483
  getRunnable(): IStatementRunnable;
480
484
  }
@@ -2016,6 +2020,7 @@ declare namespace Expressions {
2016
2020
  AssociationName,
2017
2021
  AttributeChain,
2018
2022
  AttributeName,
2023
+ BehaviorDefinitionName,
2019
2024
  BlockName,
2020
2025
  CallTransformationOptions,
2021
2026
  CallTransformationParameters,
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BehaviorDefinitionName = void 0;
4
+ const combi_1 = require("../combi");
5
+ class BehaviorDefinitionName extends combi_1.Expression {
6
+ getRunnable() {
7
+ return (0, combi_1.regex)(/^((\w*\/\w+\/)|(\w*\/\w+\/)?[\w\*$%]+)$/);
8
+ }
9
+ }
10
+ exports.BehaviorDefinitionName = BehaviorDefinitionName;
11
+ //# sourceMappingURL=behavior_definition_name.js.map
@@ -24,6 +24,7 @@ __exportStar(require("./assign_source"), exports);
24
24
  __exportStar(require("./association_name"), exports);
25
25
  __exportStar(require("./attribute_chain"), exports);
26
26
  __exportStar(require("./attribute_name"), exports);
27
+ __exportStar(require("./behavior_definition_name"), exports);
27
28
  __exportStar(require("./block_name"), exports);
28
29
  __exportStar(require("./call_transformation_options"), exports);
29
30
  __exportStar(require("./call_transformation_parameters"), exports);
@@ -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.Version.v754, (0, combi_1.seq)("FOR BEHAVIOR OF", expressions_1.NamespaceSimpleName)), 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.Version.v754, (0, combi_1.seq)("FOR BEHAVIOR 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
  }
@@ -305,11 +305,10 @@ class TypeUtils {
305
305
  }
306
306
  }
307
307
  else if (source instanceof basic_1.IntegerType) {
308
- if (target instanceof basic_1.StringType
309
- || target instanceof basic_1.PackedType) {
308
+ if (target instanceof basic_1.StringType) {
310
309
  return false;
311
310
  }
312
- else if (target instanceof basic_1.Integer8Type) {
311
+ else if (target instanceof basic_1.Integer8Type || target instanceof basic_1.PackedType) {
313
312
  if (((_h = source.getAbstractTypeData()) === null || _h === void 0 ? void 0 : _h.derivedFromConstant) === true) {
314
313
  return true;
315
314
  }
@@ -16,9 +16,15 @@ class Select {
16
16
  const token = node.getFirstToken();
17
17
  const from = node.findDirectExpression(Expressions.SQLFrom);
18
18
  const dbSources = from ? new sql_from_1.SQLFrom().runSyntax(from, scope, filename) : [];
19
+ const fields = this.findFields(node);
20
+ if (fields.length === 0
21
+ && node.findDirectExpression(Expressions.SQLFieldListLoop) === undefined) {
22
+ throw new Error(`fields missing`);
23
+ }
24
+ this.checkFields(fields, dbSources, scope);
19
25
  for (const inline of node.findAllExpressions(Expressions.InlineData)) {
20
26
  // todo, for now these are voided
21
- new inline_data_1.InlineData().runSyntax(inline, scope, filename, new basic_1.VoidType("SELECT_todo"));
27
+ new inline_data_1.InlineData().runSyntax(inline, scope, filename, this.buildType(fields));
22
28
  }
23
29
  const fae = node.findDirectExpression(Expressions.SQLForAllEntries);
24
30
  if (fae) {
@@ -62,6 +68,59 @@ class Select {
62
68
  scope.pop(node.getLastToken().getEnd());
63
69
  }
64
70
  }
71
+ checkFields(fields, dbSources, scope) {
72
+ if (dbSources.length > 1) {
73
+ return;
74
+ }
75
+ const first = dbSources[0];
76
+ if (first === undefined) {
77
+ // then its voided
78
+ return;
79
+ }
80
+ const type = first.parseType(scope.getRegistry());
81
+ if (type instanceof basic_1.VoidType || type instanceof basic_1.UnknownType) {
82
+ return;
83
+ }
84
+ if (!(type instanceof basic_1.StructureType)) {
85
+ throw new Error("checkFields, expected structure, " + type.constructor.name);
86
+ }
87
+ const isSimple = /^\w+$/;
88
+ for (const field of fields) {
89
+ if (field.code === "*") {
90
+ continue;
91
+ }
92
+ if (isSimple.test(field.code) && type.getComponentByName(field.code) === undefined) {
93
+ throw new Error(`checkFields, field ${field.code} not found`);
94
+ }
95
+ }
96
+ }
97
+ buildType(_fields) {
98
+ return new basic_1.VoidType("SELECT_todo");
99
+ }
100
+ findFields(node) {
101
+ var _a;
102
+ let expr = undefined;
103
+ const ret = [];
104
+ expr = node.findDirectExpression(Expressions.SQLFieldList);
105
+ if (expr === undefined) {
106
+ expr = node.findDirectExpression(Expressions.SQLFields);
107
+ }
108
+ if (expr === undefined) {
109
+ node.findDirectExpression(Expressions.SQLFieldName);
110
+ }
111
+ for (const field of (expr === null || expr === void 0 ? void 0 : expr.findAllExpressions(Expressions.SQLField)) || []) {
112
+ let code = field.concatTokens().toUpperCase();
113
+ const as = ((_a = field.findDirectExpression(Expressions.SQLAsName)) === null || _a === void 0 ? void 0 : _a.concatTokens()) || "";
114
+ if (as !== "") {
115
+ code = code.replace(" AS " + as, "");
116
+ }
117
+ ret.push({ code, as, expression: field });
118
+ }
119
+ if (ret.length === 0 && expr) {
120
+ ret.push({ code: expr.concatTokens(), as: "", expression: expr });
121
+ }
122
+ return ret;
123
+ }
65
124
  }
66
125
  exports.Select = Select;
67
126
  //# sourceMappingURL=select.js.map
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Symbols = void 0;
4
+ /* eslint-disable max-len */
4
5
  const LServer = require("vscode-languageserver-types");
5
6
  const _lsp_utils_1 = require("./_lsp_utils");
7
+ const statements_1 = require("../abap/2_statements/statements");
6
8
  class Symbols {
7
9
  constructor(reg) {
8
10
  this.reg = reg;
@@ -27,6 +29,16 @@ class Symbols {
27
29
  const end = identifer.getEnd();
28
30
  return LServer.Range.create(start.getRow() - 1, start.getCol() - 1, end.getRow() - 1, end.getCol() - 1);
29
31
  }
32
+ newSymbolRanged(identifier, kind, children, range) {
33
+ const symbol = {
34
+ name: identifier.getName(),
35
+ kind: kind,
36
+ range: range,
37
+ selectionRange: this.selectionRange(identifier),
38
+ children,
39
+ };
40
+ return symbol;
41
+ }
30
42
  newSymbol(identifier, kind, children) {
31
43
  const symbol = {
32
44
  name: identifier.getName(),
@@ -50,22 +62,36 @@ class Symbols {
50
62
  for (const cla of file.getInfo().listClassDefinitions()) {
51
63
  const children = [];
52
64
  children.push(...this.outputClassAttributes(cla.attributes));
53
- children.push(...this.outputMethodDefinitions(cla.methods));
54
65
  const symbol = this.newSymbol(cla.identifier, LServer.SymbolKind.Class, children);
55
66
  ret.push(symbol);
56
67
  }
57
68
  for (const cla of file.getInfo().listClassImplementations()) {
58
69
  const children = [];
59
- children.push(...this.outputMethodImplementations(cla.methods));
70
+ children.push(...this.outputMethodImplementations(cla.methods, file));
60
71
  const symbol = this.newSymbol(cla.identifier, LServer.SymbolKind.Class, children);
61
72
  ret.push(symbol);
62
73
  }
63
74
  return ret;
64
75
  }
65
- outputMethodImplementations(methods) {
76
+ outputMethodImplementations(methods, file) {
66
77
  const ret = [];
67
78
  for (const method of methods) {
68
- const symbol = this.newSymbol(method, LServer.SymbolKind.Method, []);
79
+ const start = method.getStart();
80
+ let end = undefined;
81
+ for (const s of file.getStatements()) {
82
+ if (s.getFirstToken().getStart().isBefore(start)) {
83
+ continue;
84
+ }
85
+ if (s.get() instanceof statements_1.EndMethod) {
86
+ end = s.getLastToken().getEnd();
87
+ break;
88
+ }
89
+ }
90
+ if (end === undefined) {
91
+ continue;
92
+ }
93
+ const range = LServer.Range.create(start.getRow() - 1, start.getCol() - 1, end.getRow() - 1, end.getCol() - 1);
94
+ const symbol = this.newSymbolRanged(method, LServer.SymbolKind.Method, [], range);
69
95
  ret.push(symbol);
70
96
  }
71
97
  return ret;
@@ -81,13 +107,6 @@ class Symbols {
81
107
  // todo, also add constants
82
108
  return ret;
83
109
  }
84
- outputMethodDefinitions(methods) {
85
- if (methods === undefined) {
86
- return [];
87
- }
88
- // todo
89
- return [];
90
- }
91
110
  }
92
111
  exports.Symbols = Symbols;
93
112
  //# sourceMappingURL=symbols.js.map
@@ -65,7 +65,7 @@ class Registry {
65
65
  }
66
66
  static abaplintVersion() {
67
67
  // magic, see build script "version.sh"
68
- return "2.102.45";
68
+ return "2.102.47";
69
69
  }
70
70
  getDDICReferences() {
71
71
  return this.ddicReferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.102.45",
3
+ "version": "2.102.47",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -50,12 +50,12 @@
50
50
  },
51
51
  "homepage": "https://abaplint.org",
52
52
  "devDependencies": {
53
- "@microsoft/api-extractor": "^7.37.0",
53
+ "@microsoft/api-extractor": "^7.37.1",
54
54
  "@types/chai": "^4.3.6",
55
55
  "@types/mocha": "^10.0.1",
56
- "@types/node": "^20.6.3",
56
+ "@types/node": "^20.7.0",
57
57
  "chai": "^4.3.8",
58
- "eslint": "^8.49.0",
58
+ "eslint": "^8.50.0",
59
59
  "mocha": "^10.2.0",
60
60
  "c8": "^8.0.1",
61
61
  "source-map-support": "^0.5.21",
@@ -63,8 +63,8 @@
63
63
  "typescript": "^5.2.2"
64
64
  },
65
65
  "dependencies": {
66
- "fast-xml-parser": "^4.3.0",
66
+ "fast-xml-parser": "^4.3.1",
67
67
  "json5": "^2.2.3",
68
- "vscode-languageserver-types": "^3.17.3"
68
+ "vscode-languageserver-types": "^3.17.5"
69
69
  }
70
70
  }