private string createAugmentedLog(string log, Action <int> progress)
        {
            SolutionUtils.refillAllSolutionProjectItems(solution);

            string[]      strings     = log.Split(new[] { '\n' });
            StringBuilder logSb       = new StringBuilder();
            int           prevPercent = 0;
            double        i           = 0;

            foreach (var s in strings)
            {
                if (progress != null)
                {
                    ++i;
                    int percent = (int)(i * 100 / strings.Length);
                    if (percent > prevPercent)
                    {
                        prevPercent = percent;
                        progress(percent);
                    }
                }

                StringBuilder lineSb        = new StringBuilder();
                bool          tooLong       = s.Length > MAX_PARSEABLE_LENGTH;
                string        parseablePart = tooLong ? s.Substring(0, MAX_PARSEABLE_LENGTH) : s;
                string        restPart      = tooLong ? s.Substring(MAX_PARSEABLE_LENGTH) : "";

                MatchCollection matches = FILE_AND_LINE.Matches(parseablePart);
                if (matches.Count > 0)
                {
                    foreach (Match match in matches)
                    {
                        string fileName = match.Groups[3].Value;
                        if (!fileName.EndsWith(".sln") && !fileName.EndsWith("proj") && SolutionUtils.solutionContainsFile(fileName, solution))
                        {
                            string lineNumber = match.Groups[8].Value.Trim();
                            lineSb.Append(match.Groups[1].Value)
                            .Append(" <a href=\"").Append(OPENFILE_ON_LINE_URL)
                            .Append(fileName).Append('@').Append(lineNumber).Append("\">")
                            .Append(fileName).Append('(').Append(lineNumber).Append(")</a>")
                            .Append(match.Groups[11]);
                        }
                        else
                        {
                            lineSb.Append(match.Groups[0]);
                        }
                    }
                    Match lastMatch = matches[matches.Count - 1];
                    lineSb.Append(parseablePart.Substring(lastMatch.Index + lastMatch.Length));
                }
                else
                {
                    lineSb.Append(parseablePart);
                }
                lineSb.Append(restPart);
                logSb.Append(colorLine(lineSb.ToString())).Append("<br>\r\n");
            }
            return(logSb.ToString());
        }
Ejemplo n.º 2
0
        public IEnumerable <SolutionProject> GetProjects()
        {
            var projects = SolutionUtils.Projects();

            return(projects.Select(x => new SolutionProject()
            {
                FilePath = x.FileName,
                Name = x.Name
            }));
        }
        private bool navigateToTestClassAndMethod(BambooTest test)
        {
            string fileName = null, lineNo = null;

            foreach (Project project in solution.Projects)
            {
                if (examineProjectItems(project.ProjectItems, test.ClassName, test.MethodName, ref fileName, ref lineNo))
                {
                    return(SolutionUtils.openSolutionFile(fileName, lineNo, solution));
                }
            }
            return(false);
        }
        private void logNavigating(object sender, WebBrowserNavigatingEventArgs e)
        {
            e.Cancel = true;

            if (e.Url.Equals("about:blank"))
            {
                return;
            }

            string url = e.Url.ToString();

            if (url.StartsWith(OPENFILE_ON_LINE_URL))
            {
                string file = url.Substring(OPENFILE_ON_LINE_URL.Length, url.LastIndexOf('@') - OPENFILE_ON_LINE_URL.Length);

                string lineNoStr = url.Substring(url.LastIndexOf('@') + 1);

                SolutionUtils.openSolutionFile(file, lineNoStr, solution);
            }
        }
        private async Task <SolutionUtils> GetSolutionUtilsAsync()
        {
            await this.package.JoinableTaskFactory.SwitchToMainThreadAsync(this.package.DisposalToken);

            var solutionService = (IVsSolution)await this.package.GetServiceAsync(typeof(SVsSolution));

            var componentModel = (IComponentModel)await this.package.GetServiceAsync(typeof(SComponentModel));

            var workspaceService = componentModel.GetService <IVsFolderWorkspaceService>();
            var result           = new SolutionUtils(solutionService, workspaceService, this.package.JoinableTaskFactory);

            result.SolutionChanged += (sender, solutionDir) =>
            {
                if (package.OptionChangeDirectory)
                {
                    this.ChangeWorkingDirectoryAsync(solutionDir).FileAndForget("WhackWhackTerminal/changeWorkingDirectory");
                }
            };

            return(result);
        }