Class: Objc2swiftAssistant::PropertyDeclarationRegion
- Inherits:
-
MigrationRegion
- Object
- FailableProcessingElement
- MigrationRegion
- Objc2swiftAssistant::PropertyDeclarationRegion
- Defined in:
- lib/objc2swift_assistant/recognizers/property_declaration_recognizer.rb
Instance Attribute Summary collapse
-
#block_args ⇒ Object
Returns the value of attribute block_args.
-
#block_return_type ⇒ Object
Returns the value of attribute block_return_type.
-
#is_block_property ⇒ Object
Returns the value of attribute is_block_property.
-
#is_pointer ⇒ Object
Returns the value of attribute is_pointer.
-
#modifiers ⇒ Object
Returns the value of attribute modifiers.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type_name ⇒ Object
Returns the value of attribute type_name.
Attributes inherited from MigrationRegion
#allowed_parent_region_types, #can_occur_in_class_decl, #configuration, #detection_line, #ending_line_number, #ending_of_root_header, #is_root_entity, #is_single_line, #parent_region, #region_identifier, #region_type, #root_header, #starting_line_number, #sub_regions
Attributes inherited from FailableProcessingElement
Instance Method Summary collapse
- #brief_description ⇒ Object
- #description ⇒ Object
- #extract_information(file_slice) ⇒ Object
-
#initialize(starting_line_number, is_root_entity) ⇒ PropertyDeclarationRegion
constructor
A new instance of PropertyDeclarationRegion.
- #split_modifiers(modifiers) ⇒ Object
Methods inherited from MigrationRegion
#add_sub_region, #complete, #contains_line, #dump, #dump_region_info, #generic_description, #has_failed, #resolve_ending_line_number
Methods inherited from FailableProcessingElement
#add_error, #add_warning, #has_errors, #initiailize
Constructor Details
#initialize(starting_line_number, is_root_entity) ⇒ PropertyDeclarationRegion
Returns a new instance of PropertyDeclarationRegion.
24 25 26 |
# File 'lib/objc2swift_assistant/recognizers/property_declaration_recognizer.rb', line 24 def initialize(starting_line_number, is_root_entity ) super(starting_line_number, is_root_entity, PROPERTY_DECLARATION_KEY ) end |
Instance Attribute Details
#block_args ⇒ Object
Returns the value of attribute block_args.
22 23 24 |
# File 'lib/objc2swift_assistant/recognizers/property_declaration_recognizer.rb', line 22 def block_args @block_args end |
#block_return_type ⇒ Object
Returns the value of attribute block_return_type.
21 22 23 |
# File 'lib/objc2swift_assistant/recognizers/property_declaration_recognizer.rb', line 21 def block_return_type @block_return_type end |
#is_block_property ⇒ Object
Returns the value of attribute is_block_property.
20 21 22 |
# File 'lib/objc2swift_assistant/recognizers/property_declaration_recognizer.rb', line 20 def is_block_property @is_block_property end |
#is_pointer ⇒ Object
Returns the value of attribute is_pointer.
16 17 18 |
# File 'lib/objc2swift_assistant/recognizers/property_declaration_recognizer.rb', line 16 def is_pointer @is_pointer end |
#modifiers ⇒ Object
Returns the value of attribute modifiers.
18 19 20 |
# File 'lib/objc2swift_assistant/recognizers/property_declaration_recognizer.rb', line 18 def modifiers @modifiers end |
#name ⇒ Object
Returns the value of attribute name.
17 18 19 |
# File 'lib/objc2swift_assistant/recognizers/property_declaration_recognizer.rb', line 17 def name @name end |
#type_name ⇒ Object
Returns the value of attribute type_name.
15 16 17 |
# File 'lib/objc2swift_assistant/recognizers/property_declaration_recognizer.rb', line 15 def type_name @type_name end |
Instance Method Details
#brief_description ⇒ Object
72 73 74 |
# File 'lib/objc2swift_assistant/recognizers/property_declaration_recognizer.rb', line 72 def brief_description return "(#{@modifiers.join( ', ' )}) #{@type_name} #{'*' if @is_pointer} #{@name}" end |
#description ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/objc2swift_assistant/recognizers/property_declaration_recognizer.rb', line 64 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 |
#extract_information(file_slice) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/objc2swift_assistant/recognizers/property_declaration_recognizer.rb', line 28 def extract_information( file_slice ) m = /^\s*(@property)\s*\((?<modifiers>.*)\)\s*(?<type>\w*)\s*(?<pointer>\*?)\s*(?<prop_name>\w*)/.match(file_slice[0]) unless m.nil? @type_name = m["type"] @is_pointer = m["pointer"] == '*' @name = m["prop_name"] #TODO: @modifiers = capture_modifiers( m["modifiers"] ) @modifiers = split_modifiers( m["modifiers"] ) if @type_name.nil? || @type_name.length == 0 # Test for Block declaration m = /^\s*(@property)\s*\((?<modifiers>.*)\)\s*(?<return_type>\w*)\s*\(\^(?<name>\w*)\)\s*\((?<args>.*)\)/.match(file_slice[0]) unless m.nil? @is_block_property = true @block_return_type = m[ 'return_type' ] @name = m[ 'name' ] @block_args = m[ 'args' ] # TODO: Split these @configuration.log_verbose( "Matched: " + description ) else @configuration.log_warning( "Could not match block property declaraion in #{file_slice[0]}" ) end else @configuration.log_verbose( description ) end else @configuration.log_warning( "Could not match property declaraion in #{file_slice[0]}" ) end end |
#split_modifiers(modifiers) ⇒ Object
59 60 61 62 |
# File 'lib/objc2swift_assistant/recognizers/property_declaration_recognizer.rb', line 59 def split_modifiers( modifiers ) return if modifiers.nil? @modifiers = modifiers.strip.split( /\s*,\s*/ ) end |