Skip to content

Latest commit

 

History

History
881 lines (543 loc) · 16.5 KB

neo4j-cypher_editor-support.md

File metadata and controls

881 lines (543 loc) · 16.5 KB

Home > @neo4j-cypher/editor-support

editor-support package

Cypher language support package using an antlr4 grammar

Remarks:

This package provides cypher query parsing using an antlr4 grammar.

It is mostly unchanged from the original implementation.

It provides capabilities for cypher query syntax highlighting and and autocompletion suggestions.



Classes:

Class Description
CypherEditorSupport Instances of this class are used to encapsulate the parsed cypher tree for the antlr4 grammar
CypherLexer The CypherLexer class generated by antlr4

CypherEditorSupport class

Instances of this class are used to encapsulate the parsed cypher tree for the antlr4 grammar

Signature:

export class CypherEditorSupport 

Constructors:

Constructor Description
(constructor)(input) Constructs a new instance of the CypherEditorSupport class

CypherEditorSupport.(constructor)

Constructs a new instance of the CypherEditorSupport class

Signature:

constructor(input: string);

Parameters:

Parameter Type
input string

Methods:

Method
getCompletion(line, column, doFilter)
setSchema(schema)
update(input)

CypherEditorSupport.getCompletion() method

Signature:

getCompletion(
    line: number,
    column: number,
    doFilter?: boolean
  ): {
    from: EditorSupportPosition;
    to: EditorSupportPosition;
    items: EditorSupportCompletionItem[];
  };

Parameters:

Parameter Type Description
line number
column number
doFilter boolean (Optional)

Returns:

{ from: EditorSupportPosition; to: EditorSupportPosition; items: EditorSupportCompletionItem[]; }


CypherEditorSupport.setSchema() method

Signature:

setSchema(schema: EditorSupportSchema): void;

Parameters:

Parameter Type
schema EditorSupportSchema

Returns:

void


CypherEditorSupport.update() method

Signature:

update(input: string): void;

Parameters:

Parameter Type
input string

Returns:

void


CypherLexer class

The CypherLexer class generated by antlr4

Signature:

export class CypherLexer extends Lexer 

Extends: Lexer


Constructors:

Constructor Description
(constructor)(input) Constructs a new instance of the CypherLexer class

CypherLexer.(constructor)

Constructs a new instance of the CypherLexer class

Signature:

constructor(input: string);

Parameters:

Parameter Type
input string

Properties:

Property Type
channelNames string[]
grammarFileName string
literalNames string[]
modeNames string[]
ruleNames string[]
symbolicNames string[]

CypherLexer.channelNames property

Signature:

channelNames: string[];

CypherLexer.grammarFileName property

Signature:

grammarFileName: string;

CypherLexer.literalNames property

Signature:

literalNames: string[];

CypherLexer.modeNames property

Signature:

modeNames: string[];

CypherLexer.ruleNames property

Signature:

ruleNames: string[];

CypherLexer.symbolicNames property

Signature:

symbolicNames: string[];


Functions:

Function Description
createCypherLexer(input) Helper function to instanciate a CypherLexer
parse(input) Helper function to parse a cypher query

createCypherLexer() function

Helper function to instanciate a CypherLexer

Signature:

declare function createCypherLexer(input: string): CypherLexer;

Parameters:

Parameter Type
input string

Returns:

CypherLexer


parse() function

Helper function to parse a cypher query

Signature:

declare function parse(input: string): {
  referencesListener: {
    queriesAndCommands: QueryOrCommand[];
  };
};

Parameters:

Parameter Type
input string

Returns:

{ referencesListener: { queriesAndCommands: QueryOrCommand[]; }; }



Interfaces:

Interface Description
ConsoleCommand A console command, these are typically prefixed with : like :help
EditorSupportCompletionItem EditorSupportCompletionItem
EditorSupportPosition The editor support library has its own representation of editor positions
EditorSupportSchema The editor support schema contains information about a graph database that enables advanced autocompletion & syntax highlighting.
FunctionSchema A function provided by the graph database
ProcedureSchema A procedure provided by the graph database
QueryOrCommand

ConsoleCommand interface

A console command, these are typically prefixed with : like :help

Signature:

export interface ConsoleCommand 

Properties:

Property Type Description
commands? ConsoleCommand[] (Optional)
description? string (Optional)
name string

ConsoleCommand.commands property

Signature:

commands?: ConsoleCommand[];

ConsoleCommand.description property

Signature:

description?: string;

ConsoleCommand.name property

Signature:

name: string;

EditorSupportCompletionItem interface

EditorSupportCompletionItem

Signature:

export interface EditorSupportCompletionItem 

Properties:

Property Type
content string
postfix null
type CompletionType
view string

EditorSupportCompletionItem.content property

Signature:

content: string;

EditorSupportCompletionItem.postfix property

Signature:

postfix: null;

EditorSupportCompletionItem.type property

Signature:

type: CompletionType;

EditorSupportCompletionItem.view property

Signature:

view: string;

EditorSupportPosition interface

The editor support library has its own representation of editor positions

Signature:

export interface EditorSupportPosition 

Properties:

Property Type Description
column number
line number The 1 based line number The 0 based column number

EditorSupportPosition.column property

Signature:

column: number;

EditorSupportPosition.line property

The 1 based line number The 0 based column number

Signature:

line: number;

EditorSupportSchema interface

The editor support schema contains information about a graph database that enables advanced autocompletion & syntax highlighting.

Signature:

export interface EditorSupportSchema 

Properties:

Property Type Description
consoleCommands? ConsoleCommand[] (Optional) The list of console commands
functions? FunctionSchema[] (Optional) The list of functions provided the graph database
labels? string[] (Optional) The list of labels in the graph database
parameters? string[] (Optional) The list of parameters
procedures? ProcedureSchema[] (Optional) The list of procedures provided the graph database
propertyKeys? string[] (Optional) The list of property keys in the graph database
relationshipTypes? string[] (Optional) The list of relationship types in the graph database

EditorSupportSchema.consoleCommands property

The list of console commands

Signature:

consoleCommands?: ConsoleCommand[];

EditorSupportSchema.functions property

The list of functions provided the graph database

Signature:

functions?: FunctionSchema[];

EditorSupportSchema.labels property

The list of labels in the graph database

Signature:

labels?: string[];

EditorSupportSchema.parameters property

The list of parameters

Signature:

parameters?: string[];

EditorSupportSchema.procedures property

The list of procedures provided the graph database

Signature:

procedures?: ProcedureSchema[];

EditorSupportSchema.propertyKeys property

The list of property keys in the graph database

Signature:

propertyKeys?: string[];

EditorSupportSchema.relationshipTypes property

The list of relationship types in the graph database

Signature:

relationshipTypes?: string[];

FunctionSchema interface

A function provided by the graph database

Signature:

export interface FunctionSchema 

Properties:

Property Type
name string
signature string

FunctionSchema.name property

Signature:

name: string;

FunctionSchema.signature property

Signature:

signature: string;

ProcedureSchema interface

A procedure provided by the graph database

Signature:

export interface ProcedureSchema 

Properties:

Property Type
name string
returnItems FunctionSchema[]
signature string

ProcedureSchema.name property

Signature:

name: string;

ProcedureSchema.returnItems property

Signature:

returnItems: FunctionSchema[];

ProcedureSchema.signature property

Signature:

signature: string;

QueryOrCommand interface

Signature:

declare interface QueryOrCommand 

Properties:

Property Type
cypherConsoleCommandName () => { getText: () => string }
getText () => string
start EditorSupportPosition
stop EditorSupportPosition

QueryOrCommand.cypherConsoleCommandName property

Signature:

cypherConsoleCommandName: () => { getText: () => string };

QueryOrCommand.getText property

Signature:

getText: () => string;

QueryOrCommand.start property

Signature:

start: EditorSupportPosition;

QueryOrCommand.stop property

Signature:

stop: EditorSupportPosition;


Type Aliases:

Type Alias Description
CompletionType All autocomplete options have a CompletionType

CompletionType type

All autocomplete options have a CompletionType

Signature:

export type CompletionType =
  | "keyword"
  | "label"
  | "variable"
  | "parameter"
  | "propertyKey"
  | "relationshipType"
  | "function"
  | "procedure"
  | "consoleCommand"
  | "consoleCommandSubcommand"
  | "procedureOutput"
  | "noop";