public IEnumerable<IPrimarySourceLocation> GetPrimarySourceLocationsFor(ILocation location)
 {
     IPrimarySourceLocation/*?*/ psloc = location as IPrimarySourceLocation;
       if (psloc != null) {
     IIncludedSourceLocation /*?*/ iloc = psloc as IncludedSourceLocation;
     if (iloc != null)
       yield return new OriginalSourceLocation(iloc);
     else
       yield return psloc;
       } else {
     IDerivedSourceLocation/*?*/ dsloc = location as IDerivedSourceLocation;
     if (dsloc != null) {
       foreach (IPrimarySourceLocation psl in dsloc.PrimarySourceLocations) {
     IIncludedSourceLocation /*?*/ iloc = psl as IncludedSourceLocation;
     if (iloc != null)
       yield return new OriginalSourceLocation(iloc);
     else
       yield return psl;
       }
     }
     var esloc = location as IExpressionSourceLocation;
     if (esloc != null) {
       yield return esloc.PrimarySourceLocation;
     }
       }
 }
示例#2
0
        static void GetLocationLineSpan(IPrimarySourceLocation loc, out uint startLine, out uint endLine)
        {
            IIncludedSourceLocation /*?*/ iloc = loc as IIncludedSourceLocation;

            if (iloc != null)
            {
                startLine = (uint)iloc.OriginalStartLine;
                endLine   = (uint)iloc.OriginalEndLine;
            }
            else
            {
                startLine = (uint)loc.StartLine;
                endLine   = (uint)loc.EndLine;
            }
        }
 /// <summary>
 /// Allocates a wrapper for a source location that is obtained from a region inside a primary source document that was
 /// in fact derived from another document, typically via a preprocessor #include directive. The wrapper
 /// makes the wrapped source location appear as if it were a location in the document that was included.
 /// This is useful for error reporting. For editing, the wrapped location is better.
 /// </summary>
 /// <param name="includedSourceLocation">A source location that falls inside a region of text that originally came from another source document.</param>
 public OriginalSourceLocation(IIncludedSourceLocation includedSourceLocation) {
   this.includedSourceLocation = includedSourceLocation;
 }