-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Migrate to official antlr4 package #177211
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
Conversation
23a5405
to
79258d0
Compare
@@ -905,7 +905,7 @@ | |||
"adm-zip": "^0.5.9", | |||
"ajv": "^8.12.0", | |||
"ansi-regex": "^6.0.1", | |||
"antlr4ts": "^0.5.0-alpha.3", | |||
"antlr4": "^4.13.1-patch-1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the antlr4 javascript runtime and should not be confused with the cli that's a java binary used to generate the lexer and parser for defined languages.
26da451
to
16a6499
Compare
/ci |
Pinging @elastic/appex-sharedux (Team:SharedUX) |
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with ES|QL and works ok 👍
@@ -28,10 +27,6 @@ export const ESQLLang: CustomLangModuleType<ESQLCallbacks> = { | |||
workerProxyService.setup(ESQL_LANG_ID); | |||
|
|||
monaco.languages.setTokensProvider(ESQL_LANG_ID, new ESQLTokensProvider()); | |||
|
|||
// handle syntax errors via the diagnostic adapter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is handled now together with the rest of the validation task.
d9b5c5c
to
aa65424
Compare
aa65424
to
7aababd
Compare
💚 Build Succeeded
Metrics [docs]Page load bundle
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @eokoneyo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes LGTM, didn't run locally.
// @ts-expect-error the addParseListener API does exist and is documented here | ||
// https://github.com/antlr/antlr4/blob/dev/doc/listeners.md | ||
parser.addParseListener(parseListener); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better to cast to any
instead of @ts-expect-error
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using @ts-expect-error
is actually a better choice for this scenario, in the event that this method becomes present in the type declaration we'd get an error to remove this, unlike with any.
## Summary Up till now, we had to define our own lexer rules for our client-side ES|QL validation. This was because we were using an unofficial ANTLR package (before the official ANTLR had typescript support). Now that we are using the official ANTLR library (as of #177211), we no longer have to encode case insensitivity into the lexer rules themselves because the [`caseInsensitive` option](antlr/antlr4#3399) is now available to us. This means we can adopt the very [same definitions](https://github.com/elastic/elasticsearch/blob/343b1ae1ba74fbf2e75c29adddb2790312dd680b/x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.g4) that Elasticsearch uses as long as we set `caseInsensitive` (Elasticsearch handles case insensitivity at runtime). ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
Summary
This PR migrates kibana away from using the antlr4ts to the official antlr package, so the grammar used in Kibana (for example with ES|QL) is on par with ES.