Skip to content

Commit 722d240

Browse files
committed
Filter Rubydex declarations to namespaces, constants, and aliases
1 parent d368c8c commit 722d240

2 files changed

Lines changed: 13 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: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ def graph_from_paths(paths)
2626
graph
2727
end
2828

29+
#: (Rubydex::Graph graph) -> Set[String]
30+
def symbols_from_graph(graph)
31+
graph.declarations.select do |decl|
32+
(decl.is_a?(Rubydex::Namespace) ||
33+
decl.is_a?(Rubydex::Constant) ||
34+
decl.is_a?(Rubydex::ConstantAlias)) &&
35+
# Exclude Rubydex's built-in definitions
36+
decl.definitions.any? { |defn| defn.location.uri != "rubydex:built-in" }
37+
end.map(&:name).to_set
38+
end
39+
2940
#: (Gemfile::GemSpec gem) -> Set[String]
3041
def engine_symbols(gem)
3142
gem_engine = engines.find do |engine|
@@ -47,7 +58,7 @@ def engine_symbols(gem)
4758
end
4859

4960
engine_graph = graph_from_paths(paths)
50-
engine_graph.declarations.map(&:name).to_set
61+
symbols_from_graph(engine_graph)
5162
rescue
5263
Set.new
5364
end

0 commit comments

Comments
 (0)