@apexdevtools/apex-parser 3.0.0 → 3.2.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 +15 -0
- package/README.md +39 -38
- package/lib/ApexLexer.d.ts +191 -179
- package/lib/ApexLexer.js +1452 -1328
- package/lib/ApexLexer.js.map +1 -1
- package/lib/ApexParser.d.ts +393 -270
- package/lib/ApexParser.js +3881 -2670
- package/lib/ApexParser.js.map +1 -1
- package/lib/ApexParserListener.d.ts +57 -0
- package/lib/ApexParserVisitor.d.ts +36 -0
- package/lib/__tests__/ApexParserTest.js +63 -76
- 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";
|
|
@@ -82,6 +83,7 @@ import { ReturnStatementContext } from "./ApexParser";
|
|
|
82
83
|
import { ThrowStatementContext } from "./ApexParser";
|
|
83
84
|
import { BreakStatementContext } from "./ApexParser";
|
|
84
85
|
import { ContinueStatementContext } from "./ApexParser";
|
|
86
|
+
import { AccessLevelContext } from "./ApexParser";
|
|
85
87
|
import { InsertStatementContext } from "./ApexParser";
|
|
86
88
|
import { UpdateStatementContext } from "./ApexParser";
|
|
87
89
|
import { DeleteStatementContext } from "./ApexParser";
|
|
@@ -127,6 +129,8 @@ import { SubFieldEntryContext } from "./ApexParser";
|
|
|
127
129
|
import { SoqlFieldsParameterContext } from "./ApexParser";
|
|
128
130
|
import { SoqlFunctionContext } from "./ApexParser";
|
|
129
131
|
import { DateFieldNameContext } from "./ApexParser";
|
|
132
|
+
import { LocationValueContext } from "./ApexParser";
|
|
133
|
+
import { CoordinateValueContext } from "./ApexParser";
|
|
130
134
|
import { TypeOfContext } from "./ApexParser";
|
|
131
135
|
import { WhenClauseContext } from "./ApexParser";
|
|
132
136
|
import { ElseClauseContext } from "./ApexParser";
|
|
@@ -158,6 +162,7 @@ import { DateFormulaContext } from "./ApexParser";
|
|
|
158
162
|
import { SignedIntegerContext } from "./ApexParser";
|
|
159
163
|
import { SoqlIdContext } from "./ApexParser";
|
|
160
164
|
import { SoslLiteralContext } from "./ApexParser";
|
|
165
|
+
import { SoslLiteralAltContext } from "./ApexParser";
|
|
161
166
|
import { SoslClausesContext } from "./ApexParser";
|
|
162
167
|
import { SearchGroupContext } from "./ApexParser";
|
|
163
168
|
import { FieldSpecListContext } from "./ApexParser";
|
|
@@ -222,6 +227,18 @@ export interface ApexParserListener extends ParseTreeListener {
|
|
|
222
227
|
* @param ctx the parse tree
|
|
223
228
|
*/
|
|
224
229
|
exitTypeRefPrimary?: (ctx: TypeRefPrimaryContext) => void;
|
|
230
|
+
/**
|
|
231
|
+
* Enter a parse tree produced by the `voidPrimary`
|
|
232
|
+
* labeled alternative in `ApexParser.primary`.
|
|
233
|
+
* @param ctx the parse tree
|
|
234
|
+
*/
|
|
235
|
+
enterVoidPrimary?: (ctx: VoidPrimaryContext) => void;
|
|
236
|
+
/**
|
|
237
|
+
* Exit a parse tree produced by the `voidPrimary`
|
|
238
|
+
* labeled alternative in `ApexParser.primary`.
|
|
239
|
+
* @param ctx the parse tree
|
|
240
|
+
*/
|
|
241
|
+
exitVoidPrimary?: (ctx: VoidPrimaryContext) => void;
|
|
225
242
|
/**
|
|
226
243
|
* Enter a parse tree produced by the `idPrimary`
|
|
227
244
|
* labeled alternative in `ApexParser.primary`.
|
|
@@ -1064,6 +1081,16 @@ export interface ApexParserListener extends ParseTreeListener {
|
|
|
1064
1081
|
* @param ctx the parse tree
|
|
1065
1082
|
*/
|
|
1066
1083
|
exitContinueStatement?: (ctx: ContinueStatementContext) => void;
|
|
1084
|
+
/**
|
|
1085
|
+
* Enter a parse tree produced by `ApexParser.accessLevel`.
|
|
1086
|
+
* @param ctx the parse tree
|
|
1087
|
+
*/
|
|
1088
|
+
enterAccessLevel?: (ctx: AccessLevelContext) => void;
|
|
1089
|
+
/**
|
|
1090
|
+
* Exit a parse tree produced by `ApexParser.accessLevel`.
|
|
1091
|
+
* @param ctx the parse tree
|
|
1092
|
+
*/
|
|
1093
|
+
exitAccessLevel?: (ctx: AccessLevelContext) => void;
|
|
1067
1094
|
/**
|
|
1068
1095
|
* Enter a parse tree produced by `ApexParser.insertStatement`.
|
|
1069
1096
|
* @param ctx the parse tree
|
|
@@ -1514,6 +1541,26 @@ export interface ApexParserListener extends ParseTreeListener {
|
|
|
1514
1541
|
* @param ctx the parse tree
|
|
1515
1542
|
*/
|
|
1516
1543
|
exitDateFieldName?: (ctx: DateFieldNameContext) => void;
|
|
1544
|
+
/**
|
|
1545
|
+
* Enter a parse tree produced by `ApexParser.locationValue`.
|
|
1546
|
+
* @param ctx the parse tree
|
|
1547
|
+
*/
|
|
1548
|
+
enterLocationValue?: (ctx: LocationValueContext) => void;
|
|
1549
|
+
/**
|
|
1550
|
+
* Exit a parse tree produced by `ApexParser.locationValue`.
|
|
1551
|
+
* @param ctx the parse tree
|
|
1552
|
+
*/
|
|
1553
|
+
exitLocationValue?: (ctx: LocationValueContext) => void;
|
|
1554
|
+
/**
|
|
1555
|
+
* Enter a parse tree produced by `ApexParser.coordinateValue`.
|
|
1556
|
+
* @param ctx the parse tree
|
|
1557
|
+
*/
|
|
1558
|
+
enterCoordinateValue?: (ctx: CoordinateValueContext) => void;
|
|
1559
|
+
/**
|
|
1560
|
+
* Exit a parse tree produced by `ApexParser.coordinateValue`.
|
|
1561
|
+
* @param ctx the parse tree
|
|
1562
|
+
*/
|
|
1563
|
+
exitCoordinateValue?: (ctx: CoordinateValueContext) => void;
|
|
1517
1564
|
/**
|
|
1518
1565
|
* Enter a parse tree produced by `ApexParser.typeOf`.
|
|
1519
1566
|
* @param ctx the parse tree
|
|
@@ -1824,6 +1871,16 @@ export interface ApexParserListener extends ParseTreeListener {
|
|
|
1824
1871
|
* @param ctx the parse tree
|
|
1825
1872
|
*/
|
|
1826
1873
|
exitSoslLiteral?: (ctx: SoslLiteralContext) => void;
|
|
1874
|
+
/**
|
|
1875
|
+
* Enter a parse tree produced by `ApexParser.soslLiteralAlt`.
|
|
1876
|
+
* @param ctx the parse tree
|
|
1877
|
+
*/
|
|
1878
|
+
enterSoslLiteralAlt?: (ctx: SoslLiteralAltContext) => void;
|
|
1879
|
+
/**
|
|
1880
|
+
* Exit a parse tree produced by `ApexParser.soslLiteralAlt`.
|
|
1881
|
+
* @param ctx the parse tree
|
|
1882
|
+
*/
|
|
1883
|
+
exitSoslLiteralAlt?: (ctx: SoslLiteralAltContext) => void;
|
|
1827
1884
|
/**
|
|
1828
1885
|
* Enter a parse tree produced by `ApexParser.soslClauses`.
|
|
1829
1886
|
* @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";
|
|
@@ -82,6 +83,7 @@ import { ReturnStatementContext } from "./ApexParser";
|
|
|
82
83
|
import { ThrowStatementContext } from "./ApexParser";
|
|
83
84
|
import { BreakStatementContext } from "./ApexParser";
|
|
84
85
|
import { ContinueStatementContext } from "./ApexParser";
|
|
86
|
+
import { AccessLevelContext } from "./ApexParser";
|
|
85
87
|
import { InsertStatementContext } from "./ApexParser";
|
|
86
88
|
import { UpdateStatementContext } from "./ApexParser";
|
|
87
89
|
import { DeleteStatementContext } from "./ApexParser";
|
|
@@ -127,6 +129,8 @@ import { SubFieldEntryContext } from "./ApexParser";
|
|
|
127
129
|
import { SoqlFieldsParameterContext } from "./ApexParser";
|
|
128
130
|
import { SoqlFunctionContext } from "./ApexParser";
|
|
129
131
|
import { DateFieldNameContext } from "./ApexParser";
|
|
132
|
+
import { LocationValueContext } from "./ApexParser";
|
|
133
|
+
import { CoordinateValueContext } from "./ApexParser";
|
|
130
134
|
import { TypeOfContext } from "./ApexParser";
|
|
131
135
|
import { WhenClauseContext } from "./ApexParser";
|
|
132
136
|
import { ElseClauseContext } from "./ApexParser";
|
|
@@ -158,6 +162,7 @@ import { DateFormulaContext } from "./ApexParser";
|
|
|
158
162
|
import { SignedIntegerContext } from "./ApexParser";
|
|
159
163
|
import { SoqlIdContext } from "./ApexParser";
|
|
160
164
|
import { SoslLiteralContext } from "./ApexParser";
|
|
165
|
+
import { SoslLiteralAltContext } from "./ApexParser";
|
|
161
166
|
import { SoslClausesContext } from "./ApexParser";
|
|
162
167
|
import { SearchGroupContext } from "./ApexParser";
|
|
163
168
|
import { FieldSpecListContext } from "./ApexParser";
|
|
@@ -205,6 +210,13 @@ export interface ApexParserVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
|
205
210
|
* @return the visitor result
|
|
206
211
|
*/
|
|
207
212
|
visitTypeRefPrimary?: (ctx: TypeRefPrimaryContext) => Result;
|
|
213
|
+
/**
|
|
214
|
+
* Visit a parse tree produced by the `voidPrimary`
|
|
215
|
+
* labeled alternative in `ApexParser.primary`.
|
|
216
|
+
* @param ctx the parse tree
|
|
217
|
+
* @return the visitor result
|
|
218
|
+
*/
|
|
219
|
+
visitVoidPrimary?: (ctx: VoidPrimaryContext) => Result;
|
|
208
220
|
/**
|
|
209
221
|
* Visit a parse tree produced by the `idPrimary`
|
|
210
222
|
* labeled alternative in `ApexParser.primary`.
|
|
@@ -705,6 +717,12 @@ export interface ApexParserVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
|
705
717
|
* @return the visitor result
|
|
706
718
|
*/
|
|
707
719
|
visitContinueStatement?: (ctx: ContinueStatementContext) => Result;
|
|
720
|
+
/**
|
|
721
|
+
* Visit a parse tree produced by `ApexParser.accessLevel`.
|
|
722
|
+
* @param ctx the parse tree
|
|
723
|
+
* @return the visitor result
|
|
724
|
+
*/
|
|
725
|
+
visitAccessLevel?: (ctx: AccessLevelContext) => Result;
|
|
708
726
|
/**
|
|
709
727
|
* Visit a parse tree produced by `ApexParser.insertStatement`.
|
|
710
728
|
* @param ctx the parse tree
|
|
@@ -975,6 +993,18 @@ export interface ApexParserVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
|
975
993
|
* @return the visitor result
|
|
976
994
|
*/
|
|
977
995
|
visitDateFieldName?: (ctx: DateFieldNameContext) => Result;
|
|
996
|
+
/**
|
|
997
|
+
* Visit a parse tree produced by `ApexParser.locationValue`.
|
|
998
|
+
* @param ctx the parse tree
|
|
999
|
+
* @return the visitor result
|
|
1000
|
+
*/
|
|
1001
|
+
visitLocationValue?: (ctx: LocationValueContext) => Result;
|
|
1002
|
+
/**
|
|
1003
|
+
* Visit a parse tree produced by `ApexParser.coordinateValue`.
|
|
1004
|
+
* @param ctx the parse tree
|
|
1005
|
+
* @return the visitor result
|
|
1006
|
+
*/
|
|
1007
|
+
visitCoordinateValue?: (ctx: CoordinateValueContext) => Result;
|
|
978
1008
|
/**
|
|
979
1009
|
* Visit a parse tree produced by `ApexParser.typeOf`.
|
|
980
1010
|
* @param ctx the parse tree
|
|
@@ -1161,6 +1191,12 @@ export interface ApexParserVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
|
1161
1191
|
* @return the visitor result
|
|
1162
1192
|
*/
|
|
1163
1193
|
visitSoslLiteral?: (ctx: SoslLiteralContext) => Result;
|
|
1194
|
+
/**
|
|
1195
|
+
* Visit a parse tree produced by `ApexParser.soslLiteralAlt`.
|
|
1196
|
+
* @param ctx the parse tree
|
|
1197
|
+
* @return the visitor result
|
|
1198
|
+
*/
|
|
1199
|
+
visitSoslLiteralAlt?: (ctx: SoslLiteralAltContext) => Result;
|
|
1164
1200
|
/**
|
|
1165
1201
|
* Visit a parse tree produced by `ApexParser.soslClauses`.
|
|
1166
1202
|
* @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,56 @@ 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();
|
|
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);
|
|
97
78
|
});
|
|
98
|
-
test('
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
expect(context).toBeTruthy();
|
|
79
|
+
test('testSemiAllowedAsForBody', () => {
|
|
80
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("for(x=0; x<10; x++);");
|
|
81
|
+
const context = parser.statement();
|
|
82
|
+
expect(context).toBeInstanceOf(ApexParser_1.StatementContext);
|
|
83
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
104
84
|
});
|
|
105
|
-
test('
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
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);
|
|
111
90
|
});
|
|
112
|
-
test('
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
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
|
+
}`);
|
|
116
98
|
const context = parser.statement();
|
|
117
|
-
expect(context).
|
|
99
|
+
expect(context).toBeInstanceOf(ApexParser_1.StatementContext);
|
|
100
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
118
101
|
});
|
|
119
|
-
test('
|
|
120
|
-
const
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
102
|
+
test('testSoqlModeKeywords', () => {
|
|
103
|
+
const MODES = ["USER_MODE", "SYSTEM_MODE"];
|
|
104
|
+
for (const mode of MODES) {
|
|
105
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)(`SELECT Id FROM Account WITH ${mode}`);
|
|
106
|
+
const context = parser.query();
|
|
107
|
+
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
108
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
109
|
+
}
|
|
125
110
|
});
|
|
126
|
-
test('
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
111
|
+
test('testDmlModeKeywords', () => {
|
|
112
|
+
const MODES = ["USER", "SYSTEM"];
|
|
113
|
+
for (const mode of MODES) {
|
|
114
|
+
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)(`insert as ${mode} contact;`);
|
|
115
|
+
const context = parser.statement();
|
|
116
|
+
expect(context).toBeInstanceOf(ApexParser_1.StatementContext);
|
|
117
|
+
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
118
|
+
}
|
|
132
119
|
});
|
|
133
120
|
//# 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,2B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CAAC,CAAC,CAAA;AAGF,IAAI,CAAC,qBAAqB,EAAE,GAAG,EAAE;IAC7B,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACjC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACtB,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAA,iCAAY,EAAC,aAAa,IAAI,WAAW,CAAC,CAAC;QAC1E,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,EAAE,CAAA;QAElC,MAAM,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,6BAAgB,CAAC,CAAA;QAChD,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;KACjD;AACL,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,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ACnC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAA,iCAAY,EACzC,4FAA4F,CAC7F,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"}
|
|
@@ -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;IAEt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AAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAClD,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ANTLRErrorListener, RecognitionException, Recognizer, Token } from "antlr4ts";
|
|
2
|
+
import { ApexParser } from "../ApexParser";
|
|
3
|
+
export declare class SyntaxErrorCounter 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 {};
|