in Backend/Core/ForTea.Core/Parsing/Ranges/T4TreeToDocumentTranslator.cs [54:77]
public DocumentRange Translate(TreeTextRange range)
{
if (!range.IsValid() || !SourceFile.IsValid()) return DocumentRange.InvalidRange;
var sector = FindSectorAtRange(range);
if (!sector.IsValid()) return DocumentRange.InvalidRange;
// Let the included file handle the request
if (sector.Include != null) return sector.Include.DocumentRangeTranslator.Translate(range);
// The range is in the current document
// The includes that appear before do not contribute to document offset
int extraIncludeOffset = sector.PrecedingIncludeLength;
// Neither do the other includes in the tree
// (the ones that are included before the current file)
int extraRootOffset = FileLikeNode.GetTreeStartOffset().Offset;
var start = range.StartOffset - extraIncludeOffset - extraRootOffset;
var end = range.EndOffset - extraIncludeOffset - extraRootOffset;
var resultingTextRange = new TextRange(start.Offset, end.Offset);
resultingTextRange.AssertValid();
return new DocumentRange(SourceFile.Document, resultingTextRange);
}