@apexdevtools/apex-parser 3.0.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 (35) hide show
  1. package/README.md +79 -0
  2. package/lib/ApexLexer.d.ts +265 -0
  3. package/lib/ApexLexer.js +1549 -0
  4. package/lib/ApexLexer.js.map +1 -0
  5. package/lib/ApexParser.d.ts +2852 -0
  6. package/lib/ApexParser.js +17744 -0
  7. package/lib/ApexParser.js.map +1 -0
  8. package/lib/ApexParserListener.d.ts +1937 -0
  9. package/lib/ApexParserListener.js +4 -0
  10. package/lib/ApexParserListener.js.map +1 -0
  11. package/lib/ApexParserVisitor.d.ts +1230 -0
  12. package/lib/ApexParserVisitor.js +4 -0
  13. package/lib/ApexParserVisitor.js.map +1 -0
  14. package/lib/CaseInsensitiveInputStream.d.ts +16 -0
  15. package/lib/CaseInsensitiveInputStream.js +74 -0
  16. package/lib/CaseInsensitiveInputStream.js.map +1 -0
  17. package/lib/ThrowingErrorListener.d.ts +10 -0
  18. package/lib/ThrowingErrorListener.js +18 -0
  19. package/lib/ThrowingErrorListener.js.map +1 -0
  20. package/lib/__tests__/ApexLexerTest.d.ts +1 -0
  21. package/lib/__tests__/ApexLexerTest.js +26 -0
  22. package/lib/__tests__/ApexLexerTest.js.map +1 -0
  23. package/lib/__tests__/ApexListenerTest.d.ts +1 -0
  24. package/lib/__tests__/ApexListenerTest.js +28 -0
  25. package/lib/__tests__/ApexListenerTest.js.map +1 -0
  26. package/lib/__tests__/ApexParserTest.d.ts +1 -0
  27. package/lib/__tests__/ApexParserTest.js +133 -0
  28. package/lib/__tests__/ApexParserTest.js.map +1 -0
  29. package/lib/__tests__/ApexVisitorTest.d.ts +1 -0
  30. package/lib/__tests__/ApexVisitorTest.js +33 -0
  31. package/lib/__tests__/ApexVisitorTest.js.map +1 -0
  32. package/lib/index.d.ts +9 -0
  33. package/lib/index.js +92 -0
  34. package/lib/index.js.map +1 -0
  35. package/package.json +41 -0
package/README.md ADDED
@@ -0,0 +1,79 @@
1
+ apex-parser
2
+ ===========
3
+
4
+ Parser for Salesforce Apex (including Triggers & inline SOQL/SOQL). This is based on an [ANTLR4](https://www.antlr.org/) grammar, see antlr/ApexParser.g4.
5
+
6
+ There are two builds of the parser available, a NPM module for use with Node and a Maven package for use on JVMs.
7
+
8
+ These builds just contain the Parser & Lexer and provides no further support for analysing the generated parse trees beyond what is provided by ANTLR4.
9
+
10
+ As Apex & SOQL/SOQL are case-insenstive languages you need to use the provided CaseInsensitiveInputStream for the parser to function correctly. When parsing Apex, inline SOQL/SOSL is automtaically parsed, but you can also parse SOQL/SOQL directly. You can find some minimal examples in the test classes.
11
+
12
+ ### Example
13
+ To parse a class file (NPM version):
14
+
15
+ let lexer = new ApexLexer(new CaseInsensitiveInputStream("public class Hello {}"))
16
+ let tokens = new CommonTokenStream(lexer);
17
+
18
+ let parser = new ApexParser(tokens)
19
+ let context = parser.compilationUnit()
20
+
21
+ The 'context' is a CompilationUnitContext object which is the root of the parsed representation of the class. You can access the parse tree via functions on it.
22
+
23
+ ### Unicode handling
24
+ Prior to 2.12.0 the use of ANTLRInputStream for reading data in CaseInsensitiveStream would result character positions being given for UTF-16. The switch to CharStream input in 2.12.0 for JVM and 2.14.0 for node results in character positions reflecting Unicode code points.
25
+
26
+ ### antlr4ts versions
27
+
28
+ The npm module uses antlr4ts 0.5.0-alpha.4, this was updated from 0.5.0-alpha.3 in the 2.9.1 version. You should make
29
+ sure that if you are using a matching versions of this dependency if you use it directly. To avoid issues you can
30
+ import 'CommonTokenStream' & 'ParseTreeWalker' from 'apex-parser' instead of from antlr4ts.
31
+
32
+ import { CommonTokenStream} from "apex-parser";
33
+ import { ParseTreeWalker } from "apex-parser";
34
+
35
+ ### Packages
36
+
37
+ Maven
38
+
39
+ <dependency>
40
+ <groupId>io.github.apex-dev-tools</groupId>
41
+ <artifactId>apex-parser</artifactId>
42
+ <version>3.0.0</version>
43
+ </dependency>
44
+
45
+ NPM
46
+
47
+ "@apexdevtools/apex-parser": "^3.0.0"
48
+
49
+ ### Building
50
+ To build both distributions:
51
+
52
+ npm run build
53
+
54
+ ### History
55
+ 3.0.0 - Move to @apexdevtools/apex-parser
56
+ 2.14.0 - Change npm api to replace ANTLRInputStream with CharStream, for Unicode char positions
57
+ 2.13.0 - Fixes for negative numerics & Currency literals in SOQL
58
+ 2.12.0 - Replace deprecated ANTLRInputStream, DateTime & Currency literals fixes (contrib Aaron Hurst)
59
+ 2.11.0 - Fix for SOQL UPDATE VIEWSTAT/TRACKING & removal of class type arguments
60
+ 2.10.0 - Allow type arguments on Classes (non-standard!)
61
+ 2.9.2 - Generate .d.ts files
62
+ 2.9.1 - JVM build and npm dependency updates
63
+ 2.9.0 - Add SOQL Fields function
64
+ 2.8.0 - Apex cast priority fix, SOSL & SOQL query format fixes, Added SOQL Date functions
65
+ 2.7.1 - Bugfix for 'Network' identifier
66
+ 2.7.0 - Support inline SOSL queries
67
+ 2.6.1 - Dependency security fixes
68
+ 2.6.0 - Add SOQL parsing support
69
+ 2.5.0 - Allow safe navigation operator ?.
70
+ 2.4.0 - Enable Listener & Visitor use
71
+ 2.3.0 - Removed modifers from enhanced for loop
72
+ 2.2.1 - Dependency security fixes
73
+ 2.2.0 - Parser performance improvements
74
+ 2.1.0 - Supports trigger parsing and switch statement parsing syntax was corrected
75
+ 1.0.0 - Initial version
76
+
77
+ ### Source & Licenses
78
+
79
+ All the source code included uses a 3-clause BSD license. The only third-party component included is the Apex Antlr4 grammar originally from [Tooling-force.com](https://github.com/neowit/tooling-force.com), although this version used is now markedly different from the original.
@@ -0,0 +1,265 @@
1
+ import { ATN } from "antlr4ts/atn/ATN";
2
+ import { CharStream } from "antlr4ts/CharStream";
3
+ import { Lexer } from "antlr4ts/Lexer";
4
+ import { Vocabulary } from "antlr4ts/Vocabulary";
5
+ export declare class ApexLexer extends Lexer {
6
+ static readonly ABSTRACT = 1;
7
+ static readonly AFTER = 2;
8
+ static readonly BEFORE = 3;
9
+ static readonly BREAK = 4;
10
+ static readonly CATCH = 5;
11
+ static readonly CLASS = 6;
12
+ static readonly CONTINUE = 7;
13
+ static readonly DELETE = 8;
14
+ static readonly DO = 9;
15
+ static readonly ELSE = 10;
16
+ static readonly ENUM = 11;
17
+ static readonly EXTENDS = 12;
18
+ static readonly FINAL = 13;
19
+ static readonly FINALLY = 14;
20
+ static readonly FOR = 15;
21
+ static readonly GET = 16;
22
+ static readonly GLOBAL = 17;
23
+ static readonly IF = 18;
24
+ static readonly IMPLEMENTS = 19;
25
+ static readonly INHERITED = 20;
26
+ static readonly INSERT = 21;
27
+ static readonly INSTANCEOF = 22;
28
+ static readonly INTERFACE = 23;
29
+ static readonly MERGE = 24;
30
+ static readonly NEW = 25;
31
+ static readonly NULL = 26;
32
+ static readonly ON = 27;
33
+ static readonly OVERRIDE = 28;
34
+ static readonly PRIVATE = 29;
35
+ static readonly PROTECTED = 30;
36
+ static readonly PUBLIC = 31;
37
+ static readonly RETURN = 32;
38
+ static readonly SYSTEMRUNAS = 33;
39
+ static readonly SET = 34;
40
+ static readonly SHARING = 35;
41
+ static readonly STATIC = 36;
42
+ static readonly SUPER = 37;
43
+ static readonly SWITCH = 38;
44
+ static readonly TESTMETHOD = 39;
45
+ static readonly THIS = 40;
46
+ static readonly THROW = 41;
47
+ static readonly TRANSIENT = 42;
48
+ static readonly TRIGGER = 43;
49
+ static readonly TRY = 44;
50
+ static readonly UNDELETE = 45;
51
+ static readonly UPDATE = 46;
52
+ static readonly UPSERT = 47;
53
+ static readonly VIRTUAL = 48;
54
+ static readonly VOID = 49;
55
+ static readonly WEBSERVICE = 50;
56
+ static readonly WHEN = 51;
57
+ static readonly WHILE = 52;
58
+ static readonly WITH = 53;
59
+ static readonly WITHOUT = 54;
60
+ static readonly LIST = 55;
61
+ static readonly MAP = 56;
62
+ static readonly SELECT = 57;
63
+ static readonly COUNT = 58;
64
+ static readonly FROM = 59;
65
+ static readonly AS = 60;
66
+ static readonly USING = 61;
67
+ static readonly SCOPE = 62;
68
+ static readonly WHERE = 63;
69
+ static readonly ORDER = 64;
70
+ static readonly BY = 65;
71
+ static readonly LIMIT = 66;
72
+ static readonly SOQLAND = 67;
73
+ static readonly SOQLOR = 68;
74
+ static readonly NOT = 69;
75
+ static readonly AVG = 70;
76
+ static readonly COUNT_DISTINCT = 71;
77
+ static readonly MIN = 72;
78
+ static readonly MAX = 73;
79
+ static readonly SUM = 74;
80
+ static readonly TYPEOF = 75;
81
+ static readonly END = 76;
82
+ static readonly THEN = 77;
83
+ static readonly LIKE = 78;
84
+ static readonly IN = 79;
85
+ static readonly INCLUDES = 80;
86
+ static readonly EXCLUDES = 81;
87
+ static readonly ASC = 82;
88
+ static readonly DESC = 83;
89
+ static readonly NULLS = 84;
90
+ static readonly FIRST = 85;
91
+ static readonly LAST = 86;
92
+ static readonly GROUP = 87;
93
+ static readonly ALL = 88;
94
+ static readonly ROWS = 89;
95
+ static readonly VIEW = 90;
96
+ static readonly HAVING = 91;
97
+ static readonly ROLLUP = 92;
98
+ static readonly TOLABEL = 93;
99
+ static readonly OFFSET = 94;
100
+ static readonly DATA = 95;
101
+ static readonly CATEGORY = 96;
102
+ static readonly AT = 97;
103
+ static readonly ABOVE = 98;
104
+ static readonly BELOW = 99;
105
+ static readonly ABOVE_OR_BELOW = 100;
106
+ static readonly SECURITY_ENFORCED = 101;
107
+ static readonly REFERENCE = 102;
108
+ static readonly CUBE = 103;
109
+ static readonly FORMAT = 104;
110
+ static readonly TRACKING = 105;
111
+ static readonly VIEWSTAT = 106;
112
+ static readonly CUSTOM = 107;
113
+ static readonly STANDARD = 108;
114
+ static readonly CALENDAR_MONTH = 109;
115
+ static readonly CALENDAR_QUARTER = 110;
116
+ static readonly CALENDAR_YEAR = 111;
117
+ static readonly DAY_IN_MONTH = 112;
118
+ static readonly DAY_IN_WEEK = 113;
119
+ static readonly DAY_IN_YEAR = 114;
120
+ static readonly DAY_ONLY = 115;
121
+ static readonly FISCAL_MONTH = 116;
122
+ static readonly FISCAL_QUARTER = 117;
123
+ static readonly FISCAL_YEAR = 118;
124
+ static readonly HOUR_IN_DAY = 119;
125
+ static readonly WEEK_IN_MONTH = 120;
126
+ static readonly WEEK_IN_YEAR = 121;
127
+ static readonly CONVERT_TIMEZONE = 122;
128
+ static readonly YESTERDAY = 123;
129
+ static readonly TODAY = 124;
130
+ static readonly TOMORROW = 125;
131
+ static readonly LAST_WEEK = 126;
132
+ static readonly THIS_WEEK = 127;
133
+ static readonly NEXT_WEEK = 128;
134
+ static readonly LAST_MONTH = 129;
135
+ static readonly THIS_MONTH = 130;
136
+ static readonly NEXT_MONTH = 131;
137
+ static readonly LAST_90_DAYS = 132;
138
+ static readonly NEXT_90_DAYS = 133;
139
+ static readonly LAST_N_DAYS_N = 134;
140
+ static readonly NEXT_N_DAYS_N = 135;
141
+ static readonly NEXT_N_WEEKS_N = 136;
142
+ static readonly LAST_N_WEEKS_N = 137;
143
+ static readonly NEXT_N_MONTHS_N = 138;
144
+ static readonly LAST_N_MONTHS_N = 139;
145
+ static readonly THIS_QUARTER = 140;
146
+ static readonly LAST_QUARTER = 141;
147
+ static readonly NEXT_QUARTER = 142;
148
+ static readonly NEXT_N_QUARTERS_N = 143;
149
+ static readonly LAST_N_QUARTERS_N = 144;
150
+ static readonly THIS_YEAR = 145;
151
+ static readonly LAST_YEAR = 146;
152
+ static readonly NEXT_YEAR = 147;
153
+ static readonly NEXT_N_YEARS_N = 148;
154
+ static readonly LAST_N_YEARS_N = 149;
155
+ static readonly THIS_FISCAL_QUARTER = 150;
156
+ static readonly LAST_FISCAL_QUARTER = 151;
157
+ static readonly NEXT_FISCAL_QUARTER = 152;
158
+ static readonly NEXT_N_FISCAL_QUARTERS_N = 153;
159
+ static readonly LAST_N_FISCAL_QUARTERS_N = 154;
160
+ static readonly THIS_FISCAL_YEAR = 155;
161
+ static readonly LAST_FISCAL_YEAR = 156;
162
+ static readonly NEXT_FISCAL_YEAR = 157;
163
+ static readonly NEXT_N_FISCAL_YEARS_N = 158;
164
+ static readonly LAST_N_FISCAL_YEARS_N = 159;
165
+ static readonly DateLiteral = 160;
166
+ static readonly DateTimeLiteral = 161;
167
+ static readonly IntegralCurrencyLiteral = 162;
168
+ static readonly FIND = 163;
169
+ static readonly EMAIL = 164;
170
+ static readonly NAME = 165;
171
+ static readonly PHONE = 166;
172
+ static readonly SIDEBAR = 167;
173
+ static readonly FIELDS = 168;
174
+ static readonly METADATA = 169;
175
+ static readonly PRICEBOOKID = 170;
176
+ static readonly NETWORK = 171;
177
+ static readonly SNIPPET = 172;
178
+ static readonly TARGET_LENGTH = 173;
179
+ static readonly DIVISION = 174;
180
+ static readonly RETURNING = 175;
181
+ static readonly LISTVIEW = 176;
182
+ static readonly FindLiteral = 177;
183
+ static readonly IntegerLiteral = 178;
184
+ static readonly LongLiteral = 179;
185
+ static readonly NumberLiteral = 180;
186
+ static readonly BooleanLiteral = 181;
187
+ static readonly StringLiteral = 182;
188
+ static readonly NullLiteral = 183;
189
+ static readonly LPAREN = 184;
190
+ static readonly RPAREN = 185;
191
+ static readonly LBRACE = 186;
192
+ static readonly RBRACE = 187;
193
+ static readonly LBRACK = 188;
194
+ static readonly RBRACK = 189;
195
+ static readonly SEMI = 190;
196
+ static readonly COMMA = 191;
197
+ static readonly DOT = 192;
198
+ static readonly ASSIGN = 193;
199
+ static readonly GT = 194;
200
+ static readonly LT = 195;
201
+ static readonly BANG = 196;
202
+ static readonly TILDE = 197;
203
+ static readonly QUESTIONDOT = 198;
204
+ static readonly QUESTION = 199;
205
+ static readonly COLON = 200;
206
+ static readonly EQUAL = 201;
207
+ static readonly TRIPLEEQUAL = 202;
208
+ static readonly NOTEQUAL = 203;
209
+ static readonly LESSANDGREATER = 204;
210
+ static readonly TRIPLENOTEQUAL = 205;
211
+ static readonly AND = 206;
212
+ static readonly OR = 207;
213
+ static readonly INC = 208;
214
+ static readonly DEC = 209;
215
+ static readonly ADD = 210;
216
+ static readonly SUB = 211;
217
+ static readonly MUL = 212;
218
+ static readonly DIV = 213;
219
+ static readonly BITAND = 214;
220
+ static readonly BITOR = 215;
221
+ static readonly CARET = 216;
222
+ static readonly MOD = 217;
223
+ static readonly MAPTO = 218;
224
+ static readonly ADD_ASSIGN = 219;
225
+ static readonly SUB_ASSIGN = 220;
226
+ static readonly MUL_ASSIGN = 221;
227
+ static readonly DIV_ASSIGN = 222;
228
+ static readonly AND_ASSIGN = 223;
229
+ static readonly OR_ASSIGN = 224;
230
+ static readonly XOR_ASSIGN = 225;
231
+ static readonly MOD_ASSIGN = 226;
232
+ static readonly LSHIFT_ASSIGN = 227;
233
+ static readonly RSHIFT_ASSIGN = 228;
234
+ static readonly URSHIFT_ASSIGN = 229;
235
+ static readonly ATSIGN = 230;
236
+ static readonly Identifier = 231;
237
+ static readonly WS = 232;
238
+ static readonly DOC_COMMENT = 233;
239
+ static readonly COMMENT = 234;
240
+ static readonly LINE_COMMENT = 235;
241
+ static readonly WHITESPACE_CHANNEL = 2;
242
+ static readonly COMMENT_CHANNEL = 3;
243
+ static readonly channelNames: string[];
244
+ static readonly modeNames: string[];
245
+ static readonly ruleNames: string[];
246
+ private static readonly _LITERAL_NAMES;
247
+ private static readonly _SYMBOLIC_NAMES;
248
+ static readonly VOCABULARY: Vocabulary;
249
+ get vocabulary(): Vocabulary;
250
+ constructor(input: CharStream);
251
+ get grammarFileName(): string;
252
+ get ruleNames(): string[];
253
+ get serializedATN(): string;
254
+ get channelNames(): string[];
255
+ get modeNames(): string[];
256
+ private static readonly _serializedATNSegments;
257
+ private static readonly _serializedATNSegment0;
258
+ private static readonly _serializedATNSegment1;
259
+ private static readonly _serializedATNSegment2;
260
+ private static readonly _serializedATNSegment3;
261
+ private static readonly _serializedATNSegment4;
262
+ static readonly _serializedATN: string;
263
+ static __ATN: ATN;
264
+ static get _ATN(): ATN;
265
+ }