@abaplint/core 2.120.19 → 2.120.20
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.
- package/build/abaplint.d.ts +2 -0
- package/build/src/abap/5_syntax/_current_scope.js +14 -0
- package/build/src/abap/5_syntax/_type_utils.js +2 -1
- package/build/src/abap/5_syntax/expressions/attribute_chain.js +105 -4
- package/build/src/abap/5_syntax/expressions/method_call_chain.js +5 -0
- package/build/src/abap/5_syntax/expressions/method_source.js +7 -0
- package/build/src/abap/types/class_definition.js +9 -0
- package/build/src/registry.js +1 -1
- package/package.json +4 -3
package/build/abaplint.d.ts
CHANGED
|
@@ -1263,6 +1263,7 @@ declare class ClassDefinition_3 extends Identifier implements IClassDefinition {
|
|
|
1263
1263
|
private checkClassConstructorStatic;
|
|
1264
1264
|
private checkInterfaceVisibility;
|
|
1265
1265
|
private checkMethodsFromSuperClasses;
|
|
1266
|
+
private checkMethodNameConflicts;
|
|
1266
1267
|
private findFriends;
|
|
1267
1268
|
private addReference;
|
|
1268
1269
|
private parse;
|
|
@@ -1645,6 +1646,7 @@ export declare class CurrentScope {
|
|
|
1645
1646
|
push(stype: ScopeType, sname: string, start: Position, filename: string): void;
|
|
1646
1647
|
isOO(): boolean;
|
|
1647
1648
|
isAnyOO(): boolean;
|
|
1649
|
+
isInStaticMethod(): boolean;
|
|
1648
1650
|
addLocalFriend(className: string, friendName: string): void;
|
|
1649
1651
|
isLocalFriend(className: string, friendName: string): boolean;
|
|
1650
1652
|
getEnclosingClassName(): string | undefined;
|
|
@@ -462,6 +462,20 @@ class CurrentScope {
|
|
|
462
462
|
}
|
|
463
463
|
return false;
|
|
464
464
|
}
|
|
465
|
+
isInStaticMethod() {
|
|
466
|
+
let curr = this.current;
|
|
467
|
+
while (curr !== undefined) {
|
|
468
|
+
const stype = curr.getIdentifier().stype;
|
|
469
|
+
if (stype === _scope_type_1.ScopeType.MethodInstance) {
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
else if (stype === _scope_type_1.ScopeType.ClassImplementation) {
|
|
473
|
+
return true;
|
|
474
|
+
}
|
|
475
|
+
curr = curr.getParent();
|
|
476
|
+
}
|
|
477
|
+
return false;
|
|
478
|
+
}
|
|
465
479
|
addLocalFriend(className, friendName) {
|
|
466
480
|
var _a;
|
|
467
481
|
const key = className.toUpperCase();
|
|
@@ -510,7 +510,8 @@ class TypeUtils {
|
|
|
510
510
|
}
|
|
511
511
|
}
|
|
512
512
|
else if (source instanceof basic_1.XStringType) {
|
|
513
|
-
if (target instanceof basic_1.
|
|
513
|
+
if (target instanceof basic_1.CharacterType
|
|
514
|
+
|| target instanceof basic_1.CLikeType
|
|
514
515
|
|| target instanceof basic_1.IntegerType
|
|
515
516
|
|| target instanceof basic_1.StringType
|
|
516
517
|
|| target instanceof basic_1.ObjectReferenceType
|
|
@@ -1,17 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.AttributeChain = void 0;
|
|
37
|
+
const nodes_1 = require("../../nodes");
|
|
38
|
+
const Expressions = __importStar(require("../../2_statements/expressions"));
|
|
4
39
|
const void_type_1 = require("../../types/basic/void_type");
|
|
5
|
-
const
|
|
40
|
+
const basic_1 = require("../../types/basic");
|
|
6
41
|
const _object_oriented_1 = require("../_object_oriented");
|
|
7
42
|
const expressions_1 = require("../../2_statements/expressions");
|
|
8
43
|
const _syntax_input_1 = require("../_syntax_input");
|
|
44
|
+
const component_name_1 = require("./component_name");
|
|
45
|
+
const attribute_name_1 = require("./attribute_name");
|
|
46
|
+
const table_expression_1 = require("./table_expression");
|
|
47
|
+
const field_offset_1 = require("./field_offset");
|
|
48
|
+
const field_length_1 = require("./field_length");
|
|
9
49
|
class AttributeChain {
|
|
10
50
|
static runSyntax(inputContext, node, input, type) {
|
|
11
51
|
if (inputContext instanceof void_type_1.VoidType) {
|
|
12
52
|
return inputContext;
|
|
13
53
|
}
|
|
14
|
-
else if (!(inputContext instanceof
|
|
54
|
+
else if (!(inputContext instanceof basic_1.ObjectReferenceType)) {
|
|
15
55
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), "Not an object reference(AttributeChain)"));
|
|
16
56
|
return void_type_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
17
57
|
}
|
|
@@ -41,8 +81,69 @@ class AttributeChain {
|
|
|
41
81
|
for (const t of type) {
|
|
42
82
|
input.scope.addReference(nameToken, context, t, input.filename);
|
|
43
83
|
}
|
|
44
|
-
|
|
45
|
-
|
|
84
|
+
let contextType = context.getType();
|
|
85
|
+
const children = node.getChildren();
|
|
86
|
+
for (let i = 1; i < children.length; i++) {
|
|
87
|
+
const child = children[i];
|
|
88
|
+
if (contextType instanceof void_type_1.VoidType || contextType instanceof basic_1.UnknownType) {
|
|
89
|
+
return contextType;
|
|
90
|
+
}
|
|
91
|
+
else if (child.get() instanceof Expressions.ArrowOrDash) {
|
|
92
|
+
const operator = child.getFirstToken().getStr();
|
|
93
|
+
if (operator === "-" && !(contextType instanceof basic_1.StructureType)) {
|
|
94
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, child.getFirstToken(), "AttributeChain, not a structure"));
|
|
95
|
+
return void_type_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
96
|
+
}
|
|
97
|
+
else if ((operator === "->" || operator === "=>")
|
|
98
|
+
&& !(contextType instanceof basic_1.ObjectReferenceType)
|
|
99
|
+
&& !(contextType instanceof basic_1.DataReference)) {
|
|
100
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, child.getFirstToken(), "AttributeChain, not a reference"));
|
|
101
|
+
return void_type_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else if (child.get() instanceof Expressions.ComponentName) {
|
|
105
|
+
if (contextType instanceof basic_1.ObjectReferenceType || contextType instanceof basic_1.DataReference) {
|
|
106
|
+
contextType = attribute_name_1.AttributeName.runSyntax(contextType, child, input, type);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
contextType = component_name_1.ComponentName.runSyntax(contextType, child, input);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else if (child.getFirstToken().getStr() === "*" && contextType instanceof basic_1.DataReference) {
|
|
113
|
+
contextType = contextType.getType();
|
|
114
|
+
}
|
|
115
|
+
else if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.TableExpression) {
|
|
116
|
+
if (!(contextType instanceof basic_1.TableType)) {
|
|
117
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, child.getFirstToken(), "Table expression, expected table"));
|
|
118
|
+
return void_type_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
119
|
+
}
|
|
120
|
+
table_expression_1.TableExpression.runSyntax(child, input, contextType);
|
|
121
|
+
contextType = contextType.getRowType();
|
|
122
|
+
}
|
|
123
|
+
else if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.FieldOffset) {
|
|
124
|
+
const offset = field_offset_1.FieldOffset.runSyntax(child, input);
|
|
125
|
+
if (offset !== undefined) {
|
|
126
|
+
if (contextType instanceof basic_1.CharacterType) {
|
|
127
|
+
contextType = new basic_1.CharacterType(contextType.getLength() - offset);
|
|
128
|
+
}
|
|
129
|
+
else if (contextType instanceof basic_1.HexType) {
|
|
130
|
+
contextType = new basic_1.HexType(contextType.getLength() - offset);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.FieldLength) {
|
|
135
|
+
const length = field_length_1.FieldLength.runSyntax(child, input);
|
|
136
|
+
if (length !== undefined) {
|
|
137
|
+
if (contextType instanceof basic_1.CharacterType) {
|
|
138
|
+
contextType = new basic_1.CharacterType(length);
|
|
139
|
+
}
|
|
140
|
+
else if (contextType instanceof basic_1.HexType) {
|
|
141
|
+
contextType = new basic_1.HexType(length);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return contextType;
|
|
46
147
|
}
|
|
47
148
|
}
|
|
48
149
|
exports.AttributeChain = AttributeChain;
|
|
@@ -90,6 +90,11 @@ class MethodCallChain {
|
|
|
90
90
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, methodToken, message));
|
|
91
91
|
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
92
92
|
}
|
|
93
|
+
if (current === first && (method === null || method === void 0 ? void 0 : method.isStatic()) === false && input.scope.isInStaticMethod() === true) {
|
|
94
|
+
const message = "Method \"" + methodName + "\" not static";
|
|
95
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, methodToken, message));
|
|
96
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
97
|
+
}
|
|
93
98
|
const voidedName = context instanceof basic_1.VoidType ? context.getVoided() : undefined;
|
|
94
99
|
const extra = helper.methodReferenceExtras(foundDef, className || voidedName);
|
|
95
100
|
input.scope.addReference(methodToken, method, _reference_1.ReferenceType.MethodReference, input.filename, extra);
|
|
@@ -59,9 +59,11 @@ class MethodSource {
|
|
|
59
59
|
throw new assert_error_1.AssertError("MethodSource, first child expected");
|
|
60
60
|
}
|
|
61
61
|
let context = this.findTop(first, input, children);
|
|
62
|
+
let implicitMe = false;
|
|
62
63
|
if (context === undefined) {
|
|
63
64
|
context = (_a = input.scope.findVariable("me")) === null || _a === void 0 ? void 0 : _a.getType();
|
|
64
65
|
children.unshift(first);
|
|
66
|
+
implicitMe = true;
|
|
65
67
|
}
|
|
66
68
|
if (input.scope.getLanguageVersion() === version_1.LanguageVersion.Cloud
|
|
67
69
|
&& first.get() instanceof Expressions.Dynamic
|
|
@@ -121,6 +123,11 @@ class MethodSource {
|
|
|
121
123
|
const def = input.scope.findObjectDefinition(className);
|
|
122
124
|
// eslint-disable-next-line prefer-const
|
|
123
125
|
let { method, def: foundDef } = helper.searchMethodName(def, methodName);
|
|
126
|
+
if (implicitMe && current === first && (method === null || method === void 0 ? void 0 : method.isStatic()) === false && input.scope.isInStaticMethod() === true) {
|
|
127
|
+
const message = "Method \"" + methodName + "\" not static";
|
|
128
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, methodToken, message));
|
|
129
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
130
|
+
}
|
|
124
131
|
if (method === undefined && (methodName === null || methodName === void 0 ? void 0 : methodName.toUpperCase()) === "CONSTRUCTOR") {
|
|
125
132
|
context = basic_1.VoidType.get("CONSTRUCTOR"); // todo, this is a workaround, constructors always exists
|
|
126
133
|
}
|
|
@@ -97,6 +97,7 @@ class ClassDefinition extends _identifier_1.Identifier {
|
|
|
97
97
|
// perform checks after everything has been initialized
|
|
98
98
|
this.checkInterfaceVisibility(input, node);
|
|
99
99
|
this.checkMethodsFromSuperClasses(input);
|
|
100
|
+
this.checkMethodNameConflicts(input);
|
|
100
101
|
this.checkClassNameLength(input);
|
|
101
102
|
this.checkMethodNameLength(input);
|
|
102
103
|
this.checkClassConstructorStatic(input);
|
|
@@ -228,6 +229,14 @@ class ClassDefinition extends _identifier_1.Identifier {
|
|
|
228
229
|
}
|
|
229
230
|
}
|
|
230
231
|
}
|
|
232
|
+
checkMethodNameConflicts(input) {
|
|
233
|
+
for (const m of this.methodDefs.getAll()) {
|
|
234
|
+
if (this.attributes.findByName(m.getName()) !== undefined
|
|
235
|
+
|| this.types.getByName(m.getName()) !== undefined) {
|
|
236
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, m.getToken(), `"${m.getName()}" already defined`));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
231
240
|
findFriends(def, input) {
|
|
232
241
|
var _a;
|
|
233
242
|
const result = [];
|
package/build/src/registry.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.120.
|
|
3
|
+
"version": "2.120.20",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
10
10
|
"lint:fix": "eslint \"src/**/*.ts\" \"test/**/*.ts\" --fix",
|
|
11
|
-
"clean": "
|
|
11
|
+
"clean": "rimraf build",
|
|
12
12
|
"compile": "npm run clean && tsc && node scripts/version.js",
|
|
13
13
|
"watch": "tsc --watch",
|
|
14
14
|
"test": "npm run compile && mocha --timeout 1000 && npm run lint && npm run schema && api-extractor run",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"url": "git+https://github.com/abaplint/abaplint.git"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
|
-
"node": ">=
|
|
42
|
+
"node": ">=22.0.0"
|
|
43
43
|
},
|
|
44
44
|
"keywords": [
|
|
45
45
|
"ABAP",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"chai": "^4.5.0",
|
|
61
61
|
"eslint": "^9.39.5",
|
|
62
62
|
"mocha": "^11.7.6",
|
|
63
|
+
"rimraf": "^6.1.3",
|
|
63
64
|
"source-map-support": "^0.5.21",
|
|
64
65
|
"ts-json-schema-generator": "^2.9.0",
|
|
65
66
|
"typescript": "^7.0.2"
|