@abaplint/core 2.102.43 → 2.102.45

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.
@@ -3678,6 +3678,7 @@ export declare interface ISpaghettiScopeNode {
3678
3678
  };
3679
3679
  findClassDefinition(name: string): IClassDefinition | undefined;
3680
3680
  listClassDefinitions(): IClassDefinition[];
3681
+ listInterfaceDefinitions(): IInterfaceDefinition[];
3681
3682
  findFormDefinition(name: string): IFormDefinition | undefined;
3682
3683
  listFormDefinitions(): IFormDefinition[];
3683
3684
  findInterfaceDefinition(name: string): IInterfaceDefinition | undefined;
@@ -5352,6 +5353,7 @@ export declare class SpaghettiScopeNode extends ScopeData implements ISpaghettiS
5352
5353
  findDeferred(name: string): Identifier | undefined;
5353
5354
  findClassDefinition(name: string): IClassDefinition | undefined;
5354
5355
  listClassDefinitions(): IClassDefinition[];
5356
+ listInterfaceDefinitions(): IInterfaceDefinition[];
5355
5357
  findFormDefinition(name: string): IFormDefinition | undefined;
5356
5358
  listFormDefinitions(): IFormDefinition[];
5357
5359
  findInterfaceDefinition(name: string): IInterfaceDefinition | undefined;
@@ -305,7 +305,8 @@ class TypeUtils {
305
305
  }
306
306
  }
307
307
  else if (source instanceof basic_1.IntegerType) {
308
- if (target instanceof basic_1.StringType) {
308
+ if (target instanceof basic_1.StringType
309
+ || target instanceof basic_1.PackedType) {
309
310
  return false;
310
311
  }
311
312
  else if (target instanceof basic_1.Integer8Type) {
@@ -86,6 +86,15 @@ class SpaghettiScopeNode extends ScopeData {
86
86
  }
87
87
  return ret;
88
88
  }
89
+ listInterfaceDefinitions() {
90
+ let search = this;
91
+ const ret = [];
92
+ while (search !== undefined) {
93
+ ret.push(...Object.values(search.getData().idefs));
94
+ search = search.getParent();
95
+ }
96
+ return ret;
97
+ }
89
98
  findFormDefinition(name) {
90
99
  let search = this;
91
100
  const upper = name.toUpperCase();
@@ -6,6 +6,9 @@ const target_1 = require("../expressions/target");
6
6
  const source_1 = require("../expressions/source");
7
7
  const dynamic_1 = require("../expressions/dynamic");
8
8
  const basic_types_1 = require("../basic_types");
9
+ const basic_1 = require("../../types/basic");
10
+ const _typed_identifier_1 = require("../../types/_typed_identifier");
11
+ const _reference_1 = require("../_reference");
9
12
  class CreateData {
10
13
  runSyntax(node, scope, filename) {
11
14
  for (const s of node.findDirectExpressions(Expressions.Source)) {
@@ -19,7 +22,23 @@ class CreateData {
19
22
  }
20
23
  const type = node.findDirectExpression(Expressions.TypeName);
21
24
  if (type) {
22
- new basic_types_1.BasicTypes(filename, scope).resolveTypeName(type);
25
+ const found = new basic_types_1.BasicTypes(filename, scope).resolveTypeName(type);
26
+ if (found instanceof basic_1.UnknownType) {
27
+ if (node.concatTokens().toUpperCase().includes(" REF TO ")) {
28
+ const def = scope.findObjectDefinition(type.concatTokens());
29
+ if (def) {
30
+ scope.addReference(type.getFirstToken(), def, _reference_1.ReferenceType.TypeReference, filename);
31
+ }
32
+ else {
33
+ const identifier = new _typed_identifier_1.TypedIdentifier(type.getFirstToken(), filename, found);
34
+ scope.addReference(type.getFirstToken(), identifier, _reference_1.ReferenceType.TypeReference, filename);
35
+ }
36
+ }
37
+ else {
38
+ const identifier = new _typed_identifier_1.TypedIdentifier(type.getFirstToken(), filename, found);
39
+ scope.addReference(type.getFirstToken(), identifier, _reference_1.ReferenceType.TypeReference, filename);
40
+ }
41
+ }
23
42
  }
24
43
  }
25
44
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LSPLookup = void 0;
4
+ /* eslint-disable max-len */
4
5
  const LServer = require("vscode-languageserver-types");
5
6
  const Statements = require("../abap/2_statements/statements");
6
7
  const Expressions = require("../abap/2_statements/expressions");
@@ -83,13 +84,14 @@ class LSPLookup {
83
84
  }
84
85
  return { hover: hoverValue, definition: location, implementation: location, definitionId: variable, scope: bottomScope };
85
86
  }
86
- for (const c of bottomScope.listClassDefinitions()) {
87
+ // TODO: this can be optimized, no need to loop through all the defintions, the scope knows the name of the object?
88
+ for (const c of [...bottomScope.listClassDefinitions(), ...bottomScope.listInterfaceDefinitions()]) {
87
89
  for (const m of ((_a = c.getMethodDefinitions()) === null || _a === void 0 ? void 0 : _a.getAll()) || []) {
88
90
  for (const p of ((_b = m.getParameters()) === null || _b === void 0 ? void 0 : _b.getAll()) || []) {
89
91
  if (p.getStart().equals(cursor.token.getStart())) {
90
92
  const found = _lsp_utils_1.LSPUtils.identiferToLocation(p);
91
93
  return {
92
- hover: "Method Parameter, " + cursor.token.getStr(),
94
+ hover: "Method Parameter: " + cursor.token.getStr().replace("!", ""),
93
95
  definition: found,
94
96
  definitionId: p,
95
97
  implementation: undefined,
@@ -271,11 +273,12 @@ class LSPLookup {
271
273
  };
272
274
  }
273
275
  static findMethodDefinition(found, scope) {
274
- var _a, _b, _c, _d;
276
+ var _a, _b, _c, _d, _e, _f, _g;
275
277
  if (scope === undefined) {
276
278
  return undefined;
277
279
  }
278
- if (scope.getIdentifier().stype !== _scope_type_1.ScopeType.ClassDefinition
280
+ if ((scope.getIdentifier().stype !== _scope_type_1.ScopeType.ClassDefinition
281
+ && scope.getIdentifier().stype !== _scope_type_1.ScopeType.Interface)
279
282
  || !(found.snode.get() instanceof Statements.MethodDef)) {
280
283
  return undefined;
281
284
  }
@@ -291,8 +294,14 @@ class LSPLookup {
291
294
  || nameToken.getStart().getRow() !== found.token.getStart().getRow()) {
292
295
  return undefined;
293
296
  }
294
- const def = (_d = (_c = (_b = scope.getParent()) === null || _b === void 0 ? void 0 : _b.findClassDefinition(scope.getIdentifier().sname)) === null || _c === void 0 ? void 0 : _c.getMethodDefinitions()) === null || _d === void 0 ? void 0 : _d.getByName(nameToken.getStr());
295
- return def;
297
+ if (scope.getIdentifier().stype === _scope_type_1.ScopeType.ClassDefinition) {
298
+ const def = (_d = (_c = (_b = scope.getParent()) === null || _b === void 0 ? void 0 : _b.findClassDefinition(scope.getIdentifier().sname)) === null || _c === void 0 ? void 0 : _c.getMethodDefinitions()) === null || _d === void 0 ? void 0 : _d.getByName(nameToken.getStr());
299
+ return def;
300
+ }
301
+ else {
302
+ const def = (_g = (_f = (_e = scope.getParent()) === null || _e === void 0 ? void 0 : _e.findInterfaceDefinition(scope.getIdentifier().sname)) === null || _f === void 0 ? void 0 : _f.getMethodDefinitions()) === null || _g === void 0 ? void 0 : _g.getByName(nameToken.getStr());
303
+ return def;
304
+ }
296
305
  }
297
306
  static findFunctionModule(found) {
298
307
  if (!(found.snode.get() instanceof Statements.CallFunction)) {
@@ -65,7 +65,7 @@ class Registry {
65
65
  }
66
66
  static abaplintVersion() {
67
67
  // magic, see build script "version.sh"
68
- return "2.102.43";
68
+ return "2.102.45";
69
69
  }
70
70
  getDDICReferences() {
71
71
  return this.ddicReferences;
@@ -37,7 +37,12 @@ class CloudTypes {
37
37
  }
38
38
  run(obj) {
39
39
  if (this.reg.getConfig().getVersion() !== version_1.Version.Cloud
40
+ || obj instanceof Objects.ApplicationJobCatalogEntry
41
+ || obj instanceof Objects.ApplicationJobTemplate
40
42
  || obj instanceof Objects.AssignmentServiceToAuthorizationGroup
43
+ || obj instanceof Objects.ATCCheckCategory
44
+ || obj instanceof Objects.ATCCheckObject
45
+ || obj instanceof Objects.ATCCheckVariant
41
46
  || obj instanceof Objects.AuthorizationCheckField
42
47
  || obj instanceof Objects.AuthorizationObject
43
48
  || obj instanceof Objects.AuthorizationObjectExtension
@@ -45,11 +50,7 @@ class CloudTypes {
45
50
  || obj instanceof Objects.BusinessCatalog
46
51
  || obj instanceof Objects.BusinessCatalogAppAssignment
47
52
  || obj instanceof Objects.CDSMetadataExtension
48
- || obj instanceof Objects.RestrictionField
49
53
  || obj instanceof Objects.Class
50
- || obj instanceof Objects.OutboundService
51
- || obj instanceof Objects.ApplicationJobCatalogEntry
52
- || obj instanceof Objects.ApplicationJobTemplate
53
54
  || obj instanceof Objects.CommunicationScenario
54
55
  || obj instanceof Objects.DataControl
55
56
  || obj instanceof Objects.DataDefinition
@@ -61,11 +62,11 @@ class CloudTypes {
61
62
  || obj instanceof Objects.InboundService
62
63
  || obj instanceof Objects.Interface
63
64
  || obj instanceof Objects.LockObject
64
- || obj instanceof Objects.ATCCheckCategory
65
- || obj instanceof Objects.ATCCheckObject
66
- || obj instanceof Objects.ATCCheckVariant
67
65
  || obj instanceof Objects.MessageClass
66
+ || obj instanceof Objects.NumberRange
67
+ || obj instanceof Objects.OutboundService
68
68
  || obj instanceof Objects.Package
69
+ || obj instanceof Objects.RestrictionField
69
70
  || obj instanceof Objects.RestrictionType
70
71
  || obj instanceof Objects.ServiceBinding
71
72
  || obj instanceof Objects.ServiceDefinition
@@ -4,14 +4,12 @@ exports.DefinitionsTop = exports.DefinitionsTopConf = void 0;
4
4
  const issue_1 = require("../issue");
5
5
  const _statement_1 = require("../abap/2_statements/statements/_statement");
6
6
  const Statements = require("../abap/2_statements/statements");
7
- const Expressions = require("../abap/2_statements/expressions");
8
7
  const Structures = require("../abap/3_structures/structures");
9
8
  const _abap_rule_1 = require("./_abap_rule");
10
9
  const _basic_rule_config_1 = require("./_basic_rule_config");
11
10
  const _irule_1 = require("./_irule");
12
11
  const edit_helper_1 = require("../edit_helper");
13
12
  const nodes_1 = require("../abap/nodes");
14
- const version_1 = require("../version");
15
13
  class DefinitionsTopConf extends _basic_rule_config_1.BasicRuleConfig {
16
14
  }
17
15
  exports.DefinitionsTopConf = DefinitionsTopConf;
@@ -30,10 +28,16 @@ class DefinitionsTop extends _abap_rule_1.ABAPRule {
30
28
  key: "definitions_top",
31
29
  title: "Place definitions in top of routine",
32
30
  shortDescription: `Checks that definitions are placed at the beginning of METHODs, FORMs and FUNCTIONs.`,
33
- extendedInformation: `If the routine has inline definitions then no issues are reported
34
-
35
- https://docs.abapopenchecks.org/checks/17/`,
31
+ extendedInformation: `https://docs.abapopenchecks.org/checks/17/`,
36
32
  tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
33
+ badExample: `FROM foo.
34
+ WRITE 'hello'.
35
+ DATA int TYPE i.
36
+ ENDFORM.`,
37
+ goodExample: `FROM foo.
38
+ DATA int TYPE i.
39
+ WRITE 'hello'.
40
+ ENDFORM.`,
37
41
  };
38
42
  }
39
43
  getMessage() {
@@ -62,10 +66,6 @@ https://docs.abapopenchecks.org/checks/17/`,
62
66
  this.fixed = false;
63
67
  this.mode = DEFINITION;
64
68
  this.moveTo = (_a = r.getFirstStatement()) === null || _a === void 0 ? void 0 : _a.getLastToken().getEnd();
65
- if (this.reg.getConfig().getVersion() !== version_1.Version.v702
66
- && r.findFirstExpression(Expressions.InlineData)) {
67
- continue;
68
- }
69
69
  const found = this.walk(r, file);
70
70
  if (found) {
71
71
  issues.push(found);
@@ -126,16 +126,19 @@ https://docs.abapopenchecks.org/checks/17/`,
126
126
  && (get instanceof Statements.Data
127
127
  || get instanceof Statements.Type
128
128
  || get instanceof Statements.Constant
129
+ || (get instanceof Statements.Move && c.concatTokens().toUpperCase().startsWith("DATA("))
129
130
  || get instanceof Statements.Static
130
131
  || get instanceof Statements.FieldSymbol)) {
131
132
  if (this.mode === AFTER) {
132
133
  // only one fix per routine, as it reorders a lot
133
- let fix = undefined;
134
- if (this.fixed === false && this.moveTo) {
135
- fix = this.buildFix(file, c, this.moveTo);
136
- this.fixed = true;
134
+ if (!(get instanceof Statements.Move && c.concatTokens().toUpperCase().startsWith("DATA("))) {
135
+ let fix = undefined;
136
+ if (this.fixed === false && this.moveTo) {
137
+ fix = this.buildFix(file, c, this.moveTo);
138
+ this.fixed = true;
139
+ }
140
+ return issue_1.Issue.atStatement(file, c, this.getMessage(), this.getMetadata().key, this.conf.severity, fix);
137
141
  }
138
- return issue_1.Issue.atStatement(file, c, this.getMessage(), this.getMetadata().key, this.conf.severity, fix);
139
142
  }
140
143
  else {
141
144
  this.moveTo = c.getLastToken().getEnd();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.102.43",
3
+ "version": "2.102.45",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -53,7 +53,7 @@
53
53
  "@microsoft/api-extractor": "^7.37.0",
54
54
  "@types/chai": "^4.3.6",
55
55
  "@types/mocha": "^10.0.1",
56
- "@types/node": "^20.6.2",
56
+ "@types/node": "^20.6.3",
57
57
  "chai": "^4.3.8",
58
58
  "eslint": "^8.49.0",
59
59
  "mocha": "^10.2.0",
@@ -63,7 +63,7 @@
63
63
  "typescript": "^5.2.2"
64
64
  },
65
65
  "dependencies": {
66
- "fast-xml-parser": "^4.2.7",
66
+ "fast-xml-parser": "^4.3.0",
67
67
  "json5": "^2.2.3",
68
68
  "vscode-languageserver-types": "^3.17.3"
69
69
  }