Skip to content

Commit 35b8feb

Browse files
Merge pull request #43 from apex-dev-tools/42-sosl-find-clause-with-user_mode-or-system_mode
Support USER/SYSTEM mode on SOSL
2 parents 2f9160c + d72c7fd commit 35b8feb

File tree

8 files changed

+65
-20
lines changed

8 files changed

+65
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# apex-parser - Changelog
22

3-
## 4.0.0 - 2023-03-28
3+
## 4.1.0 - 2024-05-12
4+
5+
- Allow WITH USER_MODE or SYSTEM_MODE on SOSL queries
6+
7+
## 4.0.0 - 2024-03-28
48

59
- Correct trigger body parsing to allow member declarations
610
- Add support for TYPEOF in SOQL subqueries

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ Maven
4848
<dependency>
4949
<groupId>io.github.apex-dev-tools</groupId>
5050
<artifactId>apex-parser</artifactId>
51-
<version>4.0.0</version>
51+
<version>4.1.0</version>
5252
</dependency>
5353

5454
NPM
5555

56-
"@apexdevtools/apex-parser": "^4.0.0"
56+
"@apexdevtools/apex-parser": "^4.1.0"
5757

5858
## Building
5959

antlr/ApexParser.g4

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -826,17 +826,23 @@ soslLiteralAlt
826826
soslClauses
827827
: (IN searchGroup)?
828828
(RETURNING fieldSpecList)?
829-
(WITH DIVISION ASSIGN StringLiteral)?
830-
(WITH DATA CATEGORY filteringExpression)?
831-
(WITH SNIPPET (LPAREN TARGET_LENGTH ASSIGN IntegerLiteral RPAREN)? )?
832-
(WITH NETWORK IN LPAREN networkList RPAREN)?
833-
(WITH NETWORK ASSIGN StringLiteral)?
834-
(WITH PRICEBOOKID ASSIGN StringLiteral)?
835-
(WITH METADATA ASSIGN StringLiteral)?
829+
soslWithClause*
836830
limitClause?
837831
(UPDATE updateList)?
838832
;
839833

834+
soslWithClause
835+
: WITH DIVISION ASSIGN StringLiteral
836+
| WITH DATA CATEGORY filteringExpression
837+
| WITH SNIPPET (LPAREN TARGET_LENGTH ASSIGN IntegerLiteral RPAREN)?
838+
| WITH NETWORK IN LPAREN networkList RPAREN
839+
| WITH NETWORK ASSIGN StringLiteral
840+
| WITH PRICEBOOKID ASSIGN StringLiteral
841+
| WITH METADATA ASSIGN StringLiteral
842+
| WITH USER_MODE
843+
| WITH SYSTEM_MODE
844+
;
845+
840846
searchGroup
841847
: (ALL|EMAIL|NAME|PHONE|SIDEBAR) FIELDS
842848
;

jvm/pom.xml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45

56
<groupId>io.github.apex-dev-tools</groupId>
67
<artifactId>apex-parser</artifactId>
7-
<version>4.0.0</version>
8+
<version>4.1.0</version>
89
<packaging>jar</packaging>
910

1011
<name>apex-parser</name>
@@ -59,9 +60,9 @@
5960

6061
<dependencies>
6162
<dependency>
62-
<groupId>org.antlr</groupId>
63-
<artifactId>antlr4-runtime</artifactId>
64-
<version>4.9.1</version>
63+
<groupId>org.antlr</groupId>
64+
<artifactId>antlr4-runtime</artifactId>
65+
<version>4.9.1</version>
6566
</dependency>
6667

6768
<dependency>
@@ -221,4 +222,4 @@
221222

222223
</plugins>
223224
</build>
224-
</project>
225+
</project>

jvm/src/test/java/io/github/apexdevtools/apexparser/SOSLParserTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,20 @@ void testQuotesFailOnAltFormat() {
6060
assertNotNull(context);
6161
assertEquals(1, parserAndCounter.getValue().getNumErrors());
6262
}
63+
64+
@Test
65+
void testWithUserModeQuery() {
66+
Map.Entry<ApexParser, SyntaxErrorCounter> parserAndCounter = createParser("[Find 'something' RETURNING Account WITH USER_MODE WITH METADATA='Labels']");
67+
ApexParser.SoslLiteralContext context = parserAndCounter.getKey().soslLiteral();
68+
assertNotNull(context);
69+
assertEquals(0, parserAndCounter.getValue().getNumErrors());
70+
}
71+
72+
@Test
73+
void testWithSystemModeQuery() {
74+
Map.Entry<ApexParser, SyntaxErrorCounter> parserAndCounter = createParser("[Find 'something' RETURNING Account WITH METADATA='Labels' WITH SYSTEM_MODE]");
75+
ApexParser.SoslLiteralContext context = parserAndCounter.getKey().soslLiteral();
76+
assertNotNull(context);
77+
assertEquals(0, parserAndCounter.getValue().getNumErrors());
78+
}
6379
}

npm/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

npm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@apexdevtools/apex-parser",
3-
"version": "4.0.0",
3+
"version": "4.1.0",
44
"author": "Apex Dev Tools Team <[email protected]> (https://github.com/apex-dev-tools)",
55
"bugs": "https://github.com/apex-dev-tools/apex-parser/issues",
66
"description": "Javascript parser for Salesforce Apex Language",

npm/src/__tests__/SOSLParserTest.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,21 @@ test('testQuotesFailOnAltFormat', () => {
6161
expect(context).toBeInstanceOf(SoslLiteralAltContext)
6262
expect(errorCounter.getNumErrors()).toEqual(1)
6363
})
64+
65+
test('testWithUserModeQuery', () => {
66+
const [parser, errorCounter] = createParser("[Find 'something' RETURNING Account WITH USER_MODE WITH METADATA='Labels']")
67+
68+
const context = parser.soslLiteralAlt()
69+
70+
expect(context).toBeInstanceOf(SoslLiteralAltContext)
71+
expect(errorCounter.getNumErrors()).toEqual(1)
72+
})
73+
74+
test('testWithSystemModeQuery', () => {
75+
const [parser, errorCounter] = createParser("[Find 'something' RETURNING Account WITH METADATA='Labels' WITH SYSTEM_MODE]")
76+
77+
const context = parser.soslLiteralAlt()
78+
79+
expect(context).toBeInstanceOf(SoslLiteralAltContext)
80+
expect(errorCounter.getNumErrors()).toEqual(1)
81+
})

0 commit comments

Comments
 (0)