[WIP] Symbols#3229
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3229 +/- ##
==========================================
+ Coverage 47.71% 48.89% +1.18%
==========================================
Files 98 98
Lines 4068 4174 +106
Branches 836 874 +38
==========================================
+ Hits 1941 2041 +100
- Misses 2127 2133 +6
Continue to review full report at Codecov.
|
|
|
||
| symbols.identifiers.push({ | ||
| name: path.node.name, | ||
| expression: path.node.name, |
There was a problem hiding this comment.
we can
const { loc, name } = path.node;
at the top of this block
| } | ||
|
|
||
| if (t.isVariableDeclarator(path)) { | ||
| const node = path.node.id; |
There was a problem hiding this comment.
this is a bit confusing, why is the node === path.node.id? could this be a mistake?
| return symbols; | ||
| } | ||
|
|
||
| function addProperty(name, expression, path, prevPath) { |
There was a problem hiding this comment.
rename to extendExpression
| function getObjectExpression(path, prevPath, expression = "") { | ||
| const name = path.node.key.name; | ||
|
|
||
| expression = addProperty(name, expression, path, prevPath); |
There was a problem hiding this comment.
rename to
const extendedExpression = extendExpression( ... )
|
|
||
| expression = addProperty(name, expression, path, prevPath); | ||
|
|
||
| prevPath = path; |
There was a problem hiding this comment.
rename to
const nextPrevPath = path;
| return getExpression(path, prevPath, expression); | ||
| } | ||
|
|
||
| function getExpression(path, prevPath, expression = "") { |
There was a problem hiding this comment.
this should probably be renamed to getExpressionName since it returns a string representation, and not the expression itself
| return name; | ||
| } | ||
|
|
||
| if (computed || array) { |
There was a problem hiding this comment.
i dont think we need this block, since it is doing the same thing as lines 160 - 164, and if it is computed -- we have an early return at line 150
| expression = addProperty(index, expression, path, prevPath); | ||
|
|
||
| prevPath = path; | ||
| path = path.parentPath && path.parentPath.parentPath; |
There was a problem hiding this comment.
same for lines 202 204, 205 -- avoid renaming arguments
| } | ||
|
|
||
| if (t.isVariableDeclarator(path)) { | ||
| const node = path.node.id; |
There was a problem hiding this comment.
again, a bit confused about why id is an node? would expect it to be a string...
| } | ||
|
|
||
| const name = node.name; | ||
| const prop = addProperty(name, expression, path, prevPath); |
There was a problem hiding this comment.
we can directly return this
Summary of Changes
I want to find all of the expressions in a file, this will let us anticipate what a user might want to preview or where a breakpoint might be added.
Test Plan
Lots of tests, lots and lots of them