@apexdevtools/apex-parser 3.0.0 → 3.1.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.
- package/CHANGELOG.md +12 -0
- package/README.md +37 -14
- package/lib/ApexLexer.d.ts +135 -127
- package/lib/ApexLexer.js +1360 -1266
- package/lib/ApexLexer.js.map +1 -1
- package/lib/ApexParser.d.ts +264 -173
- package/lib/ApexParser.js +3496 -2521
- package/lib/ApexParser.js.map +1 -1
- package/lib/ApexParserListener.d.ts +46 -0
- package/lib/ApexParserVisitor.d.ts +29 -0
- package/lib/__tests__/ApexParserTest.js +47 -78
- package/lib/__tests__/ApexParserTest.js.map +1 -1
- package/lib/__tests__/SOQLParserTest.d.ts +1 -0
- package/lib/__tests__/SOQLParserTest.js +59 -0
- package/lib/__tests__/SOQLParserTest.js.map +1 -0
- package/lib/__tests__/SOSLParserTest.d.ts +1 -0
- package/lib/__tests__/SOSLParserTest.js +35 -0
- package/lib/__tests__/SOSLParserTest.js.map +1 -0
- package/lib/__tests__/SyntaxErrorCounter.d.ts +8 -0
- package/lib/__tests__/SyntaxErrorCounter.js +30 -0
- package/lib/__tests__/SyntaxErrorCounter.js.map +1 -0
- package/lib/__tests__/system/SampleParseSys.d.ts +1 -0
- package/lib/__tests__/system/SampleParseSys.js +72 -0
- package/lib/__tests__/system/SampleParseSys.js.map +1 -0
- package/lib/index.d.ts +25 -9
- package/lib/index.js +99 -11
- package/lib/index.js.map +1 -1
- package/package.json +7 -4
|
@@ -3,6 +3,7 @@ import { ThisPrimaryContext } from "./ApexParser";
|
|
|
3
3
|
import { SuperPrimaryContext } from "./ApexParser";
|
|
4
4
|
import { LiteralPrimaryContext } from "./ApexParser";
|
|
5
5
|
import { TypeRefPrimaryContext } from "./ApexParser";
|
|
6
|
+
import { VoidPrimaryContext } from "./ApexParser";
|
|
6
7
|
import { IdPrimaryContext } from "./ApexParser";
|
|
7
8
|
import { SoqlPrimaryContext } from "./ApexParser";
|
|
8
9
|
import { SoslPrimaryContext } from "./ApexParser";
|
|
@@ -127,6 +128,8 @@ import { SubFieldEntryContext } from "./ApexParser";
|
|
|
127
128
|
import { SoqlFieldsParameterContext } from "./ApexParser";
|
|
128
129
|
import { SoqlFunctionContext } from "./ApexParser";
|
|
129
130
|
import { DateFieldNameContext } from "./ApexParser";
|
|
131
|
+
import { LocationValueContext } from "./ApexParser";
|
|
132
|
+
import { CoordinateValueContext } from "./ApexParser";
|
|
130
133
|
import { TypeOfContext } from "./ApexParser";
|
|
131
134
|
import { WhenClauseContext } from "./ApexParser";
|
|
132
135
|
import { ElseClauseContext } from "./ApexParser";
|
|
@@ -158,6 +161,7 @@ import { DateFormulaContext } from "./ApexParser";
|
|
|
158
161
|
import { SignedIntegerContext } from "./ApexParser";
|
|
159
162
|
import { SoqlIdContext } from "./ApexParser";
|
|
160
163
|
import { SoslLiteralContext } from "./ApexParser";
|
|
164
|
+
import { SoslLiteralAltContext } from "./ApexParser";
|
|
161
165
|
import { SoslClausesContext } from "./ApexParser";
|
|
162
166
|
import { SearchGroupContext } from "./ApexParser";
|
|
163
167
|
import { FieldSpecListContext } from "./ApexParser";
|
|
@@ -222,6 +226,18 @@ export interface ApexParserListener extends ParseTreeListener {
|
|
|
222
226
|
* @param ctx the parse tree
|
|
223
227
|
*/
|
|
224
228
|
exitTypeRefPrimary?: (ctx: TypeRefPrimaryContext) => void;
|
|
229
|
+
/**
|
|
230
|
+
* Enter a parse tree produced by the `voidPrimary`
|
|
231
|
+
* labeled alternative in `ApexParser.primary`.
|
|
232
|
+
* @param ctx the parse tree
|
|
233
|
+
*/
|
|
234
|
+
enterVoidPrimary?: (ctx: VoidPrimaryContext) => void;
|
|
235
|
+
/**
|
|
236
|
+
* Exit a parse tree produced by the `voidPrimary`
|
|
237
|
+
* labeled alternative in `ApexParser.primary`.
|
|
238
|
+
* @param ctx the parse tree
|
|
239
|
+
*/
|
|
240
|
+
exitVoidPrimary?: (ctx: VoidPrimaryContext) => void;
|
|
225
241
|
/**
|
|
226
242
|
* Enter a parse tree produced by the `idPrimary`
|
|
227
243
|
* labeled alternative in `ApexParser.primary`.
|
|
@@ -1514,6 +1530,26 @@ export interface ApexParserListener extends ParseTreeListener {
|
|
|
1514
1530
|
* @param ctx the parse tree
|
|
1515
1531
|
*/
|
|
1516
1532
|
exitDateFieldName?: (ctx: DateFieldNameContext) => void;
|
|
1533
|
+
/**
|
|
1534
|
+
* Enter a parse tree produced by `ApexParser.locationValue`.
|
|
1535
|
+
* @param ctx the parse tree
|
|
1536
|
+
*/
|
|
1537
|
+
enterLocationValue?: (ctx: LocationValueContext) => void;
|
|
1538
|
+
/**
|
|
1539
|
+
* Exit a parse tree produced by `ApexParser.locationValue`.
|
|
1540
|
+
* @param ctx the parse tree
|
|
1541
|
+
*/
|
|
1542
|
+
exitLocationValue?: (ctx: LocationValueContext) => void;
|
|
1543
|
+
/**
|
|
1544
|
+
* Enter a parse tree produced by `ApexParser.coordinateValue`.
|
|
1545
|
+
* @param ctx the parse tree
|
|
1546
|
+
*/
|
|
1547
|
+
enterCoordinateValue?: (ctx: CoordinateValueContext) => void;
|
|
1548
|
+
/**
|
|
1549
|
+
* Exit a parse tree produced by `ApexParser.coordinateValue`.
|
|
1550
|
+
* @param ctx the parse tree
|
|
1551
|
+
*/
|
|
1552
|
+
exitCoordinateValue?: (ctx: CoordinateValueContext) => void;
|
|
1517
1553
|
/**
|
|
1518
1554
|
* Enter a parse tree produced by `ApexParser.typeOf`.
|
|
1519
1555
|
* @param ctx the parse tree
|
|
@@ -1824,6 +1860,16 @@ export interface ApexParserListener extends ParseTreeListener {
|
|
|
1824
1860
|
* @param ctx the parse tree
|
|
1825
1861
|
*/
|
|
1826
1862
|
exitSoslLiteral?: (ctx: SoslLiteralContext) => void;
|
|
1863
|
+
/**
|
|
1864
|
+
* Enter a parse tree produced by `ApexParser.soslLiteralAlt`.
|
|
1865
|
+
* @param ctx the parse tree
|
|
1866
|
+
*/
|
|
1867
|
+
enterSoslLiteralAlt?: (ctx: SoslLiteralAltContext) => void;
|
|
1868
|
+
/**
|
|
1869
|
+
* Exit a parse tree produced by `ApexParser.soslLiteralAlt`.
|
|
1870
|
+
* @param ctx the parse tree
|
|
1871
|
+
*/
|
|
1872
|
+
exitSoslLiteralAlt?: (ctx: SoslLiteralAltContext) => void;
|
|
1827
1873
|
/**
|
|
1828
1874
|
* Enter a parse tree produced by `ApexParser.soslClauses`.
|
|
1829
1875
|
* @param ctx the parse tree
|
|
@@ -3,6 +3,7 @@ import { ThisPrimaryContext } from "./ApexParser";
|
|
|
3
3
|
import { SuperPrimaryContext } from "./ApexParser";
|
|
4
4
|
import { LiteralPrimaryContext } from "./ApexParser";
|
|
5
5
|
import { TypeRefPrimaryContext } from "./ApexParser";
|
|
6
|
+
import { VoidPrimaryContext } from "./ApexParser";
|
|
6
7
|
import { IdPrimaryContext } from "./ApexParser";
|
|
7
8
|
import { SoqlPrimaryContext } from "./ApexParser";
|
|
8
9
|
import { SoslPrimaryContext } from "./ApexParser";
|
|
@@ -127,6 +128,8 @@ import { SubFieldEntryContext } from "./ApexParser";
|
|
|
127
128
|
import { SoqlFieldsParameterContext } from "./ApexParser";
|
|
128
129
|
import { SoqlFunctionContext } from "./ApexParser";
|
|
129
130
|
import { DateFieldNameContext } from "./ApexParser";
|
|
131
|
+
import { LocationValueContext } from "./ApexParser";
|
|
132
|
+
import { CoordinateValueContext } from "./ApexParser";
|
|
130
133
|
import { TypeOfContext } from "./ApexParser";
|
|
131
134
|
import { WhenClauseContext } from "./ApexParser";
|
|
132
135
|
import { ElseClauseContext } from "./ApexParser";
|
|
@@ -158,6 +161,7 @@ import { DateFormulaContext } from "./ApexParser";
|
|
|
158
161
|
import { SignedIntegerContext } from "./ApexParser";
|
|
159
162
|
import { SoqlIdContext } from "./ApexParser";
|
|
160
163
|
import { SoslLiteralContext } from "./ApexParser";
|
|
164
|
+
import { SoslLiteralAltContext } from "./ApexParser";
|
|
161
165
|
import { SoslClausesContext } from "./ApexParser";
|
|
162
166
|
import { SearchGroupContext } from "./ApexParser";
|
|
163
167
|
import { FieldSpecListContext } from "./ApexParser";
|
|
@@ -205,6 +209,13 @@ export interface ApexParserVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
|
205
209
|
* @return the visitor result
|
|
206
210
|
*/
|
|
207
211
|
visitTypeRefPrimary?: (ctx: TypeRefPrimaryContext) => Result;
|
|
212
|
+
/**
|
|
213
|
+
* Visit a parse tree produced by the `voidPrimary`
|
|
214
|
+
* labeled alternative in `ApexParser.primary`.
|
|
215
|
+
* @param ctx the parse tree
|
|
216
|
+
* @return the visitor result
|
|
217
|
+
*/
|
|
218
|
+
visitVoidPrimary?: (ctx: VoidPrimaryContext) => Result;
|
|
208
219
|
/**
|
|
209
220
|
* Visit a parse tree produced by the `idPrimary`
|
|
210
221
|
* labeled alternative in `ApexParser.primary`.
|
|
@@ -975,6 +986,18 @@ export interface ApexParserVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
|
975
986
|
* @return the visitor result
|
|
976
987
|
*/
|
|
977
988
|
visitDateFieldName?: (ctx: DateFieldNameContext) => Result;
|
|
989
|
+
/**
|
|
990
|
+
* Visit a parse tree produced by `ApexParser.locationValue`.
|
|
991
|
+
* @param ctx the parse tree
|
|
992
|
+
* @return the visitor result
|
|
993
|
+
*/
|
|
994
|
+
visitLocationValue?: (ctx: LocationValueContext) => Result;
|
|
995
|
+
/**
|
|
996
|
+
* Visit a parse tree produced by `ApexParser.coordinateValue`.
|
|
997
|
+
* @param ctx the parse tree
|
|
998
|
+
* @return the visitor result
|
|
999
|
+
*/
|
|
1000
|
+
visitCoordinateValue?: (ctx: CoordinateValueContext) => Result;
|
|
978
1001
|
/**
|
|
979
1002
|
* Visit a parse tree produced by `ApexParser.typeOf`.
|
|
980
1003
|
* @param ctx the parse tree
|
|
@@ -1161,6 +1184,12 @@ export interface ApexParserVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
|
1161
1184
|
* @return the visitor result
|
|
1162
1185
|
*/
|
|
1163
1186
|
visitSoslLiteral?: (ctx: SoslLiteralContext) => Result;
|
|
1187
|
+
/**
|
|
1188
|
+
* Visit a parse tree produced by `ApexParser.soslLiteralAlt`.
|
|
1189
|
+
* @param ctx the parse tree
|
|
1190
|
+
* @return the visitor result
|
|
1191
|
+
*/
|
|
1192
|
+
visitSoslLiteralAlt?: (ctx: SoslLiteralAltContext) => Result;
|
|
1164
1193
|
/**
|
|
1165
1194
|
* Visit a parse tree produced by `ApexParser.soslClauses`.
|
|
1166
1195
|
* @param ctx the parse tree
|
|
@@ -1,69 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ApexLexer_1 = require("../ApexLexer");
|
|
4
3
|
const ApexParser_1 = require("../ApexParser");
|
|
5
|
-
const CaseInsensitiveInputStream_1 = require("../CaseInsensitiveInputStream");
|
|
6
|
-
const antlr4ts_1 = require("antlr4ts");
|
|
7
4
|
const ThrowingErrorListener_1 = require("../ThrowingErrorListener");
|
|
5
|
+
const SyntaxErrorCounter_1 = require("./SyntaxErrorCounter");
|
|
8
6
|
test('Boolean Literal', () => {
|
|
9
|
-
const
|
|
10
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
11
|
-
const parser = new ApexParser_1.ApexParser(tokens);
|
|
7
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("true");
|
|
12
8
|
const context = parser.literal();
|
|
9
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
13
10
|
expect(context).toBeInstanceOf(ApexParser_1.LiteralContext);
|
|
14
11
|
expect(context.BooleanLiteral()).toBeTruthy();
|
|
15
12
|
expect(context.BooleanLiteral().text).toBe("true");
|
|
16
13
|
});
|
|
17
14
|
test('Expression', () => {
|
|
18
|
-
const
|
|
19
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
20
|
-
const parser = new ApexParser_1.ApexParser(tokens);
|
|
15
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("a * 5");
|
|
21
16
|
const context = parser.expression();
|
|
17
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
22
18
|
expect(context).toBeInstanceOf(ApexParser_1.Arth1ExpressionContext);
|
|
23
19
|
const arthExpression = context;
|
|
24
20
|
expect(arthExpression.expression().length).toBe(2);
|
|
25
21
|
});
|
|
26
22
|
test('Compilation Unit', () => {
|
|
27
|
-
const
|
|
28
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
29
|
-
const parser = new ApexParser_1.ApexParser(tokens);
|
|
23
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("public class Hello {}");
|
|
30
24
|
const context = parser.compilationUnit();
|
|
31
|
-
expect(context
|
|
25
|
+
expect(context).toBeInstanceOf(ApexParser_1.CompilationUnitContext);
|
|
26
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
32
27
|
});
|
|
33
28
|
test('Compilation Unit (case insensitive)', () => {
|
|
34
|
-
const
|
|
35
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
36
|
-
const parser = new ApexParser_1.ApexParser(tokens);
|
|
29
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("Public CLASS Hello {}");
|
|
37
30
|
const context = parser.compilationUnit();
|
|
38
|
-
expect(context
|
|
31
|
+
expect(context).toBeInstanceOf(ApexParser_1.CompilationUnitContext);
|
|
32
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
39
33
|
});
|
|
40
34
|
test('Compilation Unit (bug test)', () => {
|
|
41
|
-
const
|
|
35
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)(`public class Hello {
|
|
42
36
|
public testMethod void func() {
|
|
43
37
|
System.runAs(u) {
|
|
44
38
|
}
|
|
45
39
|
}
|
|
46
|
-
}`)
|
|
47
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
48
|
-
const parser = new ApexParser_1.ApexParser(tokens);
|
|
40
|
+
}`);
|
|
49
41
|
const context = parser.compilationUnit();
|
|
50
|
-
expect(context
|
|
42
|
+
expect(context).toBeInstanceOf(ApexParser_1.CompilationUnitContext);
|
|
43
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
51
44
|
});
|
|
52
45
|
test('Compilation Unit (inline SOQL)', () => {
|
|
53
|
-
const
|
|
46
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)(`public class Hello {
|
|
54
47
|
public void func() {
|
|
55
48
|
List<Account> accounts = [Select Id from Accounts];
|
|
56
49
|
}
|
|
57
|
-
}`)
|
|
58
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
59
|
-
const parser = new ApexParser_1.ApexParser(tokens);
|
|
50
|
+
}`);
|
|
60
51
|
const context = parser.compilationUnit();
|
|
61
|
-
expect(context
|
|
52
|
+
expect(context).toBeInstanceOf(ApexParser_1.CompilationUnitContext);
|
|
53
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
62
54
|
});
|
|
63
55
|
test('Compilation Unit (throwing errors)', () => {
|
|
64
|
-
const
|
|
65
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
66
|
-
const parser = new ApexParser_1.ApexParser(tokens);
|
|
56
|
+
const [parser] = (0, SyntaxErrorCounter_1.createParser)("public class Hello {");
|
|
67
57
|
parser.removeErrorListeners();
|
|
68
58
|
parser.addErrorListener(new ThrowingErrorListener_1.ThrowingErrorListener());
|
|
69
59
|
try {
|
|
@@ -75,59 +65,38 @@ test('Compilation Unit (throwing errors)', () => {
|
|
|
75
65
|
}
|
|
76
66
|
});
|
|
77
67
|
test('Trigger Unit', () => {
|
|
78
|
-
const
|
|
79
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
80
|
-
const parser = new ApexParser_1.ApexParser(tokens);
|
|
68
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("trigger test on Account (before update, after update) {}");
|
|
81
69
|
const context = parser.triggerUnit();
|
|
82
|
-
expect(context).
|
|
70
|
+
expect(context).toBeInstanceOf(ApexParser_1.TriggerUnitContext);
|
|
71
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
83
72
|
});
|
|
84
|
-
test('
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
expect(context).toBeTruthy();
|
|
90
|
-
});
|
|
91
|
-
test('SOQL Query Using Field function', () => {
|
|
92
|
-
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("Select Fields(All) from Account")));
|
|
93
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
94
|
-
const parser = new ApexParser_1.ApexParser(tokens);
|
|
95
|
-
const context = parser.query();
|
|
96
|
-
expect(context).toBeTruthy();
|
|
97
|
-
});
|
|
98
|
-
test('SOSL Query', () => {
|
|
99
|
-
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("[Find {something} RETURNING Account]")));
|
|
100
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
101
|
-
const parser = new ApexParser_1.ApexParser(tokens);
|
|
102
|
-
const context = parser.soslLiteral();
|
|
103
|
-
expect(context).toBeTruthy();
|
|
104
|
-
});
|
|
105
|
-
test('CurrencyLiteral', () => {
|
|
106
|
-
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("SELECT Id FROM Account WHERE Amount > USD100.01 AND Amount < USD200")));
|
|
107
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
108
|
-
const parser = new ApexParser_1.ApexParser(tokens);
|
|
109
|
-
const context = parser.query();
|
|
110
|
-
expect(context).toBeTruthy();
|
|
73
|
+
test('testSemiAllowedAsWhileBody', () => {
|
|
74
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("while (x++ < 10 && !(y-- < 0));");
|
|
75
|
+
const context = parser.statement();
|
|
76
|
+
expect(context).toBeInstanceOf(ApexParser_1.StatementContext);
|
|
77
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
111
78
|
});
|
|
112
|
-
test('
|
|
113
|
-
const
|
|
114
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
115
|
-
const parser = new ApexParser_1.ApexParser(tokens);
|
|
79
|
+
test('testSemiAllowedAsForBody', () => {
|
|
80
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("for(x=0; x<10; x++);");
|
|
116
81
|
const context = parser.statement();
|
|
117
|
-
expect(context).
|
|
82
|
+
expect(context).toBeInstanceOf(ApexParser_1.StatementContext);
|
|
83
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
118
84
|
});
|
|
119
|
-
test('
|
|
120
|
-
const
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
expect(context).toBeTruthy();
|
|
85
|
+
test('testSemiDisallowedAsGeneralStatement', () => {
|
|
86
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("if (x == 3); else { ; }");
|
|
87
|
+
const context = parser.statement();
|
|
88
|
+
expect(context).toBeInstanceOf(ApexParser_1.StatementContext);
|
|
89
|
+
expect(errorCounter.getNumErrors()).toEqual(1);
|
|
125
90
|
});
|
|
126
|
-
test('
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
91
|
+
test('testWhenLiteralParens', () => {
|
|
92
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)(`
|
|
93
|
+
switch on (x) {
|
|
94
|
+
when 1 { return 1; }
|
|
95
|
+
when ((2)) { return 2; }
|
|
96
|
+
when (3), (4) { return 3; }
|
|
97
|
+
}`);
|
|
98
|
+
const context = parser.statement();
|
|
99
|
+
expect(context).toBeInstanceOf(ApexParser_1.StatementContext);
|
|
100
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
132
101
|
});
|
|
133
102
|
//# sourceMappingURL=ApexParserTest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApexParserTest.js","sourceRoot":"","sources":["../../src/__tests__/ApexParserTest.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"ApexParserTest.js","sourceRoot":"","sources":["../../src/__tests__/ApexParserTest.ts"],"names":[],"mappings":";;AAAA,8CAGuB;AACvB,oEAAkF;AAClF,6DAAoD;AAEpD,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAEzB,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAA,iCAAY,EAAC,MAAM,CAAC,CAAA;IACnD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;IAEhC,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAC9C,MAAM,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,2BAAc,CAAC,CAAA;IAC9C,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,UAAU,EAAE,CAAA;IAC7C,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AACtD,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE;IACpB,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAA,iCAAY,EAAC,OAAO,CAAC,CAAA;IACpD,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,CAAA;IAEnC,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAC9C,MAAM,CAAC,O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AY,EAAC;;;;;OAKzC,CAAC,CAAC;IAEL,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,EAAE,CAAA;IAElC,MAAM,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,6BAAgB,CAAC,CAAA;IAChD,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAClD,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ApexParser_1 = require("../ApexParser");
|
|
4
|
+
const SyntaxErrorCounter_1 = require("./SyntaxErrorCounter");
|
|
5
|
+
test("SOQL Query", () => {
|
|
6
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("Select Id from Account");
|
|
7
|
+
const context = parser.query();
|
|
8
|
+
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
9
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
10
|
+
});
|
|
11
|
+
test("SOQL Query Using Field function", () => {
|
|
12
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("Select Fields(All) from Account");
|
|
13
|
+
const context = parser.query();
|
|
14
|
+
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
15
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
16
|
+
});
|
|
17
|
+
test("CurrencyLiteral", () => {
|
|
18
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("SELECT Id FROM Account WHERE Amount > USD100.01 AND Amount < USD200");
|
|
19
|
+
const context = parser.query();
|
|
20
|
+
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
21
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
22
|
+
});
|
|
23
|
+
test("IdentifiersThatCouldBeCurrencyLiterals", () => {
|
|
24
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("USD100.name = 'name';");
|
|
25
|
+
const context = parser.statement();
|
|
26
|
+
expect(context).toBeInstanceOf(ApexParser_1.StatementContext);
|
|
27
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
28
|
+
});
|
|
29
|
+
test("DateTimeLiteral", () => {
|
|
30
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("SELECT Name, (SELECT Id FROM Account WHERE createdDate > 2020-01-01T12:00:00Z) FROM Opportunity");
|
|
31
|
+
const context = parser.query();
|
|
32
|
+
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
33
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
34
|
+
});
|
|
35
|
+
test("testNegativeNumericLiteral", () => {
|
|
36
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("SELECT Name FROM Opportunity WHERE Value = -100.123");
|
|
37
|
+
const context = parser.query();
|
|
38
|
+
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
39
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
40
|
+
});
|
|
41
|
+
test("testLastQuarterKeyword", () => {
|
|
42
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("SELECT Id FROM Account WHERE DueDate = LAST_QUARTER");
|
|
43
|
+
const context = parser.query();
|
|
44
|
+
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
45
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
46
|
+
});
|
|
47
|
+
test("testDistanceFunction", () => {
|
|
48
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("SELECT Id, Distance(Address, :something, 'km') FROM Account WHERE Distance(Address, :something, 'km') < 10 ORDER BY Distance(Address, :something, 'km')");
|
|
49
|
+
const context = parser.query();
|
|
50
|
+
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
51
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
52
|
+
});
|
|
53
|
+
test("testGeoLocationFunction", () => {
|
|
54
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("SELECT Id FROM Account WHERE Distance(Address, GeoLocation(:something, -23.33), 'km') < 10");
|
|
55
|
+
const context = parser.query();
|
|
56
|
+
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
57
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=SOQLParserTest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SOQLParserTest.js","sourceRoot":"","sources":["../../src/__tests__/SOQLParserTest.ts"],"names":[],"mappings":";;AAAA,8CAA+D;AAC/D,6DAAoD;AAEpD,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE;IACtB,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAA,iCAAY,EAAC,wBAAwB,CAAC,CAAC;IACtE,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;IAE/B,MAAM,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,yBAAY,CAAC,CAAC;IAC7C,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC3C,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAA,iCAAY,EACzC,iCAAiC,CAClC,CAAC;IAEF,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;IAE/B,MAAM,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,yBAAY,CAAC,CAAC;IAC7C,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC;AAEH,IAAI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AAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ApexParser_1 = require("../ApexParser");
|
|
4
|
+
const SyntaxErrorCounter_1 = require("./SyntaxErrorCounter");
|
|
5
|
+
test('testBasicQuery', () => {
|
|
6
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("[Find 'something' RETURNING Account]");
|
|
7
|
+
const context = parser.soslLiteral();
|
|
8
|
+
expect(context).toBeInstanceOf(ApexParser_1.SoslLiteralContext);
|
|
9
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
10
|
+
});
|
|
11
|
+
test('testEmbeddedQuote', () => {
|
|
12
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("[Find 'some\\'thing' RETURNING Account]");
|
|
13
|
+
const context = parser.soslLiteral();
|
|
14
|
+
expect(context).toBeInstanceOf(ApexParser_1.SoslLiteralContext);
|
|
15
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
16
|
+
});
|
|
17
|
+
test('testBracesFail', () => {
|
|
18
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("[Find {something} RETURNING Account]");
|
|
19
|
+
const context = parser.soslLiteral();
|
|
20
|
+
expect(context).toBeInstanceOf(ApexParser_1.SoslLiteralContext);
|
|
21
|
+
expect(errorCounter.getNumErrors()).toEqual(1);
|
|
22
|
+
});
|
|
23
|
+
test('testBracesOnAltFormat', () => {
|
|
24
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("[Find {something} RETURNING Account]");
|
|
25
|
+
const context = parser.soslLiteralAlt();
|
|
26
|
+
expect(context).toBeInstanceOf(ApexParser_1.SoslLiteralAltContext);
|
|
27
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
28
|
+
});
|
|
29
|
+
test('testQuotesFailOnAltFormat', () => {
|
|
30
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("[Find 'something' RETURNING Account]");
|
|
31
|
+
const context = parser.soslLiteralAlt();
|
|
32
|
+
expect(context).toBeInstanceOf(ApexParser_1.SoslLiteralAltContext);
|
|
33
|
+
expect(errorCounter.getNumErrors()).toEqual(1);
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=SOSLParserTest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SOSLParserTest.js","sourceRoot":"","sources":["../../src/__tests__/SOSLParserTest.ts"],"names":[],"mappings":";;AAAA,8CAGuB;AACvB,6DAAoD;AAEpD,IAAI,CAAC,gBAAgB,EAAE,GAAG,EAAE;IACxB,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAA,iCAAY,EAAC,sCAAsC,CAAC,CAAA;IAEnF,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;IAEpC,MAAM,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,+BAAkB,CAAC,CAAA;IAClD,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAClD,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC3B,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAA,iCAAY,EAAC,yCAAyC,CAAC,CAAA;IAEtF,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;IAEpC,MAAM,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,+BAAkB,CAAC,CAAA;IAClD,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAClD,CAAC,CAAC,CAAA;AAEF,IA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axErrorCounter implements ANTLRErrorListener<Token> {
|
|
4
|
+
numErrors: number;
|
|
5
|
+
syntaxError(recognizer: Recognizer<Token, any>, offendingSymbol: Token, line: number, charPositionInLine: number, msg: string, e: RecognitionException | undefined): any;
|
|
6
|
+
getNumErrors(): number;
|
|
7
|
+
}
|
|
8
|
+
export declare function createParser(input: string): [ApexParser, SyntaxErrorCounter];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createParser = exports.SyntaxErrorCounter = void 0;
|
|
4
|
+
const antlr4ts_1 = require("antlr4ts");
|
|
5
|
+
const ApexLexer_1 = require("../ApexLexer");
|
|
6
|
+
const ApexParser_1 = require("../ApexParser");
|
|
7
|
+
const CaseInsensitiveInputStream_1 = require("../CaseInsensitiveInputStream");
|
|
8
|
+
class SyntaxErrorCounter {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.numErrors = 0;
|
|
11
|
+
}
|
|
12
|
+
syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e) {
|
|
13
|
+
this.numErrors += 1;
|
|
14
|
+
}
|
|
15
|
+
getNumErrors() {
|
|
16
|
+
return this.numErrors;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.SyntaxErrorCounter = SyntaxErrorCounter;
|
|
20
|
+
function createParser(input) {
|
|
21
|
+
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString(input)));
|
|
22
|
+
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
23
|
+
const parser = new ApexParser_1.ApexParser(tokens);
|
|
24
|
+
parser.removeErrorListeners();
|
|
25
|
+
const errorCounter = new SyntaxErrorCounter();
|
|
26
|
+
parser.addErrorListener(errorCounter);
|
|
27
|
+
return [parser, errorCounter];
|
|
28
|
+
}
|
|
29
|
+
exports.createParser = createParser;
|
|
30
|
+
//# sourceMappingURL=SyntaxErrorCounter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SyntaxErrorCounter.js","sourceRoot":"","sources":["../../src/__tests__/SyntaxErrorCounter.ts"],"names":[],"mappings":";;;AAAA,uCAAuH;AACvH,4CAAyC;AACzC,8CAA2C;AAC3C,8EAA2E;AAE3E,MAAa,kBAAkB;IAA/B;QACI,cAAS,GAAG,CAAC,CAAA;IAWjB,CAAC;IATG,WAAW,CAAC,UAAkC,EAC1C,eAAsB,EAAE,IAAY,EAAE,kBAA0B,EAAE,GAAW,EAC7E,CAAmC;QACnC,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,YAAY;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;CACJ;AAZD,gDAYC;AAED,SAAgB,YAAY,CAAC,KAAa;IACtC,MAAM,KAAK,GAAG,IAAI,qBAAS,CAAC,IAAI,uDAA0B,CAAC,sBAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC1F,MAAM,MAAM,GAAG,IAAI,4BAAiB,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,IAAI,uBAAU,CAAC,MAAM,CAAC,CAAA;IAErC,MAAM,CAAC,oBAAoB,EAAE,CAAA;IAC7B,MAAM,YAAY,GAAG,IAAI,kBAAkB,EAAE,CAAC;IAC9C,MAAM,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAEtC,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAClC,CAAC;AAVD,oCAUC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const child_process_1 = require("child_process");
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
const path_1 = require("path");
|
|
15
|
+
const __1 = require("../..");
|
|
16
|
+
describe("Parse samples", () => {
|
|
17
|
+
// .each runs first before any hooks like beforeAll
|
|
18
|
+
function getSamples() {
|
|
19
|
+
if (!process.env.SAMPLES) {
|
|
20
|
+
throw new Error("Missing environment variable 'SAMPLES' with path to samples.");
|
|
21
|
+
}
|
|
22
|
+
const sampleDir = (0, path_1.resolve)(process.env.SAMPLES);
|
|
23
|
+
return (0, fs_1.readdirSync)(sampleDir)
|
|
24
|
+
.filter(f => !(/(^|\/)\.[^\/\.]/g).test(f)) // not hidden
|
|
25
|
+
.map(f => (0, path_1.resolve)(sampleDir, f)) // full path
|
|
26
|
+
.filter(f => (0, fs_1.lstatSync)(f).isDirectory())
|
|
27
|
+
.map(d => [(0, path_1.basename)(d), d]);
|
|
28
|
+
}
|
|
29
|
+
// disable jest wrapped logging
|
|
30
|
+
const jestConsole = console;
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
global.console = require("console");
|
|
33
|
+
});
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
global.console = jestConsole;
|
|
36
|
+
});
|
|
37
|
+
test.each(getSamples())("Sample: %s", (_name, path) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
const result = yield (0, __1.checkProject)(path);
|
|
39
|
+
expect(result).toMatchSnapshot();
|
|
40
|
+
// run the jvm version of check over same dirs
|
|
41
|
+
result.forEach(r => {
|
|
42
|
+
const jvmCheck = (0, child_process_1.spawnSync)("java", [
|
|
43
|
+
"-cp",
|
|
44
|
+
"jvm/target/dependency/*:jvm/target/apex-parser.jar",
|
|
45
|
+
"com.nawforce.apexparser.Check",
|
|
46
|
+
(0, path_1.resolve)(path, r.path)
|
|
47
|
+
], {
|
|
48
|
+
// can only be run from npm dir
|
|
49
|
+
cwd: (0, path_1.resolve)(process.cwd(), ".."),
|
|
50
|
+
timeout: 10000
|
|
51
|
+
});
|
|
52
|
+
const errors = [];
|
|
53
|
+
const logs = [];
|
|
54
|
+
// either >1 or null, truthy check not enough
|
|
55
|
+
if (jvmCheck.status || jvmCheck.status == null) {
|
|
56
|
+
logs.push(...jvmCheck.stderr.toString("utf8").split("\n"));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
jvmCheck.stdout
|
|
60
|
+
.toString("utf8")
|
|
61
|
+
.split("\n")
|
|
62
|
+
.forEach(l => (l.startsWith("{") ? errors : logs).push(l));
|
|
63
|
+
}
|
|
64
|
+
console.log(logs.filter(l => l).map(s => `(JVM) ${s}`).join("\n"));
|
|
65
|
+
// catch unexpected failures or timeouts
|
|
66
|
+
expect(jvmCheck.status).toEqual(r.status);
|
|
67
|
+
// match syntax errors to snapshot value
|
|
68
|
+
expect(errors.map(j => JSON.parse(j))).toMatchObject(r.errors);
|
|
69
|
+
});
|
|
70
|
+
}), 15000);
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=SampleParseSys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SampleParseSys.js","sourceRoot":"","sources":["../../../src/__tests__/system/SampleParseSys.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iDAA0C;AAC1C,2BAA4C;AAC5C,+BAAwC;AACxC,6BAAqC;AAErC,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAE3B,mDAAmD;IACnD,SAAS,UAAU;QACf,IAAI,CAAC,OAAO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