abl-tmlanguage 1.1.3 → 1.3.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +54 -1
  3. package/abl.tmLanguage.json +3534 -230
  4. package/azure-pipelines.yml +3 -2
  5. package/package.json +7 -6
  6. package/spec/analyze-suspend-resume/analyze-suspend-resume.spec.js +10 -10
  7. package/spec/annotations/annotation.spec.js +232 -0
  8. package/spec/array-extent/issue#5.spec.js +18 -18
  9. package/spec/blocks/finally-blocks.spec.js +90 -0
  10. package/spec/blocks/on-quit.spec.js +59 -0
  11. package/spec/comments/vscode-abl-issue#127.spec.js +165 -0
  12. package/spec/db-table-and-field/fields-except.spec.js +69 -0
  13. package/spec/db-table-and-field/foreach.spec.js +588 -0
  14. package/spec/db-table-and-field/issue#88.spec.js +120 -0
  15. package/spec/define-buffer/create-buffer.spec.js +110 -0
  16. package/spec/define-buffer/simple-single-line.spec.js +138 -0
  17. package/spec/define-parameter/simple-single-line.spec.js +140 -100
  18. package/spec/define-stream/simple-single-line.spec.js +32 -31
  19. package/spec/define-temp-table/define-index.spec.js +138 -0
  20. package/spec/define-variable/extent.spec.js +228 -0
  21. package/spec/define-variable/issue#6.spec.js +256 -198
  22. package/spec/define-variable/issue#9.spec.js +38 -32
  23. package/spec/define-variable/simple-single-line.spec.js +168 -87
  24. package/spec/define-variable/single-line-with-a-comment-at-the-end.spec.js +62 -62
  25. package/spec/define-variable/single-line-with-a-space-and-a-comment-at-the-end.spec.js +56 -56
  26. package/spec/define-variable/tm-issue#2.spec.js +20 -20
  27. package/spec/do/do-blocks.spec.js +224 -0
  28. package/spec/do/issue#3.spec.js +69 -60
  29. package/spec/function-call/nested-functions.spec.js +128 -0
  30. package/spec/function-call/vscode-abl-issue#19.spec.js +110 -107
  31. package/spec/global-scoped-define/global-define.spec.js +11 -11
  32. package/spec/global-scoped-define/scoped-define-with-procedure-keyword.spec.js +26 -26
  33. package/spec/include/abl-tmlanguage-issues#5.spec.js +40 -57
  34. package/spec/include/vscode-abl-issue#45.spec.js +15 -15
  35. package/spec/include/vscode-abl-issue#77.spec.js +129 -0
  36. package/spec/include/vscode-abl-issue#80.spec.js +40 -27
  37. package/spec/method-attribute-property-call/abl-method-attribute-call.spec.js +99 -0
  38. package/spec/method-attribute-property-call/connected-method.spec.js +30 -0
  39. package/spec/method-attribute-property-call/get-set-method-name.spec.js +96 -0
  40. package/spec/method-attribute-property-call/method-call.spec.js +112 -0
  41. package/spec/method-definition/constructor.spec.js +174 -0
  42. package/spec/method-definition/method.spec.js +320 -0
  43. package/spec/misc-statements/case-statement.spec.js +96 -0
  44. package/spec/misc-statements/copy-lob.spec.js +137 -0
  45. package/spec/misc-statements/if-then.spec.js +170 -0
  46. package/spec/misc-statements/return-statement.spec.js +53 -0
  47. package/spec/operators/operators.spec.js +78 -0
  48. package/spec/procedure-definition/empty-proc.spec.js +101 -18
  49. package/spec/procedure-definition/vscode-abl-issue#22.spec.js +46 -42
  50. package/spec/procedure-definition/vscode-abl-issue#26.spec.js +23 -16
  51. package/spec/procedure-definition/vscode-abl-issue#62.spec.js +36 -0
  52. package/spec/run-statement/run-statement.spec.js +162 -0
  53. package/spec/shared.js +84 -42
  54. package/spec/strings/translation-attribute.spec.js +52 -0
  55. package/spec/strings/vscode-abl-issue#11.spec.js +110 -114
  56. package/spec/strings/vscode-abl-issue#28.spec.js +27 -27
  57. package/spec/type-name/argument.spec.js +209 -0
  58. package/spec/type-name/cast.spec.js +165 -0
  59. package/spec/type-name/define-class.spec.js +468 -0
  60. package/spec/type-name/define-enum.spec.js +44 -0
  61. package/spec/type-name/define-interface.spec.js +159 -0
  62. package/spec/type-name/define-property.spec.js +301 -0
  63. package/spec/type-name/define-temp-table.spec.js +434 -0
  64. package/spec/type-name/define-type-spec.js +435 -0
  65. package/spec/type-name/define-variable-property.spec.js +264 -0
  66. package/spec/type-name/define-variable.spec.js +504 -0
  67. package/spec/type-name/get-class.spec.js +91 -0
  68. package/spec/type-name/new.spec.js +126 -0
  69. package/spec/type-name/parameter-as.spec.js +838 -0
  70. package/spec/type-name/type-name.spec.js +879 -0
  71. package/spec/type-name/using.spec.js +115 -0
@@ -2,23 +2,30 @@ const { assert, expect } = require('chai');
2
2
  const shared = require('../shared.js');
3
3
 
4
4
  describe('', () => {
5
- let statement =
6
- `procedure 'TpFrame.TaskPanel.ItemClick':U:
5
+ let statement =
6
+ `procedure 'TpFrame.TaskPanel.ItemClick':U:
7
7
 
8
8
  end procedure.`;
9
9
 
10
- let expectedTokens = [
11
- [
12
- {"startIndex":0,"endIndex":9,"scopes":["source.abl","meta.procedure.abl","keyword.other.abl"]},
13
- {"startIndex":9,"endIndex":10,"scopes":["source.abl","meta.procedure.abl"]},
14
- {"startIndex":10,"endIndex":41,"scopes":["source.abl","meta.procedure.abl","entity.name.function.abl"]},
15
- {"startIndex":41,"endIndex":42,"scopes":["source.abl","meta.procedure.abl","meta.procedure.body.abl"]}
16
- ],[
17
- {"startIndex":0,"endIndex":1,"scopes":["source.abl","meta.procedure.abl","meta.procedure.body.abl"]}
18
- ],[
19
- {"startIndex":0,"endIndex":13,"scopes":["source.abl","meta.procedure.abl","meta.procedure.body.abl","keyword.other.abl"]},
20
- {"startIndex":13,"endIndex":14,"scopes":["source.abl","punctuation.terminator.abl"]}
21
- ]
22
- ];
23
- shared.itShouldMatchExpectedScopes(statement, expectedTokens);
10
+ let expectedTokens = [
11
+ [
12
+ { "startIndex": 0, "endIndex": 9, "scopes": ["source.abl", "meta.procedure.abl", "keyword.other.abl"] }, // 'procedure'
13
+ { "startIndex": 9, "endIndex": 10, "scopes": ["source.abl", "meta.procedure.abl"] }, // ' '
14
+ { "startIndex": 10, "endIndex": 11, "scopes": ["source.abl", "meta.procedure.abl", "string.single.complex.abl", "punctuation.definition.string.begin.abl"] }, // '''
15
+ { "startIndex": 11, "endIndex": 38, "scopes": ["source.abl", "meta.procedure.abl", "string.single.complex.abl"] }, // 'TpFrame.TaskPanel.ItemClick'
16
+ { "startIndex": 38, "endIndex": 39, "scopes": ["source.abl", "meta.procedure.abl", "string.single.complex.abl", "punctuation.definition.string.end.abl"] }, // '''
17
+ { "startIndex": 39, "endIndex": 41, "scopes": ["source.abl", "meta.procedure.abl", "support.other.abl"] }, // ':U'
18
+ { "startIndex": 41, "endIndex": 42, "scopes": ["source.abl", "meta.procedure.abl"] } // ':'
19
+ ],
20
+ [
21
+ { "startIndex": 0, "endIndex": 1, "scopes": ["source.abl"] } // ''
22
+ ],
23
+ [
24
+ { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'end'
25
+ { "startIndex": 3, "endIndex": 4, "scopes": ["source.abl"] }, // ' '
26
+ { "startIndex": 4, "endIndex": 13, "scopes": ["source.abl", "keyword.other.abl"] }, // 'procedure'
27
+ { "startIndex": 13, "endIndex": 14, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.'
28
+ ]
29
+ ];
30
+ shared.itShouldMatchExpectedScopes(statement, expectedTokens);
24
31
  })
@@ -0,0 +1,36 @@
1
+ const { assert, expect } = require('chai');
2
+ const shared = require('../shared.js');
3
+
4
+ describe('', () => {
5
+ let statement =
6
+ `PROCEDURE EnumPrinters{&A} EXTERNAL "winspool.drv":
7
+
8
+ end procedure.`;
9
+
10
+ let expectedTokens = [
11
+ [
12
+ { "startIndex": 0, "endIndex": 9, "scopes": ["source.abl", "meta.procedure.abl", "keyword.other.abl"] }, // 'PROCEDURE'
13
+ { "startIndex": 9, "endIndex": 10, "scopes": ["source.abl", "meta.procedure.abl"] }, // ' '
14
+ { "startIndex": 10, "endIndex": 22, "scopes": ["source.abl", "meta.procedure.abl", "entity.name.function.abl"] }, // 'EnumPrinters'
15
+ { "startIndex": 22, "endIndex": 26, "scopes": ["source.abl", "meta.procedure.abl", "support.other.argument.abl"] }, // '{&A}'
16
+ { "startIndex": 26, "endIndex": 27, "scopes": ["source.abl", "meta.procedure.abl"] }, // ' '
17
+ { "startIndex": 27, "endIndex": 35, "scopes": ["source.abl", "meta.procedure.abl", "keyword.other.abl"] }, // 'EXTERNAL'
18
+ { "startIndex": 35, "endIndex": 36, "scopes": ["source.abl", "meta.procedure.abl"] }, // ' '
19
+ { "startIndex": 36, "endIndex": 37, "scopes": ["source.abl", "meta.procedure.abl", "string.double.complex.abl", "punctuation.definition.string.begin.abl"] }, // '"'
20
+ { "startIndex": 37, "endIndex": 49, "scopes": ["source.abl", "meta.procedure.abl", "string.double.complex.abl"] }, // 'winspool.drv'
21
+ { "startIndex": 49, "endIndex": 50, "scopes": ["source.abl", "meta.procedure.abl", "string.double.complex.abl", "punctuation.definition.string.end.abl"] }, // '"'
22
+ { "startIndex": 50, "endIndex": 51, "scopes": ["source.abl", "meta.procedure.abl"] } // ':'
23
+ ],
24
+ [
25
+ { "startIndex": 0, "endIndex": 1, "scopes": ["source.abl"] } // ''
26
+ ],
27
+ [
28
+ { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'end'
29
+ { "startIndex": 3, "endIndex": 4, "scopes": ["source.abl"] }, // ' '
30
+ { "startIndex": 4, "endIndex": 13, "scopes": ["source.abl", "keyword.other.abl"] }, // 'procedure'
31
+ { "startIndex": 13, "endIndex": 14, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.'
32
+ ]
33
+ ];
34
+ shared.itShouldMatchExpectedScopes(statement, expectedTokens);
35
+ })
36
+ 11
@@ -0,0 +1,162 @@
1
+ const { assert, expect } = require('chai');
2
+ const shared = require('../shared.js');
3
+
4
+ describe('', () => {
5
+ let statement =
6
+ `run foo.p.`;
7
+
8
+ let expectedTokens = [
9
+ { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'run'
10
+ { "startIndex": 3, "endIndex": 4, "scopes": ["source.abl"] }, // ' '
11
+ { "startIndex": 4, "endIndex": 9, "scopes": ["source.abl", "meta.other.procedure.abl"] }, // 'foo.p'
12
+ { "startIndex": 9, "endIndex": 10, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.'
13
+ ];
14
+
15
+ shared.itShouldMatchExpectedScopes(statement, expectedTokens);
16
+ })
17
+
18
+ describe('', () => {
19
+ let statement =
20
+ ` run destry-object.`;
21
+
22
+ let expectedTokens = [
23
+ { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl"] }, // ' '
24
+ { "startIndex": 3, "endIndex": 6, "scopes": ["source.abl", "keyword.other.abl"] }, // 'run'
25
+ { "startIndex": 6, "endIndex": 7, "scopes": ["source.abl"] }, // ' '
26
+ { "startIndex": 7, "endIndex": 20, "scopes": ["source.abl", "meta.other.procedure.abl"] }, // 'destry-object'
27
+ { "startIndex": 20, "endIndex": 21, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.'
28
+ ];
29
+ shared.itShouldMatchExpectedScopes(statement, expectedTokens);
30
+ })
31
+
32
+ describe('', () => {
33
+ let statement =
34
+ ` run a/b\\c\\program.p (today).`;
35
+
36
+ let expectedTokens = [
37
+ { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl"] }, // ' '
38
+ { "startIndex": 3, "endIndex": 6, "scopes": ["source.abl", "keyword.other.abl"] }, // 'run'
39
+ { "startIndex": 6, "endIndex": 7, "scopes": ["source.abl"] }, // ' '
40
+ { "startIndex": 7, "endIndex": 22, "scopes": ["source.abl", "meta.other.procedure.abl"] }, // 'a/b\c\program.p'
41
+ { "startIndex": 22, "endIndex": 23, "scopes": ["source.abl"] }, // ' '
42
+ { "startIndex": 23, "endIndex": 24, "scopes": ["source.abl", "meta.function.arguments.abl", "meta.brace.round.js"] }, // '('
43
+ { "startIndex": 24, "endIndex": 29, "scopes": ["source.abl", "meta.function.arguments.abl", "constant.language.abl"] }, // 'today'
44
+ { "startIndex": 29, "endIndex": 30, "scopes": ["source.abl", "meta.brace.round.js"] }, // ')'
45
+ { "startIndex": 30, "endIndex": 31, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.'
46
+ ];
47
+ shared.itShouldMatchExpectedScopes(statement, expectedTokens);
48
+ })
49
+
50
+ describe('', () => {
51
+ let statement =
52
+ ` run value(cPriogram).`;
53
+
54
+ let expectedTokens = [
55
+ { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl"] }, // ' '
56
+ { "startIndex": 3, "endIndex": 6, "scopes": ["source.abl", "keyword.other.abl"] }, // 'run'
57
+ { "startIndex": 6, "endIndex": 7, "scopes": ["source.abl", "meta.function-call.abl"] }, // ' '
58
+ { "startIndex": 7, "endIndex": 12, "scopes": ["source.abl", "meta.function-call.abl", "support.function.abl"] }, // 'value'
59
+ { "startIndex": 12, "endIndex": 13, "scopes": ["source.abl", "meta.function-call.abl", "meta.function.arguments.abl", "meta.brace.round.js"] }, // '('
60
+ { "startIndex": 13, "endIndex": 22, "scopes": ["source.abl", "meta.function-call.abl", "meta.function.arguments.abl", "variable.other.abl"] }, // 'cPriogram'
61
+ { "startIndex": 22, "endIndex": 23, "scopes": ["source.abl", "meta.function-call.abl", "meta.brace.round.js"] }, // ')'ss
62
+ { "startIndex": 23, "endIndex": 24, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.'
63
+ ];
64
+ shared.itShouldMatchExpectedScopes(statement, expectedTokens);
65
+ })
66
+
67
+ describe('', () => {
68
+ let statement = ` run a\\program.p.`;
69
+
70
+ let expectedTokens = [
71
+ { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl"] }, // ' '
72
+ { "startIndex": 3, "endIndex": 6, "scopes": ["source.abl", "keyword.other.abl"] }, // 'run'
73
+ { "startIndex": 6, "endIndex": 7, "scopes": ["source.abl"] }, // ' '
74
+ { "startIndex": 7, "endIndex": 18, "scopes": ["source.abl", "meta.other.procedure.abl"] }, // 'a\program.p'
75
+ { "startIndex": 18, "endIndex": 19, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.'
76
+ ];
77
+ shared.itShouldMatchExpectedScopes(statement, expectedTokens);
78
+ })
79
+
80
+ describe('', () => {
81
+ let statement = ` run a/b/c/program.p.`;
82
+
83
+ let expectedTokens = [
84
+ { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl"] }, // ' '
85
+ { "startIndex": 3, "endIndex": 6, "scopes": ["source.abl", "keyword.other.abl"] }, // 'run'
86
+ { "startIndex": 6, "endIndex": 7, "scopes": ["source.abl"] }, // ' '
87
+ { "startIndex": 7, "endIndex": 22, "scopes": ["source.abl", "meta.other.procedure.abl"] }, // 'a/b/c/program.p'
88
+ { "startIndex": 22, "endIndex": 23, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.'
89
+ ];
90
+ shared.itShouldMatchExpectedScopes(statement, expectedTokens);
91
+ })
92
+
93
+ describe('', () => {
94
+ let statement =
95
+ ` run "a/program.p".`;
96
+
97
+ let expectedTokens = [
98
+ { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl"] }, // ' '
99
+ { "startIndex": 3, "endIndex": 6, "scopes": ["source.abl", "keyword.other.abl"] }, // 'run'
100
+ { "startIndex": 6, "endIndex": 7, "scopes": ["source.abl"] }, // ' '
101
+ { "startIndex": 7, "endIndex": 8, "scopes": ["source.abl", "string.double.complex.abl", "punctuation.definition.string.begin.abl"] }, // '"'
102
+ { "startIndex": 8, "endIndex": 19, "scopes": ["source.abl", "string.double.complex.abl"] }, // 'a/program.p'
103
+ { "startIndex": 19, "endIndex": 20, "scopes": ["source.abl", "string.double.complex.abl", "punctuation.definition.string.end.abl"] }, // '"'
104
+ { "startIndex": 20, "endIndex": 21, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.'
105
+ ];
106
+ shared.itShouldMatchExpectedScopes(statement, expectedTokens);
107
+ })
108
+
109
+ describe('', () => {
110
+ let statement =
111
+ ` run a/program.p (input 0x4, output cData).`;
112
+
113
+ let expectedTokens = [
114
+ { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl"] }, // ' '
115
+ { "startIndex": 3, "endIndex": 6, "scopes": ["source.abl", "keyword.other.abl"] }, // 'run'
116
+ { "startIndex": 6, "endIndex": 7, "scopes": ["source.abl"] }, // ' '
117
+ { "startIndex": 7, "endIndex": 18, "scopes": ["source.abl", "meta.other.procedure.abl"] }, // 'a/program.p'
118
+ { "startIndex": 18, "endIndex": 19, "scopes": ["source.abl"] }, // ' '
119
+ { "startIndex": 19, "endIndex": 20, "scopes": ["source.abl", "meta.function.arguments.abl", "meta.brace.round.js"] }, // '('
120
+ { "startIndex": 20, "endIndex": 25, "scopes": ["source.abl", "meta.function.arguments.abl", "keyword.other.abl"] }, // 'input'
121
+ { "startIndex": 25, "endIndex": 26, "scopes": ["source.abl", "meta.function.arguments.abl"] }, // ' '
122
+ { "startIndex": 26, "endIndex": 29, "scopes": ["source.abl", "meta.function.arguments.abl", "constant.numeric.source.abl"] }, // '0x4'
123
+ { "startIndex": 29, "endIndex": 30, "scopes": ["source.abl", "meta.function.arguments.abl", "punctuation.separator.comma.abl"] }, // ','
124
+ { "startIndex": 30, "endIndex": 31, "scopes": ["source.abl", "meta.function.arguments.abl"] }, // ' '
125
+ { "startIndex": 31, "endIndex": 37, "scopes": ["source.abl", "meta.function.arguments.abl", "keyword.other.abl"] }, // 'output'
126
+ { "startIndex": 37, "endIndex": 38, "scopes": ["source.abl", "meta.function.arguments.abl"] }, // ' '
127
+ { "startIndex": 38, "endIndex": 43, "scopes": ["source.abl", "meta.function.arguments.abl", "variable.other.abl"] }, // 'cData'
128
+ { "startIndex": 43, "endIndex": 44, "scopes": ["source.abl", "meta.brace.round.js"] }, // ')'
129
+ { "startIndex": 44, "endIndex": 45, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.'
130
+ ];
131
+ shared.itShouldMatchExpectedScopes(statement, expectedTokens);
132
+ })
133
+
134
+ describe('', () => {
135
+ let statement =
136
+ `run a/program.p on hAppServer single-run (input 0x4, output cData).`;
137
+
138
+ let expectedTokens = [
139
+ { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'run'
140
+ { "startIndex": 3, "endIndex": 4, "scopes": ["source.abl"] }, // ' '
141
+ { "startIndex": 4, "endIndex": 15, "scopes": ["source.abl", "meta.other.procedure.abl"] }, // 'a/program.p'
142
+ { "startIndex": 15, "endIndex": 16, "scopes": ["source.abl"] }, // ' '
143
+ { "startIndex": 16, "endIndex": 18, "scopes": ["source.abl", "keyword.other.abl"] }, // 'on'
144
+ { "startIndex": 18, "endIndex": 19, "scopes": ["source.abl"] }, // ' '
145
+ { "startIndex": 19, "endIndex": 29, "scopes": ["source.abl", "variable.other.abl"] }, // 'hAppServer'
146
+ { "startIndex": 29, "endIndex": 30, "scopes": ["source.abl"] }, // ' '
147
+ { "startIndex": 30, "endIndex": 40, "scopes": ["source.abl", "keyword.other.abl"] }, // 'single-run'
148
+ { "startIndex": 40, "endIndex": 41, "scopes": ["source.abl"] }, // ' '
149
+ { "startIndex": 41, "endIndex": 42, "scopes": ["source.abl", "meta.function.arguments.abl", "meta.brace.round.js"] }, // '('
150
+ { "startIndex": 42, "endIndex": 47, "scopes": ["source.abl", "meta.function.arguments.abl", "keyword.other.abl"] }, // 'input'
151
+ { "startIndex": 47, "endIndex": 48, "scopes": ["source.abl", "meta.function.arguments.abl"] }, // ' '
152
+ { "startIndex": 48, "endIndex": 51, "scopes": ["source.abl", "meta.function.arguments.abl", "constant.numeric.source.abl"] }, // '0x4'
153
+ { "startIndex": 51, "endIndex": 52, "scopes": ["source.abl", "meta.function.arguments.abl", "punctuation.separator.comma.abl"] }, // ','
154
+ { "startIndex": 52, "endIndex": 53, "scopes": ["source.abl", "meta.function.arguments.abl"] }, // ' '
155
+ { "startIndex": 53, "endIndex": 59, "scopes": ["source.abl", "meta.function.arguments.abl", "keyword.other.abl"] }, // 'output'
156
+ { "startIndex": 59, "endIndex": 60, "scopes": ["source.abl", "meta.function.arguments.abl"] }, // ' '
157
+ { "startIndex": 60, "endIndex": 65, "scopes": ["source.abl", "meta.function.arguments.abl", "variable.other.abl"] }, // 'cData'
158
+ { "startIndex": 65, "endIndex": 66, "scopes": ["source.abl", "meta.brace.round.js"] }, // ')'
159
+ { "startIndex": 66, "endIndex": 67, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.'
160
+ ];
161
+ shared.itShouldMatchExpectedScopes(statement, expectedTokens);
162
+ })
package/spec/shared.js CHANGED
@@ -5,57 +5,99 @@ const oniguruma = require('vscode-oniguruma');
5
5
  const { assert } = require('chai');
6
6
 
7
7
  function readFile(p) {
8
- return new Promise((resolve, reject) => {
9
- fs.readFile(p, (error, data) => error ? reject(error) : resolve(data));
10
- })
8
+ return new Promise((resolve, reject) => {
9
+ fs.readFile(p, (error, data) => error ? reject(error) : resolve(data));
10
+ })
11
11
  }
12
12
 
13
13
  const wasmBin = fs.readFileSync(path.join(__dirname, '../node_modules/vscode-oniguruma/release/onig.wasm')).buffer;
14
14
  const vscodeOnigurumaLib = oniguruma.loadWASM(wasmBin).then(() => {
15
- return {
16
- createOnigScanner(patterns) { return new oniguruma.OnigScanner(patterns); },
17
- createOnigString(s) { return new oniguruma.OnigString(s); }
18
- };
15
+ return {
16
+ createOnigScanner(patterns) { return new oniguruma.OnigScanner(patterns); },
17
+ createOnigString(s) { return new oniguruma.OnigString(s); }
18
+ };
19
19
  });
20
20
  // Create a registry that can create a grammar from a scope name.
21
21
  const registry = new vsctm.Registry({
22
- onigLib: vscodeOnigurumaLib,
23
- loadGrammar: (scopeName) => {
24
- if (scopeName === 'source.abl') {
25
- return readFile('./abl.tmLanguage.json').then(data => vsctm.parseRawGrammar(data.toString(), './abl.tmLanguage.json'))
26
- }
27
- console.log(`Unknown scope name: ${scopeName}`);
28
- return null;
22
+ onigLib: vscodeOnigurumaLib,
23
+ loadGrammar: (scopeName) => {
24
+ if (scopeName === 'source.abl') {
25
+ return readFile('./abl.tmLanguage.json').then(data => vsctm.parseRawGrammar(data.toString(), './abl.tmLanguage.json'))
29
26
  }
27
+ console.log(`Unknown scope name: ${scopeName}`);
28
+ return null;
29
+ }
30
30
  });
31
31
 
32
+ afterEach(function () {
33
+ console.log(this.currentTest.file);
34
+ })
35
+
32
36
  module.exports = {
33
- itShouldMatchExpectedScopes: function (statement, expectedTokens) {
34
- describe(`${statement}`, () => {
35
- it('should match expected scopes', () => {
36
- return registry.loadGrammar('source.abl').then(grammar => {
37
- let tokenResult;
38
-
39
- let lines = statement.split(/\n/g);
40
- let nbLines = lines.length;
41
- if (nbLines === 1) {
42
- //singleline
43
- tokenResult = grammar.tokenizeLine(statement);
44
- } else {
45
- //multiline, we stack the tokens in an array
46
- let ruleStack = null;
47
- tokenResult = {
48
- tokens: []
49
- };
50
- lines.forEach(line => {
51
- let r = grammar.tokenizeLine(line, ruleStack);
52
- ruleStack = r.ruleStack;
53
- tokenResult.tokens.push(r.tokens);
54
- });
55
- }
56
- assert.deepEqual(tokenResult.tokens, expectedTokens, JSON.stringify(tokenResult.tokens));
57
- })
58
- })
37
+ itShouldMatchExpectedScopes: function (statement, expectedTokens) {
38
+ describe(`${statement}`, () => {
39
+ it('should match expected scopes', () => {
40
+ return registry.loadGrammar('source.abl').then(grammar => {
41
+ let tokenResult;
42
+
43
+ let lines = statement.split(/\n/g);
44
+ let nbLines = lines.length;
45
+ if (nbLines === 1) {
46
+ //singleline
47
+ tokenResult = grammar.tokenizeLine(statement);
48
+
49
+ // More human-readable output
50
+ //console.log(`\nTokenizing line: ${statement}`);
51
+ for (let j = 0; j < tokenResult.tokens.length; j++) {
52
+ const token = tokenResult.tokens[j];
53
+
54
+ // More human-readable output
55
+ // console.log(` - token from ${token.startIndex} to ${token.endIndex} ` +
56
+ // `(${statement.substring(token.startIndex, token.endIndex)}) ` +
57
+ // `with scopes ${token.scopes.join(', ')}`
58
+ // );
59
+
60
+ // Formatted as input-values
61
+ var O = token.scopes.map((e) => ('"' + e + '",')).join(' ').replace(/,\s*$/, "");
62
+ console.log(`{ "startIndex": ${token.startIndex}, "endIndex": ${token.endIndex}, "scopes": [${O}] }, // '${statement.substring(token.startIndex, token.endIndex)}'`,);
63
+
64
+ }
65
+ } else {
66
+ //multiline, we stack the tokens in an array
67
+ let ruleStack = null;
68
+ tokenResult = {
69
+ tokens: []
70
+ };
71
+ lines.forEach(line => {
72
+ let r = grammar.tokenizeLine(line, ruleStack);
73
+ ruleStack = r.ruleStack;
74
+ tokenResult.tokens.push(r.tokens);
75
+
76
+ // More human-readable output
77
+ //console.log(`\nTokenizing line: ${line}`);
78
+ // Formatted as input-values
79
+ console.log(`[`);
80
+ for (let j = 0; j < r.tokens.length; j++) {
81
+ const token = r.tokens[j];
82
+ // More human-readable output
83
+ // console.log(` - token from ${token.startIndex} to ${token.endIndex} ` +
84
+ // `(${line.substring(token.startIndex, token.endIndex)}) ` +
85
+ // `with scopes ${token.scopes.join(', ')}`
86
+ // );
87
+
88
+ // Formatted as input-values
89
+ var O = token.scopes.map((e) => ('"' + e + '",')).join(' ').replace(/,\s*$/, "");
90
+ console.log(`{ "startIndex": ${token.startIndex}, "endIndex": ${token.endIndex}, "scopes": [${O}] }, // '${line.substring(token.startIndex, token.endIndex)}'`,);
91
+
92
+ }
93
+ // Formatted as input-values
94
+ console.log(`],`);
95
+
96
+ });
97
+ }
98
+ assert.deepEqual(tokenResult.tokens, expectedTokens, JSON.stringify(tokenResult.tokens));
59
99
  })
60
- }
61
- }
100
+ })
101
+ })
102
+ }
103
+ }
@@ -0,0 +1,52 @@
1
+ const { assert, expect } = require('chai');
2
+ const shared = require('../shared.js');
3
+
4
+ describe('', () => {
5
+ // the :R in the method name should not be marked as a string colon-R
6
+ let statement = `if valid-object(oEventArgs:ResponseBody) then
7
+ assign oResponse:ContentType = "application/json":u
8
+ oResponse:Entity = oEventArgs:ResponseBody.`;
9
+ let expectedTokens = [
10
+ [
11
+ { "startIndex": 0, "endIndex": 2, "scopes": ["source.abl", "keyword.other.abl"] }, // 'if'
12
+ { "startIndex": 2, "endIndex": 3, "scopes": ["source.abl"] }, // ' '
13
+ { "startIndex": 3, "endIndex": 15, "scopes": ["source.abl", "meta.function-call.abl", "support.function.abl"] }, // 'valid-object'
14
+ { "startIndex": 15, "endIndex": 16, "scopes": ["source.abl", "meta.function-call.abl", "meta.function.arguments.abl", "meta.brace.round.js"] }, // '('
15
+ { "startIndex": 16, "endIndex": 26, "scopes": ["source.abl", "meta.function-call.abl", "meta.function.arguments.abl", "variable.other.abl"] }, // 'oEventArgs'
16
+ { "startIndex": 26, "endIndex": 27, "scopes": ["source.abl", "meta.function-call.abl", "meta.function.arguments.abl", "punctuation.separator.colon.abl"] }, // ':'
17
+ { "startIndex": 27, "endIndex": 39, "scopes": ["source.abl", "meta.function-call.abl", "meta.function.arguments.abl", "entity.name.function.abl"] }, // 'ResponseBody'
18
+ { "startIndex": 39, "endIndex": 40, "scopes": ["source.abl", "meta.function-call.abl", "meta.brace.round.js"] }, // ')'
19
+ { "startIndex": 40, "endIndex": 41, "scopes": ["source.abl"] }, // ' '
20
+ { "startIndex": 41, "endIndex": 45, "scopes": ["source.abl", "keyword.other.abl"] } // 'then'
21
+ ],
22
+ [
23
+ { "startIndex": 0, "endIndex": 4, "scopes": ["source.abl"] }, // ' '
24
+ { "startIndex": 4, "endIndex": 10, "scopes": ["source.abl", "keyword.other.abl"] }, // 'assign'
25
+ { "startIndex": 10, "endIndex": 11, "scopes": ["source.abl"] }, // ' '
26
+ { "startIndex": 11, "endIndex": 20, "scopes": ["source.abl", "variable.other.abl"] }, // 'oResponse'
27
+ { "startIndex": 20, "endIndex": 21, "scopes": ["source.abl", "punctuation.separator.colon.abl"] }, // ':'
28
+ { "startIndex": 21, "endIndex": 32, "scopes": ["source.abl", "entity.name.function.abl"] }, // 'ContentType'
29
+ { "startIndex": 32, "endIndex": 33, "scopes": ["source.abl"] }, // ' '
30
+ { "startIndex": 33, "endIndex": 34, "scopes": ["source.abl", "keyword.operator.source.abl"] }, // '='
31
+ { "startIndex": 34, "endIndex": 35, "scopes": ["source.abl"] }, // ' '
32
+ { "startIndex": 35, "endIndex": 36, "scopes": ["source.abl", "string.double.complex.abl", "punctuation.definition.string.begin.abl"] }, // '"'
33
+ { "startIndex": 36, "endIndex": 52, "scopes": ["source.abl", "string.double.complex.abl"] }, // 'application/json'
34
+ { "startIndex": 52, "endIndex": 53, "scopes": ["source.abl", "string.double.complex.abl", "punctuation.definition.string.end.abl"] }, // '"'
35
+ { "startIndex": 53, "endIndex": 55, "scopes": ["source.abl", "support.other.abl"] } // ':u'
36
+ ],
37
+ [
38
+ { "startIndex": 0, "endIndex": 12, "scopes": ["source.abl"] }, // ' '
39
+ { "startIndex": 12, "endIndex": 21, "scopes": ["source.abl", "variable.other.abl"] }, // 'oResponse'
40
+ { "startIndex": 21, "endIndex": 22, "scopes": ["source.abl", "punctuation.separator.colon.abl"] }, // ':'
41
+ { "startIndex": 22, "endIndex": 28, "scopes": ["source.abl", "entity.name.function.abl"] }, // 'Entity'
42
+ { "startIndex": 28, "endIndex": 34, "scopes": ["source.abl"] }, // ' '
43
+ { "startIndex": 34, "endIndex": 35, "scopes": ["source.abl", "keyword.operator.source.abl"] }, // '='
44
+ { "startIndex": 35, "endIndex": 36, "scopes": ["source.abl"] }, // ' '
45
+ { "startIndex": 36, "endIndex": 46, "scopes": ["source.abl", "variable.other.abl"] }, // 'oEventArgs'
46
+ { "startIndex": 46, "endIndex": 47, "scopes": ["source.abl", "punctuation.separator.colon.abl"] }, // ':'
47
+ { "startIndex": 47, "endIndex": 59, "scopes": ["source.abl", "entity.name.function.abl"] }, // 'ResponseBody'
48
+ { "startIndex": 59, "endIndex": 60, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.'
49
+ ]
50
+ ];
51
+ shared.itShouldMatchExpectedScopes(statement, expectedTokens);
52
+ })