public IPsiSourceFile FindClosestSink()

in Backend/Core/ForTea.Core/Psi/Cache/Impl/T4GraphSinkSearcher.cs [30:60]


    public IPsiSourceFile FindClosestSink(
      [NotNull] Func<IPsiSourceFile, T4ReversedFileDependencyData> provider,
      [NotNull] IPsiSourceFile source
    )
    {
      var guard = new T4IncludeGuard();
      guard.StartProcessing(source.GetLocation());
      ISet<IPsiSourceFile> currentLayer = new JetHashSet<IPsiSourceFile>(new[] { source });
      while (!currentLayer.IsEmpty())
      {
        var currentLayerSink = TrySelectSink(provider, currentLayer);
        if (currentLayerSink != null) return currentLayerSink;
        var previousLayer = currentLayer;
        currentLayer = previousLayer
          .SelectNotNull(file => provider(file)?.Includers
            .Select(path => Selector.FindMostSuitableFile(path, file)))
          .SelectMany(it => it)
          .SelectNotNull(it => it)
          .Where(path =>
          {
            bool canProcess = guard.CanProcess(path.GetLocation());
            if (canProcess) guard.StartProcessing(path.GetLocation());
            return canProcess;
          }).AsSet();
      }

      // So, there must be a recursion in includes.
      // This is not going to compile anyway,
      // so no support for this case
      return source;
    }