@@ -22,7 +22,6 @@ import type { EditorContext, ItemKind, SuggestionRawDefinition, GetColumnsByType
22
22
import {
23
23
getColumnForASTNode ,
24
24
getCommandDefinition ,
25
- getCommandOption ,
26
25
getFunctionDefinition ,
27
26
isAssignment ,
28
27
isAssignmentComplete ,
@@ -36,7 +35,6 @@ import {
36
35
isTimeIntervalItem ,
37
36
getAllFunctions ,
38
37
isSingleItem ,
39
- nonNullable ,
40
38
getColumnExists ,
41
39
findPreviousWord ,
42
40
correctQuerySyntax ,
@@ -59,7 +57,6 @@ import {
59
57
getFunctionSuggestions ,
60
58
getCompatibleLiterals ,
61
59
buildConstantsDefinitions ,
62
- buildVariablesDefinitions ,
63
60
buildOptionDefinition ,
64
61
buildValueDefinitions ,
65
62
getDateLiterals ,
@@ -172,13 +169,7 @@ export async function suggest(
172
169
return suggestions . filter ( ( def ) => ! isSourceCommand ( def ) ) ;
173
170
}
174
171
175
- if (
176
- astContext . type === 'expression' ||
177
- ( astContext . type === 'option' && astContext . command ?. name === 'join' ) ||
178
- ( astContext . type === 'option' && astContext . command ?. name === 'dissect' ) ||
179
- ( astContext . type === 'option' && astContext . command ?. name === 'from' ) ||
180
- ( astContext . type === 'option' && astContext . command ?. name === 'enrich' )
181
- ) {
172
+ if ( astContext . type === 'expression' ) {
182
173
return getSuggestionsWithinCommandExpression (
183
174
innerText ,
184
175
ast ,
@@ -194,20 +185,6 @@ export async function suggest(
194
185
supportsControls
195
186
) ;
196
187
}
197
- if ( astContext . type === 'option' ) {
198
- // need this wrap/unwrap thing to make TS happy
199
- const { option, ...rest } = astContext ;
200
- if ( option && isOptionItem ( option ) ) {
201
- return getOptionArgsSuggestions (
202
- innerText ,
203
- ast ,
204
- { option, ...rest } ,
205
- getFieldsByType ,
206
- getFieldsMap ,
207
- getPolicyMetadata
208
- ) ;
209
- }
210
- }
211
188
if ( astContext . type === 'function' ) {
212
189
return getFunctionArgsSuggestions (
213
190
innerText ,
@@ -1190,71 +1167,3 @@ async function getListArgsSuggestions(
1190
1167
}
1191
1168
return suggestions ;
1192
1169
}
1193
-
1194
- /**
1195
- * @deprecated — this will disappear when https://github.com/elastic/kibana/issues/195418 is complete
1196
- * because "options" will be handled in imperative command-specific routines instead of being independent.
1197
- */
1198
- async function getOptionArgsSuggestions (
1199
- innerText : string ,
1200
- commands : ESQLCommand [ ] ,
1201
- {
1202
- command,
1203
- option,
1204
- node,
1205
- } : {
1206
- command : ESQLCommand ;
1207
- option : ESQLCommandOption ;
1208
- node : ESQLSingleAstItem | undefined ;
1209
- } ,
1210
- getFieldsByType : GetColumnsByTypeFn ,
1211
- getFieldsMaps : GetFieldsMapFn ,
1212
- getPolicyMetadata : GetPolicyMetadataFn
1213
- ) {
1214
- const optionDef = getCommandOption ( option . name ) ;
1215
- if ( ! optionDef || ! optionDef . signature ) {
1216
- return [ ] ;
1217
- }
1218
- const { nodeArg, lastArg } = extractArgMeta ( option , node ) ;
1219
- const suggestions = [ ] ;
1220
- const isNewExpression = isRestartingExpression ( innerText ) || option . args . length === 0 ;
1221
-
1222
- const fieldsMap = await getFieldsMaps ( ) ;
1223
- const anyVariables = collectVariables ( commands , fieldsMap , innerText ) ;
1224
-
1225
- if ( command . name === 'rename' ) {
1226
- if ( option . args . length < 2 ) {
1227
- suggestions . push ( ...buildVariablesDefinitions ( [ findNewVariable ( anyVariables ) ] ) ) ;
1228
- }
1229
- }
1230
-
1231
- if ( optionDef ) {
1232
- if ( ! suggestions . length ) {
1233
- const argDefIndex = optionDef . signature . multipleParams
1234
- ? 0
1235
- : Math . max ( option . args . length - 1 , 0 ) ;
1236
- const types = [ optionDef . signature . params [ argDefIndex ] . type ] . filter ( nonNullable ) ;
1237
- // If it's a complete expression then proposed some final suggestions
1238
- // A complete expression is either a function or a column: <COMMAND> <OPTION> field <here>
1239
- // Or an assignment complete: <COMMAND> <OPTION> field = ... <here>
1240
- if (
1241
- ( option . args . length && ! isNewExpression && ! isAssignment ( lastArg ) ) ||
1242
- ( isAssignment ( lastArg ) && isAssignmentComplete ( lastArg ) )
1243
- ) {
1244
- suggestions . push (
1245
- ...getFinalSuggestions ( {
1246
- comma : optionDef . signature . multipleParams ,
1247
- } )
1248
- ) ;
1249
- } else if ( isNewExpression || ( isAssignment ( nodeArg ) && ! isAssignmentComplete ( nodeArg ) ) ) {
1250
- suggestions . push (
1251
- ...( await getFieldsByType ( types [ 0 ] === 'column' ? [ 'any' ] : types , [ ] , {
1252
- advanceCursor : true ,
1253
- openSuggestions : true ,
1254
- } ) )
1255
- ) ;
1256
- }
1257
- }
1258
- }
1259
- return suggestions ;
1260
- }
0 commit comments