Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cql autocompleter with syntax highlighter #46

Merged
merged 5 commits into from
Nov 3, 2024

Conversation

danielhe4rt
Copy link
Contributor

image

This Pull Requests aims to add Syntax Highlight for 'CQL' and bring Autocompletion for the Editor based on the Keyspace informations (fields, tables, keyspaces etc).

  • Syntax Highlight with CQL
  • Keyspace Autocompletion

At the CQL Editor you will find these lines and everything must be around it.

monaco.languages.register({
  id: "cql",
  extensions: [".cql"],
  aliases: ["CQL", "cql"],
  mimetypes: ["text/cql"],
});

monaco.languages.setMonarchTokensProvider("cql", cql_language);
// monaco.languages.registerCompletionItemProvider("cql", {}); // 

Repositories used as reference:

Warning

There is an "compilation error" poppin so far when you try to add any completion. Most of the other projects currently uses Webpack plugin to handle it. I'm not sure how to solve it in NextJS.

Closes #16


Autocompletion and Syntax Highlighting Enhancements:

Minor Adjustments:

@gvieira18
Copy link
Collaborator

Hey @danielhe4rt, I've updated the autocomplete function generator and now it seems to work for CQL syntax, but still needs to make the keyspaces autocomplete.

@danielhe4rt danielhe4rt marked this pull request as ready for review November 2, 2024 20:11
Comment on lines +17 to +196
"USING",
"VALUES",
"VIEW",
"WHERE",
"WITH",
"WRITETIME",
];

const functions = [
"blobAsBigint",
"blobAsBoolean",
"blobAsDecimal",
"blobAsDouble",
"blobAsFloat",
"blobAsInt",
"blobAsText",
"blobAsTimestamp",
"blobAsUUID",
"blobAsVarchar",
"blobAsVarint",
"dateOf",
"now",
"unixTimestampOf",
"uuid",
"timeuuid",
"minTimeuuid",
"maxTimeuuid",
"toDate",
"toTimestamp",
"toUnixTimestamp",
"writetime",
"ttl",
"token",
"bigintAsBlob",
"booleanAsBlob",
"dateAsBlob",
"decimalAsBlob",
"doubleAsBlob",
"floatAsBlob",
"inetAsBlob",
"intAsBlob",
"textAsBlob",
"timestampAsBlob",
"timeuuidAsBlob",
"uuidAsBlob",
"varcharAsBlob",
"varintAsBlob",
];

const dataTypes = [
"ascii",
"bigint",
"blob",
"boolean",
"counter",
"date",
"decimal",
"double",
"float",
"frozen",
"inet",
"int",
"list",
"map",
"set",
"smallint",
"text",
"time",
"timestamp",
"timeuuid",
"tinyint",
"tuple",
"uuid",
"varchar",
"varint",
];

const operators = [
"=",
">",
"<",
">=",
"<=",
"!=",
"+",
"-",
"*",
"/",
"%",
"IN",
"CONTAINS",
"CONTAINS KEY",
"AND",
"OR",
"NOT",
"IS",
"NULL",
"IS NOT NULL",
"IS NULL",
];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pq não move essas constantes para um arquivo separado para facilitar a leitura?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yo soy burrito mi cabeça no hablas frontend

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point, the file cql-autocompleter.ts was created to be this abstraction.

I think we can keep these constants in the same file for now, since we don't know how far the scope of the implementation will grow.

See #48

@danielhe4rt danielhe4rt merged commit d5029e3 into main Nov 3, 2024
3 checks passed
@danielhe4rt danielhe4rt deleted the feat/syntax-highlight branch November 3, 2024 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: monaco editor autocomplete with keyspaces informations
3 participants