toLocation method

Location? toLocation({
  1. int? offset,
  2. int? length,
})

Create a location based on an the given element.

Implementation

plugin.Location? toLocation({int? offset, int? length}) {
  var self = this;
  if (self == null || self.source == null) {
    return null;
  }
  offset ??= self.nameOffset;
  length ??= self.nameLength;
  if (self is analyzer.CompilationUnitElement ||
      (self is analyzer.LibraryElement && offset < 0)) {
    offset = 0;
    length = 0;
  }
  return _locationForArgs(
      self._unitElement, analyzer.SourceRange(offset, length));
}