lib/solargraph/library.rb
# Get definition suggestions for the expression at the specified file and
# location.
#
# @param filename [String] The file to analyze
# @param line [Integer] The zero-based line number
# @param column [Integer] The zero-based column number
# @return [Array<Solargraph::Pin::Base>]
# @todo Take filename/position instead of filename/line/column
Get definition suggestions for the expression at the specified file and
location.
Get definition suggestions for the expression at the specified file and location .
def definitions_at filename, line, column
      position = Position.new(line, column)
      cursor = Source::Cursor.new(read(filename), position)
      if cursor.comment?
        source = read(filename)
        offset = Solargraph::Position.to_offset(source.code, Solargraph::Position.new(line, column))
        lft = source.code[0..offset-1].match(/\[[a-z0-9_:<, ]*?([a-z0-9_:]*)\z/i)
        rgt = source.code[offset..-1].match(/^([a-z0-9_]*)(:[a-z0-9_:]*)?[\]>, ]/i)
        if lft && rgt
          tag = (lft[1] + rgt[1]).sub(/:+$/, '')
          clip = api_map.clip(cursor)
          clip.translate tag
        else
          []
        end
      else
        api_map.clip(cursor).define.map { |pin| pin.realize(api_map) }
      end
    end
def definitions_at filename , line , column position = Position . new ( line , column ) cursor = Source :: Cursor . new ( read ( filename ) , position ) if cursor . comment? source = read ( filename ) offset = Solargraph :: Position . to_offset ( source . code , Solargraph :: Position . new ( line , column ) ) lft = source . code [ 0 .. offset - 1 ] . match ( / \[ [a-z0-9_:<, ]*?([a-z0-9_:]*) \z /i ) rgt = source . code [ offset .. - 1 ] . match ( / ^([a-z0-9_]*)(:[a-z0-9_:]*)?[ \] >, ] /i ) if lft && rgt tag = ( lft [ 1 ] + rgt [ 1 ] ) . sub ( / :+$ / , '' ) clip = api_map . clip ( cursor ) clip . translate tag else [ ] end else api_map . clip ( cursor ) . define . map { | pin | pin . realize ( api_map ) } end end
Get definition suggestions for the expression at the specified file and
location.
Get definition suggestions for the expression at the specified file and location .
None
Array<Solargraph::Pin::Base>
filename
The file to analyze
The file to analyze
line
The zero-based line number
The zero - based line number
column
The zero-based column number
The zero - based column number
todo
Take filename/position instead of filename/line/column
Take filename / position instead of filename / line / column