Microsoft.Cci.CompositeSourceDocument.GetPrimarySourceLocationsFor C# (CSharp) Method

GetPrimarySourceLocationsFor() public method

Returns zero or more primary source locations that correspond to the given derived location.
public GetPrimarySourceLocationsFor ( IDerivedSourceLocation derivedSourceLocation ) : IEnumerable
derivedSourceLocation IDerivedSourceLocation A source location in this derived document
return IEnumerable
    public IEnumerable<IPrimarySourceLocation> GetPrimarySourceLocationsFor(IDerivedSourceLocation derivedSourceLocation)
      //^^ requires 0 <= position && (position < this.Length || position == 0);
      //^^ requires 0 <= length;
      //^^ requires length <= this.Length;
      //^^ requires position+length <= this.Length;
      //^^ ensures result.SourceDocument == this;
      //^^ ensures result.StartIndex == position;
      //^^ ensures result.Length == length;
    {
      foreach (ISourceLocation sourceLocation in this.GetFragmentLocationsFor(derivedSourceLocation)) {
        IPrimarySourceLocation/*?*/ primarySourceLocation = sourceLocation as IPrimarySourceLocation;
        if (primarySourceLocation != null)
          yield return primarySourceLocation;
        else {
          IDerivedSourceLocation/*?*/ dLoc = sourceLocation as IDerivedSourceLocation;
          if (dLoc != null) {
            foreach (IPrimarySourceLocation pLoc in dLoc.PrimarySourceLocations)
              yield return pLoc;
          }
        }
      }
    }