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

antlr4-c3

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

antlr4-c3 - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

.travis.yml

2

package.json
{
"name": "antlr4-c3",
"version": "1.0.1",
"version": "1.0.2",
"description": "A grammar agnostic code completion core implmentation for ANTLR4 based parsers",

@@ -5,0 +5,0 @@ "main": "out/index.js",

@@ -0,1 +1,5 @@

[![NPM](https://nodei.co/npm/antlr4-c3.png?downloads=true&downloadRank=true)](https://nodei.co/npm/antlr4-c3/) [![NPM](https://nodei.co/npm-dl/antlr4-c3.png?months=6&height=3)](https://nodei.co/npm/antlr4-c3/)
[![Build Status](https://travis-ci.org/mike-lischke/antlr4-c3.svg?branch=master)](https://travis-ci.org/mike-lischke/antlr4-c3)
# antlr4-c3 The ANTLR4 Code Completion Core

@@ -32,5 +36,5 @@

expression: assignment | simpleExpression;
assignment: (VAR | LET) ID EQUAL simpleExpression;
simpleExpression

@@ -42,9 +46,9 @@ : simpleExpression (PLUS | MINUS) simpleExpression

;
variableRef: ID;
functionRef: ID OPEN_PAR CLOSE_PAR;
VAR: [vV] [aA] [rR];
LET: [lL] [eE] [tT];
PLUS: '+';

@@ -66,7 +70,7 @@ MINUS: '-';

tableRef: ID;
instead of:
dropTable: DROP TABLE ID;
Then tell the c3 engine that you want to get back `tableRef` if it is a valid candidate at a given position.

@@ -107,3 +111,3 @@

createTable: CREATE TABLE (IF NOT EXISTS)? ...;
Here, if a possible candidate is the `IF` keyword, you can also show the entire `IF NOT EXISTS` sequence to the user (and let him complete all 3 words in one go in his/her source code). The engine will return a candidate entry for `IF` with an array containing `NOT` and `EXISTS`. This list will of course update properly when the user comes to `NOT`. Then you will get a candidate entry for `NOT` and an additional list of just `EXISTS`.

@@ -119,3 +123,3 @@

}
let symbol = ...; // Find the symbol that covers your caret position.

@@ -130,3 +134,3 @@ let functionNames: string[] = [];

functionNames.push(function.name);
break;
break;
}

@@ -142,3 +146,3 @@

}
// Finally combine all found lists into one for the UI.

@@ -151,4 +155,4 @@ // We do that in separate steps so that you can apply some ordering to each of your sublists.

candidates.push(...variableNames);
# Fine Tuning

@@ -155,0 +159,0 @@ ## Ignored Tokens

@@ -517,3 +517,4 @@ /*

let stateValue = state.stateNumber == ATNState.INVALID_STATE_NUMBER ? "Invalid" : state.stateNumber;
return "[" + stateValue + " " + ATNStateType[state.stateType] + "] in " + this.ruleNames[state.ruleIndex];
//return "[" + stateValue + " " + ATNStateType[state.stateType] + "] in " + this.ruleNames[state.ruleIndex];
return "[" + stateValue + " " + state.stateType + "] in " + this.ruleNames[state.ruleIndex];
}

@@ -543,3 +544,4 @@

transitionDescription += "\n" + currentIndent + "\t(" + labels + ") " + "[" + transition.target.stateNumber + " " +
ATNStateType[transition.target.stateType] + "] in " + this.ruleNames[transition.target.ruleIndex];
//ATNStateType[transition.target.stateType] + "] in " + this.ruleNames[transition.target.ruleIndex];
transition.target.stateType + "] in " + this.ruleNames[transition.target.ruleIndex];
}

@@ -546,0 +548,0 @@ }

@@ -82,3 +82,3 @@ /*

name: string = ""; // The name of the scope or empty if anonymous.
context: ParserRuleContext | undefined; // Reference to the parse tree which defines this symbol.
context: ParserRuleContext | undefined; // Reference to the parse tree which contains this symbol.

@@ -91,5 +91,2 @@ protected parent: Symbol | undefined;

clear() {
}
// The parent is usually a scoped symbol as only those can have children, but we allow

@@ -102,2 +99,6 @@ // any symbol here for special scenarios.

getParent(): Symbol | undefined {
return this.parent;
}
removeFromParent() {

@@ -192,6 +193,2 @@ if (this.parent instanceof ScopedSymbol) {

export class ScopedSymbol extends Symbol {
clear() {
super.clear();
}
constructor(name = "") {

@@ -266,5 +263,5 @@ super(name)

// Returns all symbols accessible from this scope.
// Returns all symbols of the the given type accessible from this scope.
// TODO: add optional position dependency (only symbols defined before a given caret pos are viable).
getAllSymbols(localOnly = false): Symbol[] {
getAllSymbols<T extends Symbol>(t: new (...args: any[]) => T, localOnly = false): Symbol[] {
let result: Symbol[] = [];

@@ -275,5 +272,7 @@

for (let child of this.children) {
result.push(child);
if (child instanceof t) {
result.push(child);
}
if (child instanceof NamespaceSymbol)
result.push(...child.getAllSymbols(true));
result.push(...child.getAllSymbols(t, true));
}

@@ -283,3 +282,3 @@

if (this.parent && this.parent instanceof ScopedSymbol)
result.push(...this.parent.getAllSymbols());
result.push(...this.parent.getAllSymbols(t));
}

@@ -290,4 +289,4 @@

// Returns a symbol with a given name from this scope or any of the parent scopes (conditionally).
// That means inner scopes can see symbols from outer scopes.
// Returns the first symbol, from top to bottom, with a given name from this scope
// or any of the parent scopes (conditionally).
resolve(name: string, localOnly = false): Symbol | undefined {

@@ -561,13 +560,22 @@ for (let child of this.children) {

clear() {
this.dependencies = [];
this.dependencies.clear();
this.children = [];
}
addDependencies(...tables: SymbolTable[]) {
this.dependencies.push(...tables);
tables.forEach((value, key) => {
this.dependencies.add(value);
});
}
removeDependency(table: SymbolTable) {
if (this.dependencies.has(table)) {
this.dependencies.delete(table);
}
}
// Instance informations, mostly relevant for unit testing.
getInfo() {
return {
dependencyCount: this.dependencies.length,
dependencyCount: this.dependencies.size,
symbolCount: this.children.length

@@ -606,7 +614,10 @@ };

getAllSymbols(): Symbol[] {
let result = super.getAllSymbols();
getAllSymbols<T extends Symbol>(t?: new (...args: any[]) => T, localOnly: boolean = false): Symbol[] {
let type = t ? t : Symbol;
let result = super.getAllSymbols(type, localOnly);
for (let dependency of this.dependencies) {
result.push(...dependency.getAllSymbols());
if (!localOnly) {
for (let dependency of this.dependencies) {
result.push(...dependency.getAllSymbols(t, localOnly));
}
}

@@ -623,3 +634,3 @@

result = dependency.resolve(name, false);
if (!result)
if (result)
break;

@@ -633,3 +644,3 @@ }

// Other symbol information available to this instance.
private dependencies: SymbolTable[] = [];
protected dependencies: Set<SymbolTable> = new Set();
};

@@ -266,3 +266,3 @@ /*

// Note: namespaces are handled in the context of their parent. Symbols in a namespace/module/library are accessible from their parent.
expect(main.getAllSymbols().length, "Test 3.1").to.equal(2566);
expect(main.getAllSymbols().length, "Test 3.1").to.equal(2232);
expect(systemFunctions.getAllSymbols().length, "Test 3.2").to.equal(334); // System functions alone + the namespace.

@@ -269,0 +269,0 @@ expect(libFunctions.getAllSymbols().length, "Test 3.3").to.equal(445); // Lib functions alone + the namespace.

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