@abaplint/core 2.118.9 → 2.118.11

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.
@@ -7226,8 +7226,10 @@ declare class TimeType extends AbstractType {
7226
7226
  export declare abstract class Token {
7227
7227
  private readonly start;
7228
7228
  private readonly str;
7229
+ private readonly strUpper;
7229
7230
  constructor(start: Position, str: string);
7230
7231
  getStr(): string;
7232
+ getUpperStr(): string;
7231
7233
  getRow(): number;
7232
7234
  getCol(): number;
7233
7235
  getStart(): Position;
@@ -6,6 +6,7 @@ class AbstractToken {
6
6
  constructor(start, str) {
7
7
  this.start = start;
8
8
  this.str = str;
9
+ this.strUpper = str.toUpperCase();
9
10
  }
10
11
  // special function, for debugging purposes, see https://github.com/abaplint/abaplint/pull/3137
11
12
  [Symbol.for("debug.description")]() {
@@ -14,6 +15,9 @@ class AbstractToken {
14
15
  getStr() {
15
16
  return this.str;
16
17
  }
18
+ getUpperStr() {
19
+ return this.strUpper;
20
+ }
17
21
  getRow() {
18
22
  return this.start.getRow();
19
23
  }
@@ -69,7 +69,7 @@ class Word {
69
69
  const result = [];
70
70
  for (const input of r) {
71
71
  if (input.remainingLength() !== 0
72
- && input.peek().getStr().toUpperCase() === this.s) {
72
+ && input.peek().getUpperStr() === this.s) {
73
73
  // console.log("match, " + this.s + result.length);
74
74
  result.push(input.shift(new nodes_1.TokenNode(input.peek())));
75
75
  }
@@ -88,7 +88,7 @@ class Word {
88
88
  }
89
89
  class Token {
90
90
  constructor(s) {
91
- this.name = s.toUpperCase();
91
+ this.name = s;
92
92
  }
93
93
  listKeywords() {
94
94
  return [];
@@ -100,7 +100,7 @@ class Token {
100
100
  const result = [];
101
101
  for (const input of r) {
102
102
  if (input.remainingLength() !== 0
103
- && input.peek().constructor.name.toUpperCase() === this.name) {
103
+ && input.peek().constructor.name === this.name) {
104
104
  result.push(input.shift(new nodes_1.TokenNode(input.peek())));
105
105
  }
106
106
  }
@@ -838,7 +838,7 @@ function tok(t) {
838
838
  }
839
839
  const expressionSingletons = {};
840
840
  const stringSingletons = {};
841
- function map(s) {
841
+ function mapInput(s) {
842
842
  const type = typeof s;
843
843
  if (type === "string") {
844
844
  if (stringSingletons[s] === undefined) {
@@ -860,48 +860,48 @@ function map(s) {
860
860
  }
861
861
  }
862
862
  function seq(first, second, ...rest) {
863
- const list = [map(first), map(second)];
864
- list.push(...rest.map(map));
863
+ const list = [mapInput(first), mapInput(second)];
864
+ list.push(...rest.map(mapInput));
865
865
  return new Sequence(list);
866
866
  }
867
867
  function alt(first, second, ...rest) {
868
- const list = [map(first), map(second)];
869
- list.push(...rest.map(map));
868
+ const list = [mapInput(first), mapInput(second)];
869
+ list.push(...rest.map(mapInput));
870
870
  return new Alternative(list);
871
871
  }
872
872
  function altPrio(first, second, ...rest) {
873
- const list = [map(first), map(second)];
874
- list.push(...rest.map(map));
873
+ const list = [mapInput(first), mapInput(second)];
874
+ list.push(...rest.map(mapInput));
875
875
  return new AlternativePriority(list);
876
876
  }
877
877
  function opt(first) {
878
- return new Optional(map(first));
878
+ return new Optional(mapInput(first));
879
879
  }
880
880
  function optPrio(first) {
881
- return new OptionalPriority(map(first));
881
+ return new OptionalPriority(mapInput(first));
882
882
  }
883
883
  function per(first, second, ...rest) {
884
- const list = [map(first), map(second)];
885
- list.push(...rest.map(map));
884
+ const list = [mapInput(first), mapInput(second)];
885
+ list.push(...rest.map(mapInput));
886
886
  return new Permutation(list);
887
887
  }
888
888
  function star(first) {
889
- return new Star(map(first));
889
+ return new Star(mapInput(first));
890
890
  }
891
891
  function starPrio(first) {
892
- return new StarPriority(map(first));
892
+ return new StarPriority(mapInput(first));
893
893
  }
894
894
  function plus(first) {
895
- return new Plus(map(first));
895
+ return new Plus(mapInput(first));
896
896
  }
897
897
  function plusPrio(first) {
898
- return new PlusPriority(map(first));
898
+ return new PlusPriority(mapInput(first));
899
899
  }
900
900
  function ver(version, first, or) {
901
- return new Vers(version, map(first), or);
901
+ return new Vers(version, mapInput(first), or);
902
902
  }
903
903
  function verNot(version, first) {
904
- return new VersNot(version, map(first));
904
+ return new VersNot(version, mapInput(first));
905
905
  }
906
906
  function failCombinator() {
907
907
  return new FailCombinator();
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Data = void 0;
4
4
  const data_1 = require("../statements/data");
5
5
  const nodes_1 = require("../../nodes");
6
+ const identifier_1 = require("../../1_lexer/tokens/identifier");
6
7
  const type_1 = require("../statements/type");
7
8
  const _typed_identifier_1 = require("../../types/_typed_identifier");
8
9
  const types_1 = require("./types");
@@ -25,7 +26,11 @@ class Data {
25
26
  this.runCommonPartSyntax(node, input);
26
27
  return undefined;
27
28
  }
28
- const name = node.findFirstExpression(Expressions.DefinitionName).getFirstToken();
29
+ const nameExpr = node.findFirstExpression(Expressions.DefinitionName);
30
+ let name = nameExpr.getFirstToken();
31
+ if (nameExpr.countTokens() > 1) { // workaround for names with dashes
32
+ name = new identifier_1.Identifier(name.getStart(), nameExpr.concatTokens());
33
+ }
29
34
  let table = false;
30
35
  const values = {};
31
36
  const components = [];
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RenameProgram = void 0;
4
+ const Statements = require("../../abap/2_statements/statements");
5
+ const Expressions = require("../../abap/2_statements/expressions");
6
+ const vscode_languageserver_types_1 = require("vscode-languageserver-types");
7
+ const __1 = require("..");
8
+ const renamer_helper_1 = require("./renamer_helper");
9
+ const _lsp_utils_1 = require("../../lsp/_lsp_utils");
10
+ const _abap_object_1 = require("../_abap_object");
11
+ class RenameProgram {
12
+ constructor(reg) {
13
+ this.reg = reg;
14
+ }
15
+ buildEdits(obj, oldName, newName) {
16
+ if (!(obj instanceof __1.Program)) {
17
+ throw new Error("RenameProgram, not a program");
18
+ }
19
+ const main = obj.getMainABAPFile();
20
+ if (main === undefined) {
21
+ throw new Error(`Main file not found, ${obj.getType()} ${obj.getName()}`);
22
+ }
23
+ let changes = [];
24
+ const helper = new renamer_helper_1.RenamerHelper(this.reg);
25
+ changes = changes.concat(helper.buildXMLFileEdits(obj, "NAME", oldName, newName));
26
+ changes = changes.concat(helper.renameFiles(obj, oldName, newName));
27
+ const edits = [];
28
+ for (const s of main.getStatements()) {
29
+ if (s.get() instanceof Statements.Report || s.get() instanceof Statements.Program) {
30
+ const exp = s.findFirstExpression(Expressions.ReportName);
31
+ if (exp) {
32
+ edits.push(vscode_languageserver_types_1.TextEdit.replace(_lsp_utils_1.LSPUtils.tokenToRange(exp.getFirstToken()), newName.toLowerCase()));
33
+ }
34
+ }
35
+ }
36
+ if (edits.length > 0) {
37
+ changes.push(vscode_languageserver_types_1.TextDocumentEdit.create({ uri: main.getFilename(), version: 1 }, edits));
38
+ }
39
+ // Rename INCLUDE statements in all ABAP objects
40
+ for (const o of this.reg.getObjects()) {
41
+ if (o instanceof _abap_object_1.ABAPObject && o !== obj) {
42
+ for (const file of o.getABAPFiles()) {
43
+ const includeEdits = [];
44
+ for (const s of file.getStatements()) {
45
+ if (s.get() instanceof Statements.Include ||
46
+ s.get() instanceof Statements.Submit ||
47
+ s.get() instanceof Statements.Perform) {
48
+ for (const exp of s.findAllExpressions(Expressions.IncludeName)) {
49
+ if (exp && exp.getFirstToken().getStr().toUpperCase() === oldName.toUpperCase()) {
50
+ includeEdits.push(vscode_languageserver_types_1.TextEdit.replace(_lsp_utils_1.LSPUtils.tokenToRange(exp.getFirstToken()), newName.toLowerCase()));
51
+ }
52
+ }
53
+ }
54
+ }
55
+ if (includeEdits.length > 0) {
56
+ changes.push(vscode_languageserver_types_1.TextDocumentEdit.create({ uri: file.getFilename(), version: 1 }, includeEdits));
57
+ }
58
+ }
59
+ }
60
+ }
61
+ return {
62
+ documentChanges: changes,
63
+ };
64
+ }
65
+ }
66
+ exports.RenameProgram = RenameProgram;
67
+ //# sourceMappingURL=rename_program.js.map
@@ -7,6 +7,7 @@ const rename_data_element_1 = require("./rename_data_element");
7
7
  const rename_domain_1 = require("./rename_domain");
8
8
  const rename_global_class_1 = require("./rename_global_class");
9
9
  const rename_global_interface_1 = require("./rename_global_interface");
10
+ const rename_program_1 = require("./rename_program");
10
11
  const rename_table_1 = require("./rename_table");
11
12
  const rename_table_type_1 = require("./rename_table_type");
12
13
  const rename_message_class_1 = require("./rename_message_class");
@@ -61,6 +62,8 @@ class Renamer {
61
62
  return new rename_table_type_1.RenameTableType(this.reg);
62
63
  case "INTF":
63
64
  return new rename_global_interface_1.RenameGlobalInterface(this.reg);
65
+ case "PROG":
66
+ return new rename_program_1.RenameProgram(this.reg);
64
67
  case "MSAG":
65
68
  return new rename_message_class_1.RenameMessageClass(this.reg);
66
69
  case "SICF":
@@ -74,7 +74,7 @@ class Registry {
74
74
  }
75
75
  static abaplintVersion() {
76
76
  // magic, see build script "version.sh"
77
- return "2.118.9";
77
+ return "2.118.11";
78
78
  }
79
79
  getDDICReferences() {
80
80
  return this.ddicReferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.118.9",
3
+ "version": "2.118.11",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",