Skip to content

Commit eeebd71

Browse files
committed
Filter Rubydex declarations to namespaces, constants, and aliases
1 parent 8dc38ea commit eeebd71

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

lib/tapioca/gem/pipeline.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def initialize(
3232

3333
@payload_symbols = Static::SymbolLoader.payload_symbols #: Set[String]
3434
gem_graph = Static::SymbolLoader.graph_from_paths(@gem.files) #: Rubydex::Graph
35-
gem_symbols = gem_graph.declarations.map(&:name).to_set
35+
gem_symbols = Static::SymbolLoader.symbols_from_graph(gem_graph)
3636
engine_symbols = Static::SymbolLoader.engine_symbols(@gem)
3737
@bootstrap_symbols = gem_symbols.union(engine_symbols) #: Set[String]
3838

lib/tapioca/static/symbol_loader.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ def graph_from_paths(paths)
2626
graph
2727
end
2828

29+
#: (Rubydex::Graph graph) -> Set[String]
30+
def symbols_from_graph(graph)
31+
namespaces = graph.declarations.grep(Rubydex::Namespace).map(&:name)
32+
constants = graph.declarations.grep(Rubydex::Constant).map(&:name)
33+
aliases = graph.declarations.grep(Rubydex::ConstantAlias).map(&:name)
34+
(namespaces + constants + aliases).to_set
35+
end
36+
2937
#: (Gemfile::GemSpec gem) -> Set[String]
3038
def engine_symbols(gem)
3139
gem_engine = engines.find do |engine|
@@ -47,7 +55,7 @@ def engine_symbols(gem)
4755
end
4856

4957
engine_graph = graph_from_paths(paths)
50-
engine_graph.declarations.map(&:name).to_set
58+
symbols_from_graph(engine_graph)
5159
rescue
5260
Set.new
5361
end

0 commit comments

Comments
 (0)