-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compile RBIs for constants not owned by the current gem
- Loading branch information
Showing
7 changed files
with
235 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# typed: strict | ||
# frozen_string_literal: true | ||
|
||
module Tapioca | ||
module Gem | ||
module Listeners | ||
class NotOwnedConstants < Base | ||
extend T::Sig | ||
|
||
include Runtime::Reflection | ||
|
||
private | ||
|
||
sig { override.params(event: ScopeNodeAdded).void } | ||
def on_scope(event) | ||
mixin = event.constant | ||
|
||
# There are cases where we want to compile RBI for constants not owned by the current | ||
# gem - e.g. constants defined in one gem that then have a mixin applied to them in | ||
# another gem. This is especially common for Ruby standard library classes. | ||
# | ||
# We can identify these cases by keeping track of which classes have mixins, and then | ||
# adding those classes to the pipeline. | ||
Runtime::Trackers::Mixin.constants_with_mixin(mixin).each do |constant| | ||
name = @pipeline.name_of(constant) | ||
@pipeline.push_not_owned_constant(name, constant) if name | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters