Skip to content

Commit

Permalink
chore: pnpm fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rosajsx committed Nov 9, 2024
1 parent 91356e9 commit 4d8edcb
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/app/(main)/query-runner/_components/cql-autocompleter.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { ScyllaKeyspace } from "@lambda-group/scylladb";
import { useMonaco } from "@monaco-editor/react";
import KeyspaceDefinitions from "@scylla-studio/app/(main)/keyspace/[keyspace]/_components/keyspace-tables";
import { getFullQueryAtCursor, getSingleLineQueryAtCursor } from "@scylla-studio/app/(main)/query-runner/_components/utils";
import {
getFullQueryAtCursor,
getSingleLineQueryAtCursor,
} from "@scylla-studio/app/(main)/query-runner/_components/utils";
import { useCqlFilters } from "@scylla-studio/hooks/use-cql-filters";
import { KeyspaceDefinition } from "@scylla-studio/lib/cql-parser/keyspace-parser";
import { TableDefinition } from "@scylla-studio/lib/cql-parser/table-parser";
import {

editor,
languages,
} from "monaco-editor";
import { editor, languages } from "monaco-editor";

export type MonacoInstance = NonNullable<ReturnType<typeof useMonaco>>;

Expand Down Expand Up @@ -304,25 +303,25 @@ export const cqlCompletionItemProvider = (
monacoInstance: MonacoInstance,
editor: editor.IStandaloneCodeEditor,
keyspaces?: KeyspaceDefinition[],
keyspacesTables?: TableCompletion[]
keyspacesTables?: TableCompletion[],
): languages.CompletionItem[] => {


const cursor = getSingleLineQueryAtCursor(editor, monacoInstance);
if (!cursor) return getDefaultSuggestions(monacoInstance);
const textUntilPosition = cursor.query.split("\n\n").shift()?.replaceAll(";", "") || "";

const textUntilPosition =
cursor.query.split("\n\n").shift()?.replaceAll(";", "") || "";

const useKeyspaceRegex = /USE\s+(\w*)$/i;
const fromTableRegex = /FROM\s+(\w*)$/i;
const selectColumnRegex = /SELECT\s+([\w,\s]*)$/i;
const whereColumnRegex = /WHERE\s+(\w*)$/i;
// Check if you're typing a keyspace
if (useKeyspaceRegex.test(textUntilPosition)) {

return prepareUseSuggestions(monacoInstance, (keyspaces as any) as KeyspaceDefinition[] || []);
return prepareUseSuggestions(
monacoInstance,
(keyspaces as any as KeyspaceDefinition[]) || [],
);
} else if (fromTableRegex.test(textUntilPosition)) {
return prepareTablesSuggestions(monacoInstance, keyspacesTables || []);
return prepareTablesSuggestions(monacoInstance, keyspacesTables || []);
} else if (selectColumnRegex.test(textUntilPosition)) {
// TODO: or we display everything related to all tables or we display nothing
return getDefaultSuggestions(monacoInstance);
Expand Down

0 comments on commit 4d8edcb

Please sign in to comment.