-
Notifications
You must be signed in to change notification settings - Fork 11
triggering a param add pop-up if running a cypher with missing params #452
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
|
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.
Good stuff! I think I found an improvement to speed up tests (or for a computer from the 1900s maybe make it less flakey), but other than that I think it's good to go
export function extractParameters(strings: string[]): string[] { | ||
const paramSet = new Set<string>(); | ||
|
||
strings.forEach((str) => { | ||
const matches = str.match(/\$`([^`]+)`|\$(\w+)/g); | ||
if (matches) { | ||
matches.forEach((match) => { | ||
// Remove the '$' | ||
const param = match.slice(1); | ||
if (param.startsWith('`') && param.endsWith('`')) { | ||
// Remove the backticks | ||
paramSet.add(param.slice(1, -1)); | ||
} else { | ||
paramSet.add(param); | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
return Array.from(paramSet); | ||
} |
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.
I think it'd make more sense to have a small method in the language support that returns the parameters using the parser instead?
I see you've added the collectedParameters: ParsedParameter[]
in #456 so it'd make sense to expose that?
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.
Makes sense! I will continue with this pr after I merge #456 and try to use collectedParameters
instead of this method.
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.
I've changed the implementation to call createParsingResult
, to get the collectedParameters
. I'm not sure if it is a too costly operation to be honest, and if I should add a new method only to collect the parameters for this purpose. What do you think?
@@ -7,7 +7,12 @@ export { _internalFeatureFlags } from './featureFlags'; | |||
export { formatQuery } from './formatting/formatting'; | |||
export { antlrUtils } from './helpers'; | |||
export { CypherTokenType, lexerSymbols } from './lexerSymbols'; | |||
export { parse, parserWrapper, parseStatementsStrs } from './parserWrapper'; | |||
export { | |||
createParsingResult, |
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 it'd be better to have a parseParameters
method in the language support rather than exposing this internal?
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.
Changed it to have a parseParameters which returns an array of strings(cleared param names)
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.
Really noice!
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.
Good stuff! Was wondering about the new escapeModal method, but if it has to use constant waiting then it looks good to merge to me
async function escapeModal(count: number) { | ||
for (let i = 0; i < count; i++) { | ||
await browser.pause(500); | ||
await browser.keys([Key.Escape]); | ||
await waitUntilNotification(browser, 'Parameter value cannot be empty.'); | ||
} | ||
} |
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.
Was this flaky when you just did waitUntilNotification without browser.pause, or why was this added? In general it feels a little sketchy to use browser.pause() but in some cases it seems hard to avoid. (For example with waiting for the inputBox to open to type things into it)
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.
Yes, actually, it was flaky. So, I'd like to keep these just in case, so that the browser wouldn't click on the Escape
button before the parameter add pop-up opens :/
This pr is to trigger the parameter add pop-up when a user wants to run a query with missing parameters. With these changes:
prompt
await
tovoid
to prevent the wait for user to manually close the error message before opening the add pop-up for the following missing parameterextractParameters
which gets an array of strings(queries) and returns distinct paramNames