@abaplint/core 2.81.0 → 2.81.1
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 +8 -0
- package/build/src/abap/2_statements/expressions/sql_arithmetics.js +2 -1
- package/build/src/abap/2_statements/expressions/sql_function.js +11 -5
- package/build/src/abap/5_syntax/_current_scope.js +26 -0
- package/build/src/abap/5_syntax/_scope_type.js +1 -0
- package/build/src/abap/5_syntax/basic_types.js +5 -1
- package/build/src/abap/5_syntax/spaghetti_scope.js +13 -0
- package/build/src/abap/5_syntax/statements/class_implementation.js +4 -2
- package/build/src/abap/5_syntax/statements/method_implementation.js +7 -3
- package/build/src/abap/5_syntax/syntax.js +6 -1
- package/build/src/registry.js +1 -1
- package/build/src/rules/no_chained_assignment.js +1 -5
- package/build/src/rules/unnecessary_chaining.js +0 -4
- package/build/src/rules/unreachable_code.js +4 -0
- package/package.json +2 -2
package/build/abaplint.d.ts
CHANGED
|
@@ -999,6 +999,8 @@ export declare class CurrentScope {
|
|
|
999
999
|
private constructor();
|
|
1000
1000
|
addType(type: TypedIdentifier | undefined): void;
|
|
1001
1001
|
addTypeNamed(name: string, type: TypedIdentifier | undefined): void;
|
|
1002
|
+
addExtraLikeType(type: TypedIdentifier | undefined): void;
|
|
1003
|
+
addExtraLikeTypeNamed(name: string, type: TypedIdentifier | undefined): void;
|
|
1002
1004
|
addClassDefinition(c: IClassDefinition): void;
|
|
1003
1005
|
addFormDefinitions(f: readonly IFormDefinition[]): void;
|
|
1004
1006
|
addInterfaceDefinition(i: IInterfaceDefinition): void;
|
|
@@ -1024,6 +1026,7 @@ export declare class CurrentScope {
|
|
|
1024
1026
|
findInterfaceDefinition(name: string): IInterfaceDefinition | undefined;
|
|
1025
1027
|
findFormDefinition(name: string): IFormDefinition | undefined;
|
|
1026
1028
|
findType(name: string | undefined): TypedIdentifier | undefined;
|
|
1029
|
+
findExtraLikeType(name: string | undefined): TypedIdentifier | undefined;
|
|
1027
1030
|
findVariable(name: string | undefined): TypedIdentifier | undefined;
|
|
1028
1031
|
getDDIC(): DDIC;
|
|
1029
1032
|
getDDICReferences(): IDDICReferences;
|
|
@@ -3067,6 +3070,9 @@ declare interface IScopeData {
|
|
|
3067
3070
|
types: {
|
|
3068
3071
|
[name: string]: TypedIdentifier;
|
|
3069
3072
|
};
|
|
3073
|
+
extraLikeTypes: {
|
|
3074
|
+
[name: string]: TypedIdentifier;
|
|
3075
|
+
};
|
|
3070
3076
|
deferred: Token[];
|
|
3071
3077
|
cdefs: IClassDefinition[];
|
|
3072
3078
|
idefs: IInterfaceDefinition[];
|
|
@@ -4312,6 +4318,7 @@ export declare enum ScopeType {
|
|
|
4312
4318
|
Form = "form",
|
|
4313
4319
|
FunctionModule = "function",
|
|
4314
4320
|
Method = "method",
|
|
4321
|
+
MethodInstance = "method_instance",
|
|
4315
4322
|
For = "for",
|
|
4316
4323
|
OpenSQL = "open_sql"
|
|
4317
4324
|
}
|
|
@@ -4595,6 +4602,7 @@ export declare class SpaghettiScopeNode extends ScopeData implements ISpaghettiS
|
|
|
4595
4602
|
listFormDefinitions(): IFormDefinition[];
|
|
4596
4603
|
findInterfaceDefinition(name: string): IInterfaceDefinition | undefined;
|
|
4597
4604
|
findType(name: string): TypedIdentifier | undefined;
|
|
4605
|
+
findExtraLikeType(name: string): TypedIdentifier | undefined;
|
|
4598
4606
|
findVariable(name: string): TypedIdentifier | undefined;
|
|
4599
4607
|
findWriteReference(pos: Position): TypedIdentifier | undefined;
|
|
4600
4608
|
findTableReference(pos: Position): string | undefined;
|
|
@@ -7,7 +7,8 @@ const tokens_1 = require("../../1_lexer/tokens");
|
|
|
7
7
|
class SQLArithmetics extends combi_1.Expression {
|
|
8
8
|
getRunnable() {
|
|
9
9
|
const operator = (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.WPlusW), (0, combi_1.tok)(tokens_1.WDashW), "*", "/");
|
|
10
|
-
|
|
10
|
+
const field = (0, combi_1.alt)(_1.SQLFieldName, _1.SQLFunction);
|
|
11
|
+
return (0, combi_1.seq)(field, (0, combi_1.starPrio)((0, combi_1.seq)(operator, field)));
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
exports.SQLArithmetics = SQLArithmetics;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SQLFunction = void 0;
|
|
4
|
+
const constant_1 = require("./constant");
|
|
4
5
|
const version_1 = require("../../../version");
|
|
5
6
|
const tokens_1 = require("../../1_lexer/tokens");
|
|
6
7
|
const combi_1 = require("../combi");
|
|
@@ -9,15 +10,20 @@ const sql_alias_field_1 = require("./sql_alias_field");
|
|
|
9
10
|
const sql_field_name_1 = require("./sql_field_name");
|
|
10
11
|
class SQLFunction extends combi_1.Expression {
|
|
11
12
|
getRunnable() {
|
|
12
|
-
const param = (0, combi_1.
|
|
13
|
-
const
|
|
13
|
+
const param = (0, combi_1.alt)(sql_field_name_1.SQLFieldName, sql_alias_field_1.SQLAliasField, SQLFunction, constant_1.Constant);
|
|
14
|
+
const castTypes = (0, combi_1.altPrio)((0, combi_1.seq)("CHAR", (0, combi_1.tok)(tokens_1.ParenLeftW), integer_1.Integer, (0, combi_1.tok)(tokens_1.WParenRightW)), "FLTP");
|
|
14
15
|
const abs = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("abs", (0, combi_1.tok)(tokens_1.ParenLeftW), param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
16
|
+
const cast = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("cast", (0, combi_1.tok)(tokens_1.ParenLeftW), param, "AS", castTypes, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
15
17
|
const ceil = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("ceil", (0, combi_1.tok)(tokens_1.ParenLeftW), param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
16
|
-
const
|
|
18
|
+
const coalesce = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("coalesce", (0, combi_1.tok)(tokens_1.ParenLeftW), param, ",", param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
19
|
+
const concat = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("concat", (0, combi_1.tok)(tokens_1.ParenLeftW), param, ",", param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
17
20
|
const div = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("div", (0, combi_1.tok)(tokens_1.ParenLeftW), param, ",", param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
21
|
+
const floor = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("floor", (0, combi_1.tok)(tokens_1.ParenLeftW), param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
22
|
+
const length = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("length", (0, combi_1.tok)(tokens_1.ParenLeftW), param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
18
23
|
const mod = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("mod", (0, combi_1.tok)(tokens_1.ParenLeftW), param, ",", param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
19
|
-
const
|
|
20
|
-
|
|
24
|
+
const replace = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("replace", (0, combi_1.tok)(tokens_1.ParenLeftW), param, ",", param, ",", param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
25
|
+
const uuid = (0, combi_1.ver)(version_1.Version.v754, (0, combi_1.seq)("uuid", (0, combi_1.tok)(tokens_1.ParenLeftW), (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
26
|
+
return (0, combi_1.altPrio)(uuid, abs, ceil, floor, cast, div, mod, coalesce, concat, replace, length);
|
|
21
27
|
}
|
|
22
28
|
}
|
|
23
29
|
exports.SQLFunction = SQLFunction;
|
|
@@ -54,6 +54,25 @@ class CurrentScope {
|
|
|
54
54
|
}
|
|
55
55
|
this.current.getData().types[upper] = type;
|
|
56
56
|
}
|
|
57
|
+
addExtraLikeType(type) {
|
|
58
|
+
if (type === undefined) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this.addExtraLikeTypeNamed(type.getName(), type);
|
|
62
|
+
}
|
|
63
|
+
addExtraLikeTypeNamed(name, type) {
|
|
64
|
+
if (type === undefined) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (this.current === undefined) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const upper = name.toUpperCase();
|
|
71
|
+
if (this.current.getData().extraLikeTypes[upper] !== undefined) {
|
|
72
|
+
throw new Error(`Type name "${name}" already defined`);
|
|
73
|
+
}
|
|
74
|
+
this.current.getData().extraLikeTypes[upper] = type;
|
|
75
|
+
}
|
|
57
76
|
addClassDefinition(c) {
|
|
58
77
|
var _a;
|
|
59
78
|
(_a = this.current) === null || _a === void 0 ? void 0 : _a.getData().cdefs.push(c);
|
|
@@ -231,6 +250,13 @@ class CurrentScope {
|
|
|
231
250
|
}
|
|
232
251
|
return (_a = this.current) === null || _a === void 0 ? void 0 : _a.findType(name);
|
|
233
252
|
}
|
|
253
|
+
findExtraLikeType(name) {
|
|
254
|
+
var _a;
|
|
255
|
+
if (name === undefined) {
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
return (_a = this.current) === null || _a === void 0 ? void 0 : _a.findExtraLikeType(name);
|
|
259
|
+
}
|
|
234
260
|
findVariable(name) {
|
|
235
261
|
var _a;
|
|
236
262
|
if (name === undefined) {
|
|
@@ -14,6 +14,7 @@ var ScopeType;
|
|
|
14
14
|
ScopeType["Form"] = "form";
|
|
15
15
|
ScopeType["FunctionModule"] = "function";
|
|
16
16
|
ScopeType["Method"] = "method";
|
|
17
|
+
ScopeType["MethodInstance"] = "method_instance";
|
|
17
18
|
ScopeType["For"] = "for";
|
|
18
19
|
ScopeType["OpenSQL"] = "open_sql";
|
|
19
20
|
})(ScopeType = exports.ScopeType || (exports.ScopeType = {}));
|
|
@@ -79,8 +79,12 @@ class BasicTypes {
|
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
81
|
const name = children.shift().getFirstToken().getStr();
|
|
82
|
-
|
|
82
|
+
let found = this.scope.findVariable(name);
|
|
83
83
|
type = found === null || found === void 0 ? void 0 : found.getType();
|
|
84
|
+
if (found === undefined) {
|
|
85
|
+
found = this.scope.findExtraLikeType(name);
|
|
86
|
+
type = found === null || found === void 0 ? void 0 : found.getType();
|
|
87
|
+
}
|
|
84
88
|
if (found) {
|
|
85
89
|
this.scope.addReference(chain === null || chain === void 0 ? void 0 : chain.getFirstToken(), found, _reference_1.ReferenceType.TypeReference, this.filename);
|
|
86
90
|
}
|
|
@@ -12,6 +12,7 @@ class ScopeData {
|
|
|
12
12
|
idefs: [],
|
|
13
13
|
forms: [],
|
|
14
14
|
types: {},
|
|
15
|
+
extraLikeTypes: {},
|
|
15
16
|
deferred: [],
|
|
16
17
|
references: [],
|
|
17
18
|
};
|
|
@@ -126,6 +127,18 @@ class SpaghettiScopeNode extends ScopeData {
|
|
|
126
127
|
}
|
|
127
128
|
return undefined;
|
|
128
129
|
}
|
|
130
|
+
findExtraLikeType(name) {
|
|
131
|
+
let search = this;
|
|
132
|
+
const upper = name.toUpperCase();
|
|
133
|
+
while (search !== undefined) {
|
|
134
|
+
const data = search.getData();
|
|
135
|
+
if (data.extraLikeTypes[upper]) {
|
|
136
|
+
return data.extraLikeTypes[upper];
|
|
137
|
+
}
|
|
138
|
+
search = search.getParent();
|
|
139
|
+
}
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
129
142
|
findVariable(name) {
|
|
130
143
|
let search = this;
|
|
131
144
|
const upper = name.toUpperCase();
|
|
@@ -28,8 +28,10 @@ class ClassImplementation {
|
|
|
28
28
|
scope.addIdentifier(new _typed_identifier_1.TypedIdentifier(new tokens_1.Identifier(new position_1.Position(1, 1), "me"), _builtin_1.BuiltIn.filename, new basic_1.ObjectReferenceType(classDefinition)));
|
|
29
29
|
helper.addAliasedAttributes(classDefinition); // todo, this is not correct, take care of instance vs static
|
|
30
30
|
scope.addList(classAttributes.getConstants());
|
|
31
|
-
scope.addList(classAttributes.
|
|
32
|
-
|
|
31
|
+
scope.addList(classAttributes.getStatic());
|
|
32
|
+
for (const i of classAttributes.getInstance()) {
|
|
33
|
+
scope.addExtraLikeType(i);
|
|
34
|
+
}
|
|
33
35
|
const implemented = helper.fromSuperClass(classDefinition);
|
|
34
36
|
helper.fromInterfaces(classDefinition, implemented);
|
|
35
37
|
}
|
|
@@ -11,17 +11,21 @@ class MethodImplementation {
|
|
|
11
11
|
const className = scope.getName();
|
|
12
12
|
const methodToken = node.findFirstExpression(Expressions.MethodName).getFirstToken();
|
|
13
13
|
const methodName = methodToken === null || methodToken === void 0 ? void 0 : methodToken.getStr();
|
|
14
|
-
scope.push(_scope_type_1.ScopeType.Method, methodName, node.getFirstToken().getStart(), filename);
|
|
15
14
|
const classDefinition = scope.findClassDefinition(className);
|
|
16
15
|
if (classDefinition === undefined) {
|
|
17
|
-
scope.pop(node.getLastToken().getEnd());
|
|
16
|
+
// scope.pop(node.getLastToken().getEnd());
|
|
18
17
|
throw new Error("Class definition for \"" + className + "\" not found");
|
|
19
18
|
}
|
|
20
19
|
const { method: methodDefinition } = helper.searchMethodName(classDefinition, methodName);
|
|
21
20
|
if (methodDefinition === undefined) {
|
|
22
|
-
scope.pop(node.getLastToken().getEnd());
|
|
21
|
+
// scope.pop(node.getLastToken().getEnd());
|
|
23
22
|
throw new Error("Method definition \"" + methodName + "\" not found");
|
|
24
23
|
}
|
|
24
|
+
if (methodDefinition.isStatic() === false) {
|
|
25
|
+
scope.push(_scope_type_1.ScopeType.MethodInstance, methodName, node.getFirstToken().getStart(), filename);
|
|
26
|
+
scope.addList(classDefinition.getAttributes().getInstance());
|
|
27
|
+
}
|
|
28
|
+
scope.push(_scope_type_1.ScopeType.Method, methodName, node.getFirstToken().getStart(), filename);
|
|
25
29
|
scope.addReference(methodToken, methodDefinition, _reference_1.ReferenceType.MethodImplementationReference, filename);
|
|
26
30
|
scope.addList(methodDefinition.getParameters().getAll());
|
|
27
31
|
for (const i of helper.findInterfaces(classDefinition)) {
|
|
@@ -412,11 +412,16 @@ class SyntaxLogic {
|
|
|
412
412
|
}
|
|
413
413
|
else if (s instanceof Statements.EndForm
|
|
414
414
|
|| s instanceof Statements.EndFunction
|
|
415
|
-
|| s instanceof Statements.EndMethod
|
|
416
415
|
|| s instanceof Statements.EndClass
|
|
417
416
|
|| s instanceof Statements.EndInterface) {
|
|
418
417
|
this.scope.pop(node.getLastToken().getEnd());
|
|
419
418
|
}
|
|
419
|
+
else if (s instanceof Statements.EndMethod) {
|
|
420
|
+
this.scope.pop(node.getLastToken().getEnd());
|
|
421
|
+
if (this.scope.getType() === _scope_type_1.ScopeType.MethodInstance) {
|
|
422
|
+
this.scope.pop(node.getLastToken().getEnd());
|
|
423
|
+
}
|
|
424
|
+
}
|
|
420
425
|
}
|
|
421
426
|
}
|
|
422
427
|
exports.SyntaxLogic = SyntaxLogic;
|
package/build/src/registry.js
CHANGED
|
@@ -8,10 +8,6 @@ const _abap_rule_1 = require("./_abap_rule");
|
|
|
8
8
|
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
9
9
|
const _irule_1 = require("./_irule");
|
|
10
10
|
class NoChainedAssignmentConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
11
|
-
constructor() {
|
|
12
|
-
super(...arguments);
|
|
13
|
-
this.onlyConstants = false;
|
|
14
|
-
}
|
|
15
11
|
}
|
|
16
12
|
exports.NoChainedAssignmentConf = NoChainedAssignmentConf;
|
|
17
13
|
class NoChainedAssignment extends _abap_rule_1.ABAPRule {
|
|
@@ -28,7 +24,7 @@ class NoChainedAssignment extends _abap_rule_1.ABAPRule {
|
|
|
28
24
|
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide],
|
|
29
25
|
badExample: `var1 = var2 = var3.`,
|
|
30
26
|
goodExample: `var2 = var3.
|
|
31
|
-
var1 =
|
|
27
|
+
var1 = var2.`,
|
|
32
28
|
};
|
|
33
29
|
}
|
|
34
30
|
getConfig() {
|
|
@@ -6,10 +6,6 @@ const _abap_rule_1 = require("./_abap_rule");
|
|
|
6
6
|
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
7
7
|
const _irule_1 = require("./_irule");
|
|
8
8
|
class UnnecessaryChainingConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
this.onlyConstants = false;
|
|
12
|
-
}
|
|
13
9
|
}
|
|
14
10
|
exports.UnnecessaryChainingConf = UnnecessaryChainingConf;
|
|
15
11
|
class UnnecessaryChaining extends _abap_rule_1.ABAPRule {
|
|
@@ -67,6 +67,10 @@ class UnreachableCode extends _abap_rule_1.ABAPRule {
|
|
|
67
67
|
return true;
|
|
68
68
|
}
|
|
69
69
|
else if (s instanceof Statements.Leave && n.findFirstExpression(Expressions.AndReturn) === undefined) {
|
|
70
|
+
const concat = n.concatTokens();
|
|
71
|
+
if (concat.includes(" TO LIST-PROCESSING")) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
70
74
|
return true;
|
|
71
75
|
}
|
|
72
76
|
else if (s instanceof Statements.Return
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.81.
|
|
3
|
+
"version": "2.81.1",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"c8": "^7.10.0",
|
|
56
56
|
"source-map-support": "^0.5.20",
|
|
57
57
|
"ts-json-schema-generator": "^0.97.0",
|
|
58
|
-
"typescript": "^4.
|
|
58
|
+
"typescript": "^4.5.2"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"fast-xml-parser": "^3.21.1",
|