@abaplint/core 2.84.10 → 2.85.1

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;
@@ -319,7 +319,12 @@ class Lexer {
319
319
  && ahead !== "`") {
320
320
  // end of ping
321
321
  this.add();
322
- this.m = Mode.Normal;
322
+ if (ahead === `"`) {
323
+ this.m = Mode.Comment;
324
+ }
325
+ else {
326
+ this.m = Mode.Normal;
327
+ }
323
328
  }
324
329
  else if (this.m === Mode.Template
325
330
  && buf.length > 1
@@ -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,11 +38,15 @@ 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++) {
@@ -52,6 +57,19 @@ class ExpandMacros {
52
57
  name = statement.getTokens()[1].getStr();
53
58
  contents = [];
54
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
+ }
55
73
  else if (name) {
56
74
  if (type instanceof Statements.EndOfDefinition) {
57
75
  this.macros.addMacro(name, contents);
@@ -116,7 +134,7 @@ class ExpandMacros {
116
134
  }
117
135
  const file = new memory_file_1.MemoryFile("expand_macros.abap.prog", str);
118
136
  const lexerResult = lexer_1.Lexer.run(file, statement.getFirstToken().getStart());
119
- 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());
120
138
  return result[0].statements;
121
139
  }
122
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;
@@ -5,7 +5,7 @@ const combi_1 = require("../combi");
5
5
  const _1 = require(".");
6
6
  class FormParam extends combi_1.Expression {
7
7
  getRunnable() {
8
- const stru = (0, combi_1.seq)("STRUCTURE", _1.NamespaceSimpleName);
8
+ const stru = (0, combi_1.seq)("STRUCTURE", _1.SimpleFieldChain);
9
9
  const ret = (0, combi_1.seq)((0, combi_1.altPrio)(_1.PassByValue, _1.FormParamName), (0, combi_1.optPrio)((0, combi_1.altPrio)(_1.FormParamType, stru)));
10
10
  return ret;
11
11
  }
@@ -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);
@@ -11,7 +11,7 @@ class FormParam {
11
11
  const nameToken = (_a = node.findFirstExpression(expressions_1.FormParamName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
12
12
  if (node.findDirectTokenByText("STRUCTURE") && nameToken) {
13
13
  // STRUCTURES typing
14
- const typeName = (_b = node.findDirectExpression(expressions_1.NamespaceSimpleName)) === null || _b === void 0 ? void 0 : _b.getFirstToken().getStr();
14
+ const typeName = (_b = node.findDirectExpression(expressions_1.SimpleFieldChain)) === null || _b === void 0 ? void 0 : _b.getFirstToken().getStr();
15
15
  let type = undefined;
16
16
  if (typeName) {
17
17
  type = (_c = scope.findType(typeName)) === null || _c === void 0 ? void 0 : _c.getType();
@@ -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();
@@ -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;
@@ -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() {
@@ -93,10 +93,8 @@ class Table extends _abstract_object_1.AbstractObject {
93
93
  if (field.GROUPNAME !== undefined) {
94
94
  components.push({ name: field.GROUPNAME, type: found });
95
95
  }
96
- else {
97
- for (const c of found.getComponents()) {
98
- components.push({ name: c.name, type: c.type });
99
- }
96
+ for (const c of found.getComponents()) {
97
+ components.push({ name: c.name, type: c.type });
100
98
  }
101
99
  }
102
100
  else if ((((_a = field.PRECFIELD) === null || _a === void 0 ? void 0 : _a.startsWith("CI_")) || ((_b = field.PRECFIELD) === null || _b === void 0 ? void 0 : _b.startsWith("SI_")))
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.84.10";
71
+ return "2.85.1";
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.10",
3
+ "version": "2.85.1",
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",