public static AskReplacementWriter Create( ContentDisplayStyle contentDisplayStyle, string input, ReplaceOptions replaceOptions, Lazy <TextWriter> lazyWriter, ContentWriterOptions options, MatchOutputInfo outputInfo) { switch (contentDisplayStyle) { case ContentDisplayStyle.Value: case ContentDisplayStyle.ValueDetail: return(new AskValueReplacementWriter(input, replaceOptions, lazyWriter, options, outputInfo)); case ContentDisplayStyle.Line: return(new AskLineReplacementWriter(input, replaceOptions, lazyWriter, options)); case ContentDisplayStyle.UnmatchedLines: case ContentDisplayStyle.AllLines: throw new InvalidOperationException(); default: throw new InvalidOperationException($"Unknown enum value '{contentDisplayStyle}'."); } }
protected override void ExecuteResult( FileSystemFinderResult result, SearchContext context, ContentWriterOptions writerOptions, Match match, string input, Encoding encoding, string baseDirectoryPath = null, ColumnWidths columnWidths = null) { string indent = GetPathIndent(baseDirectoryPath); if (!Options.OmitPath) { WritePath(context, result, baseDirectoryPath, indent, columnWidths); } if (ContentFilter.IsNegative) { WriteLineIf(!Options.OmitPath, Verbosity.Minimal); } else { WriteMatches(input, match, writerOptions, context); } AskToContinue(context, indent); }
public static ContentWriter CreateReplace( ContentDisplayStyle contentDisplayStyle, string input, ReplaceOptions replaceOptions, ContentWriterOptions options, TextWriter?textWriter = null, MatchOutputInfo?outputInfo = null) { switch (contentDisplayStyle) { case ContentDisplayStyle.Value: case ContentDisplayStyle.ValueDetail: return(new ValueReplacementWriter(input, replaceOptions, options, textWriter, outputInfo)); case ContentDisplayStyle.Line: return(new LineReplacementWriter(input, replaceOptions, options, textWriter)); case ContentDisplayStyle.AllLines: return(new AllLinesReplacementWriter(input, replaceOptions, options, textWriter)); case ContentDisplayStyle.UnmatchedLines: throw new NotSupportedException($"Value '{contentDisplayStyle}' is not supported."); default: throw new InvalidOperationException($"Unknown enum value '{contentDisplayStyle}'."); } }
private void ExecuteInput(SearchContext context, string input) { Stopwatch stopwatch = Stopwatch.StartNew(); Match?match = ContentFilter !.Match(input); ContentWriterOptions writerOptions = CreateContentWriterOptions(""); if (match != null) { WriteContent( context, match, input, writerOptions, fileMatch: null, baseDirectoryPath: null, isPathDisplayed: false); } stopwatch.Stop(); if (ShouldWriteSummary()) { context.Telemetry.Elapsed = stopwatch.Elapsed; Verbosity verbosity = (Options.IncludeSummary) ? Verbosity.Quiet : Verbosity.Detailed; WriteLine(verbosity); WriteContentSummary(context.Telemetry, verbosity); WriteLine(verbosity); } }
private void ProcessResult( FileSystemFinderResult result, SearchContext context, ContentWriterOptions writerOptions, string baseDirectoryPath = null) { string indent = GetPathIndent(baseDirectoryPath); Encoding encoding = Options.DefaultEncoding; string input = ReadFile(result.Path, baseDirectoryPath, ref encoding, context, indent); if (input == null) { return; } Match match = Options.ContentFilter.Match(input, context.CancellationToken); if (match == null) { return; } ExecuteOrAddResult(result, context, writerOptions, match, input, encoding, baseDirectoryPath); }
public static AskReplacementWriter Create( ContentDisplayStyle contentDisplayStyle, string input, IReplacer replacer, Lazy <TextWriter>?lazyWriter, ContentWriterOptions options, MatchOutputInfo?outputInfo, bool isInteractive, SpellcheckState?spellcheckState = null) { switch (contentDisplayStyle) { case ContentDisplayStyle.Value: case ContentDisplayStyle.ValueDetail: return(new AskValueReplacementWriter( input, replacer, lazyWriter, options, outputInfo, isInteractive, spellcheckState)); case ContentDisplayStyle.Line: return(new AskLineReplacementWriter(input, replacer, lazyWriter, options, isInteractive, spellcheckState)); case ContentDisplayStyle.UnmatchedLines: case ContentDisplayStyle.AllLines: throw new InvalidOperationException(); default: throw new InvalidOperationException($"Unknown enum value '{contentDisplayStyle}'."); } }
public EmptyContentWriter( string input, ContentWriterOptions options, IResultStorage resultStorage = null) : base(input, options) { ResultStorage = resultStorage; }
public ValueContentWriter( string input, ContentWriterOptions options = null, IResultStorage storage = null, MatchOutputInfo outputInfo = null) : this(input, ContentTextWriter.Default, options, storage, outputInfo) { }
public AskLineContentWriter( string input, ContentWriterOptions options, IResultStorage?storage = null) : base(input, options, storage) { Ask = true; }
public AllLinesContentWriter( string input, ContentTextWriter?writer, ContentWriterOptions options, IResultStorage?storage = null) : base(input, writer, options) { ResultStorage = storage; }
public AskLineReplacementWriter( string input, ReplaceOptions replaceOptions, Lazy <TextWriter> lazyWriter, ContentWriterOptions options) : base(input, replaceOptions, lazyWriter, options) { MatchingLineCount = 0; }
public AskValueContentWriter( string input, ContentWriterOptions options = null, IResultStorage storage = null, MatchOutputInfo outputInfo = null) : base(input, options, storage, outputInfo) { Ask = true; }
public LineReplacementWriter( string input, ReplaceOptions replaceOptions, ContentWriterOptions options = null, TextWriter textWriter = null) : base(input, options) { ReplaceOptions = replaceOptions; _textWriter = textWriter; }
public TextWriterContentWriter( string input, ReplaceOptions replaceOptions, TextWriter textWriter, ContentWriterOptions options) : base(input, options) { ReplaceOptions = replaceOptions; _textWriter = textWriter; }
public AskLineReplacementWriter( string input, ReplaceOptions replaceOptions, Lazy <TextWriter>?lazyWriter, ContentWriterOptions options, bool isInteractive) : base(input, replaceOptions, lazyWriter, options, isInteractive) { MatchingLineCount = 0; }
public AskValueReplacementWriter( string input, ReplaceOptions replaceOptions, Lazy <TextWriter> lazyWriter, ContentWriterOptions options, MatchOutputInfo outputInfo) : base(input, replaceOptions, lazyWriter, options) { OutputInfo = outputInfo; }
public UnmatchedLineWriter( string input, ContentTextWriter?writer, ContentWriterOptions options, IResultStorage?storage = null) : base(input, writer, options) { ResultStorage = storage; MatchingLineCount = 0; }
protected override void ExecuteMatchWithContentCore( FileMatch fileMatch, SearchContext context, ContentWriterOptions writerOptions, string?baseDirectoryPath = null, ColumnWidths?columnWidths = null) { ExecuteMatchCore(fileMatch, context, baseDirectoryPath, columnWidths); }
protected override void ExecuteMatchWithContentCore( FileMatch fileMatch, SearchContext context, ContentWriterOptions writerOptions, string?baseDirectoryPath = null, ColumnWidths?columnWidths = null) { List <Capture>?groups = null; try { groups = ListCache <Capture> .GetInstance(); MaxReason maxReason = GetCaptures( fileMatch.ContentMatch !, writerOptions.GroupNumber, context, isPathDisplayed: false, predicate: Options.ContentFilter !.Predicate, captures: groups); List <ICapture>?captures = GetCaptures(groups, context.CancellationToken); using (IEnumerator <ICapture> en = (captures ?? groups.Select(f => (ICapture) new RegexCapture(f))).GetEnumerator()) { if (en.MoveNext()) { if (SpellcheckState != null) { SpellcheckState.CurrentPath = fileMatch.Path; } ExecuteMatchWithContentCore( en, captures?.Count ?? groups.Count, maxReason, fileMatch, context, writerOptions, baseDirectoryPath, columnWidths); } } } finally { if (groups != null) { ListCache <Capture> .Free(groups); } if (SpellcheckState != null) { SpellcheckState.CurrentPath = null; } } }
protected AskReplacementWriter( string input, ReplaceOptions replaceOptions, Lazy <TextWriter> lazyWriter, ContentWriterOptions options) : base(input, options) { ReplaceOptions = replaceOptions; _lazyWriter = lazyWriter; }
public LineContentWriter( string input, ContentTextWriter writer, ContentWriterOptions options = null, IResultStorage storage = null) : base(input, writer, options) { ResultStorage = storage; MatchingLineCount = 0; }
private ContentWriter CreateReplacementWriter( ContentDisplayStyle contentDisplayStyle, string input, IReplacer replacer, ContentWriterOptions options, TextWriter?textWriter = null, MatchOutputInfo?outputInfo = null) { return(ContentWriter.CreateReplace(contentDisplayStyle, input, replacer, options, textWriter, outputInfo, SpellcheckState)); }
public AskLineReplacementWriter( string input, IReplacer replacer, Lazy <TextWriter>?lazyWriter, ContentWriterOptions options, bool isInteractive, SpellcheckState?spellcheckState = null) : base(input, replacer, lazyWriter, options, isInteractive, spellcheckState) { MatchingLineCount = 0; }
protected ContentWriter( string input, ContentTextWriter?writer, ContentWriterOptions options) { Input = input; Options = options; MatchingLineCount = -1; Writer = writer; }
public ValueContentWriter( string input, ContentTextWriter writer, ContentWriterOptions options = null, IResultStorage storage = null, MatchOutputInfo outputInfo = null) : base(input, writer, options) { ResultStorage = storage; OutputInfo = outputInfo; }
public ValueReplacementWriter( string input, ReplaceOptions replaceOptions, ContentWriterOptions options, TextWriter?textWriter = null, MatchOutputInfo?outputInfo = null) : base(input, options, outputInfo: outputInfo) { ReplaceOptions = replaceOptions; _textWriter = textWriter; }
public AskValueReplacementWriter( string input, ReplaceOptions replaceOptions, Lazy <TextWriter>?lazyWriter, ContentWriterOptions options, MatchOutputInfo?outputInfo, bool isInteractive) : base(input, replaceOptions, lazyWriter, options, isInteractive) { OutputInfo = outputInfo; }
public AskValueReplacementWriter( string input, IReplacer replacer, Lazy <TextWriter>?lazyWriter, ContentWriterOptions options, MatchOutputInfo?outputInfo, bool isInteractive, SpellcheckState?spellcheckState = null) : base(input, replacer, lazyWriter, options, isInteractive, spellcheckState) { OutputInfo = outputInfo; }
public LineReplacementWriter( string input, IReplacer replacer, ContentWriterOptions options, TextWriter?textWriter = null, SpellcheckState?spellcheckState = null) : base(input, options) { Replacer = replacer; _textWriter = textWriter; SpellcheckState = spellcheckState; }
public ValueReplacementWriter( string input, IReplacer replacer, ContentWriterOptions options, TextWriter?textWriter = null, MatchOutputInfo?outputInfo = null, SpellcheckState?spellcheckState = null) : base(input, options, outputInfo: outputInfo) { Replacer = replacer; _textWriter = textWriter; SpellcheckState = spellcheckState; }