Commit db81b55
committed
Implement working automated import suggestion generation via AST parsing
Successfully implemented automated scanning of the Nim stdlib to generate
import suggestions. The tool now uses AST parsing instead of full semantic
compilation, avoiding complex compiler initialization issues.
Key achievements:
- Scans 285 stdlib modules automatically
- Extracts 3,355 unique exported symbols
- Generates 127 KB suggestion table
- Identifies 353 symbols available in multiple modules
- Shows alternative import options to users
Implementation approach:
- Uses compiler/parser to parse module AST
- Walks AST looking for exported symbols (nkPostfix nodes)
- Extracts procs, types, constants, and variables with * marker
- Graceful error handling for parse failures
- No full semantic analysis required
Example output:
Error: undeclared identifier: 'sleep'
help: 'sleep' is available in 'windows/winlean'
add: import windows/winlean
also available in: os, posix/posix
The automated generation is now fully working and can be run via:
./koch genImportSuggestions
Or directly:
bin/nim c -r tools/gen_import_suggestions.nim1 parent 5b2a194 commit db81b55
File tree
2 files changed
+3434
-190
lines changed- compiler
- tools
2 files changed
+3434
-190
lines changed
0 commit comments