@abaplint/core 2.97.4 → 2.97.6
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 -0
- package/build/src/abap/2_statements/statements/call_function.js +1 -1
- package/build/src/abap/5_syntax/_current_scope.js +12 -0
- package/build/src/abap/5_syntax/expressions/method_source.js +12 -2
- package/build/src/abap/5_syntax/statements/call_function.js +8 -0
- package/build/src/abap/5_syntax/statements/create_object.js +4 -1
- package/build/src/lsp/language_server.js +9 -4
- package/build/src/pretty_printer/pretty_printer.js +0 -3
- package/build/src/registry.js +1 -1
- package/package.json +4 -4
- package/build/src/pretty_printer/remove_sequential_blanks.js +0 -50
package/build/abaplint.d.ts
CHANGED
|
@@ -1262,6 +1262,7 @@ export declare class CurrentScope {
|
|
|
1262
1262
|
addListPrefix(identifiers: readonly TypedIdentifier[], prefix: string): void;
|
|
1263
1263
|
addList(identifiers: readonly TypedIdentifier[]): void;
|
|
1264
1264
|
addReference(usage: Token | undefined, referencing: Identifier | undefined, type: ReferenceType | undefined, filename: string, extra?: IReferenceExtras): void;
|
|
1265
|
+
findFunctionModule(name: string | undefined): FunctionModuleDefinition | undefined;
|
|
1265
1266
|
findObjectDefinition(name: string | undefined): IClassDefinition | IInterfaceDefinition | undefined;
|
|
1266
1267
|
isBadiDef(name: string): boolean;
|
|
1267
1268
|
existsObject(name: string | undefined): {
|
|
@@ -6,7 +6,7 @@ const expressions_1 = require("../expressions");
|
|
|
6
6
|
const version_1 = require("../../../version");
|
|
7
7
|
class CallFunction {
|
|
8
8
|
getMatcher() {
|
|
9
|
-
const starting = (0, combi_1.seq)("STARTING NEW TASK", expressions_1.SimpleSource2);
|
|
9
|
+
const starting = (0, combi_1.verNot)(version_1.Version.Cloud, (0, combi_1.seq)("STARTING NEW TASK", expressions_1.SimpleSource2));
|
|
10
10
|
const update = (0, combi_1.verNot)(version_1.Version.Cloud, (0, combi_1.str)("IN UPDATE TASK"));
|
|
11
11
|
const unit = (0, combi_1.seq)("UNIT", expressions_1.Source);
|
|
12
12
|
const background = (0, combi_1.verNot)(version_1.Version.Cloud, (0, combi_1.seq)("IN BACKGROUND", (0, combi_1.altPrio)("TASK", unit)));
|
|
@@ -138,6 +138,18 @@ class CurrentScope {
|
|
|
138
138
|
(_a = this.current) === null || _a === void 0 ? void 0 : _a.getData().references.push({ position, resolved: referencing, referenceType: type, extra });
|
|
139
139
|
}
|
|
140
140
|
///////////////////////////
|
|
141
|
+
findFunctionModule(name) {
|
|
142
|
+
if (name === undefined) {
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
for (const fugr of this.reg.getObjectsByType("FUGR")) {
|
|
146
|
+
const func = fugr.getModule(name);
|
|
147
|
+
if (func !== undefined) {
|
|
148
|
+
return func;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
141
153
|
findObjectDefinition(name) {
|
|
142
154
|
if (name === undefined) {
|
|
143
155
|
return undefined;
|
|
@@ -14,9 +14,10 @@ const tokens_1 = require("../../1_lexer/tokens");
|
|
|
14
14
|
const attribute_name_1 = require("./attribute_name");
|
|
15
15
|
const component_name_1 = require("./component_name");
|
|
16
16
|
const types_1 = require("../../types");
|
|
17
|
+
const version_1 = require("../../../version");
|
|
17
18
|
class MethodSource {
|
|
18
19
|
runSyntax(node, scope, filename) {
|
|
19
|
-
var _a;
|
|
20
|
+
var _a, _b, _c;
|
|
20
21
|
const helper = new _object_oriented_1.ObjectOriented(scope);
|
|
21
22
|
const children = node.getChildren().slice();
|
|
22
23
|
const first = children.shift();
|
|
@@ -28,6 +29,15 @@ class MethodSource {
|
|
|
28
29
|
context = (_a = scope.findVariable("me")) === null || _a === void 0 ? void 0 : _a.getType();
|
|
29
30
|
children.unshift(first);
|
|
30
31
|
}
|
|
32
|
+
if (scope.getVersion() === version_1.Version.Cloud
|
|
33
|
+
&& first.get() instanceof Expressions.Dynamic
|
|
34
|
+
&& first instanceof nodes_1.ExpressionNode
|
|
35
|
+
&& ((_b = children[0]) === null || _b === void 0 ? void 0 : _b.concatTokens()) === "=>") {
|
|
36
|
+
const name = (_c = first.findDirectExpression(Expressions.Constant)) === null || _c === void 0 ? void 0 : _c.concatTokens().replace(/'/g, "");
|
|
37
|
+
if (name !== undefined && scope.findClassDefinition(name) === undefined) {
|
|
38
|
+
throw new Error(`Class "${name}" not found/released`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
31
41
|
if (context instanceof basic_1.VoidType) {
|
|
32
42
|
// todo, if there are more dynamic with variables, the references for the variables are not added?
|
|
33
43
|
return context;
|
|
@@ -58,7 +68,7 @@ class MethodSource {
|
|
|
58
68
|
continue;
|
|
59
69
|
}
|
|
60
70
|
}
|
|
61
|
-
catch (
|
|
71
|
+
catch (_d) {
|
|
62
72
|
// ignore
|
|
63
73
|
}
|
|
64
74
|
// try looking for method name
|
|
@@ -6,6 +6,7 @@ const source_1 = require("../expressions/source");
|
|
|
6
6
|
const target_1 = require("../expressions/target");
|
|
7
7
|
const field_chain_1 = require("../expressions/field_chain");
|
|
8
8
|
const _reference_1 = require("../_reference");
|
|
9
|
+
const version_1 = require("../../../version");
|
|
9
10
|
class CallFunction {
|
|
10
11
|
runSyntax(node, scope, filename) {
|
|
11
12
|
// todo, lots of work here, similar to receive.ts
|
|
@@ -14,6 +15,13 @@ class CallFunction {
|
|
|
14
15
|
if (chain) {
|
|
15
16
|
new field_chain_1.FieldChain().runSyntax(chain, scope, filename, _reference_1.ReferenceType.DataReadReference);
|
|
16
17
|
}
|
|
18
|
+
else if (scope.getVersion() === version_1.Version.Cloud
|
|
19
|
+
&& node.findDirectExpression(Expressions.Destination) === undefined) {
|
|
20
|
+
const functionName = name === null || name === void 0 ? void 0 : name.concatTokens().replace(/'/, "");
|
|
21
|
+
if (scope.findFunctionModule(functionName) === undefined) {
|
|
22
|
+
throw new Error(`Function module "${functionName}" not found/released`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
17
25
|
// just recurse
|
|
18
26
|
for (const s of node.findAllExpressions(Expressions.Source)) {
|
|
19
27
|
new source_1.Source().runSyntax(s, scope, filename);
|
|
@@ -56,7 +56,10 @@ class CreateObject {
|
|
|
56
56
|
}
|
|
57
57
|
else if (found instanceof basic_1.ObjectReferenceType) {
|
|
58
58
|
const id = found.getIdentifier();
|
|
59
|
-
if (id instanceof types_1.
|
|
59
|
+
if (id instanceof types_1.InterfaceDefinition && cdef === undefined) {
|
|
60
|
+
throw new Error("Interface reference, cannot be instantiated");
|
|
61
|
+
}
|
|
62
|
+
else if (id instanceof types_1.ClassDefinition && cdef === undefined) {
|
|
60
63
|
cdef = id;
|
|
61
64
|
}
|
|
62
65
|
if (type === undefined && id instanceof types_1.ClassDefinition && id.isAbstract() === true) {
|
|
@@ -49,10 +49,15 @@ class LanguageServer {
|
|
|
49
49
|
}
|
|
50
50
|
const text = new pretty_printer_1.PrettyPrinter(file, this.reg.getConfig()).run();
|
|
51
51
|
const rows = file.getRawRows();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
if (text === file.getRaw()) {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return [{
|
|
57
|
+
range: LServer.Range.create(0, 0, rows.length, rows[rows.length - 1].length + 1),
|
|
58
|
+
newText: text,
|
|
59
|
+
}];
|
|
60
|
+
}
|
|
56
61
|
}
|
|
57
62
|
// https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/#textDocument_publishDiagnostics
|
|
58
63
|
diagnostics(textDocument) {
|
|
@@ -4,7 +4,6 @@ exports.PrettyPrinter = void 0;
|
|
|
4
4
|
const _statement_1 = require("../abap/2_statements/statements/_statement");
|
|
5
5
|
const fix_keyword_case_1 = require("./fix_keyword_case");
|
|
6
6
|
const indent_1 = require("./indent");
|
|
7
|
-
const remove_sequential_blanks_1 = require("./remove_sequential_blanks");
|
|
8
7
|
const position_1 = require("../position");
|
|
9
8
|
const indentation_1 = require("../rules/indentation");
|
|
10
9
|
class PrettyPrinter {
|
|
@@ -34,8 +33,6 @@ class PrettyPrinter {
|
|
|
34
33
|
}
|
|
35
34
|
const indentation = new indent_1.Indent(this.options);
|
|
36
35
|
this.result = indentation.execute(this.file, this.result);
|
|
37
|
-
const removeBlanks = new remove_sequential_blanks_1.RemoveSequentialBlanks(this.config);
|
|
38
|
-
this.result = removeBlanks.execute(this.file, this.result);
|
|
39
36
|
return this.result;
|
|
40
37
|
}
|
|
41
38
|
}
|
package/build/src/registry.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.97.
|
|
3
|
+
"version": "2.97.6",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -52,15 +52,15 @@
|
|
|
52
52
|
"@types/mocha": "^10.0.1",
|
|
53
53
|
"@types/node": "^18.15.11",
|
|
54
54
|
"chai": "^4.3.7",
|
|
55
|
-
"eslint": "^8.
|
|
55
|
+
"eslint": "^8.38.0",
|
|
56
56
|
"mocha": "^10.2.0",
|
|
57
57
|
"c8": "^7.13.0",
|
|
58
58
|
"source-map-support": "^0.5.21",
|
|
59
59
|
"ts-json-schema-generator": "^1.2.0",
|
|
60
|
-
"typescript": "^5.0.
|
|
60
|
+
"typescript": "^5.0.4"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"fast-xml-parser": "^4.1.
|
|
63
|
+
"fast-xml-parser": "^4.1.4",
|
|
64
64
|
"json5": "^2.2.3",
|
|
65
65
|
"vscode-languageserver-types": "^3.17.3"
|
|
66
66
|
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RemoveSequentialBlanks = void 0;
|
|
4
|
-
const rules_1 = require("../rules");
|
|
5
|
-
class RemoveSequentialBlanks {
|
|
6
|
-
constructor(config) {
|
|
7
|
-
this.config = config;
|
|
8
|
-
}
|
|
9
|
-
execute(file, modified) {
|
|
10
|
-
const sequentialBlankConfig = this.getSequentialBlankConfig();
|
|
11
|
-
if (sequentialBlankConfig) {
|
|
12
|
-
return this.withoutSequentialBlanks(file, modified, sequentialBlankConfig.lines);
|
|
13
|
-
}
|
|
14
|
-
return modified;
|
|
15
|
-
}
|
|
16
|
-
withoutSequentialBlanks(file, modified, threshold) {
|
|
17
|
-
const rows = file.getRawRows();
|
|
18
|
-
let blanks = 0;
|
|
19
|
-
const rowsToRemove = [];
|
|
20
|
-
const newBlankCount = (current, row) => {
|
|
21
|
-
return rules_1.SequentialBlank.isBlankOrWhitespace(row) ? current + 1 : 0;
|
|
22
|
-
};
|
|
23
|
-
for (let i = 0; i < rows.length; i++) {
|
|
24
|
-
blanks = newBlankCount(blanks, rows[i]);
|
|
25
|
-
if (blanks === threshold) {
|
|
26
|
-
// count additional blanks
|
|
27
|
-
for (let j = i; j < rows.length; j++) {
|
|
28
|
-
if (rules_1.SequentialBlank.isBlankOrWhitespace(rows[j])) {
|
|
29
|
-
rowsToRemove.push(j);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return this.removeRows(modified.split("\n"), rowsToRemove);
|
|
38
|
-
}
|
|
39
|
-
removeRows(lines, rowsToRemove) {
|
|
40
|
-
const withoutRemoved = lines.filter((_, idx) => {
|
|
41
|
-
return rowsToRemove.indexOf(idx) === -1;
|
|
42
|
-
});
|
|
43
|
-
return withoutRemoved.join("\n").trim();
|
|
44
|
-
}
|
|
45
|
-
getSequentialBlankConfig() {
|
|
46
|
-
return this.config.readByRule(new rules_1.SequentialBlank().getMetadata().key);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.RemoveSequentialBlanks = RemoveSequentialBlanks;
|
|
50
|
-
//# sourceMappingURL=remove_sequential_blanks.js.map
|