@apexdevtools/apex-parser 4.4.1 → 5.0.0-beta.2
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 +112 -0
- package/README.md +98 -42
- package/lib/ApexErrorListener.d.ts +25 -0
- package/lib/ApexErrorListener.js +64 -0
- package/lib/ApexErrorListener.js.map +1 -0
- package/lib/ApexParserFactory.d.ts +69 -0
- package/lib/ApexParserFactory.js +125 -0
- package/lib/ApexParserFactory.js.map +1 -0
- package/lib/CaseInsensitiveInputStream.d.ts +11 -13
- package/lib/CaseInsensitiveInputStream.js +22 -28
- package/lib/CaseInsensitiveInputStream.js.map +1 -1
- package/lib/Check.d.ts +36 -0
- package/lib/Check.js +212 -0
- package/lib/Check.js.map +1 -0
- package/lib/{ApexLexer.d.ts → antlr/ApexLexer.d.ts} +11 -18
- package/lib/antlr/ApexLexer.js +1575 -0
- package/lib/antlr/ApexLexer.js.map +1 -0
- package/lib/{ApexParser.d.ts → antlr/ApexParser.d.ts} +1344 -1304
- package/lib/antlr/ApexParser.js +20976 -0
- package/lib/antlr/ApexParser.js.map +1 -0
- package/lib/{ApexParserListener.d.ts → antlr/ApexParserListener.d.ts} +708 -686
- package/lib/antlr/ApexParserListener.js +12 -0
- package/lib/antlr/ApexParserListener.js.map +1 -0
- package/lib/{ApexParserVisitor.d.ts → antlr/ApexParserVisitor.d.ts} +420 -406
- package/lib/antlr/ApexParserVisitor.js +15 -0
- package/lib/antlr/ApexParserVisitor.js.map +1 -0
- package/lib/index.d.ts +8 -24
- package/lib/index.js +13 -140
- package/lib/index.js.map +1 -1
- package/package.json +30 -27
- package/lib/ApexLexer.js +0 -1704
- package/lib/ApexLexer.js.map +0 -1
- package/lib/ApexParser.js +0 -19514
- package/lib/ApexParser.js.map +0 -1
- package/lib/ApexParserListener.js +0 -4
- package/lib/ApexParserListener.js.map +0 -1
- package/lib/ApexParserVisitor.js +0 -4
- package/lib/ApexParserVisitor.js.map +0 -1
- package/lib/ThrowingErrorListener.d.ts +0 -10
- package/lib/ThrowingErrorListener.js +0 -18
- package/lib/ThrowingErrorListener.js.map +0 -1
- package/lib/__tests__/ApexLexerTest.d.ts +0 -1
- package/lib/__tests__/ApexLexerTest.js +0 -48
- package/lib/__tests__/ApexLexerTest.js.map +0 -1
- package/lib/__tests__/ApexListenerTest.d.ts +0 -1
- package/lib/__tests__/ApexListenerTest.js +0 -41
- package/lib/__tests__/ApexListenerTest.js.map +0 -1
- package/lib/__tests__/ApexParserTest.d.ts +0 -1
- package/lib/__tests__/ApexParserTest.js +0 -199
- package/lib/__tests__/ApexParserTest.js.map +0 -1
- package/lib/__tests__/ApexTriggerTest.d.ts +0 -1
- package/lib/__tests__/ApexTriggerTest.js +0 -66
- package/lib/__tests__/ApexTriggerTest.js.map +0 -1
- package/lib/__tests__/ApexVisitorTest.d.ts +0 -1
- package/lib/__tests__/ApexVisitorTest.js +0 -46
- package/lib/__tests__/ApexVisitorTest.js.map +0 -1
- package/lib/__tests__/SOQLParserTest.d.ts +0 -1
- package/lib/__tests__/SOQLParserTest.js +0 -121
- package/lib/__tests__/SOQLParserTest.js.map +0 -1
- package/lib/__tests__/SOSLParserTest.d.ts +0 -1
- package/lib/__tests__/SOSLParserTest.js +0 -101
- package/lib/__tests__/SOSLParserTest.js.map +0 -1
- package/lib/__tests__/SyntaxErrorCounter.d.ts +0 -10
- package/lib/__tests__/SyntaxErrorCounter.js +0 -52
- package/lib/__tests__/SyntaxErrorCounter.js.map +0 -1
- package/lib/__tests__/system/SampleParseSys.d.ts +0 -1
- package/lib/__tests__/system/SampleParseSys.js +0 -75
- package/lib/__tests__/system/SampleParseSys.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApexParserListener.js","sourceRoot":"","sources":["../src/ApexParserListener.ts"],"names":[],"mappings":";AAAA,uDAAuD"}
|
package/lib/ApexParserVisitor.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApexParserVisitor.js","sourceRoot":"","sources":["../src/ApexParserVisitor.ts"],"names":[],"mappings":";AAAA,uDAAuD"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ANTLRErrorListener, RecognitionException, Recognizer, Token } from "antlr4ts";
|
|
2
|
-
export declare class SyntaxException {
|
|
3
|
-
line: number;
|
|
4
|
-
column: number;
|
|
5
|
-
message: string;
|
|
6
|
-
constructor(line: number, column: number, message: string);
|
|
7
|
-
}
|
|
8
|
-
export declare class ThrowingErrorListener implements ANTLRErrorListener<Token> {
|
|
9
|
-
syntaxError(recognizer: Recognizer<Token, any>, offendingSymbol: Token, line: number, charPositionInLine: number, msg: string, e: RecognitionException | undefined): any;
|
|
10
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ThrowingErrorListener = exports.SyntaxException = void 0;
|
|
4
|
-
class SyntaxException {
|
|
5
|
-
constructor(line, column, message) {
|
|
6
|
-
this.line = line;
|
|
7
|
-
this.column = column;
|
|
8
|
-
this.message = message;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.SyntaxException = SyntaxException;
|
|
12
|
-
class ThrowingErrorListener {
|
|
13
|
-
syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e) {
|
|
14
|
-
throw new SyntaxException(line, charPositionInLine, msg);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.ThrowingErrorListener = ThrowingErrorListener;
|
|
18
|
-
//# sourceMappingURL=ThrowingErrorListener.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ThrowingErrorListener.js","sourceRoot":"","sources":["../src/ThrowingErrorListener.ts"],"names":[],"mappings":";;;AA6BA,MAAa,eAAe;IAKxB,YAAY,IAAY,EAAE,MAAc,EAAE,OAAe;QACrD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IAC1B,CAAC;CACJ;AAVD,0CAUC;AAED,MAAa,qBAAqB;IAE9B,WAAW,CAAC,UAAkC,EAC1C,eAAsB,EAAE,IAAY,EAAE,kBAA0B,EAAE,GAAW,EAC7E,CAAmC;QAC/B,MAAM,IAAI,eAAe,CAAC,IAAI,EAAE,kBAAkB,EAAE,GAAG,CAAC,CAAA;IAC5D,CAAC;CAER;AARD,sDAQC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/*
|
|
4
|
-
Copyright (c) 2021 Kevin Jones, All rights reserved.
|
|
5
|
-
Redistribution and use in source and binary forms, with or without
|
|
6
|
-
modification, are permitted provided that the following conditions
|
|
7
|
-
are met:
|
|
8
|
-
1. Redistributions of source code must retain the above copyright
|
|
9
|
-
notice, this list of conditions and the following disclaimer.
|
|
10
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
11
|
-
notice, this list of conditions and the following disclaimer in the
|
|
12
|
-
documentation and/or other materials provided with the distribution.
|
|
13
|
-
3. The name of the author may not be used to endorse or promote products
|
|
14
|
-
derived from this software without specific prior written permission.
|
|
15
|
-
*/
|
|
16
|
-
const antlr4ts_1 = require("antlr4ts");
|
|
17
|
-
const SyntaxErrorCounter_1 = require("./SyntaxErrorCounter");
|
|
18
|
-
test("Lexer generates tokens", () => {
|
|
19
|
-
const [lexer, errorCounter] = (0, SyntaxErrorCounter_1.createLexer)("public class Hello {}", false);
|
|
20
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
21
|
-
expect(tokens.getNumberOfOnChannelTokens()).toBe(6);
|
|
22
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
23
|
-
});
|
|
24
|
-
test("Case insensitivity", () => {
|
|
25
|
-
const [lexer, errorCounter] = (0, SyntaxErrorCounter_1.createLexer)("public");
|
|
26
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
27
|
-
expect(tokens.getNumberOfOnChannelTokens()).toBe(2);
|
|
28
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
29
|
-
});
|
|
30
|
-
test("Case insensitivity (upper case)", () => {
|
|
31
|
-
const [lexer, errorCounter] = (0, SyntaxErrorCounter_1.createLexer)("PUBLIC");
|
|
32
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
33
|
-
expect(tokens.getNumberOfOnChannelTokens()).toBe(2);
|
|
34
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
35
|
-
});
|
|
36
|
-
test("Case insensitivity (mixed case)", () => {
|
|
37
|
-
const [lexer, errorCounter] = (0, SyntaxErrorCounter_1.createLexer)("PuBliC");
|
|
38
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
39
|
-
expect(tokens.getNumberOfOnChannelTokens()).toBe(2);
|
|
40
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
41
|
-
});
|
|
42
|
-
test("Lexer unicode escapes", () => {
|
|
43
|
-
const [lexer, errorCounter] = (0, SyntaxErrorCounter_1.createLexer)("'Fran\\u00E7ois'", false);
|
|
44
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
45
|
-
expect(tokens.getNumberOfOnChannelTokens()).toBe(2);
|
|
46
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
47
|
-
});
|
|
48
|
-
//# sourceMappingURL=ApexLexerTest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApexLexerTest.js","sourceRoot":"","sources":["../../src/__tests__/ApexLexerTest.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;GAYG;AACH,uCAA6C;AAC7C,6DAAmD;AAEnD,IAAI,CAAC,wBAAwB,EAAE,GAA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AC,GAAG,IAAA,gCAAW,EAAC,QAAQ,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,IAAI,4BAAiB,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,CAAC,MAAM,CAAC,0BAA0B,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpD,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,uBAAuB,EAAE,GAAG,EAAE;IAC/B,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,GAAG,IAAA,gCAAW,EAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;IACrE,MAAM,MAAM,GAAG,IAAI,4BAAiB,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,CAAC,MAAM,CAAC,0BAA0B,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpD,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/*
|
|
4
|
-
Copyright (c) 2021 Kevin Jones, All rights reserved.
|
|
5
|
-
Redistribution and use in source and binary forms, with or without
|
|
6
|
-
modification, are permitted provided that the following conditions
|
|
7
|
-
are met:
|
|
8
|
-
1. Redistributions of source code must retain the above copyright
|
|
9
|
-
notice, this list of conditions and the following disclaimer.
|
|
10
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
11
|
-
notice, this list of conditions and the following disclaimer in the
|
|
12
|
-
documentation and/or other materials provided with the distribution.
|
|
13
|
-
3. The name of the author may not be used to endorse or promote products
|
|
14
|
-
derived from this software without specific prior written permission.
|
|
15
|
-
*/
|
|
16
|
-
const ApexLexer_1 = require("../ApexLexer");
|
|
17
|
-
const ApexParser_1 = require("../ApexParser");
|
|
18
|
-
const CaseInsensitiveInputStream_1 = require("../CaseInsensitiveInputStream");
|
|
19
|
-
const antlr4ts_1 = require("antlr4ts");
|
|
20
|
-
const ParseTreeWalker_1 = require("antlr4ts/tree/ParseTreeWalker");
|
|
21
|
-
const ThrowingErrorListener_1 = require("../ThrowingErrorListener");
|
|
22
|
-
class TestListener {
|
|
23
|
-
constructor() {
|
|
24
|
-
this.methodCount = 0;
|
|
25
|
-
}
|
|
26
|
-
enterMethodDeclaration( /*ctx: MethodDeclarationContext*/) {
|
|
27
|
-
this.methodCount += 1;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
test('Listener Generates Events', () => {
|
|
31
|
-
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("public class Hello { public void func(){} }")));
|
|
32
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
33
|
-
const parser = new ApexParser_1.ApexParser(tokens);
|
|
34
|
-
parser.removeErrorListeners();
|
|
35
|
-
parser.addErrorListener(new ThrowingErrorListener_1.ThrowingErrorListener());
|
|
36
|
-
const cu = parser.compilationUnit();
|
|
37
|
-
const listener = new TestListener();
|
|
38
|
-
ParseTreeWalker_1.ParseTreeWalker.DEFAULT.walk(listener, cu);
|
|
39
|
-
expect(listener.methodCount).toBe(1);
|
|
40
|
-
});
|
|
41
|
-
//# sourceMappingURL=ApexListenerTest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApexListenerTest.js","sourceRoot":"","sources":["../../src/__tests__/ApexListenerTest.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;GAYG;AACH,4CAAyC;AAEzC,8CAA2C;AAC3C,8EAA0E;AAC1E,uCAA0D;AAC1D,mEAAgE;AAChE,oEAAiE;AAEjE,MAAM,YAAY;IAAlB;QACW,gBAAW,GAAG,CAAC,CAAA;IAK1B,CAAC;IAHG,sBAAsB,EAAC,iCAAiC;QACpD,IAAI,CAAC,WAAW,IAAI,CAAC,CAAC;IAC1B,CAAC;CACJ;AAED,IAAI,CAAC,2BAA2B,EAAE,GAAG,EAAE;IAEnC,MAAM,KAAK,GAAG,IAAI,qBAAS,CAAC,IAAI,uDAA0B,CAAC,sBAAW,CAAC,UAAU,CAAC,6CAA6C,CAAC,CAAC,CAAC,CAAC;IACnI,MAAM,MAAM,GAAG,IAAI,4BAAiB,CAAC,KAAK,CAAC,CAAC;IAE5C,MAAM,MAAM,GAAG,IAAI,uBAAU,CAAC,MAAM,CAAC,CAAA;IAErC,MAAM,CAAC,oBAAoB,EAAE,CAAA;IAC7B,MAAM,CAAC,gBAAgB,CAAC,IAAI,6CAAqB,EAAE,CAAC,CAAC;IAErD,MAAM,EAAE,GAAG,MAAM,CAAC,eAAe,EAAE,CAAA;IACnC,MAAM,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAA;IACnC,iCAAe,CAAC,OAAO,CAAC,IAAI,CAAC,QAA8B,EAAE,EAAE,CAAC,CAAA;IAEhE,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACxC,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/*
|
|
4
|
-
Copyright (c) 2021 Kevin Jones, All rights reserved.
|
|
5
|
-
Redistribution and use in source and binary forms, with or without
|
|
6
|
-
modification, are permitted provided that the following conditions
|
|
7
|
-
are met:
|
|
8
|
-
1. Redistributions of source code must retain the above copyright
|
|
9
|
-
notice, this list of conditions and the following disclaimer.
|
|
10
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
11
|
-
notice, this list of conditions and the following disclaimer in the
|
|
12
|
-
documentation and/or other materials provided with the distribution.
|
|
13
|
-
3. The name of the author may not be used to endorse or promote products
|
|
14
|
-
derived from this software without specific prior written permission.
|
|
15
|
-
*/
|
|
16
|
-
const ApexParser_1 = require("../ApexParser");
|
|
17
|
-
const ThrowingErrorListener_1 = require("../ThrowingErrorListener");
|
|
18
|
-
const SyntaxErrorCounter_1 = require("./SyntaxErrorCounter");
|
|
19
|
-
test('Boolean Literal', () => {
|
|
20
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("true");
|
|
21
|
-
const context = parser.literal();
|
|
22
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
23
|
-
expect(context).toBeInstanceOf(ApexParser_1.LiteralContext);
|
|
24
|
-
expect(context.BooleanLiteral()).toBeTruthy();
|
|
25
|
-
expect(context.BooleanLiteral().text).toBe("true");
|
|
26
|
-
});
|
|
27
|
-
test('Expression', () => {
|
|
28
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("a * 5");
|
|
29
|
-
const context = parser.expression();
|
|
30
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
31
|
-
expect(context).toBeInstanceOf(ApexParser_1.Arth1ExpressionContext);
|
|
32
|
-
const arthExpression = context;
|
|
33
|
-
expect(arthExpression.expression().length).toBe(2);
|
|
34
|
-
});
|
|
35
|
-
test("Coalesce Expression", () => {
|
|
36
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("a ?? 5");
|
|
37
|
-
const context = parser.expression();
|
|
38
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
39
|
-
expect(context).toBeInstanceOf(ApexParser_1.CoalExpressionContext);
|
|
40
|
-
const coalExpression = context;
|
|
41
|
-
expect(coalExpression.expression().length).toBe(2);
|
|
42
|
-
});
|
|
43
|
-
test("Coalesce Precedence - Arithmetic", () => {
|
|
44
|
-
// Based on the example in release notes / docs
|
|
45
|
-
// should NOT evaluate to (top ?? 100) - (bottom ?? 0) as you want
|
|
46
|
-
//
|
|
47
|
-
// left assoc = (top ?? (100 - bottom)) ?? 0
|
|
48
|
-
// right assoc = top ?? ((100 - bottom) ?? 0)
|
|
49
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("top ?? 100 - bottom ?? 0");
|
|
50
|
-
const context = parser.expression();
|
|
51
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
52
|
-
expect(context).toBeInstanceOf(ApexParser_1.CoalExpressionContext);
|
|
53
|
-
const outer = context.expression();
|
|
54
|
-
expect(outer.length).toBe(2);
|
|
55
|
-
expect(outer[0]).toBeInstanceOf(ApexParser_1.CoalExpressionContext);
|
|
56
|
-
const inner = outer[0].expression(); // top ?? 100 - bottom
|
|
57
|
-
expect(inner.length).toBe(2);
|
|
58
|
-
expect(inner[0]).toBeInstanceOf(ApexParser_1.PrimaryExpressionContext); // top
|
|
59
|
-
expect(inner[1]).toBeInstanceOf(ApexParser_1.Arth2ExpressionContext); // 100 - bottom
|
|
60
|
-
expect(outer[1]).toBeInstanceOf(ApexParser_1.PrimaryExpressionContext); // 0
|
|
61
|
-
});
|
|
62
|
-
test("Coalesce Precedence - Boolean", () => {
|
|
63
|
-
// This is more nonsense but using a much lower precedence op
|
|
64
|
-
// should NOT evaluate to (a ?? false) || (b ?? false)
|
|
65
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("a ?? false || b ?? false");
|
|
66
|
-
const context = parser.expression();
|
|
67
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
68
|
-
expect(context).toBeInstanceOf(ApexParser_1.CoalExpressionContext);
|
|
69
|
-
const outer = context.expression();
|
|
70
|
-
expect(outer.length).toBe(2);
|
|
71
|
-
expect(outer[0]).toBeInstanceOf(ApexParser_1.CoalExpressionContext);
|
|
72
|
-
const inner = outer[0].expression(); // a ?? false || b
|
|
73
|
-
expect(inner.length).toBe(2);
|
|
74
|
-
expect(inner[0]).toBeInstanceOf(ApexParser_1.PrimaryExpressionContext); // a
|
|
75
|
-
expect(inner[1]).toBeInstanceOf(ApexParser_1.LogOrExpressionContext); // false || b
|
|
76
|
-
expect(outer[1]).toBeInstanceOf(ApexParser_1.PrimaryExpressionContext); // false
|
|
77
|
-
});
|
|
78
|
-
test('Compilation Unit', () => {
|
|
79
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("public class Hello {}");
|
|
80
|
-
const context = parser.compilationUnit();
|
|
81
|
-
expect(context).toBeInstanceOf(ApexParser_1.CompilationUnitContext);
|
|
82
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
83
|
-
});
|
|
84
|
-
test('Compilation Unit (case insensitive)', () => {
|
|
85
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("Public CLASS Hello {}");
|
|
86
|
-
const context = parser.compilationUnit();
|
|
87
|
-
expect(context).toBeInstanceOf(ApexParser_1.CompilationUnitContext);
|
|
88
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
89
|
-
});
|
|
90
|
-
test('Compilation Unit (bug test)', () => {
|
|
91
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)(`public class Hello {
|
|
92
|
-
public testMethod void func() {
|
|
93
|
-
System.runAs(u) {
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}`);
|
|
97
|
-
const context = parser.compilationUnit();
|
|
98
|
-
expect(context).toBeInstanceOf(ApexParser_1.CompilationUnitContext);
|
|
99
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
100
|
-
});
|
|
101
|
-
test('Compilation Unit (inline SOQL)', () => {
|
|
102
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)(`public class Hello {
|
|
103
|
-
public void func() {
|
|
104
|
-
List<Account> accounts = [Select Id from Accounts];
|
|
105
|
-
}
|
|
106
|
-
}`);
|
|
107
|
-
const context = parser.compilationUnit();
|
|
108
|
-
expect(context).toBeInstanceOf(ApexParser_1.CompilationUnitContext);
|
|
109
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
110
|
-
});
|
|
111
|
-
test('Compilation Unit (throwing errors)', () => {
|
|
112
|
-
const [parser] = (0, SyntaxErrorCounter_1.createParser)("public class Hello {");
|
|
113
|
-
parser.removeErrorListeners();
|
|
114
|
-
parser.addErrorListener(new ThrowingErrorListener_1.ThrowingErrorListener());
|
|
115
|
-
try {
|
|
116
|
-
parser.compilationUnit();
|
|
117
|
-
expect(true).toBe(false);
|
|
118
|
-
}
|
|
119
|
-
catch (ex) {
|
|
120
|
-
expect(ex).toBeInstanceOf(ThrowingErrorListener_1.SyntaxException);
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
test('Trigger Unit', () => {
|
|
124
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("trigger test on Account (before update, after update) {}");
|
|
125
|
-
const context = parser.triggerUnit();
|
|
126
|
-
expect(context).toBeInstanceOf(ApexParser_1.TriggerUnitContext);
|
|
127
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
128
|
-
});
|
|
129
|
-
test('testSemiAllowedAsWhileBody', () => {
|
|
130
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("while (x++ < 10 && !(y-- < 0));");
|
|
131
|
-
const context = parser.statement();
|
|
132
|
-
expect(context).toBeInstanceOf(ApexParser_1.StatementContext);
|
|
133
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
134
|
-
});
|
|
135
|
-
test('testSemiAllowedAsForBody', () => {
|
|
136
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("for(x=0; x<10; x++);");
|
|
137
|
-
const context = parser.statement();
|
|
138
|
-
expect(context).toBeInstanceOf(ApexParser_1.StatementContext);
|
|
139
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
140
|
-
});
|
|
141
|
-
test('testSemiDisallowedAsGeneralStatement', () => {
|
|
142
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("if (x == 3); else { ; }");
|
|
143
|
-
const context = parser.statement();
|
|
144
|
-
expect(context).toBeInstanceOf(ApexParser_1.StatementContext);
|
|
145
|
-
expect(errorCounter.getNumErrors()).toEqual(1);
|
|
146
|
-
});
|
|
147
|
-
test('testWhenLiteralParens', () => {
|
|
148
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)(`
|
|
149
|
-
switch on (x) {
|
|
150
|
-
when 1 { return 1; }
|
|
151
|
-
when ((2)) { return 2; }
|
|
152
|
-
when (3), (4) { return 3; }
|
|
153
|
-
}`);
|
|
154
|
-
const context = parser.statement();
|
|
155
|
-
expect(context).toBeInstanceOf(ApexParser_1.StatementContext);
|
|
156
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
157
|
-
});
|
|
158
|
-
test("testWhenLiteralParens", () => {
|
|
159
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)(`
|
|
160
|
-
switch on (x) {
|
|
161
|
-
when 1 { return 1; }
|
|
162
|
-
when ((2)) { return 2; }
|
|
163
|
-
when (3), (4) { return 3; }
|
|
164
|
-
}`);
|
|
165
|
-
const context = parser.statement();
|
|
166
|
-
expect(context).toBeInstanceOf(ApexParser_1.StatementContext);
|
|
167
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
168
|
-
});
|
|
169
|
-
test('testSoqlModeKeywords', () => {
|
|
170
|
-
const MODES = ["USER_MODE", "SYSTEM_MODE"];
|
|
171
|
-
for (const mode of MODES) {
|
|
172
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)(`SELECT Id FROM Account WITH ${mode}`);
|
|
173
|
-
const context = parser.query();
|
|
174
|
-
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
175
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
test('testDmlModeKeywords', () => {
|
|
179
|
-
const MODES = ["USER", "SYSTEM"];
|
|
180
|
-
for (const mode of MODES) {
|
|
181
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)(`insert as ${mode} contact;`);
|
|
182
|
-
const context = parser.statement();
|
|
183
|
-
expect(context).toBeInstanceOf(ApexParser_1.StatementContext);
|
|
184
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
test('testDoWhileBlock', () => {
|
|
188
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("public class Hello {{ do { System.debug(''); } while (true); }}");
|
|
189
|
-
const context = parser.compilationUnit();
|
|
190
|
-
expect(context).toBeInstanceOf(ApexParser_1.CompilationUnitContext);
|
|
191
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
192
|
-
});
|
|
193
|
-
test('testDoWhileWithoutBlockFails', () => {
|
|
194
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("public class Hello {{ do System.debug(''); while (true); }}");
|
|
195
|
-
const context = parser.compilationUnit();
|
|
196
|
-
expect(context).toBeInstanceOf(ApexParser_1.CompilationUnitContext);
|
|
197
|
-
expect(errorCounter.getNumErrors()).toEqual(3);
|
|
198
|
-
});
|
|
199
|
-
//# sourceMappingURL=ApexParserTest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApexParserTest.js","sourceRoot":"","sources":["../../src/__tests__/ApexParserTest.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;GAYG;AACH,8CAWuB;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,CA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AC1B,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAA,iCAAY,EAAC,iEAAiE,CAAC,CAAA;IAE9G,MAAM,OAAO,GAAG,MAAM,CAAC,eAAe,EAAE,CAAA;IAExC,MAAM,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,mCAAsB,CAAC,CAAA;IACtD,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAClD,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,8BAA8B,EAAE,GAAG,EAAE;IACtC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAA,iCAAY,EAAC,6DAA6D,CAAC,CAAA;IAE1G,MAAM,OAAO,GAAG,MAAM,CAAC,eAAe,EAAE,CAAA;IAExC,MAAM,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,mCAAsB,CAAC,CAAA;IACtD,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAClD,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Copyright (c) 2023 Kevin Jones, All rights reserved.
|
|
4
|
-
Redistribution and use in source and binary forms, with or without
|
|
5
|
-
modification, are permitted provided that the following conditions
|
|
6
|
-
are met:
|
|
7
|
-
1. Redistributions of source code must retain the above copyright
|
|
8
|
-
notice, this list of conditions and the following disclaimer.
|
|
9
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
10
|
-
notice, this list of conditions and the following disclaimer in the
|
|
11
|
-
documentation and/or other materials provided with the distribution.
|
|
12
|
-
3. The name of the author may not be used to endorse or promote products
|
|
13
|
-
derived from this software without specific prior written permission.
|
|
14
|
-
*/
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
const ApexParser_1 = require("../ApexParser");
|
|
17
|
-
const SyntaxErrorCounter_1 = require("./SyntaxErrorCounter");
|
|
18
|
-
test('Empty Trigger', () => {
|
|
19
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("trigger test on Account (before update, after update) {}");
|
|
20
|
-
const context = parser.triggerUnit();
|
|
21
|
-
expect(context).toBeInstanceOf(ApexParser_1.TriggerUnitContext);
|
|
22
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
23
|
-
});
|
|
24
|
-
test('Trigger with statement', () => {
|
|
25
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("trigger test on Account (before update, after update) {System.debug('');}");
|
|
26
|
-
const context = parser.triggerUnit();
|
|
27
|
-
expect(context).toBeInstanceOf(ApexParser_1.TriggerUnitContext);
|
|
28
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
29
|
-
});
|
|
30
|
-
test('Trigger with method', () => {
|
|
31
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("trigger test on Account (before update, after update) {public void func() {}}");
|
|
32
|
-
const context = parser.triggerUnit();
|
|
33
|
-
expect(context).toBeInstanceOf(ApexParser_1.TriggerUnitContext);
|
|
34
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
35
|
-
});
|
|
36
|
-
test('Trigger with field', () => {
|
|
37
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("trigger test on Account (before update, after update) {String a;}");
|
|
38
|
-
const context = parser.triggerUnit();
|
|
39
|
-
expect(context).toBeInstanceOf(ApexParser_1.TriggerUnitContext);
|
|
40
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
41
|
-
});
|
|
42
|
-
test('Trigger with interface', () => {
|
|
43
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("trigger test on Account (before update, after update) {interface Foo {}}");
|
|
44
|
-
const context = parser.triggerUnit();
|
|
45
|
-
expect(context).toBeInstanceOf(ApexParser_1.TriggerUnitContext);
|
|
46
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
47
|
-
});
|
|
48
|
-
test('Trigger with class', () => {
|
|
49
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("trigger test on Account (before update, after update) {class Foo {}}");
|
|
50
|
-
const context = parser.triggerUnit();
|
|
51
|
-
expect(context).toBeInstanceOf(ApexParser_1.TriggerUnitContext);
|
|
52
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
53
|
-
});
|
|
54
|
-
test('Trigger with enum', () => {
|
|
55
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("trigger test on Account (before update, after update) {enum Foo {}}");
|
|
56
|
-
const context = parser.triggerUnit();
|
|
57
|
-
expect(context).toBeInstanceOf(ApexParser_1.TriggerUnitContext);
|
|
58
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
59
|
-
});
|
|
60
|
-
test('Trigger with property', () => {
|
|
61
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("trigger test on Account (before update, after update) { String a {get { return a; } set { a = value; }} }");
|
|
62
|
-
const context = parser.triggerUnit();
|
|
63
|
-
expect(context).toBeInstanceOf(ApexParser_1.TriggerUnitContext);
|
|
64
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
65
|
-
});
|
|
66
|
-
//# sourceMappingURL=ApexTriggerTest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApexTriggerTest.js","sourceRoot":"","sources":["../../src/__tests__/ApexTriggerTest.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAEH,8CAAiD;AACjD,6DAAoD;AAEpD,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE;IACvB,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAA,iCAAY,EAAC,0DAA0D,CAAC,CAAA;IACvG,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,EAAE,CAA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AG,IAAA,iCAAY,EAAC,2GAA2G,CAAC,CAAA;IACxJ,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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/*
|
|
4
|
-
Copyright (c) 2021 Kevin Jones, All rights reserved.
|
|
5
|
-
Redistribution and use in source and binary forms, with or without
|
|
6
|
-
modification, are permitted provided that the following conditions
|
|
7
|
-
are met:
|
|
8
|
-
1. Redistributions of source code must retain the above copyright
|
|
9
|
-
notice, this list of conditions and the following disclaimer.
|
|
10
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
11
|
-
notice, this list of conditions and the following disclaimer in the
|
|
12
|
-
documentation and/or other materials provided with the distribution.
|
|
13
|
-
3. The name of the author may not be used to endorse or promote products
|
|
14
|
-
derived from this software without specific prior written permission.
|
|
15
|
-
*/
|
|
16
|
-
const ApexLexer_1 = require("../ApexLexer");
|
|
17
|
-
const ApexParser_1 = require("../ApexParser");
|
|
18
|
-
const CaseInsensitiveInputStream_1 = require("../CaseInsensitiveInputStream");
|
|
19
|
-
const antlr4ts_1 = require("antlr4ts");
|
|
20
|
-
const AbstractParseTreeVisitor_1 = require("antlr4ts/tree/AbstractParseTreeVisitor");
|
|
21
|
-
const ThrowingErrorListener_1 = require("../ThrowingErrorListener");
|
|
22
|
-
class TestVisitor extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
23
|
-
constructor() {
|
|
24
|
-
super(...arguments);
|
|
25
|
-
this.methodCount = 0;
|
|
26
|
-
}
|
|
27
|
-
visitMethodDeclaration(ctx) {
|
|
28
|
-
this.methodCount += 1;
|
|
29
|
-
return 1 + super.visitChildren(ctx);
|
|
30
|
-
}
|
|
31
|
-
defaultResult() {
|
|
32
|
-
return 0;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
test('Vistor is visited', () => {
|
|
36
|
-
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("public class Hello { public void func(){} }")));
|
|
37
|
-
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
|
|
38
|
-
const parser = new ApexParser_1.ApexParser(tokens);
|
|
39
|
-
parser.removeErrorListeners();
|
|
40
|
-
parser.addErrorListener(new ThrowingErrorListener_1.ThrowingErrorListener());
|
|
41
|
-
const cu = parser.compilationUnit();
|
|
42
|
-
const visitor = new TestVisitor();
|
|
43
|
-
visitor.visit(cu);
|
|
44
|
-
expect(visitor.methodCount).toBe(1);
|
|
45
|
-
});
|
|
46
|
-
//# sourceMappingURL=ApexVisitorTest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApexVisitorTest.js","sourceRoot":"","sources":["../../src/__tests__/ApexVisitorTest.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;GAYG;AACH,4CAAyC;AACzC,8CAAqE;AACrE,8EAA0E;AAC1E,uCAA0D;AAC1D,qFAAkF;AAClF,oEAAiE;AAGjE,MAAM,WAAY,SAAQ,mDAAgC;IAA1D;;QACW,gBAAW,GAAG,CAAC,CAAA;IAU1B,CAAC;IARG,sBAAsB,CAAC,GAA6B;QAChD,IAAI,CAAC,WAAW,IAAI,CAAC,CAAC;QACtB,OAAO,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;IACvC,CAAC;IAED,aAAa;QACT,OAAO,CAAC,CAAA;IACZ,CAAC;CACJ;AAED,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAE3B,MAAM,KAAK,GAAG,IAAI,qBAAS,CAAC,IAAI,uDAA0B,CAAC,sBAAW,CAAC,UAAU,CAAC,6CAA6C,CAAC,CAAC,CAAC,CAAC;IACnI,MAAM,MAAM,GAAG,IAAI,4BAAiB,CAAC,KAAK,CAAC,CAAC;IAE5C,MAAM,MAAM,GAAG,IAAI,uBAAU,CAAC,MAAM,CAAC,CAAA;IAErC,MAAM,CAAC,oBAAoB,EAAE,CAAA;IAC7B,MAAM,CAAC,gBAAgB,CAAC,IAAI,6CAAqB,EAAE,CAAC,CAAC;IAErD,MAAM,EAAE,GAAG,MAAM,CAAC,eAAe,EAAE,CAAA;IACnC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;IACjC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAEjB,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACvC,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/*
|
|
4
|
-
Copyright (c) 2021 Kevin Jones, All rights reserved.
|
|
5
|
-
Redistribution and use in source and binary forms, with or without
|
|
6
|
-
modification, are permitted provided that the following conditions
|
|
7
|
-
are met:
|
|
8
|
-
1. Redistributions of source code must retain the above copyright
|
|
9
|
-
notice, this list of conditions and the following disclaimer.
|
|
10
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
11
|
-
notice, this list of conditions and the following disclaimer in the
|
|
12
|
-
documentation and/or other materials provided with the distribution.
|
|
13
|
-
3. The name of the author may not be used to endorse or promote products
|
|
14
|
-
derived from this software without specific prior written permission.
|
|
15
|
-
*/
|
|
16
|
-
const ApexParser_1 = require("../ApexParser");
|
|
17
|
-
const SyntaxErrorCounter_1 = require("./SyntaxErrorCounter");
|
|
18
|
-
test("SOQL Query", () => {
|
|
19
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("Select Id from Account");
|
|
20
|
-
const context = parser.query();
|
|
21
|
-
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
22
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
23
|
-
});
|
|
24
|
-
test("SOQL Query Using Field function", () => {
|
|
25
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("Select Fields(All) from Account");
|
|
26
|
-
const context = parser.query();
|
|
27
|
-
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
28
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
29
|
-
});
|
|
30
|
-
test("CurrencyLiteral", () => {
|
|
31
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("SELECT Id FROM Account WHERE Amount > USD100.01 AND Amount < USD200");
|
|
32
|
-
const context = parser.query();
|
|
33
|
-
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
34
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
35
|
-
});
|
|
36
|
-
test("IdentifiersThatCouldBeCurrencyLiterals", () => {
|
|
37
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("USD100.name = 'name';");
|
|
38
|
-
const context = parser.statement();
|
|
39
|
-
expect(context).toBeInstanceOf(ApexParser_1.StatementContext);
|
|
40
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
41
|
-
});
|
|
42
|
-
test("DateTimeLiteral", () => {
|
|
43
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("SELECT Name, (SELECT Id FROM Account WHERE createdDate > 2020-01-01T12:00:00Z) FROM Opportunity");
|
|
44
|
-
const context = parser.query();
|
|
45
|
-
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
46
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
47
|
-
});
|
|
48
|
-
test("testNegativeNumericLiteral", () => {
|
|
49
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("SELECT Name FROM Opportunity WHERE Value = -100.123");
|
|
50
|
-
const context = parser.query();
|
|
51
|
-
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
52
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
53
|
-
});
|
|
54
|
-
test("testLastQuarterKeyword", () => {
|
|
55
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("SELECT Id FROM Account WHERE DueDate = LAST_QUARTER");
|
|
56
|
-
const context = parser.query();
|
|
57
|
-
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
58
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
59
|
-
});
|
|
60
|
-
test("testDistanceFunction", () => {
|
|
61
|
-
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')");
|
|
62
|
-
const context = parser.query();
|
|
63
|
-
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
64
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
65
|
-
});
|
|
66
|
-
test("testGeoLocationFunction", () => {
|
|
67
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("SELECT Id FROM Account WHERE Distance(Address, GeoLocation(:something, -23.33), 'km') < 10");
|
|
68
|
-
const context = parser.query();
|
|
69
|
-
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
70
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
71
|
-
});
|
|
72
|
-
test("SubQuery", () => {
|
|
73
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("SELECT Name, (SELECT Id, (SELECT Id, (SELECT Id, (SELECT Id FROM Child4 ) FROM Child3 ) FROM Child2 ) FROM Child1) FROM Parent");
|
|
74
|
-
const context = parser.query();
|
|
75
|
-
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
76
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
77
|
-
});
|
|
78
|
-
test("Grouping function", () => {
|
|
79
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)(`SELECT
|
|
80
|
-
OBJ1__c O1,
|
|
81
|
-
OBJ2__c O2,
|
|
82
|
-
OBJ3__c O3,
|
|
83
|
-
SUM(OBJ4__c) O4,
|
|
84
|
-
GROUPING(OBJ1__c) O1Group,
|
|
85
|
-
GROUPING(OBJ2__c) O2Group,
|
|
86
|
-
GROUPING(OBJ3__c) O3Group
|
|
87
|
-
FROM OBJ4__c
|
|
88
|
-
GROUP BY ROLLUP(OBJ1__c, OBJ2__c, OBJ3__c)`);
|
|
89
|
-
const context = parser.query();
|
|
90
|
-
expect(context).toBeInstanceOf(ApexParser_1.QueryContext);
|
|
91
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
92
|
-
});
|
|
93
|
-
test("Convert Currency function", () => {
|
|
94
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)('[ SELECT convertCurrency(Amount) FROM Opportunity ]');
|
|
95
|
-
const context = parser.soqlLiteral();
|
|
96
|
-
expect(context).toBeInstanceOf(ApexParser_1.SoqlLiteralContext);
|
|
97
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
98
|
-
});
|
|
99
|
-
test("Convert Currency with format", () => {
|
|
100
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)(`[
|
|
101
|
-
SELECT Amount, FORMAT(amount) Amt, convertCurrency(amount) convertedAmount,
|
|
102
|
-
FORMAT(convertCurrency(amount)) convertedCurrency
|
|
103
|
-
FROM Opportunity where id = '006R00000024gDtIAI'
|
|
104
|
-
]`);
|
|
105
|
-
const context = parser.soqlLiteral();
|
|
106
|
-
expect(context).toBeInstanceOf(ApexParser_1.SoqlLiteralContext);
|
|
107
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
108
|
-
});
|
|
109
|
-
test("Format function with aggregate", () => {
|
|
110
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)('[ SELECT FORMAT(MIN(closedate)) Amt FROM opportunity ]');
|
|
111
|
-
const context = parser.soqlLiteral();
|
|
112
|
-
expect(context).toBeInstanceOf(ApexParser_1.SoqlLiteralContext);
|
|
113
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
114
|
-
});
|
|
115
|
-
test("Time Literal", () => {
|
|
116
|
-
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)('[SELECT Break__c,Check_Out__c FROM VMS_Time_Card_Item__c WHERE Time_Card__c =:timeCard.Id AND Check_Out__c = 01:00:00.000Z]');
|
|
117
|
-
const context = parser.soqlLiteral();
|
|
118
|
-
expect(context).toBeInstanceOf(ApexParser_1.SoqlLiteralContext);
|
|
119
|
-
expect(errorCounter.getNumErrors()).toEqual(0);
|
|
120
|
-
});
|
|
121
|
-
//# sourceMappingURL=SOQLParserTest.js.map
|