public static string FormatPath(string absoluteIncludeFilename, FormatterOptionsPage.PathMode pathformat, IEnumerable <string> includeDirectories)
        {
            if (pathformat == FormatterOptionsPage.PathMode.Absolute)
            {
                return(absoluteIncludeFilename);
            }
            else
            {
                // todo: Treat std library files special?
                if (absoluteIncludeFilename != null)
                {
                    int    bestLength    = Int32.MaxValue;
                    string bestCandidate = null;

                    foreach (string includeDirectory in includeDirectories)
                    {
                        string proposal = Utils.MakeRelative(includeDirectory, absoluteIncludeFilename);

                        if (proposal.Length < bestLength)
                        {
                            if (pathformat == FormatterOptionsPage.PathMode.Shortest ||
                                (proposal.IndexOf("../") < 0 && proposal.IndexOf("..\\") < 0))
                            {
                                bestCandidate = proposal;
                                bestLength    = proposal.Length;
                            }
                        }
                    }

                    return(bestCandidate);
                }
            }

            return(null);
        }
        /// <summary>
        /// Formats the paths of a given list of include line info.
        /// </summary>
        private static void FormatPaths(IEnumerable <IncludeLineInfo> lines, FormatterOptionsPage.PathMode pathformat, IEnumerable <string> includeDirectories)
        {
            if (pathformat == FormatterOptionsPage.PathMode.Unchanged)
            {
                return;
            }

            foreach (var line in lines)
            {
                string absoluteIncludeDir = line.TryResolveInclude(includeDirectories, out bool resolvedPath);
                if (resolvedPath)
                {
                    line.IncludeContent = FormatPath(absoluteIncludeDir, pathformat, includeDirectories) ?? line.IncludeContent;
                }
            }
        }