@abaplint/core 2.95.38 → 2.95.40
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 +1 -1
- package/build/src/abap/1_lexer/lexer.js +4 -4
- package/build/src/abap/5_syntax/expressions/component_chain.js +4 -1
- package/build/src/abap/5_syntax/expressions/component_compare.js +2 -18
- package/build/src/abap/5_syntax/statements/delete_internal.js +8 -3
- package/build/src/abap/types/basic/structure_type.js +5 -2
- package/build/src/objects/table.js +1 -1
- package/build/src/position.js +2 -2
- package/build/src/registry.js +1 -1
- package/build/src/rules/downport.js +20 -4
- package/package.json +2 -2
package/build/abaplint.d.ts
CHANGED
|
@@ -5819,7 +5819,7 @@ export { Structures }
|
|
|
5819
5819
|
declare class StructureType extends AbstractType {
|
|
5820
5820
|
private readonly indexed;
|
|
5821
5821
|
private readonly components;
|
|
5822
|
-
constructor(components: IStructureComponent[], qualifiedName?: string);
|
|
5822
|
+
constructor(components: IStructureComponent[], qualifiedName?: string, ddicName?: string);
|
|
5823
5823
|
getComponents(): IStructureComponent[];
|
|
5824
5824
|
getComponentByName(name: string): AbstractType | undefined;
|
|
5825
5825
|
toText(level: number): string;
|
|
@@ -330,7 +330,10 @@ class Lexer {
|
|
|
330
330
|
const ahead = this.stream.nextChar();
|
|
331
331
|
const aahead = this.stream.nextNextChar();
|
|
332
332
|
if (this.m === this.ModeNormal) {
|
|
333
|
-
if (ahead
|
|
333
|
+
if (splits[ahead]) {
|
|
334
|
+
this.add();
|
|
335
|
+
}
|
|
336
|
+
else if (ahead === "'") {
|
|
334
337
|
// start string
|
|
335
338
|
this.add();
|
|
336
339
|
this.m = this.ModeStr;
|
|
@@ -356,9 +359,6 @@ class Lexer {
|
|
|
356
359
|
this.add();
|
|
357
360
|
this.m = this.ModeComment;
|
|
358
361
|
}
|
|
359
|
-
else if (splits[ahead]) {
|
|
360
|
-
this.add();
|
|
361
|
-
}
|
|
362
362
|
else if (ahead === "@" && buf.trim().length === 0) {
|
|
363
363
|
this.add();
|
|
364
364
|
}
|
|
@@ -10,6 +10,9 @@ const _reference_1 = require("../_reference");
|
|
|
10
10
|
const _object_oriented_1 = require("../_object_oriented");
|
|
11
11
|
class ComponentChain {
|
|
12
12
|
runSyntax(context, node, scope, filename) {
|
|
13
|
+
if (context === undefined) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
13
16
|
const children = node.getChildren();
|
|
14
17
|
for (let i = 0; i < children.length; i++) {
|
|
15
18
|
if (context instanceof void_type_1.VoidType || context instanceof basic_1.UnknownType) {
|
|
@@ -72,7 +75,7 @@ class ComponentChain {
|
|
|
72
75
|
}
|
|
73
76
|
}
|
|
74
77
|
else {
|
|
75
|
-
throw new Error("ComponentChain, not a structure");
|
|
78
|
+
throw new Error("ComponentChain, not a structure, " + (context === null || context === void 0 ? void 0 : context.constructor.name));
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ComponentCompare = void 0;
|
|
4
4
|
const Expressions = require("../../2_statements/expressions");
|
|
5
|
-
const
|
|
5
|
+
const component_chain_1 = require("./component_chain");
|
|
6
6
|
const source_1 = require("./source");
|
|
7
7
|
class ComponentCompare {
|
|
8
8
|
runSyntax(node, scope, filename, type) {
|
|
@@ -10,23 +10,7 @@ class ComponentCompare {
|
|
|
10
10
|
if (chain === undefined) {
|
|
11
11
|
throw new Error("ComponentCompare, chain not found");
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
if (chain.getChildren().length === 1
|
|
15
|
-
&& type !== undefined
|
|
16
|
-
&& !(type instanceof basic_1.VoidType)
|
|
17
|
-
&& !(type instanceof basic_1.UnknownType)
|
|
18
|
-
&& !(type instanceof basic_1.AnyType)) {
|
|
19
|
-
const fieldName = chain.concatTokens();
|
|
20
|
-
if (fieldName.toLowerCase() !== "table_line") {
|
|
21
|
-
if (!(type instanceof basic_1.StructureType)) {
|
|
22
|
-
throw new Error("ComponentCompare, source not structured");
|
|
23
|
-
}
|
|
24
|
-
if (type.getComponentByName(fieldName) === undefined) {
|
|
25
|
-
throw new Error("Component \"" + fieldName + "\" not part of structure");
|
|
26
|
-
}
|
|
27
|
-
// todo, check type compatibility
|
|
28
|
-
}
|
|
29
|
-
}
|
|
13
|
+
new component_chain_1.ComponentChain().runSyntax(type, chain, scope, filename);
|
|
30
14
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
31
15
|
new source_1.Source().runSyntax(s, scope, filename);
|
|
32
16
|
}
|
|
@@ -6,12 +6,14 @@ const target_1 = require("../expressions/target");
|
|
|
6
6
|
const source_1 = require("../expressions/source");
|
|
7
7
|
const component_compare_1 = require("../expressions/component_compare");
|
|
8
8
|
const component_cond_1 = require("../expressions/component_cond");
|
|
9
|
+
const basic_1 = require("../../types/basic");
|
|
9
10
|
class DeleteInternal {
|
|
10
11
|
runSyntax(node, scope, filename) {
|
|
11
12
|
var _a;
|
|
12
13
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
13
14
|
new source_1.Source().runSyntax(s, scope, filename);
|
|
14
15
|
}
|
|
16
|
+
let targetType = undefined;
|
|
15
17
|
const target = node.findDirectExpression(Expressions.Target);
|
|
16
18
|
if (target) {
|
|
17
19
|
let tabl = undefined;
|
|
@@ -23,14 +25,17 @@ class DeleteInternal {
|
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
if (tabl === undefined) {
|
|
26
|
-
new target_1.Target().runSyntax(target, scope, filename);
|
|
28
|
+
targetType = new target_1.Target().runSyntax(target, scope, filename);
|
|
29
|
+
if (targetType instanceof basic_1.TableType) {
|
|
30
|
+
targetType = targetType.getRowType();
|
|
31
|
+
}
|
|
27
32
|
}
|
|
28
33
|
}
|
|
29
34
|
for (const t of node.findDirectExpressions(Expressions.ComponentCompare)) {
|
|
30
|
-
new component_compare_1.ComponentCompare().runSyntax(t, scope, filename);
|
|
35
|
+
new component_compare_1.ComponentCompare().runSyntax(t, scope, filename, targetType);
|
|
31
36
|
}
|
|
32
37
|
for (const t of node.findDirectExpressions(Expressions.ComponentCond)) {
|
|
33
|
-
new component_cond_1.ComponentCond().runSyntax(t, scope, filename);
|
|
38
|
+
new component_cond_1.ComponentCond().runSyntax(t, scope, filename, targetType);
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
}
|
|
@@ -3,8 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.StructureType = void 0;
|
|
4
4
|
const _abstract_type_1 = require("./_abstract_type");
|
|
5
5
|
class StructureType extends _abstract_type_1.AbstractType {
|
|
6
|
-
constructor(components, qualifiedName) {
|
|
7
|
-
super({
|
|
6
|
+
constructor(components, qualifiedName, ddicName) {
|
|
7
|
+
super({
|
|
8
|
+
qualifiedName: qualifiedName,
|
|
9
|
+
ddicName: ddicName,
|
|
10
|
+
});
|
|
8
11
|
if (components.length === 0) {
|
|
9
12
|
throw new Error("Structure does not contain any components");
|
|
10
13
|
}
|
|
@@ -231,7 +231,7 @@ class Table extends _abstract_object_1.AbstractObject {
|
|
|
231
231
|
return new Types.UnknownType("Table/Structure " + this.getName() + " does not contain any components");
|
|
232
232
|
}
|
|
233
233
|
reg.getDDICReferences().setUsing(this, references);
|
|
234
|
-
return new Types.StructureType(components, this.getName());
|
|
234
|
+
return new Types.StructureType(components, this.getName(), this.getName());
|
|
235
235
|
}
|
|
236
236
|
getTableCategory() {
|
|
237
237
|
var _a;
|
package/build/src/position.js
CHANGED
|
@@ -31,7 +31,6 @@ exports.Position = Position;
|
|
|
31
31
|
class VirtualPosition extends Position {
|
|
32
32
|
constructor(virtual, row, col) {
|
|
33
33
|
super(virtual.getRow(), virtual.getCol());
|
|
34
|
-
// this.virtual = virtual;
|
|
35
34
|
this.vrow = row;
|
|
36
35
|
this.vcol = col;
|
|
37
36
|
}
|
|
@@ -39,7 +38,8 @@ class VirtualPosition extends Position {
|
|
|
39
38
|
if (!(p instanceof VirtualPosition)) {
|
|
40
39
|
return false;
|
|
41
40
|
}
|
|
42
|
-
|
|
41
|
+
const casted = p;
|
|
42
|
+
return super.equals(this) && this.vrow === casted.vrow && this.vcol === casted.vcol;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
exports.VirtualPosition = VirtualPosition;
|
package/build/src/registry.js
CHANGED
|
@@ -25,6 +25,7 @@ const include_graph_1 = require("../utils/include_graph");
|
|
|
25
25
|
const objects_1 = require("../objects");
|
|
26
26
|
const _builtin_1 = require("../abap/5_syntax/_builtin");
|
|
27
27
|
const _scope_type_1 = require("../abap/5_syntax/_scope_type");
|
|
28
|
+
const statements_1 = require("../abap/2_statements/statements");
|
|
28
29
|
// todo: refactor each sub-rule to new classes?
|
|
29
30
|
// todo: add configuration
|
|
30
31
|
class DownportConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
@@ -430,7 +431,7 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
430
431
|
if (found) {
|
|
431
432
|
return found;
|
|
432
433
|
}
|
|
433
|
-
found = this.replaceLineFunctions(high, lowFile, highSyntax);
|
|
434
|
+
found = this.replaceLineFunctions(high, lowFile, highSyntax, highFile);
|
|
434
435
|
if (found) {
|
|
435
436
|
return found;
|
|
436
437
|
}
|
|
@@ -2471,7 +2472,7 @@ ${indentation} output = ${topTarget}.`;
|
|
|
2471
2472
|
}
|
|
2472
2473
|
return undefined;
|
|
2473
2474
|
}
|
|
2474
|
-
replaceLineFunctions(node, lowFile, highSyntax) {
|
|
2475
|
+
replaceLineFunctions(node, lowFile, highSyntax, highFile) {
|
|
2475
2476
|
var _a, _b;
|
|
2476
2477
|
const spag = highSyntax.spaghetti.lookupPosition(node.getFirstToken().getStart(), lowFile.getFilename());
|
|
2477
2478
|
for (const r of (spag === null || spag === void 0 ? void 0 : spag.getData().references) || []) {
|
|
@@ -2506,16 +2507,31 @@ ${indentation} output = ${topTarget}.`;
|
|
|
2506
2507
|
indentation + `READ TABLE ${tableName} ${condition}TRANSPORTING NO FIELDS.\n` +
|
|
2507
2508
|
indentation + uniqueName + ` = ${sy}.\n` +
|
|
2508
2509
|
indentation;
|
|
2509
|
-
|
|
2510
|
+
let insertAt = node.getFirstToken().getStart();
|
|
2511
|
+
if (node.get() instanceof statements_1.ElseIf) {
|
|
2512
|
+
// assumption: no side effects in IF conditions
|
|
2513
|
+
insertAt = this.findStartOfIf(node, highFile);
|
|
2514
|
+
}
|
|
2515
|
+
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, insertAt, code);
|
|
2510
2516
|
const start = expression.getFirstToken().getStart();
|
|
2511
2517
|
const end = expression.getLastToken().getEnd();
|
|
2512
2518
|
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, uniqueName + (func === "LINE_EXISTS" ? " = 0" : ""));
|
|
2513
2519
|
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
2514
|
-
return issue_1.Issue.atToken(lowFile, token, "
|
|
2520
|
+
return issue_1.Issue.atToken(lowFile, token, "Replace line function", this.getMetadata().key, this.conf.severity, fix);
|
|
2515
2521
|
}
|
|
2516
2522
|
}
|
|
2517
2523
|
return undefined;
|
|
2518
2524
|
}
|
|
2525
|
+
findStartOfIf(node, highFile) {
|
|
2526
|
+
var _a;
|
|
2527
|
+
const structure = highFile.getStructure();
|
|
2528
|
+
for (const c of (structure === null || structure === void 0 ? void 0 : structure.findAllStructuresRecursive(Structures.If)) || []) {
|
|
2529
|
+
if (((_a = c.findDirectStructure(Structures.ElseIf)) === null || _a === void 0 ? void 0 : _a.getFirstStatement()) === node) {
|
|
2530
|
+
return c.getFirstToken().getStart();
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
return node.getFirstToken().getStart();
|
|
2534
|
+
}
|
|
2519
2535
|
newToCreateObject(low, high, lowFile, highSyntax) {
|
|
2520
2536
|
if (!(low.get() instanceof _statement_1.Unknown)) {
|
|
2521
2537
|
return undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.95.
|
|
3
|
+
"version": "2.95.40",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@types/mocha": "^10.0.1",
|
|
53
53
|
"@types/node": "^18.15.0",
|
|
54
54
|
"chai": "^4.3.7",
|
|
55
|
-
"eslint": "^8.
|
|
55
|
+
"eslint": "^8.36.0",
|
|
56
56
|
"mocha": "^10.2.0",
|
|
57
57
|
"c8": "^7.13.0",
|
|
58
58
|
"source-map-support": "^0.5.21",
|