~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to contrib/ICSharpCode.NRefactory/Editor/IDocument.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
Import upstream version 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
2
 
// 
3
 
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
4
 
// software and associated documentation files (the "Software"), to deal in the Software
5
 
// without restriction, including without limitation the rights to use, copy, modify, merge,
6
 
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7
 
// to whom the Software is furnished to do so, subject to the following conditions:
8
 
// 
9
 
// The above copyright notice and this permission notice shall be included in all copies or
10
 
// substantial portions of the Software.
11
 
// 
12
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13
 
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14
 
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15
 
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
 
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17
 
// DEALINGS IN THE SOFTWARE.
18
 
 
19
 
using System;
20
 
 
21
 
namespace ICSharpCode.NRefactory.Editor
22
 
{
23
 
        /// <summary>
24
 
        /// A document representing a source code file for refactoring.
25
 
        /// Line and column counting starts at 1.
26
 
        /// Offset counting starts at 0.
27
 
        /// </summary>
28
 
        public interface IDocument : ITextSource, IServiceProvider
29
 
        {
30
 
                /// <summary>
31
 
                /// Creates an immutable snapshot of this document.
32
 
                /// </summary>
33
 
                IDocument CreateDocumentSnapshot();
34
 
                
35
 
                /// <summary>
36
 
                /// Gets/Sets the text of the whole document..
37
 
                /// </summary>
38
 
                new string Text { get; set; } // hides ITextSource.Text to add the setter
39
 
                
40
 
                /// <summary>
41
 
                /// This event is called directly before a change is applied to the document.
42
 
                /// </summary>
43
 
                /// <remarks>
44
 
                /// It is invalid to modify the document within this event handler.
45
 
                /// Aborting the change (by throwing an exception) is likely to cause corruption of data structures
46
 
                /// that listen to the Changing and Changed events.
47
 
                /// </remarks>
48
 
                event EventHandler<TextChangeEventArgs> TextChanging;
49
 
                
50
 
                /// <summary>
51
 
                /// This event is called directly after a change is applied to the document.
52
 
                /// </summary>
53
 
                /// <remarks>
54
 
                /// It is invalid to modify the document within this event handler.
55
 
                /// Aborting the event handler (by throwing an exception) is likely to cause corruption of data structures
56
 
                /// that listen to the Changing and Changed events.
57
 
                /// </remarks>
58
 
                event EventHandler<TextChangeEventArgs> TextChanged;
59
 
                
60
 
                /// <summary>
61
 
                /// This event is called after a group of changes is completed.
62
 
                /// </summary>
63
 
                /// <seealso cref="EndUndoableAction"/>
64
 
                event EventHandler ChangeCompleted;
65
 
                
66
 
                /// <summary>
67
 
                /// Gets the number of lines in the document.
68
 
                /// </summary>
69
 
                int LineCount { get; }
70
 
                
71
 
                /// <summary>
72
 
                /// Gets the document line with the specified number.
73
 
                /// </summary>
74
 
                /// <param name="lineNumber">The number of the line to retrieve. The first line has number 1.</param>
75
 
                IDocumentLine GetLineByNumber(int lineNumber);
76
 
                
77
 
                /// <summary>
78
 
                /// Gets the document line that contains the specified offset.
79
 
                /// </summary>
80
 
                IDocumentLine GetLineByOffset(int offset);
81
 
                
82
 
                /// <summary>
83
 
                /// Gets the offset from a text location.
84
 
                /// </summary>
85
 
                /// <seealso cref="GetLocation"/>
86
 
                int GetOffset(int line, int column);
87
 
                
88
 
                /// <summary>
89
 
                /// Gets the offset from a text location.
90
 
                /// </summary>
91
 
                /// <seealso cref="GetLocation"/>
92
 
                int GetOffset(TextLocation location);
93
 
                
94
 
                /// <summary>
95
 
                /// Gets the location from an offset.
96
 
                /// </summary>
97
 
                /// <seealso cref="GetOffset(TextLocation)"/>
98
 
                TextLocation GetLocation(int offset);
99
 
                
100
 
                /// <summary>
101
 
                /// Inserts text.
102
 
                /// </summary>
103
 
                /// <param name="offset">The offset at which the text is inserted.</param>
104
 
                /// <param name="text">The new text.</param>
105
 
                /// <remarks>
106
 
                /// Anchors positioned exactly at the insertion offset will move according to their movement type.
107
 
                /// For AnchorMovementType.Default, they will move behind the inserted text.
108
 
                /// The caret will also move behind the inserted text.
109
 
                /// </remarks>
110
 
                void Insert(int offset, string text);
111
 
                
112
 
                /// <summary>
113
 
                /// Inserts text.
114
 
                /// </summary>
115
 
                /// <param name="offset">The offset at which the text is inserted.</param>
116
 
                /// <param name="text">The new text.</param>
117
 
                /// <param name="defaultAnchorMovementType">
118
 
                /// Anchors positioned exactly at the insertion offset will move according to the anchor's movement type.
119
 
                /// For AnchorMovementType.Default, they will move according to the movement type specified by this parameter.
120
 
                /// The caret will also move according to the <paramref name="defaultAnchorMovementType"/> parameter.
121
 
                /// </param>
122
 
                void Insert(int offset, string text, AnchorMovementType defaultAnchorMovementType);
123
 
                
124
 
                /// <summary>
125
 
                /// Removes text.
126
 
                /// </summary>
127
 
                /// <param name="offset">Starting offset of the text to be removed.</param>
128
 
                /// <param name="length">Length of the text to be removed.</param>
129
 
                void Remove(int offset, int length);
130
 
                
131
 
                /// <summary>
132
 
                /// Replaces text.
133
 
                /// </summary>
134
 
                /// <param name="offset">The starting offset of the text to be replaced.</param>
135
 
                /// <param name="length">The length of the text to be replaced.</param>
136
 
                /// <param name="newText">The new text.</param>
137
 
                void Replace(int offset, int length, string newText);
138
 
                
139
 
                /// <summary>
140
 
                /// Make the document combine the following actions into a single
141
 
                /// action for undo purposes.
142
 
                /// </summary>
143
 
                void StartUndoableAction();
144
 
                
145
 
                /// <summary>
146
 
                /// Ends the undoable action started with <see cref="StartUndoableAction"/>.
147
 
                /// </summary>
148
 
                void EndUndoableAction();
149
 
                
150
 
                /// <summary>
151
 
                /// Creates an undo group. Dispose the returned value to close the undo group.
152
 
                /// </summary>
153
 
                /// <returns>An object that closes the undo group when Dispose() is called.</returns>
154
 
                IDisposable OpenUndoGroup();
155
 
                
156
 
                /// <summary>
157
 
                /// Creates a new <see cref="ITextAnchor"/> at the specified offset.
158
 
                /// </summary>
159
 
                /// <inheritdoc cref="ITextAnchor" select="remarks|example"/>
160
 
                ITextAnchor CreateAnchor(int offset);
161
 
        }
162
 
}