suggestionKind.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { StatementPosition, SuggestionKind } from '../../monarch/types';
  2. export function getSuggestionKinds(statementPosition: StatementPosition): SuggestionKind[] {
  3. switch (statementPosition) {
  4. case StatementPosition.SelectKeyword:
  5. return [SuggestionKind.SelectKeyword];
  6. case StatementPosition.AfterSelectKeyword:
  7. return [SuggestionKind.FunctionsWithArguments];
  8. case StatementPosition.AfterSelectFuncFirstArgument:
  9. return [SuggestionKind.Metrics];
  10. case StatementPosition.AfterFromKeyword:
  11. return [SuggestionKind.Namespaces, SuggestionKind.SchemaKeyword];
  12. case StatementPosition.SchemaFuncFirstArgument:
  13. return [SuggestionKind.Namespaces];
  14. case StatementPosition.SchemaFuncExtraArgument:
  15. return [SuggestionKind.LabelKeys];
  16. case StatementPosition.FromKeyword:
  17. return [SuggestionKind.FromKeyword];
  18. case StatementPosition.AfterFrom:
  19. return [
  20. SuggestionKind.WhereKeyword,
  21. SuggestionKind.GroupByKeywords,
  22. SuggestionKind.OrderByKeywords,
  23. SuggestionKind.LimitKeyword,
  24. ];
  25. case StatementPosition.WhereKey:
  26. return [SuggestionKind.LabelKeys];
  27. case StatementPosition.WhereComparisonOperator:
  28. return [SuggestionKind.ComparisonOperators];
  29. case StatementPosition.WhereValue:
  30. return [SuggestionKind.LabelValues];
  31. case StatementPosition.AfterWhereValue:
  32. return [
  33. SuggestionKind.LogicalOperators,
  34. SuggestionKind.GroupByKeywords,
  35. SuggestionKind.OrderByKeywords,
  36. SuggestionKind.LimitKeyword,
  37. ];
  38. case StatementPosition.AfterGroupByKeywords:
  39. return [SuggestionKind.LabelKeys];
  40. case StatementPosition.AfterGroupBy:
  41. return [SuggestionKind.OrderByKeywords, SuggestionKind.LimitKeyword];
  42. case StatementPosition.AfterOrderByKeywords:
  43. return [SuggestionKind.FunctionsWithoutArguments];
  44. case StatementPosition.AfterOrderByFunction:
  45. return [SuggestionKind.SortOrderDirectionKeyword, SuggestionKind.LimitKeyword];
  46. case StatementPosition.AfterOrderByDirection:
  47. return [SuggestionKind.LimitKeyword];
  48. }
  49. return [];
  50. }