diff --git a/src/plugins/data/public/antlr/dql/code_completion.ts b/src/plugins/data/public/antlr/dql/code_completion.ts index 63ede2436385..5968d2408c11 100644 --- a/src/plugins/data/public/antlr/dql/code_completion.ts +++ b/src/plugins/data/public/antlr/dql/code_completion.ts @@ -254,6 +254,8 @@ export const getSuggestions = async ({ } } + const dqlOperators = new Set([DQLParser.AND, DQLParser.OR, DQLParser.NOT]); + // suggest other candidates, mainly keywords [...candidates.tokens.keys()].forEach((token: number) => { // ignore identifier, already handled with field rule @@ -262,11 +264,18 @@ export const getSuggestions = async ({ } const tokenSymbolName = parser.vocabulary.getSymbolicName(token)?.toLowerCase(); + if (tokenSymbolName) { + let type = monaco.languages.CompletionItemKind.Keyword; + let detail = SuggestionItemDetailsTags.Keyword; + if (dqlOperators.has(token)) { + type = monaco.languages.CompletionItemKind.Operator; + detail = SuggestionItemDetailsTags.Operator; + } completions.push({ text: tokenSymbolName, - type: monaco.languages.CompletionItemKind.Keyword, - detail: SuggestionItemDetailsTags.Keyword, + type, + detail, insertText: `${tokenSymbolName} `, }); } diff --git a/src/plugins/data/public/antlr/shared/constants.ts b/src/plugins/data/public/antlr/shared/constants.ts index bd38cedc3822..16fe97b737a0 100644 --- a/src/plugins/data/public/antlr/shared/constants.ts +++ b/src/plugins/data/public/antlr/shared/constants.ts @@ -8,5 +8,6 @@ export const enum SuggestionItemDetailsTags { Keyword = 'Keyword', AggregateFunction = 'Aggregate Function', Value = 'Value', + Operator = 'Operator', } export const quotesRegex = /^'(.*)'$/;