private static DocumentRange GetDocumentRange()

in Backend/Core/ForTea.Core/Parsing/Ranges/T4UnsafeManualRangeTranslationUtil.cs [31:58]


    private static DocumentRange GetDocumentRange([NotNull] IFile file, TreeTextRange range)
    {
      // The whole purpose of this class is to remove the following line:
      // Assertion.Assert(file.IsValid(), "file.IsValid()");

      if (!range.IsValid())
        return DocumentRange.InvalidRange;

      var tmpFile = (IFileImpl)file;
      var translator = tmpFile.SecondaryRangeTranslator;
      var tmpRange = range;
      while (translator != null)
      {
        tmpRange = translator.GeneratedToOriginal(tmpRange);
        if (!tmpRange.IsValid()) return DocumentRange.InvalidRange;

        tmpFile = (IFileImpl)translator.OriginalFile;
        if (tmpFile == null) return DocumentRange.InvalidRange;

        translator = tmpFile.SecondaryRangeTranslator;
      }

      var parsedDocumentRange = tmpFile.DocumentRangeTranslator.Translate(tmpRange);
      if (!parsedDocumentRange.IsValid())
        return DocumentRange.InvalidRange;

      return parsedDocumentRange;
    }