Class: Yoda::Parsing::Query::CurrentCommentTokenQuery::InputtingLine

Inherits:
Object
  • Object
show all
Defined in:
lib/yoda/parsing/query/current_comment_token_query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token_sequence, column) ⇒ InputtingLine

Returns a new instance of InputtingLine.

Parameters:



77
78
79
80
# File 'lib/yoda/parsing/query/current_comment_token_query.rb', line 77

def initialize(token_sequence, column)
  @token_sequence = token_sequence
  @column = column
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



73
74
75
# File 'lib/yoda/parsing/query/current_comment_token_query.rb', line 73

def column
  @column
end

#token_sequenceObject (readonly)

Returns the value of attribute token_sequence.



70
71
72
# File 'lib/yoda/parsing/query/current_comment_token_query.rb', line 70

def token_sequence
  @token_sequence
end

Instance Method Details

#at_sign?true, false

Returns:

  • (true, false)


116
117
118
119
120
# File 'lib/yoda/parsing/query/current_comment_token_query.rb', line 116

def at_sign?
  current_token &&
  current_token.to_s.match?(/\A[{}.&\]\[\(\)<>]/) &&
  column == current_token.offset + current_token.size
end

#current_range(Integer, Integer)?

Returns:

  • ((Integer, Integer), nil)


88
89
90
91
# File 'lib/yoda/parsing/query/current_comment_token_query.rb', line 88

def current_range
  return nil unless current_token
  [current_token.offset, current_token.offset + current_token.size]
end

#current_stateSymbol

Returns:

  • (Symbol)


99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/yoda/parsing/query/current_comment_token_query.rb', line 99

def current_state
  @current_state ||= begin
    if tag && %w(@type @!sig).include?(tag.to_s) && !on_tag?
      :type_tag_type
    elsif tag && token_sequence.parameter_tokens.empty?
      :tag
    elsif in_bracket?
      :type
    elsif at_parameter_name?
      :param
    else
      :none
    end
  end
end

#current_tokenParslet::Slice?

Returns:

  • (Parslet::Slice, nil)


94
95
96
# File 'lib/yoda/parsing/query/current_comment_token_query.rb', line 94

def current_token
  @current_token ||= token_sequence.all_tokens.find { |token| token.offset <= column && column <= token.offset + token.size }
end

#tagParslet::Slice?

Returns:

  • (Parslet::Slice, nil)


83
84
85
# File 'lib/yoda/parsing/query/current_comment_token_query.rb', line 83

def tag
  token_sequence.tag
end