Skip to content

Commit 22868bf

Browse files
committed
rid of comments in stateprops
1 parent 21242f4 commit 22868bf

File tree

1 file changed

+0
-81
lines changed

1 file changed

+0
-81
lines changed

src/backend/controllers/statePropExtractors.ts

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -178,84 +178,3 @@ export function getHooksNames(elementType: string): { hookName: string; varName:
178178
throw new Error('getHooksNameError' + err.message);
179179
}
180180
}
181-
182-
/**
183-
// * // ---------------------GET STATE VAR NAME & HOOK NAME--------------------------
184-
// /**
185-
// * This function receive a string representation of a functional component.
186-
// * This function then uses JSX parser to traverse through the function string,
187-
// * and extract the state variable name and its corresponding setState method.
188-
// * @param elementType - The string representation of a functional component
189-
// * @returns - An array of objects with key: hookName (the name of setState method) | value: varName (the state variable name)
190-
// */
191-
// export function getHooksNames(elementType: string): { hookName: string; varName: string }[] {
192-
// // Initialize empty object to store the setters and getter
193-
// // Abstract Syntax Tree
194-
// let AST: any;
195-
// try {
196-
// AST = JSXParser.parse(elementType).body;
197-
// console.log('AST');
198-
// console.log(AST);
199-
// let count = 0;
200-
// // Begin search for hook names, only if ast has a body property.
201-
// // Statements get all the names of the hooks. For example: useCount, useWildcard, ...
202-
// const statements: { hookName: string; varName: string }[] = [];
203-
// /** All module exports always start off as a single 'FunctionDeclaration' type
204-
// * Other types: "BlockStatement" / "ExpressionStatement" / "ReturnStatement"
205-
// * Iterate through AST of every function(al component) declaration
206-
// * Check within each function(al component) declaration if there are hook declarations & variable name declaration */
207-
// AST.forEach((functionDec: any) => {
208-
// console.log('functionDec');
209-
// console.log(functionDec);
210-
// let declarationBody: any;
211-
// if (functionDec.expression?.body) declarationBody = functionDec.expression.body.body;
212-
// // check if functionDec.expression.body exists, then set declarationBody to functionDec's body
213-
// else declarationBody = functionDec.body?.body ?? [];
214-
// // Traverse through the function's funcDecs and Expression Statements
215-
// console.log('declarationBody');
216-
// console.log( declarationBody);
217-
// declarationBody.forEach((elem: any) => {
218-
// // Hooks will always be contained in a variable declaration
219-
// console.log('elem type:', count++, elem.type);
220-
// console.log(elem);
221-
222-
// if (elem.type === 'VariableDeclaration') {
223-
// // Obtain the declarations array from elem.
224-
// const { declarations } = elem;
225-
// // Obtain the reactHook:
226-
// // Due to difference in babel transpilation in browser vs for jest test, expression is stored in differen location
227-
// const expression =
228-
// declarations[0]?.init?.callee?.expressions || //work for browser
229-
// declarations[0]?.init?.arguments[0]?.callee?.expressions; //work for jest test
230-
// let reactHook: string;
231-
// reactHook = expression[1].property?.name;
232-
// if (reactHook === 'useState') {
233-
// // Obtain the variable being set:
234-
// let varName: string =
235-
// declarations[declarations.length - 2]?.id?.name || // work react application; Mark's note: changed to point to second to last element of declarations because webpack added an extra variable and therefor declaration in the middle of the array cuz es6
236-
// (Array.isArray(declarations[0]?.id?.elements)
237-
// ? declarations[0]?.id?.elements[0]?.name
238-
// : undefined); //work for nextJS application
239-
// // Obtain the setState method:
240-
// let hookName: string =
241-
// declarations[declarations.length - 1]?.id?.name || // work react application; Mark's note: changed to point to last element of declarations because webpack added an extra variable and therefor declaration in the middle of the array cuz es6
242-
// (Array.isArray(declarations[0]?.id?.elements)
243-
// ? declarations[0]?.id?.elements[0]?.name
244-
// : undefined); //work for nextJS & Remix
245-
// // Push reactHook & varName to statements array
246-
// /**
247-
// * Mark's notes, it's interesting that they don't want to
248-
// * pass on reactHook 'useState'. I wonder why.
249-
// */
250-
// statements.push({ hookName, varName });
251-
// }
252-
// }
253-
// });
254-
// });
255-
// return statements;
256-
// } catch (err) {
257-
// throw new Error('getHooksNameError' + err.message);
258-
// }
259-
// }
260-
261-
// */

0 commit comments

Comments
 (0)