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

apex-parser

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apex-parser - npm Package Compare versions

Comparing version 2.13.0 to 2.14.0

8

lib/__tests__/ApexLexerTest.js

@@ -7,3 +7,3 @@ "use strict";

test('Lexer generates tokens', () => {
const lexer = new ApexLexer_1.ApexLexer(new antlr4ts_1.ANTLRInputStream("public class Hello {}"));
const lexer = new ApexLexer_1.ApexLexer(antlr4ts_1.CharStreams.fromString("public class Hello {}"));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -13,3 +13,3 @@ expect(tokens.getNumberOfOnChannelTokens()).toBe(6);

test('Case insensitivity', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.cls", "public"));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("public")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -19,3 +19,3 @@ expect(tokens.getNumberOfOnChannelTokens()).toBe(2);

test('Case insensitivity (upper case)', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.cls", "PUBLIC"));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("PUBLIC")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -25,3 +25,3 @@ expect(tokens.getNumberOfOnChannelTokens()).toBe(2);

test('Case insensitivity (mixed case)', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.cls", "PuBliC"));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("PuBliC")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -28,0 +28,0 @@ expect(tokens.getNumberOfOnChannelTokens()).toBe(2);

@@ -18,3 +18,3 @@ "use strict";

test('Listener Generates Events', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.cls", "public class Hello { public void func(){} }"));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("public class Hello { public void func(){} }")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -21,0 +21,0 @@ const parser = new ApexParser_1.ApexParser(tokens);

@@ -9,3 +9,3 @@ "use strict";

test('Boolean Literal', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.cls", "true"));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("true")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -19,3 +19,3 @@ const parser = new ApexParser_1.ApexParser(tokens);

test('Expression', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.cls", "a * 5"));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("a * 5")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -29,3 +29,3 @@ const parser = new ApexParser_1.ApexParser(tokens);

test('Compilation Unit', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.cls", "public class Hello {}"));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("public class Hello {}")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -37,3 +37,3 @@ const parser = new ApexParser_1.ApexParser(tokens);

test('Compilation Unit (case insensitive)', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.cls", "Public CLASS Hello {}"));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("Public CLASS Hello {}")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -45,3 +45,3 @@ const parser = new ApexParser_1.ApexParser(tokens);

test('Compilation Unit (bug test)', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.cls", `public class Hello {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString(`public class Hello {
public testMethod void func() {

@@ -51,3 +51,3 @@ System.runAs(u) {

}
}`));
}`)));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -59,7 +59,7 @@ const parser = new ApexParser_1.ApexParser(tokens);

test('Compilation Unit (inline SOQL)', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.cls", `public class Hello {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString(`public class Hello {
public void func() {
List<Account> accounts = [Select Id from Accounts];
}
}`));
}`)));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -71,3 +71,3 @@ const parser = new ApexParser_1.ApexParser(tokens);

test('Compilation Unit (throwing errors)', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.cls", "public class Hello {"));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("public class Hello {")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -86,3 +86,3 @@ const parser = new ApexParser_1.ApexParser(tokens);

test('Trigger Unit', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.trigger", "trigger test on Account (before update, after update) {}"));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("trigger test on Account (before update, after update) {}")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -94,3 +94,3 @@ const parser = new ApexParser_1.ApexParser(tokens);

test('SOQL Query', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.soql", "Select Id from Account"));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("Select Id from Account")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -102,3 +102,3 @@ const parser = new ApexParser_1.ApexParser(tokens);

test('SOQL Query Using Field function', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.soql", "Select Fields(All) from Account"));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("Select Fields(All) from Account")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -110,3 +110,3 @@ const parser = new ApexParser_1.ApexParser(tokens);

test('SOSL Query', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.sosl", "[Find {something} RETURNING Account]"));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("[Find {something} RETURNING Account]")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -118,3 +118,3 @@ const parser = new ApexParser_1.ApexParser(tokens);

test('CurrencyLiteral', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.soql", "SELECT Id FROM Account WHERE Amount > USD100.01 AND Amount < USD200"));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("SELECT Id FROM Account WHERE Amount > USD100.01 AND Amount < USD200")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -126,3 +126,3 @@ const parser = new ApexParser_1.ApexParser(tokens);

test('IdentifiersThatCouldBeCurrencyLiterals', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.apex", "USD100.name = 'name';"));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("USD100.name = 'name';")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -134,3 +134,3 @@ const parser = new ApexParser_1.ApexParser(tokens);

test('DateTimeLiteral', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.soql", "SELECT Name, (SELECT Id FROM Account WHERE createdDate > 2020-01-01T12:00:00Z) FROM Opportunity"));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("SELECT Name, (SELECT Id FROM Account WHERE createdDate > 2020-01-01T12:00:00Z) FROM Opportunity")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -142,3 +142,3 @@ const parser = new ApexParser_1.ApexParser(tokens);

test('testNegativeNumericLiteral', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.soql", "SELECT Name FROM Opportunity WHERE Value = -100.123"));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("SELECT Name FROM Opportunity WHERE Value = -100.123")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -145,0 +145,0 @@ const parser = new ApexParser_1.ApexParser(tokens);

@@ -23,5 +23,5 @@ "use strict";

test('Vistor is visited', () => {
let lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream("test.cls", "public class Hello { public void func(){} }"));
let tokens = new antlr4ts_1.CommonTokenStream(lexer);
let parser = new ApexParser_1.ApexParser(tokens);
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("public class Hello { public void func(){} }")));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
const parser = new ApexParser_1.ApexParser(tokens);
parser.removeErrorListeners();

@@ -28,0 +28,0 @@ parser.addErrorListener(new ThrowingErrorListener_1.ThrowingErrorListener());

@@ -1,7 +0,16 @@

import { ANTLRInputStream } from "antlr4ts";
export declare class CaseInsensitiveInputStream extends ANTLRInputStream {
userData: any;
constructor(userData: any, input: string);
import { CharStream } from "antlr4ts";
import { Interval } from "antlr4ts/misc/Interval";
export declare class CaseInsensitiveInputStream implements CharStream {
private src;
constructor(src: CharStream);
getText(interval: Interval): string;
consume(): void;
LA(i: number): number;
toLower(c: number): number;
mark(): number;
release(marker: number): void;
get index(): number;
seek(index: number): void;
get size(): number;
get sourceName(): string;
private toLower;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CaseInsensitiveInputStream = void 0;
/*

@@ -31,12 +29,36 @@ [The "BSD licence"]

*/
const antlr4ts_1 = require("antlr4ts");
class CaseInsensitiveInputStream extends antlr4ts_1.ANTLRInputStream {
// userData is an untyped identifier of where the stream is from
constructor(userData, input) {
super(input);
this.userData = userData;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CaseInsensitiveInputStream = void 0;
class CaseInsensitiveInputStream {
// userData is an untyped identifierfor the stream, for string input use CharStreams.fromString()
constructor(src) {
this.src = src;
}
getText(interval) {
return this.src.getText(interval);
}
consume() {
this.src.consume();
}
LA(i) {
return this.toLower(super.LA(i));
return this.toLower(this.src.LA(i));
}
mark() {
return this.src.mark();
}
release(marker) {
this.src.release(marker);
}
get index() {
return this.src.index;
}
seek(index) {
return this.src.seek(index);
}
get size() {
return this.src.size;
}
get sourceName() {
return this.src.sourceName;
}
// We only need basic upper to lower conversions

@@ -43,0 +65,0 @@ toLower(c) {

@@ -73,3 +73,3 @@ "use strict";

const content = (0, fs_1.readFileSync)(file);
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(file, content.toString()));
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString(content.toString())));
const tokens = new antlr4ts_1.CommonTokenStream(lexer);

@@ -76,0 +76,0 @@ const parser = new ApexParser_1.ApexParser(tokens);

{
"name": "apex-parser",
"version": "2.13.0",
"version": "2.14.0",
"author": "Kevin Jones <nawforce@gmail.com> (https://github.com/nawforce)",

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

@@ -23,6 +23,9 @@ apex-parser

### Unicode handling
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.
### antlr4ts versions
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
sure that if you are using a matching verions of this dependency if you use it directly. To avoid issues you can
sure that if you are using a matching versions of this dependency if you use it directly. To avoid issues you can
import 'CommonTokenStream' & 'ParseTreeWalker' from 'apex-parser' instead of from antlr4ts.

@@ -40,3 +43,3 @@

<artifactId>apex-parser</artifactId>
<version>2.13.0</version>
<version>2.14.0</version>
</dependency>

@@ -46,3 +49,3 @@

"apex-parser": "^2.13.0"
"apex-parser": "^2.14.0"

@@ -55,4 +58,5 @@ ### Building

### History
2.14.0 - Change npm api to replace ANTLRInputStream with CharStream, for Unicode char positions
2.13.0 - Fixes for negative numerics & Currency literals in SOQL
2.12.0 - Replace deprecated ANTLRINputStream, DateTime & Currency literals fixes (contrib Aaron Hurst)
2.12.0 - Replace deprecated ANTLRInputStream, DateTime & Currency literals fixes (contrib Aaron Hurst)
2.11.0 - Fix for SOQL UPDATE VIEWSTAT/TRACKING & removal of class type arguments

@@ -59,0 +63,0 @@ 2.10.0 - Allow type arguments on Classes (non-standard!)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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