Class: Objc2swiftAssistant::ObjCDirectoryNode

Inherits:
DirectoryNode show all
Defined in:
lib/objc2swift_assistant/file_sets.rb

Instance Attribute Summary collapse

Attributes inherited from DirectoryNode

#child_directories, #file_nodes_by_name, #file_set, #full_path, #parent_node, #pruned, #relative_path

Instance Method Summary collapse

Methods inherited from DirectoryNode

#add_child_directory, #dump

Constructor Details

#initialize(path, file_set) ⇒ ObjCDirectoryNode

Returns a new instance of ObjCDirectoryNode.



163
164
165
# File 'lib/objc2swift_assistant/file_sets.rb', line 163

def initialize(path, file_set)
  super(path, file_set)
end

Instance Attribute Details

#associated_generated_directoryObject

Returns the value of attribute associated_generated_directory.



161
162
163
# File 'lib/objc2swift_assistant/file_sets.rb', line 161

def associated_generated_directory
  @associated_generated_directory
end

Instance Method Details

#create_associated_generated_nodes(generated_file_set) ⇒ Object



198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/objc2swift_assistant/file_sets.rb', line 198

def create_associated_generated_nodes( generated_file_set )
  # puts( "generaating file node: #{@relative_path}")
  #TODO: Break this out into Swift generation-specific ruby file
  return if @pruned

#   #TODO: allow mapping to new directory scruture for this file
  generated_relative_path = generated_file_set.root + @relative_path
  @associated_generated_directory = generated_file_set.directory_node_for_path( generated_relative_path )
  @file_nodes_by_name.each_value do |file_node|
    # puts( "generaating file node: #{file_node.}")
    file_node.create_generated_file_nodes( generated_file_set, @associated_generated_directory )
  end
end

#file_node_for_file(without_extension_string) ⇒ Object



187
188
189
190
191
192
193
194
195
196
# File 'lib/objc2swift_assistant/file_sets.rb', line 187

def file_node_for_file( without_extension_string )
  file_node = @file_nodes_by_name[ without_extension_string ]

  if file_node.nil?
    file_node = ObjCFileNode.new( self, without_extension_string )
    @file_nodes_by_name[ without_extension_string ] = file_node
  end

  return file_node
end

#process_file(path) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/objc2swift_assistant/file_sets.rb', line 167

def process_file( path )
  basename = path.basename

  without_extension = path.basename(".h") || path.basename(".hh")
  if without_extension != basename
    file_node = file_node_for_file( without_extension.to_s )
    file_node.header_file_path = path
    return
  end

  without_extension = path.basename(".m") || path.basename(".mm")
  if without_extension != basename
    file_node = file_node_for_file( without_extension.to_s )
    file_node.implementation_file_path = path
    return
  end

  @file_set.configuration.log_verbose( "File not captured:#{path.to_s}")
end