5 ms·
I'm also struggling on the same problem. One technique is to read the code base in reverse. For example, pick a variable or a function or a statement or an expr
by _f9cu 3y ago
I'm also struggling on the same problem. One technique is to read the code base in reverse. For example, pick a variable or a function or a statement or an expression, trace its source upwards.
This will create a graph from destination to source, then flipping the direction will help to traverse from top to down.
I get lost on the problem, I made sure I'll not use computer science concept to solve this problem.
to be simple,
For each identifier in the code base, trace its source.
For each trace, sort it in order of code execution. For example, in case of javascript this is simple problem because there is no concurrancy.
I'm trying to solve this to create a code base refactoring tool, and one step further to automatically watch the code refactor itself. Initially I thought it was cool, but I couldnt take a step or two.
- khanhhuy 3y agoAfter some searching, I think the possible approach is to use a Language Server. For example: the "Find References" in VSCode is implemented through TypeScript Language Server. I skimmed some LSP extensions (Vue, TS), the codes are quite complex, but you only need to interact with those language servers, not re-implement them, so that's still possible