Fetch a reasonable location to start scanning
given the desired start location.  This allows
for adjustments needed to accomodate multiline
comments.
766613
public int getScannerStart( int p )
  {
    Element elem = getDefaultRootElement();
    int lineNum = elem.getElementIndex( p );
    Element line = elem.getElement( lineNum );
    AttributeSet a = line.getAttributes();
    while( a.isDefined( CommentAttribute ) && lineNum > 0 )
    {
      lineNum -= 1;
      line = elem.getElement( lineNum );
      a = line.getAttributes();
    }
    return line.getStartOffset();
  }
1294914
def __getLocation(self, web):
        
        try:
            self.location = web.find("span", {"class": "p-label"}).text
        except AttributeError as error:
            print("There was an error with the user " + self.name)
            print(error)
62011
def get_location_posts(self, location: str) -> Iterator[Post]:
        
        has_next_page = True
        end_cursor = None
        while has_next_page:
            if end_cursor:
                params = {'__a': 1, 'max_id': end_cursor}
            else:
                params = {'__a': 1}
            location_data = self.context.get_json('explore/locations/{0}/'.format(location),
                                                  params)['graphql']['location']['edge_location_to_media']
            yield from (Post(self.context, edge['node']) for edge in location_data['edges'])
            has_next_page = location_data['page_info']['has_next_page']
            end_cursor = location_data['page_info']['end_cursor']
81136
def next_cursor_location(self):
        
        self._verify_entrypoint_selected()
        self.current_trace_frame_index = min(
            self.current_trace_frame_index + 1, len(self.trace_tuples) - 1
        )
        self.trace()
793818
def parse_file_name_starting_position(self):
        
        groups = mod_re.findall('([NS])(\d+)([EW])(\d+)\.hgt', self.file_name)

        assert groups and len(groups) == 1 and len(groups[0]) == 4, 'Invalid file name {0}'.format(self.file_name)

        groups = groups[0]

        if groups[0] == 'N':
            latitude = float(groups[1])
        else:
            latitude = - float(groups[1])

        if groups[2] == 'E':
            longitude = float(groups[3])
        else:
            longitude = - float(groups[3])

        self.latitude = latitude
        self.longitude = longitude
170877
function locationInRangeLoc(loc, start, end) {
    if (loc.line < start.line || end.line < loc.line) {
        return false
    }
    if (loc.line === start.line) {
        if (start.column > loc.column) {
            return false
        }
    }
    if (loc.line === end.line) {
        if (loc.column >= end.column) {
            return false
        }
    }
    return true
}
1317704
public CursorLocation locate(int index, int width) {
        // Upper lines location has been lost.
        if (isLocationInvalidated()) {
            return null;
        }
        int cumulated = 0;

        List<Integer> allLines = new ArrayList<>();
        allLines.addAll(linesSize);
        allLines.add(buffer.length());
        allLines.add(buffer.prompt().getLength());
        int lineIndex = 0;
        for (int i = 0; i < allLines.size(); i++) {
            int cmdSize = allLines.get(i++);
            int promptSize = allLines.get(i);
            lineIndex += 1;
            if (cumulated + cmdSize > index) {
                int part = index - cumulated;
                int col = (part + promptSize) % width;
                // if the part + prompt is longer than width, then
                // the row is in a lower line.
                lineIndex += (promptSize + part) / width;
                return new CursorLocation(lineIndex - 1, col);
            }
            cumulated += cmdSize;
            // Each line could be wrapped if longer than width.
            lineIndex += (cmdSize + promptSize) / width;
        }
        // we are on the last line at the last character.
        if (cumulated == index) {
            int cmdSize = allLines.get(allLines.size() - 2);
            int promptSize = allLines.get(allLines.size() - 1);
            int col = (cmdSize + promptSize) % width;
            return new CursorLocation(lineIndex - 1, col);
        } else {
            return null;
        }
    }
379628
def get_input_location(location):
    
    try:
        if location.SUBCLASS_OF_ID == 0x1523d462:
            return None, location  # crc32(b'InputFileLocation'):
    except AttributeError:
        _raise_cast_fail(location, 'InputFileLocation')

    if isinstance(location, types.Message):
        location = location.media

    if isinstance(location, types.MessageMediaDocument):
        location = location.document
    elif isinstance(location, types.MessageMediaPhoto):
        location = location.photo

    if isinstance(location, types.Document):
        return (location.dc_id, types.InputDocumentFileLocation(
            id=location.id,
            access_hash=location.access_hash,
            file_reference=location.file_reference,
            thumb_size=''  # Presumably to download one of its thumbnails
        ))
    elif isinstance(location, types.Photo):
        return (location.dc_id, types.InputPhotoFileLocation(
            id=location.id,
            access_hash=location.access_hash,
            file_reference=location.file_reference,
            thumb_size=location.sizes[-1].type
        ))

    if isinstance(location, types.FileLocationToBeDeprecated):
        raise TypeError('Unavailable location cannot be used as input')

    _raise_cast_fail(location, 'InputFileLocation')
1041931
def location_nearbystops(self, origin_coord_lat, origin_coord_long):
        
        response = self._request(
            '',
            originCoordLat=origin_coord_lat,
            originCoordLong=origin_coord_long)
        return _get_node(response, 'LocationList', 'StopLocation')
1215495
public int getLineNumber(Location start) {
        LineNumberTableAttr table = mOldLineNumberTable;
        if (table == null) {
            table = mLineNumberTable;
        }

        if (table == null || start.getLocation() < 0) {
            return -1;
        } else {
            return table.getLineNumber(start);
        }
    }
742938
def locate(self):
        
        stored_location = self._get_stored_location()
        if not stored_location:
            ip_range = self._get_ip_range()
            stored_location = self._get_corresponding_location(ip_range)
        return stored_location
1360079
def window_locations(pos, windows):
    
    start_locs = np.searchsorted(pos, windows[:, 0])
    stop_locs = np.searchsorted(pos, windows[:, 1], side='right')
    locs = np.column_stack((start_locs, stop_locs))
    return locs
1044701
def _get_hit_nearest_ref_start(self, hits):
        ''''''
        nearest_to_start = hits[0]
        for hit in hits[1:]:
            if hit.ref_coords().start < nearest_to_start.ref_coords().start:
                nearest_to_start = hit
        return nearest_to_start
4460
public int getMinStartPosition(int docId, int position) throws IOException {
    if (ignoreSpans != null && docId == currentDocId) {
      if (position < minimumPosition) {
        throw new IOException(
            "Unexpected position, should be >= " + minimumPosition + "!");
      } else {
        computeFullStartPositionMinimum(position);
        if (minFullStartPosition.containsKey(position)) {
          return minFullStartPosition.get(position);
        } else {
          return 0;
        }
      }
    } else {
      return 0;
    }
  }
1067920
def locations(params={})
      args = [ :query, :lat, :lon, :count ]
      params.each do |k,v|
        if !args.include?(k)
          raise ArgumentError.new 'Search term not allowed: ' + k.to_s
        end
      end

      if !params.include?(:query)
        raise ArgumentError.new '"query" term with location name is required'
      end

      results = get('locations', params)
      if results.key?("location_suggestions")
        results["location_suggestions"].map { |l| Location.new(self, l) }
      else
        nil
      end
    end
1185526
def get_location(self):
        
        response = self.connection.make_request('GET', self.name,
                                                query_args='location')
        body = response.read()
        if response.status == 200:
            rs = ResultSet(self)
            h = handler.XmlHandler(rs, self)
            xml.sax.parseString(body, h)
            return rs.LocationConstraint
        else:
            raise self.connection.provider.storage_response_error(
                response.status, response.reason, body)
293234
def update_start_position(self):
        ""
        x_start = self.field_array.ScanFieldData.FieldXCoordinate
        y_start = self.field_array.ScanFieldData.FieldYCoordinate

        # empty template have all fields positions set to zero
        # --> avoid overwriting start position
        if x_start != 0 and y_start != 0:
            self.properties.ScanFieldStageStartPositionX = int(x_start * 1e6) # in um
            self.properties.ScanFieldStageStartPositionY = int(y_start * 1e6)