@abaplint/core 2.119.61 → 2.119.62

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.
@@ -412,6 +412,8 @@ declare class Attributes implements IAttributes {
412
412
  private readonly filename;
413
413
  private readonly aliases;
414
414
  private readonly declaredInterfaces;
415
+ private readonly all;
416
+ private readonly byName;
415
417
  constructor(node: StructureNode, input: SyntaxInput);
416
418
  getTypes(): TypeDefinitions;
417
419
  getStatic(): ClassAttribute[];
@@ -423,6 +425,7 @@ declare class Attributes implements IAttributes {
423
425
  getConstants(): ClassConstant[];
424
426
  getConstantsByVisibility(visibility: Visibility): ClassConstant[];
425
427
  findByName(name: string): ClassAttribute | ClassConstant | undefined;
428
+ private buildByName;
426
429
  private parse;
427
430
  private parseSection;
428
431
  private parseAlias;
@@ -4398,7 +4401,6 @@ declare interface ISyntaxResult {
4398
4401
  declare interface ISyntaxSettings {
4399
4402
  /** ABAP language version */
4400
4403
  version?: VersionOldOrNew;
4401
- languageVersion?: LanguageVersion;
4402
4404
  /** Report error for objects in this regex namespace. Types not in namespace will be void. Case insensitive */
4403
4405
  errorNamespace: string;
4404
4406
  /** List of full named global constants (regex not possible)
@@ -6759,6 +6761,7 @@ declare class Skip implements IStatement {
6759
6761
 
6760
6762
  export declare class SkipLogic {
6761
6763
  private readonly reg;
6764
+ private includeGraph;
6762
6765
  /** TOBJ cache hashmap */
6763
6766
  private tobj;
6764
6767
  constructor(reg: IRegistry);
@@ -239,7 +239,9 @@ class StatementParser {
239
239
  statement = input;
240
240
  }
241
241
  else if (length === 1 && lastToken instanceof tokens_1.Pragma) {
242
- statement = new nodes_1.StatementNode(new _statement_1.Empty(), undefined, [lastToken]);
242
+ // special case, everything crashes if StatementNodes doesnt have children
243
+ statement = new nodes_1.StatementNode(new _statement_1.Empty(), undefined, [lastToken])
244
+ .setChildren(this.tokensToNodes([lastToken]));
243
245
  }
244
246
  }
245
247
  return statement;
@@ -296,7 +296,7 @@ class CurrentScope {
296
296
  }
297
297
  findTypePoolConstant(name) {
298
298
  var _a;
299
- if (name === undefined || name.includes("_") === undefined) {
299
+ if (name === undefined || name.includes("_") === false) {
300
300
  return undefined;
301
301
  }
302
302
  const typePoolName = name.split("_")[0];
@@ -318,7 +318,7 @@ class CurrentScope {
318
318
  }
319
319
  findTypePoolType(name) {
320
320
  var _a;
321
- if (name.includes("_") === undefined) {
321
+ if (name.includes("_") === false) {
322
322
  return undefined;
323
323
  }
324
324
  const typePoolName = name.split("_")[0];
@@ -108,11 +108,9 @@ class ObjectOriented {
108
108
  findMethodInInterface(interfaceName, methodName) {
109
109
  const idef = this.scope.findInterfaceDefinition(interfaceName);
110
110
  if (idef) {
111
- const methods = idef.getMethodDefinitions().getAll();
112
- for (const method of methods) {
113
- if (method.getName().toUpperCase() === methodName.toUpperCase()) {
114
- return { method, def: idef };
115
- }
111
+ const method = idef.getMethodDefinitions().getByName(methodName);
112
+ if (method) {
113
+ return { method, def: idef };
116
114
  }
117
115
  return this.findMethodViaAlias(methodName, idef);
118
116
  }
@@ -334,17 +332,14 @@ class ObjectOriented {
334
332
  if (defs === undefined) {
335
333
  return undefined;
336
334
  }
337
- for (const method of defs.getAll()) {
338
- if (method.getName().toUpperCase() === methodName.toUpperCase()) {
339
- if (method.isRedefinition()) {
340
- return this.findMethodInSuper(def, methodName);
341
- }
342
- else {
343
- return method;
344
- }
345
- }
335
+ const method = defs.getByName(methodName);
336
+ if (method === undefined) {
337
+ return undefined;
346
338
  }
347
- return undefined;
339
+ if (method.isRedefinition()) {
340
+ return this.findMethodInSuper(def, methodName);
341
+ }
342
+ return method;
348
343
  }
349
344
  findMethodInSuper(child, methodName) {
350
345
  let sup = child.getSuperClass();
@@ -63,6 +63,8 @@ class Attributes {
63
63
  this.tlist = [];
64
64
  this.filename = input.filename;
65
65
  this.parse(node, input);
66
+ this.all = this.static.concat(this.instance);
67
+ this.byName = this.buildByName();
66
68
  this.types = new type_definitions_1.TypeDefinitions(this.tlist);
67
69
  }
68
70
  getTypes() {
@@ -75,10 +77,7 @@ class Attributes {
75
77
  return this.aliases;
76
78
  }
77
79
  getAll() {
78
- let res = [];
79
- res = res.concat(this.static);
80
- res = res.concat(this.instance);
81
- return res;
80
+ return this.all;
82
81
  }
83
82
  getStaticsByVisibility(visibility) {
84
83
  const attributes = [];
@@ -113,27 +112,29 @@ class Attributes {
113
112
  }
114
113
  return attributes;
115
114
  }
116
- // todo, optimize
117
115
  findByName(name) {
118
- const upper = name.toUpperCase();
119
- for (const a of this.getStatic()) {
120
- if (a.getName().toUpperCase() === upper) {
121
- return a;
122
- }
116
+ return this.byName[name.toUpperCase()];
117
+ }
118
+ /////////////////////////////
119
+ buildByName() {
120
+ const ret = {};
121
+ for (const a of this.static) {
122
+ ret[a.getName().toUpperCase()] = a;
123
123
  }
124
- for (const a of this.getInstance()) {
125
- if (a.getName().toUpperCase() === upper) {
126
- return a;
124
+ for (const a of this.instance) {
125
+ const name = a.getName().toUpperCase();
126
+ if (ret[name] === undefined) {
127
+ ret[name] = a;
127
128
  }
128
129
  }
129
- for (const a of this.getConstants()) {
130
- if (a.getName().toUpperCase() === upper) {
131
- return a;
130
+ for (const a of this.constants) {
131
+ const name = a.getName().toUpperCase();
132
+ if (ret[name] === undefined) {
133
+ ret[name] = a;
132
134
  }
133
135
  }
134
- return undefined;
136
+ return ret;
135
137
  }
136
- /////////////////////////////
137
138
  parse(node, input) {
138
139
  var _a, _b;
139
140
  const cdef = node.findDirectStructure(Structures.ClassDefinition);
@@ -47,10 +47,19 @@ class Config {
47
47
  for (const rule of sorted) {
48
48
  rules[rule.getMetadata().key] = rule.getConfig();
49
49
  }
50
- const version = ver !== null && ver !== void 0 ? ver : {
51
- release: version_1.Release.Newest.name,
52
- language: langVer !== null && langVer !== void 0 ? langVer : version_1.LanguageVersion.Normal,
53
- };
50
+ const version = langVer !== undefined
51
+ ? {
52
+ release: ver === undefined || ver === version_1.Version.Cloud
53
+ ? version_1.Release.Newest.name
54
+ : typeof ver === "string"
55
+ ? (0, version_1.versionToABAPRelease)(ver).name
56
+ : ver.release,
57
+ language: langVer,
58
+ }
59
+ : ver !== null && ver !== void 0 ? ver : {
60
+ release: version_1.Release.Newest.name,
61
+ language: version_1.LanguageVersion.Normal,
62
+ };
54
63
  // defaults: dont skip anything, report everything. The user can decide to skip stuff
55
64
  // its difficult to debug errors not being reported
56
65
  const config = {
@@ -75,7 +84,6 @@ class Config {
75
84
  }],
76
85
  syntax: {
77
86
  version,
78
- languageVersion: langVer,
79
87
  errorNamespace: "^(Z|Y|LCL\_|TY\_|LIF\_)",
80
88
  globalConstants: [],
81
89
  ambigiousVoids: [],
@@ -184,9 +192,6 @@ class Config {
184
192
  return v;
185
193
  }
186
194
  getLanguageVersion() {
187
- if (this.config.syntax.languageVersion !== undefined) {
188
- return this.config.syntax.languageVersion;
189
- }
190
195
  const v = this.config.syntax.version;
191
196
  if (v !== undefined && typeof v !== "string") {
192
197
  return v.language;
@@ -211,7 +216,10 @@ class Config {
211
216
  return;
212
217
  }
213
218
  if (version === version_1.Version.Cloud) {
214
- this.config.syntax.languageVersion = version_1.LanguageVersion.Cloud;
219
+ this.config.syntax.version = {
220
+ release: version_1.Release.Newest.name,
221
+ language: version_1.LanguageVersion.Cloud,
222
+ };
215
223
  }
216
224
  // OpenABAP keeps its own version identity; open-abap-ness is derived from the
217
225
  // release in getOpenABAP() rather than a separate stored flag.
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.119.61";
78
+ return "2.119.62";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;
@@ -39,7 +39,6 @@ const Expressions = __importStar(require("../abap/2_statements/expressions"));
39
39
  const _abap_rule_1 = require("./_abap_rule");
40
40
  const _basic_rule_config_1 = require("./_basic_rule_config");
41
41
  const issue_1 = require("../issue");
42
- const tokens_1 = require("../abap/1_lexer/tokens");
43
42
  const expressions_1 = require("../abap/2_statements/expressions");
44
43
  const _irule_1 = require("./_irule");
45
44
  class NamesNoDashConf extends _basic_rule_config_1.BasicRuleConfig {
@@ -79,32 +78,26 @@ class NamesNoDash extends _abap_rule_1.ABAPRule {
79
78
  if (obj.getType() !== "CLAS" && obj.getType() !== "INTF") {
80
79
  for (const form of struc.findAllStatements(Statements.Form)) {
81
80
  const expr = form.findFirstExpression(expressions_1.FormName);
82
- for (const token of expr.getTokens()) {
83
- if (token instanceof tokens_1.Dash || token instanceof tokens_1.DashW) {
84
- const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
85
- issues.push(issue);
86
- break;
87
- }
81
+ const token = expr === null || expr === void 0 ? void 0 : expr.findDirectTokenByText("-");
82
+ if (token) {
83
+ const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
84
+ issues.push(issue);
88
85
  }
89
86
  }
90
87
  for (const form of struc.findAllStatements(Statements.Parameter)) {
91
88
  const expr = form.findFirstExpression(Expressions.FieldSub);
92
- for (const token of expr.getTokens()) {
93
- if (token instanceof tokens_1.Dash || token instanceof tokens_1.DashW) {
94
- const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
95
- issues.push(issue);
96
- break;
97
- }
89
+ const token = expr === null || expr === void 0 ? void 0 : expr.findDirectTokenByText("-");
90
+ if (token) {
91
+ const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
92
+ issues.push(issue);
98
93
  }
99
94
  }
100
95
  for (const form of struc.findAllStatements(Statements.SelectOption)) {
101
96
  const expr = form.findFirstExpression(Expressions.FieldSub);
102
- for (const token of expr.getTokens()) {
103
- if (token instanceof tokens_1.Dash || token instanceof tokens_1.DashW) {
104
- const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
105
- issues.push(issue);
106
- break;
107
- }
97
+ const token = expr === null || expr === void 0 ? void 0 : expr.findDirectTokenByText("-");
98
+ if (token) {
99
+ const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
100
+ issues.push(issue);
108
101
  }
109
102
  }
110
103
  }
@@ -42,6 +42,7 @@ const _basic_rule_config_1 = require("./_basic_rule_config");
42
42
  const _statement_1 = require("../abap/2_statements/statements/_statement");
43
43
  const _irule_1 = require("./_irule");
44
44
  const edit_helper_1 = require("../edit_helper");
45
+ const tokens_1 = require("../abap/1_lexer/tokens");
45
46
  class UnnecessaryPragmaConf extends _basic_rule_config_1.BasicRuleConfig {
46
47
  constructor() {
47
48
  super(...arguments);
@@ -110,6 +111,17 @@ DATA: BEGIN OF blah ##NEEDED,
110
111
  for (let i = 0; i < statements.length; i++) {
111
112
  const statement = statements[i];
112
113
  const nextStatement = statements[i + 1];
114
+ if (statement.get() instanceof _statement_1.Empty
115
+ && statement.getChildren().length === 1) {
116
+ const tokens = statement.getTokens();
117
+ if (tokens.length === 1
118
+ && tokens[0] instanceof tokens_1.Pragma) {
119
+ const message = "Pragma without a statement can be removed";
120
+ const fix = edit_helper_1.EditHelper.deleteToken(file, tokens[0]);
121
+ issues.push(issue_1.Issue.atToken(file, tokens[0], message, this.getMetadata().key, this.conf.severity, fix));
122
+ continue;
123
+ }
124
+ }
113
125
  if (statement.get() instanceof Statements.EndTry) {
114
126
  noHandler = false;
115
127
  }
@@ -6,9 +6,11 @@ const include_graph_1 = require("./utils/include_graph");
6
6
  class SkipLogic {
7
7
  constructor(reg) {
8
8
  this.reg = reg;
9
+ this.includeGraph = undefined;
9
10
  this.tobj = undefined;
10
11
  }
11
12
  skip(obj) {
13
+ var _a;
12
14
  const global = this.reg.getConfig().getGlobal();
13
15
  if (global.skipGeneratedGatewayClasses === true
14
16
  && obj instanceof objects_1.Class
@@ -18,9 +20,9 @@ class SkipLogic {
18
20
  else if (global.skipIncludesWithoutMain === true
19
21
  && obj instanceof objects_1.Program
20
22
  && obj.isInclude() === true) {
21
- const ig = new include_graph_1.IncludeGraph(this.reg);
23
+ (_a = this.includeGraph) !== null && _a !== void 0 ? _a : (this.includeGraph = new include_graph_1.IncludeGraph(this.reg));
22
24
  const file = obj.getMainABAPFile();
23
- if (file && ig.listMainForInclude(file.getFilename()).length === 0) {
25
+ if (file && this.includeGraph.listMainForInclude(file.getFilename()).length === 0) {
24
26
  return true;
25
27
  }
26
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.119.61",
3
+ "version": "2.119.62",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",