carloea2 commented on code in PR #9314:
URL: https://github.com/apache/texera/pull/9314#discussion_r4529953452
##########
frontend/src/app/workspace/service/code-editor/r-ui-udf-parameters-parser.ts:
##########
@@ -198,12 +249,31 @@ export function computeRParameterInsertion(
const tokens = tokenize(code);
const names = new Set<string>();
let depth = 0;
+ let argumentDepth = 0;
for (let index = 0; index < tokens.length; index++) {
const token = tokens[index];
+ if (
+ ((token.kind === "keyword" && token.text === "function") || (token.kind
=== "symbol" && token.text === "\\")) &&
+ tokens[index + 1]?.text === "("
+ ) {
+ index = endOfExpression(tokens, index);
+ continue;
+ }
if (token.kind === "symbol") {
if (["(", "[", "{"].includes(token.text)) depth++;
else if ([")", "]", "}"].includes(token.text)) depth--;
+ if (["(", "["].includes(token.text)) argumentDepth++;
+ else if ([")", "]"].includes(token.text)) argumentDepth--;
}
+ if (
+ argumentDepth === 0 &&
+ token.kind === "keyword" &&
+ token.text === "for" &&
+ tokens[index + 1]?.text === "(" &&
+ tokens[index + 2]?.kind === "name" &&
+ tokens[index + 3]?.text === "in"
+ )
+ names.add(tokens[index + 2].text);
if (
depth === 0 &&
Review Comment:
Implemented your suggestion, with the block and nested-call examples as
regressions. All 67 parser tests and 7200 frontend tests pass locally.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]