@abaplint/core 2.97.3 → 2.97.5
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 +2 -2
- package/build/src/abap/5_syntax/_current_scope.js +12 -0
- package/build/src/abap/5_syntax/statements/call_function.js +8 -0
- 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/build/src/rules/sql_escape_host_variables.js +1 -1
- package/build/src/rules/strict_sql.js +6 -2
- package/package.json +1 -1
- 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,8 +6,8 @@ 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);
|
|
10
|
-
const update = (0, combi_1.str)("IN UPDATE TASK");
|
|
9
|
+
const starting = (0, combi_1.verNot)(version_1.Version.Cloud, (0, combi_1.seq)("STARTING NEW TASK", expressions_1.SimpleSource2));
|
|
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)));
|
|
13
13
|
const calling = (0, combi_1.seq)("CALLING", expressions_1.MethodName, "ON END OF TASK");
|
|
@@ -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;
|
|
@@ -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);
|
|
@@ -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
|
@@ -51,7 +51,7 @@ class SQLEscapeHostVariables extends _abap_rule_1.ABAPRule {
|
|
|
51
51
|
|| s.get() instanceof Statements.SelectLoop
|
|
52
52
|
|| s.get() instanceof Statements.InsertDatabase
|
|
53
53
|
|| s.get() instanceof Statements.DeleteDatabase) {
|
|
54
|
-
for (const o of s.
|
|
54
|
+
for (const o of s.findAllExpressionsMulti([Expressions.SQLSource, Expressions.SQLSourceSimple])) {
|
|
55
55
|
const first = o.getFirstChild();
|
|
56
56
|
if (((first === null || first === void 0 ? void 0 : first.get()) instanceof Expressions.Source && first.getChildren()[0].get() instanceof Expressions.FieldChain)
|
|
57
57
|
|| ((first === null || first === void 0 ? void 0 : first.get()) instanceof Expressions.SimpleSource3 && first.getChildren()[0].get() instanceof Expressions.FieldChain)) {
|
|
@@ -53,6 +53,7 @@ Activates from v750 and up`,
|
|
|
53
53
|
|| s.get() instanceof Statements.SelectLoop) {
|
|
54
54
|
const expr = s.findDirectExpression(Expressions.Select);
|
|
55
55
|
const where = expr === null || expr === void 0 ? void 0 : expr.findDirectExpression(Expressions.SQLCond);
|
|
56
|
+
const order = expr === null || expr === void 0 ? void 0 : expr.findDirectExpression(Expressions.SQLOrderBy);
|
|
56
57
|
const into = (expr === null || expr === void 0 ? void 0 : expr.findDirectExpression(Expressions.SQLIntoStructure))
|
|
57
58
|
|| (expr === null || expr === void 0 ? void 0 : expr.findDirectExpression(Expressions.SQLIntoTable));
|
|
58
59
|
if (into === undefined || where === undefined) {
|
|
@@ -62,8 +63,11 @@ Activates from v750 and up`,
|
|
|
62
63
|
continue;
|
|
63
64
|
}
|
|
64
65
|
const fix1 = edit_helper_1.EditHelper.deleteRange(file, into.getFirstToken().getStart(), into.getLastToken().getEnd());
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
let last = where.getLastToken();
|
|
67
|
+
if (order && order.getLastToken().getEnd().isAfter(last.getEnd())) {
|
|
68
|
+
last = order.getLastToken();
|
|
69
|
+
}
|
|
70
|
+
const fix2 = edit_helper_1.EditHelper.insertAt(file, last.getEnd(), " " + into.concatTokens());
|
|
67
71
|
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
68
72
|
const message = "INTO/APPENDING must be last in strict SQL";
|
|
69
73
|
const issue = issue_1.Issue.atToken(file, s.getFirstToken(), message, this.getMetadata().key, this.conf.severity, fix);
|
package/package.json
CHANGED
|
@@ -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
|