class Yoda::Parsing::Query::CurrentCommentTokenQuery::InputtingLine

Attributes

column[R]

@type Integer

token_sequence[R]

Public Class Methods

new(token_sequence, column) click to toggle source

@param token_sequence [CommentTokenizer::Sequence] @param column [Integer]

# File lib/yoda/parsing/query/current_comment_token_query.rb, line 76
def initialize(token_sequence, column)
  @token_sequence = token_sequence
  @column = column
end

Public Instance Methods

at_sign?() click to toggle source

@return [true, false]

# File lib/yoda/parsing/query/current_comment_token_query.rb, line 115
def at_sign?
  current_token &&
  current_token.to_s.match?(/\A[{}.&\]\[\(\)<>]/) &&
  column == current_token.offset + current_token.size
end
current_range() click to toggle source

@return [(Integer, Integer), nil]

# File lib/yoda/parsing/query/current_comment_token_query.rb, line 87
def current_range
  return nil unless current_token
  [current_token.offset, current_token.offset + current_token.size]
end
current_state() click to toggle source

@return [Symbol]

# File lib/yoda/parsing/query/current_comment_token_query.rb, line 98
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_token() click to toggle source

@return [Parslet::Slice, nil]

# File lib/yoda/parsing/query/current_comment_token_query.rb, line 93
def current_token
  @current_token ||= token_sequence.all_tokens.find { |token| token.offset <= column && column <= token.offset + token.size }
end
tag() click to toggle source

@return [Parslet::Slice, nil]

# File lib/yoda/parsing/query/current_comment_token_query.rb, line 82
def tag
  token_sequence.tag
end

Private Instance Methods

at_parameter_name?() click to toggle source

@return [Boolean]

# File lib/yoda/parsing/query/current_comment_token_query.rb, line 129
def at_parameter_name?
  case token_sequence.parameter_tokens.length
  when 0
    # TODO
    false
  when 1
    tag && %w(@param).include?(tag.to_s)
  else
    false
  end
end
in_bracket?() click to toggle source

@return [Boolean]

# File lib/yoda/parsing/query/current_comment_token_query.rb, line 142
def in_bracket?
  token_sequence.parameter_tokens.reverse_each do |token|
    return false if token.to_s == ']'
    return true if token.to_s == '['
  end
  false
end
on_tag?() click to toggle source

@return [Boolean]

# File lib/yoda/parsing/query/current_comment_token_query.rb, line 124
def on_tag?
  tag && tag.offset <= column && column <= tag.offset + tag.size
end