Ejemplo n.º 1
0
        protected string GetLinkUrl()
        {
            Location location = syntaxNode.GetLocation();
            string   filePath = syntaxNode.SyntaxTree.FilePath;

            if (!location.IsInSource)
            {
                return(ActionBuilder.PathOpenUri(filePath));
            }

            return(ActionBuilder.BuildActionUri(
                       ActionNames.PATH_OPEN,
                       new Dictionary <string, string>
            {
                { ActionParameters.PATH, filePath },
                { "line", (location.GetLineSpan().StartLinePosition.Line + 1).ToString() }
            }));
        }
Ejemplo n.º 2
0
        private static void SearchLine(SearchContext context, string filePath)
        {
            if ((context.IsRegex && !context.Regex.IsMatch(context.Line)) ||
                context.Line.IndexOf(context.SearchTerm, 0, StringComparison.OrdinalIgnoreCase) < 0)
            {
                return;
            }

            context.MatchResult = new SpanBuilder();
            context.MatchResult.Write("- ");
            context.MatchResult.Link(
                $"{context.LineNumber:0000}",
                ActionBuilder.BuildActionUri(
                    ActionNames.PATH_OPEN,
                    new Dictionary <string, string>
            {
                { ActionParameters.PATH, filePath.GetFullPath() },
                { "line", context.LineNumber.ToString() }
            }));
            context.MatchResult.Write(": ");
            int countBefore = context.MatchesCount;

            if (context.IsRegex)
            {
                RegexSearch(context);
            }
            else
            {
                IndexSearch(context);
            }

            if (context.MatchesCount <= countBefore)
            {
                return;
            }

            context.MatchResult.WriteLine();
            context.MatchResults = context.MatchResults.AddChild(context.MatchResult.Span);
        }