-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make dead code indexing use a Model
to index classes
#562
Conversation
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
6359779
to
49c816f
Compare
# end | ||
# end | ||
# ~~~ | ||
sig { params(indexer: Indexer, definition: Definition).void } | ||
def on_define_class(indexer, definition) | ||
sig { params(symbol_def: Model::Class, definition: Definition).void } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be abstract?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to crash when calling on_define_class
to a plugin that do nothing with it, we just want it to no-op.
We _could_refactor this to have multiple interfaces:
module ClassPlugin
interface!
sig { abstract.void }
def on_define_class; end
and then let the plugins cherry pick the interfaces they want to implement.
But in practice I just rely on YJIT to optimize this empty calls away.
This is the first PR on a sequence moving the dead code analysis use the
Model
introduced in #557 rather than its custom indexer.In this PR we migrate the indexing of classes:
Deadcode::Index
take aModel
(bc18520)Deadcode::Indexer
(9433fda)Deadcode::Plugins
takeModel::SymbolDef
when callingon_define_class
(6359779)There is no behavior change: no tests are changed.
This PR is easier to review commit by commit.