public void Report(LogLevel level, TextRange?position, string message, params object[] args) { Debug.WriteLine($"[{level}] [{position}] {string.Format(message, args)}"); if (level == LogLevel.Error) { } }
private TextRange?CheckEntriesInRange( TextRange textRange, IEnumerable <ParsedSearchString.Entry> entries) { TextRange?result = null; foreach (var entry in entries) { var entryRange = _findEntry(textRange, entry); if (entryRange == null) { return(null); } var newOffset = entryRange.Value.EndPosition; textRange = new TextRange(newOffset, textRange.EndPosition - newOffset); if (result == null) { result = entryRange; } else { result = new TextRange(result.Value.Position, newOffset - result.Value.Position); } } return(result); }
public TextRange GetLineExtent(int position) { if (_previousSpan.HasValue) { if (position >= _previousSpan.Value.Position && position < _previousSpan.Value.Position + _previousSpan.Value.Length) { return _previousSpan.Value; } } _previousSpan = _getLineRange(position); return _previousSpan.Value; }
public TextRange?FilterSearchHit(TextRange match) { var lineExtentStart = _getLineExtentCache.GetLineExtent(match.Position); var lineExtentEnd = _getLineExtentCache.GetLineExtent(match.EndPosition); var lineExtent = new TextRange( lineExtentStart.Position, lineExtentEnd.EndPosition - lineExtentStart.Position); if (_previousMatch.HasValue) { // If match overlaps with previous one, fail if (match.Position < _previousMatch.Value.EndPosition) { return(null); } // If line extent overlaps with previous match, shrink it. if (lineExtent.Position < _previousMatch.Value.EndPosition) { lineExtent = new TextRange( _previousMatch.Value.EndPosition, lineExtent.EndPosition - _previousMatch.Value.EndPosition); } } // We got the line extent, the offset at which we found the MainEntry. // Now we need to check that "OtherEntries" are present (in order) and // in appropriate intervals. var range1 = new TextRange( lineExtent.Position, match.Position - lineExtent.Position); var entriesInterval1 = _parsedSearchString.EntriesBeforeMainEntry; var foundRange1 = entriesInterval1.Any() ? CheckEntriesInRange(range1, entriesInterval1) : match; var range2 = new TextRange( match.EndPosition, lineExtent.EndPosition - match.EndPosition); var entriesInterval2 = _parsedSearchString.EntriesAfterMainEntry; var foundRange2 = entriesInterval2.Any() ? CheckEntriesInRange(range2, entriesInterval2) : match; if (foundRange1.HasValue && foundRange2.HasValue) { var newMatch = new TextRange( foundRange1.Value.Position, foundRange2.Value.EndPosition - foundRange1.Value.Position); // Save the this match for next iteration _previousMatch = newMatch; return(newMatch); } return(null); }
public TextRange GetLineExtent(int position) { if (_previousSpan.HasValue) { if (position >= _previousSpan.Value.Position && position < _previousSpan.Value.Position + _previousSpan.Value.Length) { return(_previousSpan.Value); } } _previousSpan = _getLineRange(position); return(_previousSpan.Value); }
public TextRange? FilterSearchHit(TextRange match) { var lineExtentStart = _getLineExtentCache.GetLineExtent(match.Position); var lineExtentEnd = _getLineExtentCache.GetLineExtent(match.EndPosition); var lineExtent = new TextRange( lineExtentStart.Position, lineExtentEnd.EndPosition - lineExtentStart.Position); if (_previousMatch.HasValue) { // If match overlaps with previous one, fail if (match.Position < _previousMatch.Value.EndPosition) { return null; } // If line extent overlaps with previous match, shrink it. if (lineExtent.Position < _previousMatch.Value.EndPosition) { lineExtent = new TextRange( _previousMatch.Value.EndPosition, lineExtent.EndPosition - _previousMatch.Value.EndPosition); } } // We got the line extent, the offset at which we found the MainEntry. // Now we need to check that "OtherEntries" are present (in order) and // in appropriate intervals. var range1 = new TextRange( lineExtent.Position, match.Position - lineExtent.Position); var entriesInterval1 = _parsedSearchString.EntriesBeforeMainEntry; var foundRange1 = entriesInterval1.Any() ? CheckEntriesInRange(range1, entriesInterval1) : match; var range2 = new TextRange( match.EndPosition, lineExtent.EndPosition - match.EndPosition); var entriesInterval2 = _parsedSearchString.EntriesAfterMainEntry; var foundRange2 = entriesInterval2.Any() ? CheckEntriesInRange(range2, entriesInterval2) : match; if (foundRange1.HasValue && foundRange2.HasValue) { var newMatch = new TextRange( foundRange1.Value.Position, foundRange2.Value.EndPosition - foundRange1.Value.Position); // Save the this match for next iteration _previousMatch = newMatch; return newMatch; } return null; }
protected void Report(LogLevel level, TextRange?position, string message, params object[] args) { if (this.SupressMessages) { return; } message = string.Format(message, args); Debug.WriteLine($"[{level}] [{position}] {message}"); if (level == LogLevel.Error) { this.HasError = true; } if (level == LogLevel.Error) { throw new System.Exception(message); } //todo }
/// <summary> /// Find positions of tags in specified string. /// </summary> /// <returns>The tags positions.</returns> /// <param name="input">A string containing tags.</param> public static TextRange[] ExtractTagsRanges(string input) { if (input == null) { throw new ArgumentNullException("Input can not be null"); } var result = new List <TextRange>(); TextRange?range = null; do { if (range != null) { result.Add(range); } var startIndex = range != null ? range.Position + range.Length : 0; range = ExtractFirstTagRange(input, startIndex); } while (range != null); return(result.ToArray()); }
void ILogger.Report(LogLevel level, TextRange?position, string message, params object[] args) { this.Report(level, position, message, args); }