File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -26,6 +26,28 @@ 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 . filter_map do |decl |
32+ next unless decl . is_a? ( Rubydex ::Namespace ) ||
33+ decl . is_a? ( Rubydex ::Constant ) ||
34+ decl . is_a? ( Rubydex ::ConstantAlias ) ||
35+ decl . is_a? ( Rubydex ::Todo )
36+
37+ # Declarations added by `graph.resolve` only have `rubydex:built-in` definitions.
38+ # We exclude those unless the namespace has method or constant members defined in
39+ # source files, which indicates a class reopening (e.g. `class Object; def Nokogiri(); end`).
40+ if decl . definitions . any? && decl . definitions . all? { |defn | defn . location . uri == "rubydex:built-in" }
41+ next unless decl . is_a? ( Rubydex ::Namespace ) && decl . members . any? do |m |
42+ ( m . is_a? ( Rubydex ::Method ) || m . is_a? ( Rubydex ::Constant ) || m . is_a? ( Rubydex ::ConstantAlias ) ) &&
43+ m . definitions . any?
44+ end
45+ end
46+
47+ decl . name
48+ end . to_set
49+ end
50+
2951 #: (Gemfile::GemSpec gem) -> Set[String]
3052 def engine_symbols ( gem )
3153 gem_engine = engines . find do |engine |
@@ -47,7 +69,7 @@ def engine_symbols(gem)
4769 end
4870
4971 engine_graph = graph_from_paths ( paths )
50- engine_graph . declarations . map ( & :name ) . to_set
72+ symbols_from_graph ( engine_graph )
5173 rescue
5274 Set . new
5375 end
You can’t perform that action at this time.
0 commit comments