PackageAnalyzer.jl
PackageAnalyzer.jl copied to clipboard
WIP: Use JuliaSyntax to count things out of parsed source code
xref https://github.com/JuliaEcosystem/PackageAnalyzer.jl/issues/63
so far:
julia> analyze_syntax(PackageAnalyzer)
Dict{String, Int64} with 6 entries:
"struct" => 6
"usings" => 16
"call" => 593
"function" => 53
"imports" => 1
"exports" => 7
Overall comments on this:
- Having a well defined category precedence (eg,
code > docstring > comment) would make categorizing lines easy, given there can be multiple categories per line. (cf in the comment about a two-pass system.) - The API for
JuliaSyntax.SyntaxNodeis ... honestly kind of WIP and not entirely awesome haha :grimacing: I feel like some additions to that could really help you here, though I'm not entirely sure what they should be. Ideas welcome.
I've just thought of an upstream change that would help make this cleaner.
I'm planning to emit docstrings as nodes of kind K"doc" in the next version - this reflects the fact that it's special surface syntax, not an explicit macro call. (You can already detect this by detecting the special kind K"core_@doc", but I think emitting a K"macrocall" for this is one of those cases where lowering has crept into the parser a little.)