Closed ashish10alex closed 1 week ago
Thanks for the simplifications @ashish10alex —it's looking good! I completely forgot about declarations inside the JavaScript block.
One issue, though: we can't assume the function name is the same as the file name because sometimes imports are from a subdirectory within the includes directory. So, we also need to search the paths of imported modules (getImportedModules) in the findModuleVarDefinition function.
Additionally, we need to search for the variable based on const searchTerm = document.getText(wordRange); (or do some transformation of variableOrFunctionName
instead of splitting on the period. When a function has parameters passed to it, like functionName("param1", "param2"), the search won't succeed if it’s split on the period.
I'll merge this PR and make a few small adjustments in the original PR to address these issues.
This PR:
Test case where the above implementation works
Assumptions of the implementation (generous*)
${some_text}
it assumes some_text is variable defined in either a.js
file inincludes
directory or injs
block in the same sqlx file 2.If go to def is triggered from${some_text.other_text
} it assumessome_text
is the file name andother_text
is the variable name that exsists in the.js
file