whitequark / whitequark/parser
Summarize `inspect`
Open
Nobody has claimed this yet.
- Dominant language
- Yacc
- Stars
- 1.6k
- Forks
- 205
- PR merge metrics
- No merged PRs in 30d
Description
The current inspect methods for most classes are not very usable:
@corrector=
#<Parser::Source::TreeRewriter:0x00007fd280304148
@action_root=
#<Parser::Source::TreeRewriter::Action:0x00007fd280d73d90
@children=[],
@enforcer=
#<Method: RuboCop::Cop::Corrector(Parser::Source::TreeRewriter)#enforce_policy(event) /Users/mal/parser/lib/parser/source/tree_rewriter.rb:384>,
@insert_after="",
@insert_before="",
@range=#<Parser::Source::Range /Users/mal/rubocop/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb -1...10139>,
@replacement=nil>,
@diagnostics=
#<Parser::Diagnostic::Engine:0x00007fd2803040a8
@all_errors_are_fatal=false,
@consumer=#<Proc:0x00007fd280d73b88 /Users/mal/rubocop/lib/rubocop/cop/corrector.rb:26 (lambda)>,
@ignore_warnings=false>,
@enforcer=
#<Method: RuboCop::Cop::Corrector(Parser::Source::TreeRewriter)#enforce_policy(event) /Users/mal/parser/lib/parser/source/tree_rewriter.rb:384>,
@in_transaction=false,
@policy={:crossing_deletions=>:accept, :different_replacements=>:raise, :swallowed_insertions=>:raise},
@source_buffer=
#<Parser::Source::Buffer:0x00007fd284028358
@column_for_position=
{0=>0,
31=>0,
102=>0,
166=>0,
268=>6,
343=>6,
421=>6,
492=>6,
571=>6,
646=>6,
722=>6,
#...
@line_for_position= {
# ...
Parser::Source::Range has nice inspect and to_s, but Parser::Source::Buffer and Parser::Source::TreeRewriter (at a minimum) would benefit from a summarized version...
I hope to propose a PR one day...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the inspect implementations for Parser::Source::Buffer and Parser::Source::TreeRewriter, and compare their output with Parser::Source::Range’s inspect and to_s. Done means those classes produce concise, useful summaries instead of recursively dumping internal state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100