@@ -2,9 +2,10 @@ import { CharStreams, CommonTokenStream, TerminalNode, Token } from 'antlr4';
22import { default as CypherCmdLexer } from '../generated-parser/CypherCmdLexer' ;
33import CypherCmdParser , {
44 EscapedSymbolicNameStringContext ,
5- UnescapedSymbolicNameString_Context ,
5+ UnescapedSymbolicNameStringContext ,
66} from '../generated-parser/CypherCmdParser' ;
77import { lexerKeywords } from '../lexerSymbols' ;
8+ import { findParent } from '../helpers' ;
89
910export const INTERNAL_FORMAT_ERROR_MESSAGE = `
1011Internal formatting error: An unexpected issue occurred while formatting.
@@ -103,12 +104,20 @@ export function isComment(token: Token) {
103104export const isInlineComment = ( chunk : Chunk ) =>
104105 chunk . comment && chunk . comment . startsWith ( '/*' ) ;
105106
106- // Variables or property names that have the same name as a keyword should not be
107+ // Variables, functions/procedures namespaces or property names that have the same name as a keyword should not be
107108// treated as keywords
108109function isSymbolicName ( node : TerminalNode ) : boolean {
109- return (
110- node . parentCtx instanceof UnescapedSymbolicNameString_Context ||
111- node . parentCtx instanceof EscapedSymbolicNameStringContext
110+ const unescapedSymbolicNameStringParent = findParent (
111+ node ,
112+ ( x ) => x instanceof UnescapedSymbolicNameStringContext ,
113+ ) ;
114+ const escapedSymbolicNameStringParent = findParent (
115+ node ,
116+ ( x ) => x instanceof EscapedSymbolicNameStringContext ,
117+ ) ;
118+ return ! (
119+ unescapedSymbolicNameStringParent == null &&
120+ escapedSymbolicNameStringParent == null
112121 ) ;
113122}
114123
0 commit comments