From aaadbc675fd92e55e2cc9cfca30992399b64dce9 Mon Sep 17 00:00:00 2001 From: Ashit Rath Date: Thu, 8 Aug 2024 13:46:12 +0530 Subject: [PATCH] chore: add isError to return value of extractIdentifierInfoFromCode in AST (#35525) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Adds an isError flag to know if there is a syntax error while parsing PR for https://github.com/appsmithorg/appsmith-ee/pull/4547 ## Automation /ok-to-test tags="@tag.All" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: d69958d73ceb625ce82101ee98e5c81fe3d46697 > Cypress dashboard. > Tags: `@tag.All` > Spec: >
Thu, 08 Aug 2024 06:45:00 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **New Features** - Introduced a new `isError` property in the identifier information interface, enhancing error reporting during code extraction. - **Bug Fixes** - Updated extraction function to properly set the `isError` property based on success or `SyntaxError`, improving clarity on extraction outcomes. - **Tests** - Enhanced test cases by incorporating the `isError` property, improving clarity on expected outcomes and robustness of the testing framework. --- app/client/packages/ast/src/index.ts | 3 +++ app/client/packages/rts/src/test/server.test.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/app/client/packages/ast/src/index.ts b/app/client/packages/ast/src/index.ts index 6e6213189b..3f9e1daf0e 100644 --- a/app/client/packages/ast/src/index.ts +++ b/app/client/packages/ast/src/index.ts @@ -399,6 +399,7 @@ export interface IdentifierInfo { references: string[]; functionalParams: string[]; variables: string[]; + isError: boolean; } export const extractIdentifierInfoFromCode = ( code: string, @@ -435,6 +436,7 @@ export const extractIdentifierInfoFromCode = ( references: referencesArr, functionalParams: Array.from(functionalParams), variables: Array.from(variableDeclarations), + isError: false, }; } catch (e) { if (e instanceof SyntaxError) { @@ -443,6 +445,7 @@ export const extractIdentifierInfoFromCode = ( references: [], functionalParams: [], variables: [], + isError: true, }; } throw e; diff --git a/app/client/packages/rts/src/test/server.test.ts b/app/client/packages/rts/src/test/server.test.ts index d63f1d63f8..65ec4b03d6 100644 --- a/app/client/packages/rts/src/test/server.test.ts +++ b/app/client/packages/rts/src/test/server.test.ts @@ -109,6 +109,7 @@ describe("AST tests", () => { references: ["str.data", "Api1.data"], functionalParams: [], variables: ["Api2"], + isError: false, }; await supertest(app) @@ -129,11 +130,13 @@ describe("AST tests", () => { references: ["Api1.data"], functionalParams: [], variables: [], + isError: false, }, { references: ["Api1.data"], functionalParams: [], variables: ["str"], + isError: false, }, ];