Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@apexdevtools/apex-parser

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apexdevtools/apex-parser - npm Package Compare versions

Comparing version 3.5.0 to 3.6.0

4

CHANGELOG.md
# apex-parser - Changelog
## 3.6.0 - 2024-02-15
- Add null coalesce operator and expression
## 3.5.0 - 2023-10-15

@@ -4,0 +8,0 @@

@@ -35,2 +35,45 @@ "use strict";

});
test("Coalesce Expression", () => {
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("a ?? 5");
const context = parser.expression();
expect(errorCounter.getNumErrors()).toEqual(0);
expect(context).toBeInstanceOf(ApexParser_1.CoalExpressionContext);
const coalExpression = context;
expect(coalExpression.expression().length).toBe(2);
});
test("Coalesce Precedence - Arithmetic", () => {
// Based on the example in release notes / docs
// should NOT evaluate to (top ?? 100) - (bottom ?? 0) as you want
//
// left assoc = (top ?? (100 - bottom)) ?? 0
// right assoc = top ?? ((100 - bottom) ?? 0)
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("top ?? 100 - bottom ?? 0");
const context = parser.expression();
expect(errorCounter.getNumErrors()).toEqual(0);
expect(context).toBeInstanceOf(ApexParser_1.CoalExpressionContext);
const outer = context.expression();
expect(outer.length).toBe(2);
expect(outer[0]).toBeInstanceOf(ApexParser_1.CoalExpressionContext);
const inner = outer[0].expression(); // top ?? 100 - bottom
expect(inner.length).toBe(2);
expect(inner[0]).toBeInstanceOf(ApexParser_1.PrimaryExpressionContext); // top
expect(inner[1]).toBeInstanceOf(ApexParser_1.Arth2ExpressionContext); // 100 - bottom
expect(outer[1]).toBeInstanceOf(ApexParser_1.PrimaryExpressionContext); // 0
});
test("Coalesce Precedence - Boolean", () => {
// This is more nonsense but using a much lower precedence op
// should NOT evaluate to (a ?? false) || (b ?? false)
const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("a ?? false || b ?? false");
const context = parser.expression();
expect(errorCounter.getNumErrors()).toEqual(0);
expect(context).toBeInstanceOf(ApexParser_1.CoalExpressionContext);
const outer = context.expression();
expect(outer.length).toBe(2);
expect(outer[0]).toBeInstanceOf(ApexParser_1.CoalExpressionContext);
const inner = outer[0].expression(); // a ?? false || b
expect(inner.length).toBe(2);
expect(inner[0]).toBeInstanceOf(ApexParser_1.PrimaryExpressionContext); // a
expect(inner[1]).toBeInstanceOf(ApexParser_1.LogOrExpressionContext); // false || b
expect(outer[1]).toBeInstanceOf(ApexParser_1.PrimaryExpressionContext); // false
});
test('Compilation Unit', () => {

@@ -37,0 +80,0 @@ const [parser, errorCounter] = (0, SyntaxErrorCounter_1.createParser)("public class Hello {}");

53

lib/ApexLexer.d.ts

@@ -227,28 +227,29 @@ import { ATN } from "antlr4ts/atn/ATN";

static readonly OR = 221;
static readonly INC = 222;
static readonly DEC = 223;
static readonly ADD = 224;
static readonly SUB = 225;
static readonly MUL = 226;
static readonly DIV = 227;
static readonly BITAND = 228;
static readonly BITOR = 229;
static readonly CARET = 230;
static readonly MAPTO = 231;
static readonly ADD_ASSIGN = 232;
static readonly SUB_ASSIGN = 233;
static readonly MUL_ASSIGN = 234;
static readonly DIV_ASSIGN = 235;
static readonly AND_ASSIGN = 236;
static readonly OR_ASSIGN = 237;
static readonly XOR_ASSIGN = 238;
static readonly LSHIFT_ASSIGN = 239;
static readonly RSHIFT_ASSIGN = 240;
static readonly URSHIFT_ASSIGN = 241;
static readonly ATSIGN = 242;
static readonly Identifier = 243;
static readonly WS = 244;
static readonly DOC_COMMENT = 245;
static readonly COMMENT = 246;
static readonly LINE_COMMENT = 247;
static readonly COAL = 222;
static readonly INC = 223;
static readonly DEC = 224;
static readonly ADD = 225;
static readonly SUB = 226;
static readonly MUL = 227;
static readonly DIV = 228;
static readonly BITAND = 229;
static readonly BITOR = 230;
static readonly CARET = 231;
static readonly MAPTO = 232;
static readonly ADD_ASSIGN = 233;
static readonly SUB_ASSIGN = 234;
static readonly MUL_ASSIGN = 235;
static readonly DIV_ASSIGN = 236;
static readonly AND_ASSIGN = 237;
static readonly OR_ASSIGN = 238;
static readonly XOR_ASSIGN = 239;
static readonly LSHIFT_ASSIGN = 240;
static readonly RSHIFT_ASSIGN = 241;
static readonly URSHIFT_ASSIGN = 242;
static readonly ATSIGN = 243;
static readonly Identifier = 244;
static readonly WS = 245;
static readonly DOC_COMMENT = 246;
static readonly COMMENT = 247;
static readonly LINE_COMMENT = 248;
static readonly WHITESPACE_CHANNEL = 2;

@@ -255,0 +256,0 @@ static readonly COMMENT_CHANNEL = 3;

@@ -31,2 +31,3 @@ import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor";

import { LogOrExpressionContext } from "./ApexParser";
import { CoalExpressionContext } from "./ApexParser";
import { CondExpressionContext } from "./ApexParser";

@@ -390,2 +391,9 @@ import { AssignExpressionContext } from "./ApexParser";

/**
* Visit a parse tree produced by the `coalExpression`
* labeled alternative in `ApexParser.expression`.
* @param ctx the parse tree
* @return the visitor result
*/
visitCoalExpression?: (ctx: CoalExpressionContext) => Result;
/**
* Visit a parse tree produced by the `condExpression`

@@ -392,0 +400,0 @@ * labeled alternative in `ApexParser.expression`.

{
"name": "@apexdevtools/apex-parser",
"version": "3.5.0",
"version": "3.6.0",
"author": "Apex Dev Tools Team <apexdevtools@gmail.com> (https://github.com/apex-dev-tools)",

@@ -5,0 +5,0 @@ "bugs": "https://github.com/apex-dev-tools/apex-parser/issues",

@@ -51,3 +51,3 @@ # apex-parser

<artifactId>apex-parser</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
</dependency>

@@ -57,3 +57,3 @@

"@apexdevtools/apex-parser": "^3.5.0"
"@apexdevtools/apex-parser": "^3.6.0"

@@ -60,0 +60,0 @@ ## Building

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc