@abaplint/core 2.84.9 → 2.85.0

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.
@@ -25,7 +25,7 @@ export declare abstract class ABAPObject extends AbstractObject {
25
25
  abstract getDescription(): string | undefined;
26
26
  constructor(name: string);
27
27
  static is(x: any): x is ABAPObject;
28
- parse(version: Version, globalMacros?: readonly string[]): IParseResult;
28
+ parse(version: Version, globalMacros?: readonly string[], reg?: IRegistry): IParseResult;
29
29
  setDirty(): void;
30
30
  getABAPFiles(): readonly ABAPFile[];
31
31
  getABAPFileByName(filename: string): ABAPFile | undefined;
@@ -79,7 +79,7 @@ declare abstract class AbstractObject implements IObject {
79
79
  abstract getDescription(): string | undefined;
80
80
  constructor(name: string);
81
81
  getParsingIssues(): readonly Issue[];
82
- parse(_version?: Version, _globalMacros?: readonly string[]): IParseResult;
82
+ parse(_version?: Version, _globalMacros?: readonly string[], _reg?: IRegistry): IParseResult;
83
83
  getName(): string;
84
84
  setDirty(): void;
85
85
  addFile(file: IFile): void;
@@ -3100,8 +3100,10 @@ export declare interface IObject extends IArtifact {
3100
3100
  getDescription(): string | undefined;
3101
3101
  setDirty(): void;
3102
3102
  isDirty(): boolean;
3103
- /** returns true if the object was parsed, false if no changes since last parse */
3104
- parse(version?: Version, globalMacros?: readonly string[], globalExclude?: readonly string[]): IParseResult;
3103
+ /** returns true if the object was parsed, false if no changes since last parse
3104
+ * registry for global cross object macros
3105
+ */
3106
+ parse(version?: Version, globalMacros?: readonly string[], reg?: IRegistry): IParseResult;
3105
3107
  getParsingIssues(): readonly Issue[];
3106
3108
  getFiles(): readonly IFile[];
3107
3109
  addFile(file: IFile): void;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExpandMacros = void 0;
4
4
  const Statements = require("./statements");
5
+ const Expressions = require("./expressions");
5
6
  const Tokens = require("../1_lexer/tokens");
6
7
  const _statement_1 = require("./statements/_statement");
7
8
  const statement_node_1 = require("../nodes/statement_node");
@@ -37,26 +38,44 @@ class Macros {
37
38
  }
38
39
  }
39
40
  class ExpandMacros {
40
- constructor(globalMacros, version) {
41
+ // "reg" must be supplied if there are cross object macros via INCLUDE
42
+ constructor(globalMacros, version, reg) {
41
43
  this.macros = new Macros(globalMacros);
42
44
  this.version = version;
45
+ this.globalMacros = globalMacros;
46
+ this.reg = reg;
43
47
  }
44
48
  find(statements) {
49
+ var _a, _b;
45
50
  let name = undefined;
46
51
  let contents = [];
47
52
  for (let i = 0; i < statements.length; i++) {
48
53
  const statement = statements[i];
49
- if (statement.get() instanceof Statements.Define) {
54
+ const type = statement.get();
55
+ if (type instanceof Statements.Define) {
50
56
  // todo, will this break if first token is a pragma?
51
57
  name = statement.getTokens()[1].getStr();
52
58
  contents = [];
53
59
  }
60
+ else if (type instanceof Statements.Include) {
61
+ const includeName = (_a = statement.findDirectExpression(Expressions.IncludeName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
62
+ // todo, this does not take function module includes into account
63
+ const prog = (_b = this.reg) === null || _b === void 0 ? void 0 : _b.getObject("PROG", includeName);
64
+ if (prog) {
65
+ prog.parse(this.version, this.globalMacros, this.reg);
66
+ const main = prog.getMainABAPFile();
67
+ if (main) {
68
+ // slow, this copies everything,
69
+ this.find([...main.getStatements()]);
70
+ }
71
+ }
72
+ }
54
73
  else if (name) {
55
- if (statement.get() instanceof Statements.EndOfDefinition) {
74
+ if (type instanceof Statements.EndOfDefinition) {
56
75
  this.macros.addMacro(name, contents);
57
76
  name = undefined;
58
77
  }
59
- else if (!(statement.get() instanceof _statement_1.Comment)) {
78
+ else if (!(type instanceof _statement_1.Comment)) {
60
79
  statements[i] = new statement_node_1.StatementNode(new _statement_1.MacroContent()).setChildren(this.tokensToNodes(statement.getTokens()));
61
80
  contents.push(statements[i]);
62
81
  }
@@ -67,7 +86,8 @@ class ExpandMacros {
67
86
  const result = [];
68
87
  let containsUnknown = false;
69
88
  for (const statement of statements) {
70
- if (statement.get() instanceof _statement_1.Unknown || statement.get() instanceof _statement_1.MacroCall) {
89
+ const type = statement.get();
90
+ if (type instanceof _statement_1.Unknown || type instanceof _statement_1.MacroCall) {
71
91
  const macroName = this.findName(statement.getTokens());
72
92
  if (macroName && this.macros.isMacro(macroName)) {
73
93
  result.push(new statement_node_1.StatementNode(new _statement_1.MacroCall()).setChildren(this.tokensToNodes(statement.getTokens())));
@@ -114,7 +134,7 @@ class ExpandMacros {
114
134
  }
115
135
  const file = new memory_file_1.MemoryFile("expand_macros.abap.prog", str);
116
136
  const lexerResult = lexer_1.Lexer.run(file, statement.getFirstToken().getStart());
117
- const result = new statement_parser_1.StatementParser(this.version).run([lexerResult], this.macros.listMacroNames());
137
+ const result = new statement_parser_1.StatementParser(this.version, this.reg).run([lexerResult], this.macros.listMacroNames());
118
138
  return result[0].statements;
119
139
  }
120
140
  buildInput(statement) {
@@ -4,8 +4,9 @@ exports.ConcatenatedConstant = void 0;
4
4
  const combi_1 = require("../combi");
5
5
  class ConcatenatedConstant extends combi_1.Expression {
6
6
  getRunnable() {
7
- // todo: replace optPrio with plusPrio when its implemented, below is a workaround
8
- return (0, combi_1.seq)((0, combi_1.regex)(/^`.*`$/), "&", (0, combi_1.regex)(/^`.*`$/), (0, combi_1.optPrio)((0, combi_1.seq)("&", (0, combi_1.regex)(/^`.*`$/))), (0, combi_1.optPrio)((0, combi_1.seq)("&", (0, combi_1.regex)(/^`.*`$/))), (0, combi_1.optPrio)((0, combi_1.seq)("&", (0, combi_1.regex)(/^`.*`$/))));
7
+ const str = (0, combi_1.seq)((0, combi_1.regex)(/^`.*`$/), (0, combi_1.plusPrio)((0, combi_1.seq)("&", (0, combi_1.regex)(/^`.*`$/))));
8
+ const char = (0, combi_1.seq)((0, combi_1.regex)(/^'.*'$/), (0, combi_1.plusPrio)((0, combi_1.seq)("&", (0, combi_1.regex)(/^'.*'$/))));
9
+ return (0, combi_1.altPrio)(str, char);
9
10
  }
10
11
  }
11
12
  exports.ConcatenatedConstant = ConcatenatedConstant;
@@ -63,15 +63,16 @@ class WorkArea {
63
63
  }
64
64
  }
65
65
  class StatementParser {
66
- constructor(version) {
66
+ constructor(version, reg) {
67
67
  if (!StatementParser.map) {
68
68
  StatementParser.map = new StatementMap();
69
69
  }
70
70
  this.version = version;
71
+ this.reg = reg;
71
72
  }
72
73
  /** input is one full object */
73
74
  run(input, globalMacros) {
74
- const macros = new expand_macros_1.ExpandMacros(globalMacros, this.version);
75
+ const macros = new expand_macros_1.ExpandMacros(globalMacros, this.version, this.reg);
75
76
  const wa = input.map(i => new WorkArea(i.file, i.tokens));
76
77
  for (const w of wa) {
77
78
  this.process(w);
@@ -114,7 +114,7 @@ class FindGlobalDefinitions {
114
114
  obj.setDefinition(undefined);
115
115
  }
116
116
  }
117
- else if (obj instanceof class_1.Class) {
117
+ else {
118
118
  const found = struc === null || struc === void 0 ? void 0 : struc.findFirstStructure(Structures.ClassDefinition);
119
119
  if (struc && file && found) {
120
120
  try {
@@ -8,9 +8,10 @@ const structure_parser_1 = require("./3_structures/structure_parser");
8
8
  const abap_file_information_1 = require("./4_file_information/abap_file_information");
9
9
  const abap_file_1 = require("./abap_file");
10
10
  class ABAPParser {
11
- constructor(version, globalMacros) {
11
+ constructor(version, globalMacros, reg) {
12
12
  this.version = version ? version : version_1.defaultVersion;
13
13
  this.globalMacros = globalMacros ? globalMacros : [];
14
+ this.reg = reg;
14
15
  }
15
16
  // files is input for a single object
16
17
  parse(files) {
@@ -23,7 +24,7 @@ class ABAPParser {
23
24
  const lexingRuntime = Date.now() - b1;
24
25
  // 2: statements
25
26
  const b2 = Date.now();
26
- const statementResult = new statement_parser_1.StatementParser(this.version).run(lexerResult, this.globalMacros);
27
+ const statementResult = new statement_parser_1.StatementParser(this.version, this.reg).run(lexerResult, this.globalMacros);
27
28
  const statementsRuntime = Date.now() - b2;
28
29
  // 3: structures
29
30
  const b3 = Date.now();
@@ -30,6 +30,7 @@ class Diagnostics {
30
30
  end: { line: issue.getEnd().getRow() - 1, character: issue.getEnd().getCol() - 1 },
31
31
  },
32
32
  code: issue.getKey(),
33
+ codeDescription: { href: "https://rules.abaplint.org/" + issue.getKey() + "/" },
33
34
  message: issue.getMessage().toString(),
34
35
  source: "abaplint",
35
36
  };
@@ -13,12 +13,12 @@ class ABAPObject extends _abstract_object_1.AbstractObject {
13
13
  static is(x) {
14
14
  return !!x && x instanceof ABAPObject;
15
15
  }
16
- parse(version, globalMacros) {
16
+ parse(version, globalMacros, reg) {
17
17
  if (this.isDirty() === false) {
18
18
  return { updated: false, runtime: 0 };
19
19
  }
20
20
  const abapFiles = this.getFiles().filter(f => f.getFilename().endsWith(".abap"));
21
- const result = new abap_parser_1.ABAPParser(version, globalMacros).parse(abapFiles);
21
+ const result = new abap_parser_1.ABAPParser(version, globalMacros, reg).parse(abapFiles);
22
22
  this.parsed = result.output;
23
23
  this.old = result.issues;
24
24
  this.dirty = false;
@@ -41,7 +41,7 @@ class ABAPObject extends _abstract_object_1.AbstractObject {
41
41
  return undefined;
42
42
  }
43
43
  getMainABAPFile() {
44
- // todo, uris
44
+ // todo, uris, https://github.com/abaplint/abaplint/issues/673
45
45
  const search = this.getName().replace(/\//g, "#").toLowerCase() + "." + this.getType().toLowerCase() + ".abap";
46
46
  for (const file of this.getABAPFiles()) {
47
47
  if (file.getFilename().endsWith(search)) {
@@ -15,7 +15,7 @@ class AbstractObject {
15
15
  getParsingIssues() {
16
16
  return this.old;
17
17
  }
18
- parse(_version, _globalMacros) {
18
+ parse(_version, _globalMacros, _reg) {
19
19
  return { updated: false, runtime: 0 };
20
20
  }
21
21
  getName() {
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.84.9";
71
+ return "2.85.0";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -259,7 +259,7 @@ class Registry {
259
259
  // todo, refactor, this is a mess, see where-used, a lot of the code should be in this method instead
260
260
  parsePrivate(input) {
261
261
  const config = this.getConfig();
262
- const result = input.parse(config.getVersion(), config.getSyntaxSetttings().globalMacros);
262
+ const result = input.parse(config.getVersion(), config.getSyntaxSetttings().globalMacros, this);
263
263
  ParsingPerformance.push(input, result);
264
264
  }
265
265
  isDirty() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.84.9",
3
+ "version": "2.85.0",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -50,7 +50,7 @@
50
50
  "@types/mocha": "^9.1.0",
51
51
  "@types/node": "^17.0.13",
52
52
  "chai": "^4.3.6",
53
- "eslint": "^8.7.0",
53
+ "eslint": "^8.8.0",
54
54
  "mocha": "^9.2.0",
55
55
  "c8": "^7.11.0",
56
56
  "source-map-support": "^0.5.21",