class Objc2swiftAssistant::MigrationRegion
Attributes
allowed_parent_region_types[RW]
can_occur_in_class_decl[RW]
configuration[RW]
detection_line[RW]
ending_line_number[RW]
ending_of_root_header[RW]
is_root_entity[RW]
is_single_line[RW]
parent_region[RW]
region_identifier[RW]
region_type[RW]
root_header[RW]
starting_line_number[RW]
sub_regions[RW]
attr_accessor :consumed_line_count
Public Class Methods
new( starting_line_number, is_root_entity, region_type, can_occur_in_class_decl:false )
click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 119 def initialize( starting_line_number, is_root_entity, region_type, can_occur_in_class_decl:false ) @starting_line_number = starting_line_number @is_root_entity = is_root_entity @region_type = region_type @detection_line = detection_line @can_occur_in_class_decl = can_occur_in_class_decl @sub_regions = [] @error_messages = [] @is_single_line = false end
Public Instance Methods
add_sub_region( sub_region )
click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 134 def add_sub_region( sub_region ) @sub_regions << sub_region sub_region.parent_region = self end
brief_description()
click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 184 def brief_description() return "" end
complete( file_lines )
click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 139 def complete( file_lines ) # Delimit sub-regions previous_sub_region = nil @sub_regions.each do |sub_region| resolve_ending_line_number( previous_sub_region, sub_region.starting_line_number - 1) unless previous_sub_region.nil? previous_sub_region = sub_region end resolve_ending_line_number( previous_sub_region, self.ending_line_number ) unless previous_sub_region.nil? self.extract_information( file_lines[ @starting_line_number..@ending_line_number] ) @sub_regions.each do |sub_region| sub_region.complete( file_lines ) end #Find the limits of the unrecognized code in the root migration region @ending_of_root_header = nil @sub_regions.each.with_index(0) do |sub_region, i| if ! sub_region.can_occur_in_class_decl @ending_of_root_header = sub_region.starting_line_number - 1 break end end @ending_of_root_header = @ending_line_number if @ending_of_root_header.nil? @root_header = file_lines[ @starting_line_number..@ending_of_root_header ] # can_occur_in_class_decl end
contains_line( line_number )
click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 130 def contains_line( line_number ) line_number >= @starting_line_number && line_number <= @ending_line_number end
dump( indent, tab, errors_only )
click to toggle source
Output
# File lib/objc2swift_assistant/code_recognizer.rb, line 193 def dump( indent, tab, errors_only ) dump_region_info( indent, tab, errors_only ) @sub_regions.each do |sub_region| sub_region.dump( indent+tab, tab, errors_only ) end end
dump_region_info( indent, tab, errors_only )
click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 200 def dump_region_info( indent, tab, errors_only ) # puts( indent + "#{@region_type} [lines: #{@starting_line_number || '?'}-#{@ending_line_number || '?'}]") printf( "%s%-25s [lines: %3d-%-3d] %s %s\n", indent, @region_type, @starting_line_number+1|| -1, @ending_line_number+1 || -1, brief_description(), @error_message.nil? ? '' : 'ERROR: ' + @error_message ) end
extract_information( file_lines )
click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 176 def extract_information( file_lines ) # Do nothing by default end
generic_description( detail )
click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 180 def generic_description( detail ) return detail end
has_failed()
click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 188 def has_failed ! @error_messages.length > 0 end
resolve_ending_line_number( region, suggested_line_number )
click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 168 def resolve_ending_line_number( region, suggested_line_number ) if region.is_single_line region.ending_line_number = region.starting_line_number else region.ending_line_number = suggested_line_number end end