/* Copyright (C) 2014-2019 de4dot@gmail.com This file is part of dnSpy dnSpy is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. dnSpy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with dnSpy. If not, see . */ using System; using dnSpy.Contracts.Documents.Tabs; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; namespace dnSpy.Contracts.Debugger.Code.TextEditor { /// /// Creates breakpoint locations in text views /// public abstract class DbgTextViewCodeLocationProvider { /// /// Creates a new instance whose text view span is >= /// /// Tab /// Text view /// Position /// public abstract DbgTextViewBreakpointLocationResult? CreateLocation(IDocumentTab tab, ITextView textView, VirtualSnapshotPoint position); } /// /// Text view locations /// public readonly struct DbgTextViewBreakpointLocationResult { /// /// Gets all locations /// public DbgCodeLocation[] Locations { get; } /// /// Gets the span /// public VirtualSnapshotSpan Span { get; } /// /// Constructor /// /// Location /// Text view span public DbgTextViewBreakpointLocationResult(DbgCodeLocation location, SnapshotSpan span) : this(location, new VirtualSnapshotSpan(span)) { } /// /// Constructor /// /// Location /// Text view span public DbgTextViewBreakpointLocationResult(DbgCodeLocation location, VirtualSnapshotSpan span) { if (span.Snapshot is null) throw new ArgumentException(); Locations = new[] { location ?? throw new ArgumentNullException(nameof(location)) }; Span = span; } /// /// Constructor /// /// Locations /// Text view span public DbgTextViewBreakpointLocationResult(DbgCodeLocation[] locations, SnapshotSpan span) : this(locations, new VirtualSnapshotSpan(span)) { } /// /// Constructor /// /// Locations /// Text view span public DbgTextViewBreakpointLocationResult(DbgCodeLocation[] locations, VirtualSnapshotSpan span) { if (span.Snapshot is null) throw new ArgumentException(); Locations = locations ?? throw new ArgumentNullException(nameof(locations)); Span = span; } } }