Class: IncludeDependencyGraph

Inherits:
Object
  • Object
show all
Defined in:
lib/cpp_dependency_graph/include_dependency_graph.rb

Overview

Returns a hash of intra-component include links

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ IncludeDependencyGraph

Returns a new instance of IncludeDependencyGraph.



9
10
11
# File 'lib/cpp_dependency_graph/include_dependency_graph.rb', line 9

def initialize(project)
  @project = project
end

Instance Method Details



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cpp_dependency_graph/include_dependency_graph.rb', line 13

def include_links(component_name)
  component = @project.source_component(component_name)
  source_files = component.source_files
  source_files.map do |file|
    class_name = file.basename
    # TODO: Very inefficient

    internal_includes = file.includes.reject { |inc| @project.external_includes(component).any?(inc) }
    include_links = internal_includes.map { |inc| ComponentLink.new(class_name, inc, false) }
    [class_name, include_links]
  end.to_h
end