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

@neo4j-cypher/language-support

Package Overview
Dependencies
Maintainers
2
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neo4j-cypher/language-support - npm Package Compare versions

Comparing version 2.0.0-next.4 to 2.0.0-next.5

dist/types/tests/autocompletion/parameterCompletions.test.d.ts

6

CHANGELOG.md
# @neo4j-cypher/language-support
## 2.0.0-next.5
### Patch Changes
- 1f790d0: Adds auto-completion of usernames and roles
## 2.0.0-next.4

@@ -4,0 +10,0 @@

2

dist/types/autocompletion/autocompletion.d.ts
import { CompletionItem } from 'vscode-languageserver-types';
import { DbSchema } from '../dbSchema';
export declare function autocomplete(query: string, dbSchema: DbSchema, caretPosition?: number): CompletionItem[];
export declare function autocomplete(query: string, dbSchema: DbSchema, caretPosition?: number, manual?: boolean): CompletionItem[];
import { CompletionItem } from 'vscode-languageserver-types';
import { DbSchema } from '../dbSchema';
import { ParsedStatement } from '../parserWrapper';
export declare function completionCoreCompletion(parsingResult: ParsedStatement, dbSchema: DbSchema): CompletionItem[];
export declare function completionCoreCompletion(parsingResult: ParsedStatement, dbSchema: DbSchema, manualTrigger?: boolean): CompletionItem[];

@@ -7,2 +7,4 @@ import { Neo4jFunction, Neo4jProcedure } from './types';

aliasNames?: string[];
userNames?: string[];
roleNames?: string[];
parameters?: Record<string, unknown>;

@@ -9,0 +11,0 @@ propertyKeys?: string[];

@@ -6,306 +6,315 @@ import { ATN, CharStream, DFA, Lexer } from "antlr4";

static readonly HISTORY = 3;
static readonly SPACE = 4;
static readonly SINGLE_LINE_COMMENT = 5;
static readonly DECIMAL_DOUBLE = 6;
static readonly UNSIGNED_DECIMAL_INTEGER = 7;
static readonly UNSIGNED_HEX_INTEGER = 8;
static readonly UNSIGNED_OCTAL_INTEGER = 9;
static readonly ACCESS = 10;
static readonly ACTIVE = 11;
static readonly ADMIN = 12;
static readonly ADMINISTRATOR = 13;
static readonly ALIAS = 14;
static readonly ALIASES = 15;
static readonly ALL_SHORTEST_PATH = 16;
static readonly ALL = 17;
static readonly ALTER = 18;
static readonly AND = 19;
static readonly ANY = 20;
static readonly ARRAY = 21;
static readonly AS = 22;
static readonly ASC = 23;
static readonly ASSERT = 24;
static readonly ASSIGN = 25;
static readonly AT = 26;
static readonly BAR = 27;
static readonly BINDINGS = 28;
static readonly BOOL = 29;
static readonly BOOLEAN = 30;
static readonly BOOSTED = 31;
static readonly BREAK = 32;
static readonly BRIEF = 33;
static readonly BTREE = 34;
static readonly BUILT = 35;
static readonly BY = 36;
static readonly CALL = 37;
static readonly CASE = 38;
static readonly CHANGE = 39;
static readonly CIDR = 40;
static readonly COLLECT = 41;
static readonly COLON = 42;
static readonly COLONCOLON = 43;
static readonly COMMA = 44;
static readonly COMMAND = 45;
static readonly COMMANDS = 46;
static readonly COMMIT = 47;
static readonly COMPOSITE = 48;
static readonly CONSTRAINT = 49;
static readonly CONSTRAINTS = 50;
static readonly CONTAINS = 51;
static readonly COPY = 52;
static readonly CONTINUE = 53;
static readonly COUNT = 54;
static readonly CREATE = 55;
static readonly CSV = 56;
static readonly CURRENT = 57;
static readonly DATA = 58;
static readonly DATABASE = 59;
static readonly DATABASES = 60;
static readonly DATE = 61;
static readonly DATETIME = 62;
static readonly DBMS = 63;
static readonly DEALLOCATE = 64;
static readonly DEFAULT = 65;
static readonly DEFINED = 66;
static readonly DELETE = 67;
static readonly DENY = 68;
static readonly DESC = 69;
static readonly DESTROY = 70;
static readonly DETACH = 71;
static readonly DIFFERENT = 72;
static readonly DOLLAR = 73;
static readonly DISTINCT = 74;
static readonly DIVIDE = 75;
static readonly DOT = 76;
static readonly DOTDOT = 77;
static readonly DRIVER = 78;
static readonly DROP = 79;
static readonly DRYRUN = 80;
static readonly DUMP = 81;
static readonly DURATION = 82;
static readonly EACH = 83;
static readonly EDGE = 84;
static readonly ENABLE = 85;
static readonly ELEMENT = 86;
static readonly ELEMENTS = 87;
static readonly ELSE = 88;
static readonly ENCRYPTED = 89;
static readonly END = 90;
static readonly ENDS = 91;
static readonly EQ = 92;
static readonly EXECUTABLE = 93;
static readonly EXECUTE = 94;
static readonly EXIST = 95;
static readonly EXISTENCE = 96;
static readonly EXISTS = 97;
static readonly ERROR = 98;
static readonly FAIL = 99;
static readonly FALSE = 100;
static readonly FIELDTERMINATOR = 101;
static readonly FLOAT = 102;
static readonly FOR = 103;
static readonly FOREACH = 104;
static readonly FROM = 105;
static readonly FULLTEXT = 106;
static readonly FUNCTION = 107;
static readonly FUNCTIONS = 108;
static readonly GE = 109;
static readonly GRANT = 110;
static readonly GRAPH = 111;
static readonly GRAPHS = 112;
static readonly GROUP = 113;
static readonly GROUPS = 114;
static readonly GT = 115;
static readonly HEADERS = 116;
static readonly HOME = 117;
static readonly IF = 118;
static readonly IMPERSONATE = 119;
static readonly IMMUTABLE = 120;
static readonly IN = 121;
static readonly INDEX = 122;
static readonly INDEXES = 123;
static readonly INF = 124;
static readonly INFINITY = 125;
static readonly INT = 126;
static readonly INTEGER = 127;
static readonly IS = 128;
static readonly JOIN = 129;
static readonly KEY = 130;
static readonly LABEL = 131;
static readonly LABELS = 132;
static readonly AMPERSAND = 133;
static readonly EXCLAMATION_MARK = 134;
static readonly LBRACKET = 135;
static readonly LCURLY = 136;
static readonly LE = 137;
static readonly LIMITROWS = 138;
static readonly LIST = 139;
static readonly LOAD = 140;
static readonly LOCAL = 141;
static readonly LOOKUP = 142;
static readonly LPAREN = 143;
static readonly LT = 144;
static readonly MANAGEMENT = 145;
static readonly MAP = 146;
static readonly MATCH = 147;
static readonly MERGE = 148;
static readonly MINUS = 149;
static readonly PERCENT = 150;
static readonly NEQ = 151;
static readonly NEQ2 = 152;
static readonly NAME = 153;
static readonly NAMES = 154;
static readonly NAN = 155;
static readonly NEW = 156;
static readonly NODE = 157;
static readonly NODES = 158;
static readonly NONE = 159;
static readonly NOT = 160;
static readonly NOTHING = 161;
static readonly NOWAIT = 162;
static readonly NULL = 163;
static readonly OF = 164;
static readonly ON = 165;
static readonly ONLY = 166;
static readonly OPTIONAL = 167;
static readonly OPTIONS = 168;
static readonly OPTION = 169;
static readonly OR = 170;
static readonly ORDER = 171;
static readonly OUTPUT = 172;
static readonly PASSWORD = 173;
static readonly PASSWORDS = 174;
static readonly PATH = 175;
static readonly PATHS = 176;
static readonly PERIODIC = 177;
static readonly PLAINTEXT = 178;
static readonly PLUS = 179;
static readonly PLUSEQUAL = 180;
static readonly POINT = 181;
static readonly POPULATED = 182;
static readonly POW = 183;
static readonly PRIMARY = 184;
static readonly PRIMARIES = 185;
static readonly PRIVILEGE = 186;
static readonly PRIVILEGES = 187;
static readonly PROCEDURE = 188;
static readonly PROCEDURES = 189;
static readonly PROPERTIES = 190;
static readonly PROPERTY = 191;
static readonly QUESTION = 192;
static readonly RANGE = 193;
static readonly RBRACKET = 194;
static readonly RCURLY = 195;
static readonly READ = 196;
static readonly REALLOCATE = 197;
static readonly REDUCE = 198;
static readonly RENAME = 199;
static readonly REGEQ = 200;
static readonly REL = 201;
static readonly RELATIONSHIP = 202;
static readonly RELATIONSHIPS = 203;
static readonly REMOVE = 204;
static readonly REPEATABLE = 205;
static readonly REPLACE = 206;
static readonly REPORT = 207;
static readonly REQUIRE = 208;
static readonly REQUIRED = 209;
static readonly RETURN = 210;
static readonly REVOKE = 211;
static readonly ROLE = 212;
static readonly ROLES = 213;
static readonly ROW = 214;
static readonly ROWS = 215;
static readonly RPAREN = 216;
static readonly SCAN = 217;
static readonly SEC = 218;
static readonly SECOND = 219;
static readonly SECONDARY = 220;
static readonly SECONDARIES = 221;
static readonly SECONDS = 222;
static readonly SEEK = 223;
static readonly SEMICOLON = 224;
static readonly SERVER = 225;
static readonly SERVERS = 226;
static readonly SET = 227;
static readonly SETTING = 228;
static readonly SETTINGS = 229;
static readonly SHORTEST_PATH = 230;
static readonly SHORTEST = 231;
static readonly SHOW = 232;
static readonly SIGNED = 233;
static readonly SINGLE = 234;
static readonly SKIPROWS = 235;
static readonly START = 236;
static readonly STARTS = 237;
static readonly STATUS = 238;
static readonly STOP = 239;
static readonly STRING = 240;
static readonly SUPPORTED = 241;
static readonly SUSPENDED = 242;
static readonly TARGET = 243;
static readonly TERMINATE = 244;
static readonly TEXT = 245;
static readonly THEN = 246;
static readonly TIME = 247;
static readonly TIMES = 248;
static readonly TIMESTAMP = 249;
static readonly TIMEZONE = 250;
static readonly TO = 251;
static readonly TOPOLOGY = 252;
static readonly TRANSACTION = 253;
static readonly TRANSACTIONS = 254;
static readonly TRAVERSE = 255;
static readonly TRUE = 256;
static readonly TYPE = 257;
static readonly TYPED = 258;
static readonly TYPES = 259;
static readonly UNION = 260;
static readonly UNIQUE = 261;
static readonly UNIQUENESS = 262;
static readonly UNWIND = 263;
static readonly URL = 264;
static readonly USE = 265;
static readonly USER = 266;
static readonly USERS = 267;
static readonly USING = 268;
static readonly VALUE = 269;
static readonly VARCHAR = 270;
static readonly VERBOSE = 271;
static readonly VERTEX = 272;
static readonly WAIT = 273;
static readonly WHEN = 274;
static readonly WHERE = 275;
static readonly WITH = 276;
static readonly WITHOUT = 277;
static readonly WRITE = 278;
static readonly XOR = 279;
static readonly YIELD = 280;
static readonly ZONED = 281;
static readonly EXPLAIN = 282;
static readonly PROFILE = 283;
static readonly IDENTIFIER = 284;
static readonly ErrorChar = 285;
static readonly ARROW_LINE = 286;
static readonly ARROW_LEFT_HEAD = 287;
static readonly ARROW_RIGHT_HEAD = 288;
static readonly FORMAL_COMMENT = 289;
static readonly STRING_LITERAL1 = 290;
static readonly STRING_LITERAL2 = 291;
static readonly MULTI_LINE_COMMENT = 292;
static readonly ESCAPED_SYMBOLIC_NAME = 293;
static readonly MORE1 = 294;
static readonly STRING1_OPEN = 295;
static readonly STRING2_OPEN = 296;
static readonly ESCAPED_SYMBOLIC_NAME_OPEN = 297;
static readonly MORE3 = 298;
static readonly MORE4 = 299;
static readonly MORE5 = 300;
static readonly MORE6 = 301;
static readonly MORE7 = 302;
static readonly MORE8 = 303;
static readonly MORE9 = 304;
static readonly MORE10 = 305;
static readonly MORE11 = 306;
static readonly MORE24 = 307;
static readonly EXPLAIN = 4;
static readonly PROFILE = 5;
static readonly SPACE = 6;
static readonly SINGLE_LINE_COMMENT = 7;
static readonly DECIMAL_DOUBLE = 8;
static readonly UNSIGNED_DECIMAL_INTEGER = 9;
static readonly UNSIGNED_HEX_INTEGER = 10;
static readonly UNSIGNED_OCTAL_INTEGER = 11;
static readonly ACCESS = 12;
static readonly ACTIVE = 13;
static readonly ADMIN = 14;
static readonly ADMINISTRATOR = 15;
static readonly ALIAS = 16;
static readonly ALIASES = 17;
static readonly ALL_SHORTEST_PATH = 18;
static readonly ALL = 19;
static readonly ALTER = 20;
static readonly AND = 21;
static readonly ANY = 22;
static readonly ARRAY = 23;
static readonly AS = 24;
static readonly ASC = 25;
static readonly ASCENDING = 26;
static readonly ASSERT = 27;
static readonly ASSIGN = 28;
static readonly AT = 29;
static readonly BAR = 30;
static readonly BINDINGS = 31;
static readonly BOOLEAN = 32;
static readonly BOOSTED = 33;
static readonly BREAK = 34;
static readonly BRIEF = 35;
static readonly BTREE = 36;
static readonly BUILT = 37;
static readonly BY = 38;
static readonly CALL = 39;
static readonly CASE = 40;
static readonly CHANGE = 41;
static readonly CIDR = 42;
static readonly COLLECT = 43;
static readonly COLON = 44;
static readonly COLONCOLON = 45;
static readonly COMMA = 46;
static readonly COMMAND = 47;
static readonly COMMANDS = 48;
static readonly COMMIT = 49;
static readonly COMPOSITE = 50;
static readonly CONCURRENT = 51;
static readonly CONSTRAINT = 52;
static readonly CONSTRAINTS = 53;
static readonly CONTAINS = 54;
static readonly COPY = 55;
static readonly CONTINUE = 56;
static readonly COUNT = 57;
static readonly CREATE = 58;
static readonly CSV = 59;
static readonly CURRENT = 60;
static readonly DATA = 61;
static readonly DATABASE = 62;
static readonly DATABASES = 63;
static readonly DATE = 64;
static readonly DATETIME = 65;
static readonly DBMS = 66;
static readonly DEALLOCATE = 67;
static readonly DEFAULT = 68;
static readonly DEFINED = 69;
static readonly DELETE = 70;
static readonly DENY = 71;
static readonly DESC = 72;
static readonly DESCENDING = 73;
static readonly DESTROY = 74;
static readonly DETACH = 75;
static readonly DIFFERENT = 76;
static readonly DOLLAR = 77;
static readonly DISTINCT = 78;
static readonly DIVIDE = 79;
static readonly DOT = 80;
static readonly DOTDOT = 81;
static readonly DRIVER = 82;
static readonly DROP = 83;
static readonly DRYRUN = 84;
static readonly DUMP = 85;
static readonly DURATION = 86;
static readonly EACH = 87;
static readonly EDGE = 88;
static readonly ENABLE = 89;
static readonly ELEMENT = 90;
static readonly ELEMENTS = 91;
static readonly ELSE = 92;
static readonly ENCRYPTED = 93;
static readonly END = 94;
static readonly ENDS = 95;
static readonly EQ = 96;
static readonly EXECUTABLE = 97;
static readonly EXECUTE = 98;
static readonly EXIST = 99;
static readonly EXISTENCE = 100;
static readonly EXISTS = 101;
static readonly ERROR = 102;
static readonly FAIL = 103;
static readonly FALSE = 104;
static readonly FIELDTERMINATOR = 105;
static readonly FLOAT = 106;
static readonly FOR = 107;
static readonly FOREACH = 108;
static readonly FROM = 109;
static readonly FULLTEXT = 110;
static readonly FUNCTION = 111;
static readonly FUNCTIONS = 112;
static readonly GE = 113;
static readonly GRANT = 114;
static readonly GRAPH = 115;
static readonly GRAPHS = 116;
static readonly GROUP = 117;
static readonly GROUPS = 118;
static readonly GT = 119;
static readonly HEADERS = 120;
static readonly HOME = 121;
static readonly IF = 122;
static readonly IMPERSONATE = 123;
static readonly IMMUTABLE = 124;
static readonly IN = 125;
static readonly INDEX = 126;
static readonly INDEXES = 127;
static readonly INFINITY = 128;
static readonly INSERT = 129;
static readonly INT = 130;
static readonly INTEGER = 131;
static readonly IS = 132;
static readonly JOIN = 133;
static readonly KEY = 134;
static readonly LABEL = 135;
static readonly LABELS = 136;
static readonly AMPERSAND = 137;
static readonly EXCLAMATION_MARK = 138;
static readonly LBRACKET = 139;
static readonly LCURLY = 140;
static readonly LE = 141;
static readonly LIMITROWS = 142;
static readonly LIST = 143;
static readonly LOAD = 144;
static readonly LOCAL = 145;
static readonly LOOKUP = 146;
static readonly LPAREN = 147;
static readonly LT = 148;
static readonly MANAGEMENT = 149;
static readonly MAP = 150;
static readonly MATCH = 151;
static readonly MERGE = 152;
static readonly MINUS = 153;
static readonly PERCENT = 154;
static readonly INVALID_NEQ = 155;
static readonly NEQ = 156;
static readonly NAME = 157;
static readonly NAMES = 158;
static readonly NAN = 159;
static readonly NFC = 160;
static readonly NFD = 161;
static readonly NFKC = 162;
static readonly NFKD = 163;
static readonly NEW = 164;
static readonly NODE = 165;
static readonly NODETACH = 166;
static readonly NODES = 167;
static readonly NONE = 168;
static readonly NORMALIZE = 169;
static readonly NORMALIZED = 170;
static readonly NOT = 171;
static readonly NOTHING = 172;
static readonly NOWAIT = 173;
static readonly NULL = 174;
static readonly OF = 175;
static readonly ON = 176;
static readonly ONLY = 177;
static readonly OPTIONAL = 178;
static readonly OPTIONS = 179;
static readonly OPTION = 180;
static readonly OR = 181;
static readonly ORDER = 182;
static readonly OUTPUT = 183;
static readonly PASSWORD = 184;
static readonly PASSWORDS = 185;
static readonly PATH = 186;
static readonly PATHS = 187;
static readonly PERIODIC = 188;
static readonly PLAINTEXT = 189;
static readonly PLUS = 190;
static readonly PLUSEQUAL = 191;
static readonly POINT = 192;
static readonly POPULATED = 193;
static readonly POW = 194;
static readonly PRIMARY = 195;
static readonly PRIMARIES = 196;
static readonly PRIVILEGE = 197;
static readonly PRIVILEGES = 198;
static readonly PROCEDURE = 199;
static readonly PROCEDURES = 200;
static readonly PROPERTIES = 201;
static readonly PROPERTY = 202;
static readonly QUESTION = 203;
static readonly RANGE = 204;
static readonly RBRACKET = 205;
static readonly RCURLY = 206;
static readonly READ = 207;
static readonly REALLOCATE = 208;
static readonly REDUCE = 209;
static readonly RENAME = 210;
static readonly REGEQ = 211;
static readonly REL = 212;
static readonly RELATIONSHIP = 213;
static readonly RELATIONSHIPS = 214;
static readonly REMOVE = 215;
static readonly REPEATABLE = 216;
static readonly REPLACE = 217;
static readonly REPORT = 218;
static readonly REQUIRE = 219;
static readonly REQUIRED = 220;
static readonly RETURN = 221;
static readonly REVOKE = 222;
static readonly ROLE = 223;
static readonly ROLES = 224;
static readonly ROW = 225;
static readonly ROWS = 226;
static readonly RPAREN = 227;
static readonly SCAN = 228;
static readonly SEC = 229;
static readonly SECOND = 230;
static readonly SECONDARY = 231;
static readonly SECONDARIES = 232;
static readonly SECONDS = 233;
static readonly SEEK = 234;
static readonly SEMICOLON = 235;
static readonly SERVER = 236;
static readonly SERVERS = 237;
static readonly SET = 238;
static readonly SETTING = 239;
static readonly SETTINGS = 240;
static readonly SHORTEST_PATH = 241;
static readonly SHORTEST = 242;
static readonly SHOW = 243;
static readonly SIGNED = 244;
static readonly SINGLE = 245;
static readonly SKIPROWS = 246;
static readonly START = 247;
static readonly STARTS = 248;
static readonly STATUS = 249;
static readonly STOP = 250;
static readonly STRING = 251;
static readonly SUPPORTED = 252;
static readonly SUSPENDED = 253;
static readonly TARGET = 254;
static readonly TERMINATE = 255;
static readonly TEXT = 256;
static readonly THEN = 257;
static readonly TIME = 258;
static readonly TIMES = 259;
static readonly TIMESTAMP = 260;
static readonly TIMEZONE = 261;
static readonly TO = 262;
static readonly TOPOLOGY = 263;
static readonly TRANSACTION = 264;
static readonly TRANSACTIONS = 265;
static readonly TRAVERSE = 266;
static readonly TRUE = 267;
static readonly TYPE = 268;
static readonly TYPED = 269;
static readonly TYPES = 270;
static readonly UNION = 271;
static readonly UNIQUE = 272;
static readonly UNIQUENESS = 273;
static readonly UNWIND = 274;
static readonly URL = 275;
static readonly USE = 276;
static readonly USER = 277;
static readonly USERS = 278;
static readonly USING = 279;
static readonly VALUE = 280;
static readonly VECTOR = 281;
static readonly VERBOSE = 282;
static readonly VERTEX = 283;
static readonly WAIT = 284;
static readonly WHEN = 285;
static readonly WHERE = 286;
static readonly WITH = 287;
static readonly WITHOUT = 288;
static readonly WRITE = 289;
static readonly XOR = 290;
static readonly YIELD = 291;
static readonly ZONED = 292;
static readonly IDENTIFIER = 293;
static readonly ErrorChar = 294;
static readonly ARROW_LINE = 295;
static readonly ARROW_LEFT_HEAD = 296;
static readonly ARROW_RIGHT_HEAD = 297;
static readonly FORMAL_COMMENT = 298;
static readonly STRING_LITERAL1 = 299;
static readonly STRING_LITERAL2 = 300;
static readonly MULTI_LINE_COMMENT = 301;
static readonly ESCAPED_SYMBOLIC_NAME = 302;
static readonly MORE1 = 303;
static readonly STRING1_OPEN = 304;
static readonly STRING2_OPEN = 305;
static readonly ESCAPED_SYMBOLIC_NAME_OPEN = 306;
static readonly MORE3 = 307;
static readonly MORE4 = 308;
static readonly MORE5 = 309;
static readonly MORE6 = 310;
static readonly MORE7 = 311;
static readonly MORE8 = 312;
static readonly MORE9 = 313;
static readonly MORE10 = 314;
static readonly MORE11 = 315;
static readonly MORE24 = 316;
static readonly EOF: number;

@@ -312,0 +321,0 @@ static readonly IN_FORMAL_COMMENT = 1;

@@ -28,4 +28,5 @@ import antlrDefaultExport, { CommonTokenStream, ParserRuleContext, ParseTree, Token } from 'antlr4';

export declare function splitIntoStatements(tokenStream: CommonTokenStream, lexer: CypherLexer): CommonTokenStream[];
export declare function findPreviousNonSpace(tokens: Token[], index: number): Token | undefined;
export declare const rulesDefiningVariables: number[];
export declare const rulesDefiningOrUsingVariables: number[];
export {};
import { CompletionItem } from 'vscode-languageserver-types';
import { DbSchema } from '../../dbSchema';
export declare function testCompletions({ query, offset, dbSchema, excluded, expected, assertEmpty, }: {
export declare function testCompletionsExactly({ query, offset, dbSchema, expected, }: {
query: string;
offset?: number;
dbSchema?: DbSchema;
expected?: CompletionItem[];
}): void;
export declare function testCompletions({ query, offset, dbSchema, excluded, expected, assertEmpty, manualTrigger, }: {
query: string;
offset?: number;
dbSchema?: DbSchema;
excluded?: Partial<CompletionItem>[];
expected?: CompletionItem[];
assertEmpty?: boolean;
manualTrigger?: boolean;
}): void;

@@ -21,3 +21,3 @@ {

],
"version": "2.0.0-next.4",
"version": "2.0.0-next.5",
"main": "./dist/cjs/index.cjs",

@@ -24,0 +24,0 @@ "module": "./dist/esm/index.mjs",

@@ -12,2 +12,3 @@ import { CompletionItem } from 'vscode-languageserver-types';

caretPosition: number = query.length,
manual = false,
): CompletionItem[] {

@@ -30,3 +31,3 @@ const parsingResult = parserWrapper.parse(query);

const statement = caret.statement;
return completionCoreCompletion(statement, dbSchema);
return completionCoreCompletion(statement, dbSchema, manual);
}

@@ -33,0 +34,0 @@

@@ -7,2 +7,3 @@ import { Token } from 'antlr4';

CompletionItemKind,
InsertTextFormat,
} from 'vscode-languageserver-types';

@@ -14,3 +15,3 @@ import { DbSchema } from '../dbSchema';

} from '../generated-parser/CypherCmdParser';
import { rulesDefiningVariables } from '../helpers';
import { findPreviousNonSpace, rulesDefiningVariables } from '../helpers';
import {

@@ -220,2 +221,3 @@ CypherTokenType,

const parentRule = context.ruleList.at(-1);
const grandParentRule = context.ruleList.at(-2);
if (

@@ -225,4 +227,18 @@ [

CypherParser.RULE_symbolicNameOrStringParameter,
CypherParser.RULE_symbolicNameOrStringParameterList,
CypherParser.RULE_symbolicAliasNameOrParameter,
CypherParser.RULE_passwordExpression,
].includes(parentRule)
CypherParser.RULE_createUser,
CypherParser.RULE_dropUser,
CypherParser.RULE_alterUser,
CypherParser.RULE_renameUser,
CypherParser.RULE_createRole,
CypherParser.RULE_dropRole,
CypherParser.RULE_renameRole,
CypherParser.RULE_revokeRole,
].includes(parentRule) ||
[
CypherParser.RULE_showUserPrivileges,
CypherParser.RULE_grantRole,
].includes(grandParentRule)
) {

@@ -292,2 +308,3 @@ return ExpectedParameterType.String;

dbSchema: DbSchema,
manualTrigger = false,
): CompletionItem[] {

@@ -312,6 +329,6 @@ const parser = parsingResult.parser;

// If the previous token is an identifier, we don't count it as "finished" so we move the caret back one token
// The identfier is finished when the last token is a SPACE or dot etc. etc.
// The identifier is finished when the last token is a SPACE or dot etc. etc.
// this allows us to give completions that replace the current text => for example `RET` <- it's parsed as an identifier
// The need for this caret movement is outlined in the documentation of antlr4-c3 in the section about caret position
// When an identifer overlaps with a keyword, it's no longer treates as an identifier (although it's a valid identifier)
// When an identifier overlaps with a keyword, it's no longer treats as an identifier (although it's a valid identifier)
// So we need to move the caret back for keywords as well

@@ -334,2 +351,5 @@ const previousToken = tokens[caretIndex - 1]?.type;

CypherParser.RULE_variable,
CypherParser.RULE_leftArrow,
// this rule is used for usernames and roles.
CypherParser.RULE_symbolicNameOrStringParameter,

@@ -392,3 +412,3 @@ // Either enable the helper rules for lexer clashes,

if (
parentRule === CypherParser.RULE_mapLiteral &&
parentRule === CypherParser.RULE_map &&
grandParentRule === CypherParser.RULE_literal

@@ -407,3 +427,3 @@ ) {

parentRule === CypherParser.RULE_property &&
grandParentRule == CypherParser.RULE_postFix1 &&
grandParentRule == CypherParser.RULE_postFix &&
greatGrandParentRule === CypherParser.RULE_expression2

@@ -446,2 +466,6 @@ ) {

if (ruleNumber === CypherParser.RULE_symbolicNameOrStringParameter) {
return completeSymbolicName({ candidateRule, dbSchema, parsingResult });
}
if (ruleNumber === CypherParser.RULE_labelExpression1) {

@@ -466,8 +490,3 @@ const topExprIndex = candidateRule.ruleList.indexOf(

if (topExprParent === CypherParser.RULE_labelExpressionPredicate) {
return [
...labelCompletions(dbSchema),
...reltypeCompletions(dbSchema),
];
}
return [...labelCompletions(dbSchema), ...reltypeCompletions(dbSchema)];
}

@@ -484,2 +503,34 @@

if (ruleNumber === CypherParser.RULE_leftArrow) {
return [
{
label: '-[]->()',
kind: CompletionItemKind.Snippet,
insertTextFormat: InsertTextFormat.Snippet,
insertText: '-[${1: }]->(${2: })',
detail: 'path template',
// vscode does not call the completion provider for every single character
// after the second character is typed (i.e) `MATCH ()-[` the completion is no longer valid
// it'd insert `MATCH ()-[[]->()` which is not valid. Hence we filter it out by using the filterText
filterText: '',
},
{
label: '-[]-()',
kind: CompletionItemKind.Snippet,
insertTextFormat: InsertTextFormat.Snippet,
insertText: '-[${1: }]-(${2: })',
detail: 'path template',
filterText: '',
},
{
label: '<-[]-()',
kind: CompletionItemKind.Snippet,
insertTextFormat: InsertTextFormat.Snippet,
insertText: '<-[${1: }]-(${2: })',
detail: 'path template',
filterText: '',
},
];
}
return [];

@@ -489,2 +540,10 @@ },

// if the completion was automatically triggered by a snippet trigger character
// we should only return snippet completions
if (CypherLexer.RPAREN === previousToken && !manualTrigger) {
return ruleCompletions.filter(
(completion) => completion.kind === CompletionItemKind.Snippet,
);
}
return [

@@ -570,1 +629,80 @@ ...ruleCompletions,

}
function completeSymbolicName({
candidateRule,
dbSchema,
parsingResult,
}: CompletionHelperArgs): CompletionItem[] {
// parameters are valid values in all cases of symbolic name
const baseSuggestions = parameterCompletions(
dbSchema,
inferExpectedParameterTypeFromContext(candidateRule),
);
const rulesCreatingNewUserOrRole = [
CypherParser.RULE_createUser,
CypherParser.RULE_createRole,
];
const previousToken = findPreviousNonSpace(
parsingResult.tokens,
candidateRule.startTokenIndex,
);
const afterToToken = previousToken.type === CypherParser.TO;
const ruleList = candidateRule.ruleList;
// avoid suggesting existing user names or role names when creating a new one
if (
rulesCreatingNewUserOrRole.some((rule) => ruleList.includes(rule)) ||
// We are suggesting an user as target for the renaming
// RENAME USER existing TO target
// so target should be non-existent
(ruleList.includes(CypherParser.RULE_renameUser) && afterToToken)
) {
return baseSuggestions;
}
const rulesThatAcceptExistingUsers = [
CypherParser.RULE_dropUser,
CypherParser.RULE_renameUser,
CypherParser.RULE_alterUser,
CypherParser.RULE_showUserPrivileges,
CypherParser.RULE_roleUser,
CypherParser.RULE_showPrivilege,
CypherParser.RULE_dbmsPrivilege,
CypherParser.RULE_databasePrivilege,
];
if (rulesThatAcceptExistingUsers.some((rule) => ruleList.includes(rule))) {
return [
...baseSuggestions,
...(dbSchema?.userNames ?? []).map((userName) => ({
label: userName,
kind: CompletionItemKind.Value,
})),
];
}
const rulesThatAcceptExistingRoles = [
CypherParser.RULE_grantRole,
CypherParser.RULE_revokeRole,
CypherParser.RULE_dropRole,
CypherParser.RULE_renameRole,
CypherParser.RULE_showRolePrivileges,
CypherParser.RULE_grantRoleManagement,
CypherParser.RULE_revokeRoleManagement,
CypherParser.RULE_grantPrivilege,
CypherParser.RULE_denyPrivilege,
CypherParser.RULE_revokePrivilege,
];
if (rulesThatAcceptExistingRoles.some((rule) => ruleList.includes(rule))) {
return [
...baseSuggestions,
...(dbSchema?.roleNames ?? []).map((roleName) => ({
label: roleName,
kind: CompletionItemKind.Value,
})),
];
}
}

@@ -8,2 +8,4 @@ import { Neo4jFunction, Neo4jProcedure } from './types';

aliasNames?: string[];
userNames?: string[];
roleNames?: string[];
parameters?: Record<string, unknown>;

@@ -10,0 +12,0 @@ propertyKeys?: string[];

@@ -179,2 +179,18 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment

export function findPreviousNonSpace(
tokens: Token[],
index: number,
): Token | undefined {
let i = index;
while (i > 0) {
const token = tokens[--i];
if (token.type !== CypherParser.SPACE) {
return token;
}
}
return undefined;
}
export const rulesDefiningVariables = [

@@ -188,6 +204,3 @@ CypherParser.RULE_returnItem,

CypherParser.RULE_reduceExpression,
CypherParser.RULE_allExpression,
CypherParser.RULE_anyExpression,
CypherParser.RULE_noneExpression,
CypherParser.RULE_singleExpression,
CypherParser.RULE_listItemsPredicate,
CypherParser.RULE_listComprehension,

@@ -194,0 +207,0 @@ ];

@@ -45,3 +45,3 @@ import CypherLexer from './generated-parser/CypherCmdLexer';

CypherLexer.NEQ,
CypherLexer.NEQ2,
CypherLexer.INVALID_NEQ,
CypherLexer.PERCENT,

@@ -129,2 +129,3 @@ CypherLexer.PLUS,

CypherLexer.ASC,
CypherLexer.ASCENDING,
CypherLexer.ASSERT,

@@ -134,3 +135,2 @@ CypherLexer.ASSIGN,

CypherLexer.BINDINGS,
CypherLexer.BOOL,
CypherLexer.BOOLEAN,

@@ -160,2 +160,3 @@ CypherLexer.BOOSTED,

CypherLexer.CSV,
CypherLexer.CONCURRENT,
CypherLexer.CURRENT,

@@ -174,2 +175,3 @@ CypherLexer.DATA,

CypherLexer.DESC,
CypherLexer.DESCENDING,
CypherLexer.DESTROY,

@@ -222,4 +224,4 @@ CypherLexer.DETACH,

CypherLexer.INDEXES,
CypherLexer.INF,
CypherLexer.INFINITY,
CypherLexer.INSERT,
CypherLexer.INT,

@@ -245,5 +247,12 @@ CypherLexer.INTEGER,

CypherLexer.NEW,
CypherLexer.NFC,
CypherLexer.NFD,
CypherLexer.NFKC,
CypherLexer.NFKD,
CypherLexer.NODE,
CypherLexer.NODETACH,
CypherLexer.NODES,
CypherLexer.NONE,
CypherLexer.NORMALIZE,
CypherLexer.NORMALIZED,
CypherLexer.NOT,

@@ -349,3 +358,3 @@ CypherLexer.NOTHING,

CypherLexer.VALUE,
CypherLexer.VARCHAR,
CypherLexer.VECTOR,
CypherLexer.VERBOSE,

@@ -352,0 +361,0 @@ CypherLexer.VERTEX,

@@ -300,3 +300,3 @@ import type { ParserRuleContext, Token } from 'antlr4';

const cypherStmt = stmt.statement();
const cypherStmt = stmt.preparsedStatement();
if (cypherStmt) {

@@ -349,3 +349,3 @@ // we get the original text input to preserve whitespace

const names = cypherMap
?.symbolicNameString_list()
?.propertyKeyName_list()
.map((name) => name.getText());

@@ -352,0 +352,0 @@ const expressions = cypherMap

import { ParseTreeWalker, TerminalNode, Token } from 'antlr4';
import {
AllExpressionContext,
AnyExpressionContext,
ArrowLineContext,

@@ -15,3 +13,3 @@ BooleanLiteralContext,

LeftArrowContext,
NoneExpressionContext,
ListItemsPredicateContext,
NumberLiteralContext,

@@ -25,5 +23,4 @@ ParameterContext,

RightArrowContext,
SingleExpressionContext,
StringLiteralContext,
StringsLiteralContext,
StringTokenContext,
SymbolicNameStringContext,

@@ -183,3 +180,4 @@ UseCompletionRuleContext,

exitStringToken = (ctx: StringTokenContext) => {
// TODO Do we need this one and the one below?
exitStringLiteral = (ctx: StringLiteralContext) => {
this.addToken(ctx.start, CypherTokenType.stringLiteral, ctx.getText());

@@ -216,18 +214,9 @@ };

exitAllExpression = (ctx: AllExpressionContext) => {
this.colourPredicateFunction(ctx.ALL());
exitListItemsPredicate = (ctx: ListItemsPredicateContext) => {
if (ctx.ANY()) this.colourPredicateFunction(ctx.ANY());
if (ctx.ALL()) this.colourPredicateFunction(ctx.ALL());
if (ctx.NONE()) this.colourPredicateFunction(ctx.NONE());
if (ctx.SINGLE()) this.colourPredicateFunction(ctx.SINGLE());
};
exitAnyExpression = (ctx: AnyExpressionContext) => {
this.colourPredicateFunction(ctx.ANY());
};
exitNoneExpression = (ctx: NoneExpressionContext) => {
this.colourPredicateFunction(ctx.NONE());
};
exitSingleExpression = (ctx: SingleExpressionContext) => {
this.colourPredicateFunction(ctx.SINGLE());
};
exitReduceExpression = (ctx: ReduceExpressionContext) => {

@@ -234,0 +223,0 @@ this.colourPredicateFunction(ctx.REDUCE());

@@ -42,4 +42,3 @@ import { Token } from 'antlr4';

[CypherParser.RULE_procedureName]: 'a procedure name',
[CypherParser.RULE_stringToken]: 'a string',
[CypherParser.RULE_mapLiteral]: 'a map literal',
[CypherParser.RULE_stringLiteral]: 'a string',
[CypherParser.RULE_numberLiteral]: 'a number literal',

@@ -46,0 +45,0 @@ [CypherParser.RULE_parameter]: 'a parameter',

@@ -5,2 +5,17 @@ import { CompletionItem } from 'vscode-languageserver-types';

export function testCompletionsExactly({
query,
offset = query.length,
dbSchema = {},
expected = [],
}: {
query: string;
offset?: number;
dbSchema?: DbSchema;
expected?: CompletionItem[];
}) {
const actualCompletionList = autocomplete(query, dbSchema, offset);
expect(actualCompletionList).toEqual(expected);
}
export function testCompletions({

@@ -13,2 +28,3 @@ query,

assertEmpty = false,
manualTrigger = false,
}: {

@@ -21,4 +37,10 @@ query: string;

assertEmpty?: boolean;
manualTrigger?: boolean;
}) {
const actualCompletionList = autocomplete(query, dbSchema, offset);
const actualCompletionList = autocomplete(
query,
dbSchema,
offset,
manualTrigger,
);

@@ -25,0 +47,0 @@ if (assertEmpty) {

@@ -5,3 +5,3 @@ import { CompletionItemKind } from 'vscode-languageserver-types';

describe('can complete database names', () => {
describe('Can complete database names', () => {
const dbSchema: DbSchema = {

@@ -115,3 +115,3 @@ databaseNames: ['db1', 'db2', 'movies'],

test('suggest only aliases when dropping alias', () => {
test('Suggests only aliases when dropping alias', () => {
const query = 'DROP ALIAS ';

@@ -138,3 +138,3 @@ testCompletions({

test('suggest only aliases when showing alias', () => {
test('Suggests only aliases when showing alias', () => {
const query = 'SHOW ALIAS ';

@@ -159,3 +159,3 @@ testCompletions({

test('suggest only aliases when altering alias', () => {
test('Suggests only aliases when altering alias', () => {
const query = 'ALTER ALIAS a';

@@ -182,3 +182,3 @@ testCompletions({

test('can complete when typing scoped alias', () => {
test('Can complete when typing scoped alias', () => {
const query = 'ALTER ALIAS a.b.c.';

@@ -205,3 +205,3 @@ testCompletions({

test('handle that the parser allows spaces in symbolicAliasName', () => {
test('Handles that the parser allows spaces in symbolicAliasName', () => {
// Since the parser allows for spaces in the symbolicAliasName rule but not in created alias (unless quoted)

@@ -232,15 +232,11 @@ // I've added a test to verify we don't suggest aliases after the space (false positives)

describe('can complete parameters outside of database names', () => {
const dbSchema: DbSchema = {
parameters: {
stringParam: 'something',
intParam: 1337,
mapParam: {
property: 'value',
},
},
};
test('Correctly completes parameters, database names and alias in DENY PRIVILEGE TO ROLE', () => {
const cases = [
'DENY TRAVERSE ON GRAPH ',
'DENY TRAVERSE ON GRAPH neo4j, ',
'DENY INDEX MANAGEMENT ON DATABASE ',
'DENY INDEX MANAGEMENT ON DATABASE neo4j, ',
];
test('correctly completes started parameter in return body', () => {
const query = 'RETURN $';
cases.forEach((query) =>
testCompletions({

@@ -250,37 +246,30 @@ query,

expected: [
{ label: '$stringParam', kind: CompletionItemKind.Variable },
{ label: '$intParam', kind: CompletionItemKind.Variable },
{ label: '$mapParam', kind: CompletionItemKind.Variable },
{ label: 'db1', kind: CompletionItemKind.Value },
{ label: 'db2', kind: CompletionItemKind.Value },
{ label: 'movies', kind: CompletionItemKind.Value },
{ label: 'myMovies', kind: CompletionItemKind.Value },
{ label: 'scoped.alias', kind: CompletionItemKind.Value },
{ label: 'a.b.c.d', kind: CompletionItemKind.Value },
{ label: '$param1', kind: CompletionItemKind.Variable },
],
});
});
test('correctly completes unstarted parameter in return body', () => {
const query = 'RETURN ';
testCompletions({
query,
dbSchema,
expected: [
{ label: '$stringParam', kind: CompletionItemKind.Variable },
{ label: '$intParam', kind: CompletionItemKind.Variable },
{ label: '$mapParam', kind: CompletionItemKind.Variable },
excluded: [
// validate invalid keyword bug isn't present
{ label: '', kind: CompletionItemKind.Keyword },
// do not suggest non-string parameters
{ label: '$param2', kind: CompletionItemKind.Variable },
{ label: '$param3', kind: CompletionItemKind.Variable },
],
});
});
}),
);
});
test('correctly completes started parameter in where clause', () => {
const query = 'MATCH (n) WHERE ';
testCompletions({
query,
dbSchema,
expected: [
{ label: '$stringParam', kind: CompletionItemKind.Variable },
{ label: '$intParam', kind: CompletionItemKind.Variable },
{ label: '$mapParam', kind: CompletionItemKind.Variable },
],
});
});
test('Correctly completes parameters, database names and alias in GRANT PRIVILEGE TO ROLE', () => {
const cases = [
'GRANT TRAVERSE ON GRAPH ',
'GRANT TRAVERSE ON GRAPH neo4j, ',
'GRANT INDEX MANAGEMENT ON DATABASE ',
'GRANT INDEX MANAGEMENT ON DATABASE neo4j, ',
];
test('correctly completes started parameter in expression', () => {
const query = 'RETURN 1 + ';
cases.forEach((query) =>
testCompletions({

@@ -290,11 +279,30 @@ query,

expected: [
{ label: '$stringParam', kind: CompletionItemKind.Variable },
{ label: '$intParam', kind: CompletionItemKind.Variable },
{ label: '$mapParam', kind: CompletionItemKind.Variable },
{ label: 'db1', kind: CompletionItemKind.Value },
{ label: 'db2', kind: CompletionItemKind.Value },
{ label: 'movies', kind: CompletionItemKind.Value },
{ label: 'myMovies', kind: CompletionItemKind.Value },
{ label: 'scoped.alias', kind: CompletionItemKind.Value },
{ label: 'a.b.c.d', kind: CompletionItemKind.Value },
{ label: '$param1', kind: CompletionItemKind.Variable },
],
});
});
excluded: [
// validate invalid keyword bug isn't present
{ label: '', kind: CompletionItemKind.Keyword },
// do not suggest non-string parameters
{ label: '$param2', kind: CompletionItemKind.Variable },
{ label: '$param3', kind: CompletionItemKind.Variable },
],
}),
);
});
test('correctly suggests parameter in ENABLE SERVER', () => {
const query = 'ENABLE SERVER ';
test('Correctly completes parameters, database names and alias in REVOKE PRIVILEGE FROM ROLE', () => {
const cases = [
'REVOKE GRANT TRAVERSE ON GRAPH ',
'REVOKE GRANT TRAVERSE ON GRAPH neo4j, ',
'REVOKE GRANT INDEX MANAGEMENT ON DATABASE ',
'REVOKE GRANT INDEX MANAGEMENT ON DATABASE neo4j, ',
];
cases.forEach((query) =>
testCompletions({

@@ -304,159 +312,80 @@ query,

expected: [
{ label: '$stringParam', kind: CompletionItemKind.Variable },
{ label: 'db1', kind: CompletionItemKind.Value },
{ label: 'db2', kind: CompletionItemKind.Value },
{ label: 'movies', kind: CompletionItemKind.Value },
{ label: 'myMovies', kind: CompletionItemKind.Value },
{ label: 'scoped.alias', kind: CompletionItemKind.Value },
{ label: 'a.b.c.d', kind: CompletionItemKind.Value },
{ label: '$param1', kind: CompletionItemKind.Variable },
],
excluded: [
{ label: '$intParam', kind: CompletionItemKind.Variable },
{ label: '$mapParam', kind: CompletionItemKind.Variable },
// validate invalid keyword bug isn't present
{ label: '', kind: CompletionItemKind.Keyword },
// do not suggest non-string parameters
{ label: '$param2', kind: CompletionItemKind.Variable },
{ label: '$param3', kind: CompletionItemKind.Variable },
],
});
});
}),
);
});
test('suggests parameter as map properties', () => {
const query = 'match (v :Movie ';
test('Correctly completes parameters and existing database names in GRANT privilege', () => {
const cases = [
'GRANT SHOW TRANSACTION (user1, user2) ON DATABASE ',
'GRANT SHOW TRANSACTION (user1, user2) ON DATABASE neo4j, ',
];
cases.forEach((query) =>
testCompletions({
query,
dbSchema,
expected: [{ label: '$mapParam', kind: CompletionItemKind.Variable }],
excluded: [
{ label: '$stringParam', kind: CompletionItemKind.Variable },
{ label: '$intParam', kind: CompletionItemKind.Variable },
// ensure variables are not suggested in place of parameters (parameters reuse the variable rule)
{ label: 'v', kind: CompletionItemKind.Variable },
expected: [
{ label: 'db1', kind: CompletionItemKind.Value },
{ label: 'db2', kind: CompletionItemKind.Value },
{ label: 'movies', kind: CompletionItemKind.Value },
{ label: 'myMovies', kind: CompletionItemKind.Value },
{ label: 'scoped.alias', kind: CompletionItemKind.Value },
{ label: 'a.b.c.d', kind: CompletionItemKind.Value },
{ label: '$param1', kind: CompletionItemKind.Variable },
],
});
});
test('suggests parameter in options field of create constraint', () => {
const query =
'CREATE CONSTRAINT abc ON (n:person) ASSERT EXISTS n.name OPTIONS ';
testCompletions({
query,
dbSchema,
expected: [{ label: '$mapParam', kind: CompletionItemKind.Variable }],
excluded: [
{ label: '$stringParam', kind: CompletionItemKind.Variable },
{ label: '$intParam', kind: CompletionItemKind.Variable },
// validate invalid keyword bug isn't present
{ label: '', kind: CompletionItemKind.Keyword },
// do not suggest non-string parameters
{ label: '$param2', kind: CompletionItemKind.Variable },
{ label: '$param3', kind: CompletionItemKind.Variable },
],
});
});
}),
);
});
test('suggests parameter in options field of create index', () => {
const query = 'CREATE INDEX abc FOR (n:person) ON (n.name) OPTIONS ';
test('Correctly completes parameters and existing database names in GRANT database privilege', () => {
const cases = [
'GRANT TERMINATE TRANSACTION (user) ON DATABASE ',
'GRANT TERMINATE TRANSACTION (user) ON DATABASE neo4j, ',
];
cases.forEach((query) =>
testCompletions({
query,
dbSchema,
expected: [{ label: '$mapParam', kind: CompletionItemKind.Variable }],
excluded: [
{ label: '$stringParam', kind: CompletionItemKind.Variable },
{ label: '$intParam', kind: CompletionItemKind.Variable },
expected: [
{ label: 'db1', kind: CompletionItemKind.Value },
{ label: 'db2', kind: CompletionItemKind.Value },
{ label: 'movies', kind: CompletionItemKind.Value },
{ label: 'myMovies', kind: CompletionItemKind.Value },
{ label: 'scoped.alias', kind: CompletionItemKind.Value },
{ label: 'a.b.c.d', kind: CompletionItemKind.Value },
{ label: '$param1', kind: CompletionItemKind.Variable },
],
});
});
test('suggests parameter in options field of create composite database', () => {
const query = 'CREATE COMPOSITE DATABASE name IF NOT EXISTS OPTIONS ';
testCompletions({
query,
dbSchema,
expected: [{ label: '$mapParam', kind: CompletionItemKind.Variable }],
excluded: [
{ label: '$stringParam', kind: CompletionItemKind.Variable },
{ label: '$intParam', kind: CompletionItemKind.Variable },
// validate invalid keyword bug isn't present
{ label: '', kind: CompletionItemKind.Keyword },
// do not suggest non-string parameters
{ label: '$param2', kind: CompletionItemKind.Variable },
{ label: '$param3', kind: CompletionItemKind.Variable },
],
});
});
test('suggests parameters for user management', () => {
const cases = [
'CREATE USER ',
'DROP USER ',
'ALTER USER ',
'RENAME USER ',
'SHOW USER ',
'ALTER CURRENT USER SET PASSWORD FROM ',
'ALTER CURRENT USER SET PASSWORD FROM $pw to ',
'ALTER USER ',
'ALTER USER foo IF EXISTS SET PASSWORD ',
];
cases.forEach((query) => {
testCompletions({
query,
dbSchema,
expected: [
{ label: '$stringParam', kind: CompletionItemKind.Variable },
],
excluded: [
{ label: '$intParam', kind: CompletionItemKind.Variable },
{ label: '$mapParam', kind: CompletionItemKind.Variable },
],
});
});
});
test('suggests parameters for role management', () => {
const cases = [
'CREATE ROLE ',
'DROP ROLE ',
'RENAME ROLE ',
'GRANT ROLE ',
'GRANT ROLE abc TO ',
];
cases.forEach((query) => {
testCompletions({
query,
dbSchema,
expected: [
{ label: '$stringParam', kind: CompletionItemKind.Variable },
],
excluded: [
{ label: '$intParam', kind: CompletionItemKind.Variable },
{ label: '$mapParam', kind: CompletionItemKind.Variable },
],
});
});
});
test('suggests parameters for server management', () => {
const nameCases = [
'ENABLE SERVER ',
'ALTER SERVER ',
'RENAME SERVER ',
'RENAME SERVER $adb TO ',
'DROP SERVER ',
'DEALLOCATE DATABASES FROM SERVERS ',
'DEALLOCATE DATABASES FROM SERVERS "ab", ',
];
const optionsCases = [
'ENABLE SERVER "abc" OPTIONS ',
'ALTER SERVER "abc" SET OPTIONS ',
];
nameCases.forEach((query) => {
testCompletions({
query,
dbSchema,
expected: [
{ label: '$stringParam', kind: CompletionItemKind.Variable },
],
excluded: [
{ label: '$intParam', kind: CompletionItemKind.Variable },
{ label: '$mapParam', kind: CompletionItemKind.Variable },
],
});
});
optionsCases.forEach((query) => {
testCompletions({
query,
dbSchema,
expected: [{ label: '$mapParam', kind: CompletionItemKind.Variable }],
excluded: [
{ label: '$intParam', kind: CompletionItemKind.Variable },
{ label: '$stringParam', kind: CompletionItemKind.Variable },
],
});
});
});
}),
);
});
});

@@ -286,6 +286,9 @@ import { autocomplete } from '../autocompletion/autocompletion';

expectErrorMessage(':param b => ', 'Expected an expression');
expectErrorMessage(':param {', "Expected '}' or an identifier");
expectErrorMessage(':param {', "Expected any of '}', ',' or an identifier");
expectErrorMessage(':param {x}', "Expected ':'");
expectErrorMessage(':param {x: ', 'Expected an expression');
expectErrorMessage(':param {: 4} ', "Expected '}' or an identifier");
expectErrorMessage(
':param {: 4} ',
"Expected any of '}', ',' or an identifier",
);
});

@@ -424,3 +427,3 @@

token: 'd',
tokenType: 'symbolicName',
tokenType: 'property',
},

@@ -427,0 +430,0 @@ {

@@ -1119,3 +1119,3 @@ import { applySyntaxColouring } from '../../syntaxColouring/syntaxColouring';

token: 'neo4j',
tokenType: 'variable',
tokenType: 'symbolicName',
},

@@ -1122,0 +1122,0 @@ {

@@ -39,3 +39,3 @@ import { getDiagnosticsForQuery } from './helpers';

message:
'Expected any of ALTER, CALL, CREATE, DEALLOCATE, DELETE, DENY, DETACH, DROP, DRYRUN, ENABLE, EXPLAIN, FOREACH, GRANT, LOAD, MATCH, MERGE, OPTIONAL, PROFILE, REALLOCATE, REMOVE, RENAME, RETURN, REVOKE, SET, SHOW, START, STOP, TERMINATE, UNWIND, USE, USING or WITH',
'Expected any of ALTER, CALL, CREATE, DEALLOCATE, DELETE, DENY, DETACH, DROP, DRYRUN, ENABLE, EXPLAIN, FOREACH, GRANT, INSERT, LOAD, MATCH, MERGE, NODETACH, OPTIONAL, PROFILE, REALLOCATE, REMOVE, RENAME, RETURN, REVOKE, SET, SHOW, START, STOP, TERMINATE, UNWIND, USE, USING or WITH',
range: {

@@ -120,3 +120,3 @@ end: {

message:
"Expected any of '}', AND, CALL, CREATE, DELETE, DETACH, FOREACH, LOAD, MATCH, MERGE, OPTIONAL, OR, REMOVE, RETURN, SET, UNION, UNWIND, USE, WITH, XOR or an expression",
"Expected any of '}', AND, CALL, CREATE, DELETE, DETACH, FOREACH, INSERT, LOAD, MATCH, MERGE, NODETACH, OPTIONAL, OR, REMOVE, RETURN, SET, UNION, UNWIND, USE, WITH, XOR or an expression",
range: {

@@ -494,3 +494,4 @@ end: {

},
message: `Expected any of ALIAS, ALIASES, ALL, BTREE, BUILT, CONSTRAINT, CONSTRAINTS, CURRENT, DATABASE, DATABASES, DEFAULT, EXIST, EXISTENCE, EXISTS, FULLTEXT, FUNCTION, FUNCTIONS, HOME, INDEX, INDEXES, KEY, LOOKUP, NODE, POINT, POPULATED, PRIVILEGE, PRIVILEGES, PROCEDURE, PROCEDURES, PROPERTY, RANGE, REL, RELATIONSHIP, ROLE, ROLES, SERVER, SERVERS, SETTING, SETTINGS, SUPPORTED, TEXT, TRANSACTION, TRANSACTIONS, UNIQUE, UNIQUENESS, USER or USERS`,
message:
'Expected any of ALIAS, ALIASES, ALL, BTREE, BUILT, CONSTRAINT, CONSTRAINTS, CURRENT, DATABASE, DATABASES, DEFAULT, EXIST, EXISTENCE, EXISTS, FULLTEXT, FUNCTION, FUNCTIONS, HOME, INDEX, INDEXES, KEY, LOOKUP, NODE, POINT, POPULATED, PRIVILEGE, PRIVILEGES, PROCEDURE, PROCEDURES, PROPERTY, RANGE, REL, RELATIONSHIP, ROLE, ROLES, SERVER, SERVERS, SETTING, SETTINGS, SUPPORTED, TEXT, TRANSACTION, TRANSACTIONS, UNIQUE, UNIQUENESS, USER, USERS or VECTOR',
range: {

@@ -729,3 +730,3 @@ end: {

{
message: 'Expected a map literal',
message: "Expected any of '}', ',' or an identifier",
offsets: {

@@ -759,4 +760,3 @@ end: 9,

{
message:
"Expected any of '=', ')', ':', IS, WHERE, a map literal or a parameter",
message: "Expected any of '=', ')', '{', ':', IS, WHERE or a parameter",
offsets: {

@@ -849,3 +849,3 @@ end: 14,

{
message: "Expected '=' or a database name",
message: "Expected any of '=', a database name or a parameter",
offsets: {

@@ -852,0 +852,0 @@ end: 27,

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 too big to display

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

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 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 too big to display

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

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