require "objc2swift_assistant/version"

require "objc2swift_assistant/code_recognizer"

module Objc2swiftAssistant

  PRAGMA_MARK_REGEX = /^\s*((#pragma mark)|(\/\/\s*MARK\s*\:))(?<mark_text>.*)/

  class PragmaMarkRecognizer < CodeRecognizer
    def initialize( )
      super( PRAGMA_MARK_REGEX, PragmaMarkRegion, :all_source_files, false )
    end
  end


  class PragmaMarkRegion < MigrationRegion
    attr_accessor :mark_text

    def initialize( starting_line_number, is_root_entity )
      super( starting_line_number, is_root_entity, PRAGMA_MARK_KEY, can_occur_in_class_decl:true )
    end


    def extract_information( file_slice )
      m = PRAGMA_MARK_REGEX.match(file_slice[0])
      unless m.nil?
        @mark_text = m[ 'mark_text' ]
      end
    end
  end

  def description()
    if @is_block_property
      return generic_description( "Block Property: prop_name=#{@prop_name} block_return_type=#{@block_return_type} block_args=#{@block_args}" )
    else
      return generic_description( "type_name=#{@type_name} is_pointer=#{@is_pointer} prop_name=#{@prop_name}" )
    end
  end


end
