lib/solargraph/language_server/host.rb
# Locate multiple pins that match a completion item. The first match is
# based on the corresponding location in a library source if available.
# Subsequent matches are based on path.
#
# @param params [Hash] A hash representation of a completion item
# @return [Array<Pin::Base>]
Locate multiple pins that match a completion item. The first match is
based on the corresponding location in a library source if available.
Subsequent matches are based on path.
Locate multiple pins that match a completion item . The first match is based on the corresponding location in a library source if available . Subsequent matches are based on path .
def locate_pins params
        return [] unless params['data'] && params['data']['uri']
        library = library_for(params['data']['uri'])
        result = []
        if params['data']['location']
          location = Location.new(
            params['data']['location']['filename'],
            Range.from_to(
              params['data']['location']['range']['start']['line'],
              params['data']['location']['range']['start']['character'],
              params['data']['location']['range']['end']['line'],
              params['data']['location']['range']['end']['character']
            )
          )
          result.concat library.locate_pins(location).select{ |pin| pin.name == params['label'] }
        end
        if params['data']['path']
          result.concat library.path_pins(params['data']['path'])
        end
        result.uniq
      end
def locate_pins params return [ ] unless params [ 'data' ] && params [ 'data' ] [ 'uri' ] library = library_for ( params [ 'data' ] [ 'uri' ] ) result = [ ] if params [ 'data' ] [ 'location' ] location = Location . new ( params [ 'data' ] [ 'location' ] [ 'filename' ] , Range . from_to ( params [ 'data' ] [ 'location' ] [ 'range' ] [ 'start' ] [ 'line' ] , params [ 'data' ] [ 'location' ] [ 'range' ] [ 'start' ] [ 'character' ] , params [ 'data' ] [ 'location' ] [ 'range' ] [ 'end' ] [ 'line' ] , params [ 'data' ] [ 'location' ] [ 'range' ] [ 'end' ] [ 'character' ] ) ) result . concat library . locate_pins ( location ) . select { | pin | pin . name == params [ 'label' ] } end if params [ 'data' ] [ 'path' ] result . concat library . path_pins ( params [ 'data' ] [ 'path' ] ) end result . uniq end
Locate multiple pins that match a completion item.
Locate multiple pins that match a completion item .
None
Array<Pin::Base>
params
A hash representation of a completion item
A hash representation of a completion item