@abaplint/core 2.119.47 → 2.119.49
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/src/abap/2_statements/expand_macros.js +14 -7
- package/build/src/abap/2_statements/statements/_statement.js +7 -1
- package/build/src/abap/3_structures/structures/_combi.js +1 -1
- package/build/src/abap/3_structures/structures/normal.js +1 -1
- package/build/src/abap/5_syntax/_syntax_input.js +2 -2
- package/build/src/abap/5_syntax/expressions/select.js +20 -1
- package/build/src/registry.js +1 -1
- package/build/src/rules/index.js +1 -0
- package/build/src/rules/no_macros.js +82 -0
- package/build/src/rules/parser_error.js +15 -11
- package/package.json +1 -1
|
@@ -134,7 +134,7 @@ class ExpandMacros {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
handleMacros(statements, file) {
|
|
137
|
+
handleMacros(statements, file, seen = new Set()) {
|
|
138
138
|
var _a;
|
|
139
139
|
const result = [];
|
|
140
140
|
let containsUnknown = false;
|
|
@@ -152,13 +152,20 @@ class ExpandMacros {
|
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
result.push(new statement_node_1.StatementNode(new _statement_1.MacroCall(), statement.getColon()).setChildren(this.tokensToNodes(statement.getTokens())));
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
if (!seen.has(macroName.toUpperCase())) {
|
|
156
|
+
const expanded = this.expandContents(macroName, statement);
|
|
157
|
+
const nextSeen = new Set(seen).add(macroName.toUpperCase());
|
|
158
|
+
const handled = this.handleMacros(expanded, file, nextSeen);
|
|
159
|
+
for (const e of handled.statements) {
|
|
160
|
+
result.push(e);
|
|
161
|
+
}
|
|
162
|
+
if (handled.containsUnknown === true) {
|
|
163
|
+
containsUnknown = true;
|
|
164
|
+
}
|
|
159
165
|
}
|
|
160
|
-
|
|
161
|
-
|
|
166
|
+
else {
|
|
167
|
+
const node = new statement_node_1.StatementNode(new _statement_1.MacroRecursion(), statement.getColon());
|
|
168
|
+
result.push(node.setChildren(this.tokensToNodes(statement.getTokens())));
|
|
162
169
|
}
|
|
163
170
|
continue;
|
|
164
171
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NativeSQL = exports.MacroContent = exports.MacroCall = exports.Empty = exports.Comment = exports.Unknown = void 0;
|
|
3
|
+
exports.NativeSQL = exports.MacroRecursion = exports.MacroContent = exports.MacroCall = exports.Empty = exports.Comment = exports.Unknown = void 0;
|
|
4
4
|
class Unknown {
|
|
5
5
|
getMatcher() {
|
|
6
6
|
throw new Error("Unknown Statement, get_matcher");
|
|
@@ -31,6 +31,12 @@ class MacroContent {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
exports.MacroContent = MacroContent;
|
|
34
|
+
class MacroRecursion {
|
|
35
|
+
getMatcher() {
|
|
36
|
+
throw new Error("MacroRecursion Statement, get_matcher");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.MacroRecursion = MacroRecursion;
|
|
34
40
|
class NativeSQL {
|
|
35
41
|
getMatcher() {
|
|
36
42
|
throw new Error("NativeSQL Statement, get_matcher");
|
|
@@ -266,7 +266,7 @@ class SubStatement {
|
|
|
266
266
|
}
|
|
267
267
|
first() {
|
|
268
268
|
const o = new this.obj();
|
|
269
|
-
if (o instanceof _statement_1.MacroCall || o instanceof _statement_1.NativeSQL) {
|
|
269
|
+
if (o instanceof _statement_1.MacroCall || o instanceof _statement_1.MacroRecursion || o instanceof _statement_1.NativeSQL) {
|
|
270
270
|
return [""];
|
|
271
271
|
}
|
|
272
272
|
return o.getMatcher().first();
|
|
@@ -41,7 +41,7 @@ const _statement_1 = require("../../2_statements/statements/_statement");
|
|
|
41
41
|
class Normal {
|
|
42
42
|
getMatcher() {
|
|
43
43
|
// note that the sequence of alternatives here influences performance
|
|
44
|
-
return (0, _combi_1.alt)((0, _combi_1.sta)(Statements.Move), (0, _combi_1.sta)(Statements.Call), (0, _combi_1.sta)(Statements.Data), (0, _combi_1.sub)(Structures.If), (0, _combi_1.sta)(Statements.Clear), (0, _combi_1.sta)(Statements.FieldSymbol), (0, _combi_1.sta)(Statements.CreateObject), (0, _combi_1.sta)(Statements.CallFunction), (0, _combi_1.sta)(_statement_1.MacroCall), (0, _combi_1.sub)(Structures.LoopAtScreen), (0, _combi_1.sub)(Structures.Loop), (0, _combi_1.sub)(Structures.LoopExtract), (0, _combi_1.sta)(Statements.Append), (0, _combi_1.sub)(Structures.Try), (0, _combi_1.sub)(Structures.OnChange), (0, _combi_1.sta)(Statements.ReadTable), (0, _combi_1.sta)(Statements.Assert), (0, _combi_1.sta)(Statements.Return), (0, _combi_1.sta)(Statements.Select), (0, _combi_1.sta)(Statements.Assign), (0, _combi_1.sta)(Statements.InsertInternal), (0, _combi_1.sta)(Statements.DeleteInternal), (0, _combi_1.sta)(Statements.Concatenate), (0, _combi_1.sub)(Structures.Case), (0, _combi_1.sub)(Structures.CaseType), (0, _combi_1.sub)(Structures.Enhancement), (0, _combi_1.sub)(Structures.EnhancementSection), (0, _combi_1.sta)(Statements.AddCorresponding), (0, _combi_1.sta)(Statements.Add), (0, _combi_1.sta)(Statements.AssignLocalCopy), (0, _combi_1.sta)(Statements.AuthorityCheck), (0, _combi_1.sta)(Statements.Back), (0, _combi_1.sta)(Statements.Break), (0, _combi_1.sta)(Statements.BreakId), (0, _combi_1.sta)(Statements.CallDatabase), (0, _combi_1.sta)(Statements.CallDialog), (0, _combi_1.sta)(Statements.CallKernel), (0, _combi_1.sta)(Statements.CallOLE), (0, _combi_1.sta)(Statements.CallScreen), (0, _combi_1.sta)(Statements.ModifyScreen), (0, _combi_1.sta)(Statements.CallSelectionScreen), (0, _combi_1.sta)(Statements.CallTransaction), (0, _combi_1.sta)(Statements.CallTransformation), (0, _combi_1.sta)(Statements.Check), (0, _combi_1.sta)(Statements.ClassDefinitionLoad), (0, _combi_1.sta)(Statements.CloseCursor), (0, _combi_1.sta)(Statements.CloseDataset), (0, _combi_1.sta)(Statements.Collect), (0, _combi_1.sta)(Statements.Commit), (0, _combi_1.sta)(Statements.Communication), (0, _combi_1.sta)(Statements.Compute), (0, _combi_1.sta)(Statements.CallBadi), (0, _combi_1.sta)(Statements.Condense), (0, _combi_1.sta)(Statements.Constant), (0, _combi_1.sta)(Statements.Contexts), (0, _combi_1.sta)(Statements.Continue), (0, _combi_1.sta)(Statements.ConvertText), (0, _combi_1.sta)(Statements.Convert), (0, _combi_1.sta)(Statements.CreateData), (0, _combi_1.sta)(Statements.CreateOLE), (0, _combi_1.sta)(Statements.DeleteCluster), (0, _combi_1.sta)(Statements.DeleteDatabase), (0, _combi_1.sta)(Statements.DeleteDataset), (0, _combi_1.sta)(Statements.DeleteDynpro), (0, _combi_1.sta)(Statements.DeleteMemory), (0, _combi_1.sta)(Statements.DeleteReport), (0, _combi_1.sta)(Statements.DeleteTextpool), (0, _combi_1.sta)(Statements.Demand), (0, _combi_1.sta)(Statements.Describe), (0, _combi_1.sta)(Statements.Detail), (0, _combi_1.sta)(Statements.Divide), (0, _combi_1.sta)(Statements.EditorCall), (0, _combi_1.sta)(Statements.EnhancementPoint), (0, _combi_1.sta)(Statements.Exit), (0, _combi_1.sta)(Statements.ExportDynpro), (0, _combi_1.sta)(Statements.Export), (0, _combi_1.sta)(Statements.Extract), (0, _combi_1.sta)(Statements.FetchNextCursor), (0, _combi_1.sta)(Statements.FieldGroup), (0, _combi_1.sta)(Statements.Fields), (0, _combi_1.sta)(Statements.Find), (0, _combi_1.sta)(Statements.Format), (0, _combi_1.sta)(Statements.FreeMemory), (0, _combi_1.sta)(Statements.FreeObject), (0, _combi_1.sta)(Statements.Free), (0, _combi_1.sta)(Statements.GenerateDynpro), (0, _combi_1.sta)(Statements.GenerateReport), (0, _combi_1.sta)(Statements.GenerateSubroutine), (0, _combi_1.sta)(Statements.GetBadi), (0, _combi_1.sta)(Statements.GetBit), (0, _combi_1.sta)(Statements.GetCursor), (0, _combi_1.sta)(Statements.GetDataset), (0, _combi_1.sta)(Statements.GetLocale), (0, _combi_1.sta)(Statements.GetParameter), (0, _combi_1.sta)(Statements.GetPFStatus), (0, _combi_1.sta)(Statements.GetProperty), (0, _combi_1.sta)(Statements.GetReference), (0, _combi_1.sta)(Statements.GetRunTime), (0, _combi_1.sta)(Statements.GetTime), (0, _combi_1.sta)(Statements.Hide), (0, _combi_1.sta)(Statements.Nodes), (0, _combi_1.sta)(Statements.ImportDynpro), (0, _combi_1.sta)(Statements.ImportNametab), (0, _combi_1.sta)(Statements.MoveCorresponding), (0, _combi_1.sta)(Statements.Import), (0, _combi_1.sta)(Statements.Infotypes), (0, _combi_1.sta)(Statements.Include), // include does not have to be at top level
|
|
44
|
+
return (0, _combi_1.alt)((0, _combi_1.sta)(Statements.Move), (0, _combi_1.sta)(Statements.Call), (0, _combi_1.sta)(Statements.Data), (0, _combi_1.sub)(Structures.If), (0, _combi_1.sta)(Statements.Clear), (0, _combi_1.sta)(Statements.FieldSymbol), (0, _combi_1.sta)(Statements.CreateObject), (0, _combi_1.sta)(Statements.CallFunction), (0, _combi_1.sta)(_statement_1.MacroCall), (0, _combi_1.sta)(_statement_1.MacroRecursion), (0, _combi_1.sub)(Structures.LoopAtScreen), (0, _combi_1.sub)(Structures.Loop), (0, _combi_1.sub)(Structures.LoopExtract), (0, _combi_1.sta)(Statements.Append), (0, _combi_1.sub)(Structures.Try), (0, _combi_1.sub)(Structures.OnChange), (0, _combi_1.sta)(Statements.ReadTable), (0, _combi_1.sta)(Statements.Assert), (0, _combi_1.sta)(Statements.Return), (0, _combi_1.sta)(Statements.Select), (0, _combi_1.sta)(Statements.Assign), (0, _combi_1.sta)(Statements.InsertInternal), (0, _combi_1.sta)(Statements.DeleteInternal), (0, _combi_1.sta)(Statements.Concatenate), (0, _combi_1.sub)(Structures.Case), (0, _combi_1.sub)(Structures.CaseType), (0, _combi_1.sub)(Structures.Enhancement), (0, _combi_1.sub)(Structures.EnhancementSection), (0, _combi_1.sta)(Statements.AddCorresponding), (0, _combi_1.sta)(Statements.Add), (0, _combi_1.sta)(Statements.AssignLocalCopy), (0, _combi_1.sta)(Statements.AuthorityCheck), (0, _combi_1.sta)(Statements.Back), (0, _combi_1.sta)(Statements.Break), (0, _combi_1.sta)(Statements.BreakId), (0, _combi_1.sta)(Statements.CallDatabase), (0, _combi_1.sta)(Statements.CallDialog), (0, _combi_1.sta)(Statements.CallKernel), (0, _combi_1.sta)(Statements.CallOLE), (0, _combi_1.sta)(Statements.CallScreen), (0, _combi_1.sta)(Statements.ModifyScreen), (0, _combi_1.sta)(Statements.CallSelectionScreen), (0, _combi_1.sta)(Statements.CallTransaction), (0, _combi_1.sta)(Statements.CallTransformation), (0, _combi_1.sta)(Statements.Check), (0, _combi_1.sta)(Statements.ClassDefinitionLoad), (0, _combi_1.sta)(Statements.CloseCursor), (0, _combi_1.sta)(Statements.CloseDataset), (0, _combi_1.sta)(Statements.Collect), (0, _combi_1.sta)(Statements.Commit), (0, _combi_1.sta)(Statements.Communication), (0, _combi_1.sta)(Statements.Compute), (0, _combi_1.sta)(Statements.CallBadi), (0, _combi_1.sta)(Statements.Condense), (0, _combi_1.sta)(Statements.Constant), (0, _combi_1.sta)(Statements.Contexts), (0, _combi_1.sta)(Statements.Continue), (0, _combi_1.sta)(Statements.ConvertText), (0, _combi_1.sta)(Statements.Convert), (0, _combi_1.sta)(Statements.CreateData), (0, _combi_1.sta)(Statements.CreateOLE), (0, _combi_1.sta)(Statements.DeleteCluster), (0, _combi_1.sta)(Statements.DeleteDatabase), (0, _combi_1.sta)(Statements.DeleteDataset), (0, _combi_1.sta)(Statements.DeleteDynpro), (0, _combi_1.sta)(Statements.DeleteMemory), (0, _combi_1.sta)(Statements.DeleteReport), (0, _combi_1.sta)(Statements.DeleteTextpool), (0, _combi_1.sta)(Statements.Demand), (0, _combi_1.sta)(Statements.Describe), (0, _combi_1.sta)(Statements.Detail), (0, _combi_1.sta)(Statements.Divide), (0, _combi_1.sta)(Statements.EditorCall), (0, _combi_1.sta)(Statements.EnhancementPoint), (0, _combi_1.sta)(Statements.Exit), (0, _combi_1.sta)(Statements.ExportDynpro), (0, _combi_1.sta)(Statements.Export), (0, _combi_1.sta)(Statements.Extract), (0, _combi_1.sta)(Statements.FetchNextCursor), (0, _combi_1.sta)(Statements.FieldGroup), (0, _combi_1.sta)(Statements.Fields), (0, _combi_1.sta)(Statements.Find), (0, _combi_1.sta)(Statements.Format), (0, _combi_1.sta)(Statements.FreeMemory), (0, _combi_1.sta)(Statements.FreeObject), (0, _combi_1.sta)(Statements.Free), (0, _combi_1.sta)(Statements.GenerateDynpro), (0, _combi_1.sta)(Statements.GenerateReport), (0, _combi_1.sta)(Statements.GenerateSubroutine), (0, _combi_1.sta)(Statements.GetBadi), (0, _combi_1.sta)(Statements.GetBit), (0, _combi_1.sta)(Statements.GetCursor), (0, _combi_1.sta)(Statements.GetDataset), (0, _combi_1.sta)(Statements.GetLocale), (0, _combi_1.sta)(Statements.GetParameter), (0, _combi_1.sta)(Statements.GetPFStatus), (0, _combi_1.sta)(Statements.GetProperty), (0, _combi_1.sta)(Statements.GetReference), (0, _combi_1.sta)(Statements.GetRunTime), (0, _combi_1.sta)(Statements.GetTime), (0, _combi_1.sta)(Statements.Hide), (0, _combi_1.sta)(Statements.Nodes), (0, _combi_1.sta)(Statements.ImportDynpro), (0, _combi_1.sta)(Statements.ImportNametab), (0, _combi_1.sta)(Statements.MoveCorresponding), (0, _combi_1.sta)(Statements.Import), (0, _combi_1.sta)(Statements.Infotypes), (0, _combi_1.sta)(Statements.Include), // include does not have to be at top level
|
|
45
45
|
(0, _combi_1.sta)(Statements.InsertDatabase), (0, _combi_1.sta)(Statements.InsertReport), (0, _combi_1.sta)(Statements.InsertTextpool), (0, _combi_1.sta)(Statements.InsertFieldGroup), (0, _combi_1.sta)(Statements.InterfaceLoad), (0, _combi_1.sta)(Statements.Leave), (0, _combi_1.sta)(Statements.LoadReport), (0, _combi_1.sta)(Statements.Local), (0, _combi_1.sta)(Statements.With), (0, _combi_1.sta)(Statements.LogPoint), (0, _combi_1.sta)(Statements.Message), (0, _combi_1.sta)(Statements.MergeDatabase), (0, _combi_1.sta)(Statements.ModifyLine), (0, _combi_1.sta)(Statements.ModifyDatabase), (0, _combi_1.sta)(Statements.ModifyInternal), (0, _combi_1.sta)(Statements.Multiply), (0, _combi_1.sta)(Statements.NewLine), (0, _combi_1.sta)(Statements.NewPage), (0, _combi_1.sta)(Statements.OpenCursor), (0, _combi_1.sta)(Statements.OpenDataset), (0, _combi_1.sta)(Statements.Overlay), (0, _combi_1.sta)(Statements.Pack), (0, _combi_1.sta)(Statements.Perform), (0, _combi_1.sta)(Statements.FormDefinition), (0, _combi_1.sta)(Statements.Position), (0, _combi_1.sta)(Statements.Put), (0, _combi_1.sta)(Statements.PrintControl), (0, _combi_1.sta)(Statements.RaiseEvent), (0, _combi_1.sta)(Statements.RaiseEntityEvent), (0, _combi_1.sta)(Statements.Raise), (0, _combi_1.sta)(Statements.Ranges), (0, _combi_1.sta)(Statements.ReadDataset), (0, _combi_1.sta)(Statements.ReadLine), (0, _combi_1.sta)(Statements.ReadReport), (0, _combi_1.sta)(Statements.ReadTextpool), (0, _combi_1.sta)(Statements.Receive), (0, _combi_1.sta)(Statements.RefreshControl), (0, _combi_1.sta)(Statements.Refresh), (0, _combi_1.sta)(Statements.Reject), (0, _combi_1.sta)(Statements.Replace), (0, _combi_1.sta)(Statements.Reserve), (0, _combi_1.sta)(Statements.Resume), (0, _combi_1.sta)(Statements.Retry), (0, _combi_1.sta)(Statements.Rollback), (0, _combi_1.sta)(Statements.Scan), (0, _combi_1.sta)(Statements.ScrollList), (0, _combi_1.sta)(Statements.Search), (0, _combi_1.sta)(Statements.SetBit), (0, _combi_1.sta)(Statements.SetBlank), (0, _combi_1.sta)(Statements.SetCountry), (0, _combi_1.sta)(Statements.SetCursor), (0, _combi_1.sta)(Statements.SetDataset), (0, _combi_1.sta)(Statements.SetExtendedCheck), (0, _combi_1.sta)(Statements.SetHandler), (0, _combi_1.sta)(Statements.SetLanguage), (0, _combi_1.sta)(Statements.SetLeft), (0, _combi_1.sta)(Statements.SetLocale), (0, _combi_1.sta)(Statements.SetMargin), (0, _combi_1.sta)(Statements.SetParameter), (0, _combi_1.sta)(Statements.SetPFStatus), (0, _combi_1.sta)(Statements.SetProperty), (0, _combi_1.sta)(Statements.SetRunTime), (0, _combi_1.sta)(Statements.SetScreen), (0, _combi_1.sta)(Statements.SetTitlebar), (0, _combi_1.sta)(Statements.SetUserCommand), (0, _combi_1.sta)(Statements.SetUpdateTask), (0, _combi_1.sta)(Statements.Shift), (0, _combi_1.sta)(Statements.Skip), (0, _combi_1.sta)(Statements.SortDataset), (0, _combi_1.sta)(Statements.Sort), (0, _combi_1.sta)(Statements.Static), (0, _combi_1.sta)(Statements.Split), (0, _combi_1.sta)(Statements.Stop), (0, _combi_1.sta)(Statements.Submit), (0, _combi_1.sta)(Statements.Summary), (0, _combi_1.sta)(Statements.SubtractCorresponding), (0, _combi_1.sta)(Statements.Subtract), (0, _combi_1.sta)(Statements.SuppressDialog), (0, _combi_1.sta)(Statements.Supply), (0, _combi_1.sta)(Statements.Sum), (0, _combi_1.sta)(Statements.SyntaxCheck), (0, _combi_1.sta)(Statements.SystemCall), (0, _combi_1.sta)(Statements.Tables), (0, _combi_1.sta)(Statements.Transfer), (0, _combi_1.sta)(Statements.Translate), (0, _combi_1.sta)(Statements.Type), (0, _combi_1.sta)(Statements.TypePools), (0, _combi_1.sta)(Statements.Uline), (0, _combi_1.sta)(Statements.Unassign), (0, _combi_1.sta)(Statements.Unpack), (0, _combi_1.sta)(Statements.UpdateDatabase), (0, _combi_1.sta)(Statements.Wait), (0, _combi_1.sta)(Statements.Window), (0, _combi_1.sta)(Statements.Write), (0, _combi_1.sta)(Statements.CommitEntities), (0, _combi_1.sta)(Statements.GetPermissions), (0, _combi_1.sta)(Statements.SetLocks), (0, _combi_1.sta)(Statements.ModifyEntities), (0, _combi_1.sta)(Statements.ReadEntities), (0, _combi_1.sta)(Statements.RollbackEntities), (0, _combi_1.sta)(Statements.Module), // todo, should be dynpro specific
|
|
46
46
|
(0, _combi_1.sta)(Statements.Field), // todo, should be dynpro specific
|
|
47
47
|
(0, _combi_1.sub)(Structures.Chain), // todo, should be dynpro specific
|
|
@@ -5,7 +5,7 @@ exports.syntaxIssue = syntaxIssue;
|
|
|
5
5
|
const issue_1 = require("../../issue");
|
|
6
6
|
const severity_1 = require("../../severity");
|
|
7
7
|
exports.CheckSyntaxKey = "check_syntax";
|
|
8
|
-
function syntaxIssue(input, token, message) {
|
|
9
|
-
return issue_1.Issue.atTokenFilename(input.filename, token, message, exports.CheckSyntaxKey, severity_1.Severity.Error);
|
|
8
|
+
function syntaxIssue(input, token, message, fix) {
|
|
9
|
+
return issue_1.Issue.atTokenFilename(input.filename, token, message, exports.CheckSyntaxKey, severity_1.Severity.Error, fix);
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=_syntax_input.js.map
|
|
@@ -123,7 +123,7 @@ class Select {
|
|
|
123
123
|
&& from.getFirstToken().getStart().isBefore(up.getFirstToken().getStart())
|
|
124
124
|
&& up.getFirstToken().getStart().isBefore(intoExpression.getFirstToken().getStart())) {
|
|
125
125
|
const message = `The addition "UP TO n ROWS" must only be placed after the INTO/APPENDING clause.`;
|
|
126
|
-
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, up.getFirstToken(), message));
|
|
126
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, up.getFirstToken(), message, this.buildUpToRowsFix(node, input, up, intoExpression)));
|
|
127
127
|
}
|
|
128
128
|
for (const s of up.findDirectExpressions(Expressions.SQLSource)) {
|
|
129
129
|
sql_source_1.SQLSource.runSyntax(s, input);
|
|
@@ -157,6 +157,25 @@ class Select {
|
|
|
157
157
|
input.scope.pop(node.getLastToken().getEnd());
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
+
static buildUpToRowsFix(node, input, up, intoExpression) {
|
|
161
|
+
const tokens = node.getTokens();
|
|
162
|
+
const upLast = up.getLastToken();
|
|
163
|
+
const next = tokens[tokens.findIndex(t => t === upLast) + 1];
|
|
164
|
+
const deleteEnd = (next === null || next === void 0 ? void 0 : next.getStart()) || upLast.getEnd();
|
|
165
|
+
const range = { start: up.getFirstToken().getStart(), end: deleteEnd };
|
|
166
|
+
return {
|
|
167
|
+
[input.filename]: [
|
|
168
|
+
{
|
|
169
|
+
range: { start: intoExpression.getLastToken().getEnd(), end: intoExpression.getLastToken().getEnd() },
|
|
170
|
+
newText: " " + up.concatTokens(),
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
range,
|
|
174
|
+
newText: "",
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
};
|
|
178
|
+
}
|
|
160
179
|
// there are multiple rules, but gotta start somewhere
|
|
161
180
|
static isStrictMode(node, input) {
|
|
162
181
|
// strict OpenSQL is always required in the cloud language version
|
package/build/src/registry.js
CHANGED
package/build/src/rules/index.js
CHANGED
|
@@ -124,6 +124,7 @@ __exportStar(require("./no_chained_assignment"), exports);
|
|
|
124
124
|
__exportStar(require("./no_comments_between_methods"), exports);
|
|
125
125
|
__exportStar(require("./no_external_form_calls"), exports);
|
|
126
126
|
__exportStar(require("./no_inline_in_optional_branches"), exports);
|
|
127
|
+
__exportStar(require("./no_macros"), exports);
|
|
127
128
|
__exportStar(require("./no_prefixes"), exports);
|
|
128
129
|
__exportStar(require("./no_public_attributes"), exports);
|
|
129
130
|
__exportStar(require("./no_yoda_conditions"), exports);
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.NoMacros = exports.NoMacrosConf = void 0;
|
|
37
|
+
const issue_1 = require("../issue");
|
|
38
|
+
const _abap_rule_1 = require("./_abap_rule");
|
|
39
|
+
const Statements = __importStar(require("../abap/2_statements/statements"));
|
|
40
|
+
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
41
|
+
const _irule_1 = require("./_irule");
|
|
42
|
+
class NoMacrosConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
43
|
+
}
|
|
44
|
+
exports.NoMacrosConf = NoMacrosConf;
|
|
45
|
+
class NoMacros extends _abap_rule_1.ABAPRule {
|
|
46
|
+
constructor() {
|
|
47
|
+
super(...arguments);
|
|
48
|
+
this.conf = new NoMacrosConf();
|
|
49
|
+
}
|
|
50
|
+
getMetadata() {
|
|
51
|
+
return {
|
|
52
|
+
key: "no_macros",
|
|
53
|
+
title: "No macros",
|
|
54
|
+
shortDescription: `Checks that macros are not used`,
|
|
55
|
+
extendedInformation: `Macros reduce readability and are difficult to debug, use methods or form routines instead.
|
|
56
|
+
|
|
57
|
+
https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenmacros_guidl.htm`,
|
|
58
|
+
tags: [_irule_1.RuleTag.SingleFile],
|
|
59
|
+
badExample: `DEFINE _macro.
|
|
60
|
+
WRITE 'hello'.
|
|
61
|
+
END-OF-DEFINITION.`,
|
|
62
|
+
goodExample: `WRITE 'hello'.`,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
getConfig() {
|
|
66
|
+
return this.conf;
|
|
67
|
+
}
|
|
68
|
+
setConfig(conf) {
|
|
69
|
+
this.conf = conf;
|
|
70
|
+
}
|
|
71
|
+
runParsed(file) {
|
|
72
|
+
const issues = [];
|
|
73
|
+
for (const stat of file.getStatements()) {
|
|
74
|
+
if (stat.get() instanceof Statements.Define) {
|
|
75
|
+
issues.push(issue_1.Issue.atStatement(file, stat, "Do not define macros", this.getMetadata().key, this.conf.severity));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return issues;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.NoMacros = NoMacros;
|
|
82
|
+
//# sourceMappingURL=no_macros.js.map
|
|
@@ -41,19 +41,23 @@ See recognized syntax at https://syntax.abaplint.org`,
|
|
|
41
41
|
if (obj instanceof _abap_object_1.ABAPObject) {
|
|
42
42
|
for (const file of obj.getABAPFiles()) {
|
|
43
43
|
for (const statement of file.getStatements()) {
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
if (statement.get() instanceof _statement_1.Unknown) {
|
|
45
|
+
if (statement.getTokens().length > statement_parser_1.STATEMENT_MAX_TOKENS) {
|
|
46
|
+
const message = "Statement too long, refactor statement";
|
|
47
|
+
const issue = issue_1.Issue.atToken(file, statement.getTokens()[0], message, this.getMetadata().key, this.conf.severity);
|
|
48
|
+
issues.push(issue);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const tok = statement.getFirstToken();
|
|
52
|
+
const message = "Statement does not exist in ABAP " + this.reg.getConfig().getRelease().name + " (or a parser error), \"" + tok.getStr() + "\"";
|
|
53
|
+
const issue = issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity);
|
|
54
|
+
issues.push(issue);
|
|
55
|
+
}
|
|
51
56
|
}
|
|
52
|
-
else {
|
|
57
|
+
else if (statement.get() instanceof _statement_1.MacroRecursion) {
|
|
53
58
|
const tok = statement.getFirstToken();
|
|
54
|
-
const message = "
|
|
55
|
-
|
|
56
|
-
issues.push(issue);
|
|
59
|
+
const message = "Macro recursion detected involving \"" + tok.getStr() + "\"";
|
|
60
|
+
issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
if (this.reg.getConfig().getRelease() === version_1.Release.v700) {
|