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

@apexdevtools/apex-parser

Package Overview
Dependencies
Maintainers
0
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 4.3.0 to 4.3.1

29

lib/__tests__/ApexLexerTest.js

@@ -16,25 +16,34 @@ "use strict";

*/
const ApexLexer_1 = require("../ApexLexer");
const CaseInsensitiveInputStream_1 = require("../CaseInsensitiveInputStream");
const antlr4ts_1 = require("antlr4ts");
test('Lexer generates tokens', () => {
const lexer = new ApexLexer_1.ApexLexer(antlr4ts_1.CharStreams.fromString("public class Hello {}"));
const SyntaxErrorCounter_1 = require("./SyntaxErrorCounter");
test("Lexer generates tokens", () => {
const [lexer, errorCounter] = (0, SyntaxErrorCounter_1.createLexer)("public class Hello {}", false);
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
expect(tokens.getNumberOfOnChannelTokens()).toBe(6);
expect(errorCounter.getNumErrors()).toEqual(0);
});
test('Case insensitivity', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("public")));
test("Case insensitivity", () => {
const [lexer, errorCounter] = (0, SyntaxErrorCounter_1.createLexer)("public");
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
expect(tokens.getNumberOfOnChannelTokens()).toBe(2);
expect(errorCounter.getNumErrors()).toEqual(0);
});
test('Case insensitivity (upper case)', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("PUBLIC")));
test("Case insensitivity (upper case)", () => {
const [lexer, errorCounter] = (0, SyntaxErrorCounter_1.createLexer)("PUBLIC");
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
expect(tokens.getNumberOfOnChannelTokens()).toBe(2);
expect(errorCounter.getNumErrors()).toEqual(0);
});
test('Case insensitivity (mixed case)', () => {
const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString("PuBliC")));
test("Case insensitivity (mixed case)", () => {
const [lexer, errorCounter] = (0, SyntaxErrorCounter_1.createLexer)("PuBliC");
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
expect(tokens.getNumberOfOnChannelTokens()).toBe(2);
expect(errorCounter.getNumErrors()).toEqual(0);
});
test("Lexer unicode escapes", () => {
const [lexer, errorCounter] = (0, SyntaxErrorCounter_1.createLexer)("'Fran\\u00E7ois'", false);
const tokens = new antlr4ts_1.CommonTokenStream(lexer);
expect(tokens.getNumberOfOnChannelTokens()).toBe(2);
expect(errorCounter.getNumErrors()).toEqual(0);
});
//# sourceMappingURL=ApexLexerTest.js.map
import { ANTLRErrorListener, RecognitionException, Recognizer, Token } from "antlr4ts";
import { ApexLexer } from "../ApexLexer";
import { ApexParser } from "../ApexParser";
export declare class SyntaxErrorCounter implements ANTLRErrorListener<Token> {
export declare class SyntaxErrorCounter<T = Token> implements ANTLRErrorListener<T> {
numErrors: number;
syntaxError(recognizer: Recognizer<Token, any>, offendingSymbol: Token, line: number, charPositionInLine: number, msg: string, e: RecognitionException | undefined): any;
syntaxError(recognizer: Recognizer<T, any>, offendingSymbol: T, line: number, charPositionInLine: number, msg: string, e: RecognitionException | undefined): any;
getNumErrors(): number;
}
export declare function createLexer(input: string, caseInsensitive?: boolean): [ApexLexer, SyntaxErrorCounter<number>];
export declare function createParser(input: string): [ApexParser, SyntaxErrorCounter];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createParser = exports.SyntaxErrorCounter = void 0;
exports.createParser = exports.createLexer = exports.SyntaxErrorCounter = void 0;
/*

@@ -33,2 +33,11 @@ Copyright (c) 2021 Kevin Jones, All rights reserved.

exports.SyntaxErrorCounter = SyntaxErrorCounter;
function createLexer(input, caseInsensitive = true) {
const stream = antlr4ts_1.CharStreams.fromString(input);
const lexer = new ApexLexer_1.ApexLexer(caseInsensitive ? new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(stream) : stream);
lexer.removeErrorListeners();
const errorCounter = new SyntaxErrorCounter();
lexer.addErrorListener(errorCounter);
return [lexer, errorCounter];
}
exports.createLexer = createLexer;
function createParser(input) {

@@ -35,0 +44,0 @@ const lexer = new ApexLexer_1.ApexLexer(new CaseInsensitiveInputStream_1.CaseInsensitiveInputStream(antlr4ts_1.CharStreams.fromString(input)));

{
"name": "@apexdevtools/apex-parser",
"version": "4.3.0",
"version": "4.3.1",
"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>4.3.0</version>
<version>4.3.1</version>
</dependency>

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

"@apexdevtools/apex-parser": "^4.3.0"
"@apexdevtools/apex-parser": "^4.3.1"

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

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 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

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