public override PhysicalLocation VisitPhysicalLocation(PhysicalLocation node) { if (node.Region == null || node.Region.IsBinaryRegion) { goto Exit; } bool insertRegionSnippets = _dataToInsert.HasFlag(OptionallyEmittedData.RegionSnippets); bool overwriteExistingData = _dataToInsert.HasFlag(OptionallyEmittedData.OverwriteExistingData); bool insertContextCodeSnippets = _dataToInsert.HasFlag(OptionallyEmittedData.ContextRegionSnippets); bool populateRegionProperties = _dataToInsert.HasFlag(OptionallyEmittedData.ComprehensiveRegionProperties); if (insertRegionSnippets || populateRegionProperties || insertContextCodeSnippets) { Region expandedRegion; _fileRegionsCache = _fileRegionsCache ?? new FileRegionsCache(_run); // If we can resolve a file location to a newly constructed // absolute URI, we will prefer that if (!node.ArtifactLocation.TryReconstructAbsoluteUri(_run.OriginalUriBaseIds, out Uri resolvedUri)) { resolvedUri = node.ArtifactLocation.Uri; } if (!resolvedUri.IsAbsoluteUri) { goto Exit; } expandedRegion = _fileRegionsCache.PopulateTextRegionProperties(node.Region, resolvedUri, populateSnippet: insertRegionSnippets); ArtifactContent originalSnippet = node.Region.Snippet; if (populateRegionProperties) { node.Region = expandedRegion; } if (originalSnippet == null || overwriteExistingData) { node.Region.Snippet = expandedRegion.Snippet; } else { node.Region.Snippet = originalSnippet; } if (insertContextCodeSnippets && (node.ContextRegion == null || overwriteExistingData)) { node.ContextRegion = _fileRegionsCache.ConstructMultilineContextSnippet(expandedRegion, resolvedUri); } } Exit: return(base.VisitPhysicalLocation(node)); }
public override PhysicalLocation VisitPhysicalLocation(PhysicalLocation node) { if (node.Region == null || node.Region.IsBinaryRegion) { goto Exit; } bool insertRegionSnippets = _dataToInsert.HasFlag(OptionallyEmittedData.RegionSnippets); bool overwriteExistingData = _dataToInsert.HasFlag(OptionallyEmittedData.OverwriteExistingData); bool insertContextCodeSnippets = _dataToInsert.HasFlag(OptionallyEmittedData.ContextRegionSnippets); bool populateRegionProperties = _dataToInsert.HasFlag(OptionallyEmittedData.ComprehensiveRegionProperties); if (insertRegionSnippets || populateRegionProperties || insertContextCodeSnippets) { Region expandedRegion; ArtifactLocation artifactLocation = node.ArtifactLocation; _fileRegionsCache = _fileRegionsCache ?? new FileRegionsCache(_run); if (artifactLocation.Uri == null && artifactLocation.Index >= 0) { // Uri is not stored at result level, but we have an index to go look in run.Artifacts // we must pick the ArtifactLocation details from run.artifacts array Artifact artifactFromRun = _run.Artifacts[artifactLocation.Index]; artifactLocation = artifactFromRun.Location; } // If we can resolve a file location to a newly constructed // absolute URI, we will prefer that if (!artifactLocation.TryReconstructAbsoluteUri(_run.OriginalUriBaseIds, out Uri resolvedUri)) { resolvedUri = artifactLocation.Uri; } if (!resolvedUri.IsAbsoluteUri) { goto Exit; } expandedRegion = _fileRegionsCache.PopulateTextRegionProperties(node.Region, resolvedUri, populateSnippet: insertRegionSnippets); ArtifactContent originalSnippet = node.Region.Snippet; if (populateRegionProperties) { node.Region = expandedRegion; } if (originalSnippet == null || overwriteExistingData) { node.Region.Snippet = expandedRegion.Snippet; } else { node.Region.Snippet = originalSnippet; } if (insertContextCodeSnippets && (node.ContextRegion == null || overwriteExistingData)) { node.ContextRegion = _fileRegionsCache.ConstructMultilineContextSnippet(expandedRegion, resolvedUri); } } Exit: return(base.VisitPhysicalLocation(node)); }