Browse Source

Rename ITextBuffer -> ITextSource

newNRvisualizers
Daniel Grunwald 15 years ago
parent
commit
b2d2678472
  1. 72
      ICSharpCode.Editor/ICSharpCode.Editor.csproj
  2. 7
      ICSharpCode.Editor/IDocument.cs
  3. 49
      ICSharpCode.Editor/ITextSource.cs
  4. 31
      ICSharpCode.Editor/Properties/AssemblyInfo.cs
  5. 14
      ICSharpCode.Editor/ReadOnlyDocument.cs
  6. 18
      ICSharpCode.Editor/StringTextSource.cs

72
ICSharpCode.Editor/ICSharpCode.Editor.csproj

@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectGuid>{F054A788-B591-4561-A8BA-AE745BBEB817}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.Editor</RootNamespace>
<AssemblyName>ICSharpCode.Editor</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<AppDesignerFolder>Properties</AppDesignerFolder>
<SignAssembly>False</SignAssembly>
<DelaySign>False</DelaySign>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<DocumentationFile>bin\Debug\ICSharpCode.Editor.xml</DocumentationFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<RunCodeAnalysis>False</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<PlatformTarget>x86</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<StartAction>Project</StartAction>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="IDocument.cs" />
<Compile Include="IDocumentLine.cs" />
<Compile Include="ISegment.cs" />
<Compile Include="ITextEditor.cs" />
<Compile Include="ITextSource.cs" />
<Compile Include="LinkedElement.cs" />
<Compile Include="ReadOnlyDocument.cs" />
<Compile Include="StringTextSource.cs" />
<Compile Include="TextLocation.cs" />
<Compile Include="ITextAnchor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TextChangeEventArgs.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

7
ICSharpCode.Editor/IDocument.cs

@ -10,13 +10,18 @@ namespace ICSharpCode.Editor @@ -10,13 +10,18 @@ namespace ICSharpCode.Editor
/// Line and column counting starts at 1.
/// Offset counting starts at 0.
/// </summary>
public interface IDocument : ITextBuffer, IServiceProvider
public interface IDocument : ITextSource, IServiceProvider
{
/// <summary>
/// Gets/Sets the text of the whole document..
/// </summary>
new string Text { get; set; } // hides TextBuffer.Text to add the setter
/// <summary>
/// Is raised when the Text property changes.
/// </summary>
event EventHandler TextChanged;
/// <summary>
/// Gets the total number of lines in the document.
/// </summary>

49
ICSharpCode.Editor/ITextBuffer.cs → ICSharpCode.Editor/ITextSource.cs

@ -8,36 +8,36 @@ using System.IO; @@ -8,36 +8,36 @@ using System.IO;
namespace ICSharpCode.Editor
{
/// <summary>
/// A read-only view on a (potentially mutable) text buffer.
/// A read-only view on a (potentially mutable) text source.
/// The IDocument interfaces derives from this interface.
/// </summary>
public interface ITextBuffer
public interface ITextSource
{
/// <summary>
/// Gets a version identifier for this text buffer.
/// Returns null for unversioned text buffers.
/// Gets a version identifier for this text source.
/// Returns null for unversioned text sources.
/// </summary>
ITextBufferVersion Version { get; }
ITextSourceVersion Version { get; }
/// <summary>
/// Creates an immutable snapshot of this text buffer.
/// Creates an immutable snapshot of this text source.
/// Unlike all other methods in this interface, this method is thread-safe.
/// </summary>
ITextBuffer CreateSnapshot();
ITextSource CreateSnapshot();
/// <summary>
/// Creates an immutable snapshot of a part of this text buffer.
/// Creates an immutable snapshot of a part of this text source.
/// Unlike all other methods in this interface, this method is thread-safe.
/// </summary>
ITextBuffer CreateSnapshot(int offset, int length);
ITextSource CreateSnapshot(int offset, int length);
/// <summary>
/// Creates a new TextReader to read from this text buffer.
/// Creates a new TextReader to read from this text source.
/// </summary>
TextReader CreateReader();
/// <summary>
/// Creates a new TextReader to read from this text buffer.
/// Creates a new TextReader to read from this text source.
/// </summary>
TextReader CreateReader(int offset, int length);
@ -54,11 +54,6 @@ namespace ICSharpCode.Editor @@ -54,11 +54,6 @@ namespace ICSharpCode.Editor
/// </summary>
string Text { get; }
/// <summary>
/// Is raised when the Text property changes.
/// </summary>
event EventHandler TextChanged;
/// <summary>
/// Gets a character at the specified position in the document.
/// </summary>
@ -110,20 +105,20 @@ namespace ICSharpCode.Editor @@ -110,20 +105,20 @@ namespace ICSharpCode.Editor
}
/// <summary>
/// Represents a version identifier for a text buffer.
/// Represents a version identifier for a text source.
/// </summary>
/// <remarks>
/// This is SharpDevelop's equivalent to AvalonEdit ChangeTrackingCheckpoint.
/// It is used by the ParserService to efficiently detect whether a document has changed and needs reparsing.
/// It is a separate class from ITextBuffer to allow the GC to collect the text buffer while the version checkpoint
/// is still in use.
/// Verions can be used to efficiently detect whether a document has changed and needs reparsing;
/// or even to implement incremental parsers.
/// It is a separate class from ITextBuffer to allow the GC to collect the text buffer while
/// the version checkpoint is still in use.
/// </remarks>
public interface ITextBufferVersion
public interface ITextSourceVersion
{
/// <summary>
/// Gets whether this checkpoint belongs to the same document as the other checkpoint.
/// </summary>
bool BelongsToSameDocumentAs(ITextBufferVersion other);
bool BelongsToSameDocumentAs(ITextSourceVersion other);
/// <summary>
/// Compares the age of this checkpoint to the other checkpoint.
@ -133,7 +128,7 @@ namespace ICSharpCode.Editor @@ -133,7 +128,7 @@ namespace ICSharpCode.Editor
/// <returns>-1 if this version is older than <paramref name="other"/>.
/// 0 if <c>this</c> version instance represents the same version as <paramref name="other"/>.
/// 1 if this version is newer than <paramref name="other"/>.</returns>
int CompareAge(ITextBufferVersion other);
int CompareAge(ITextSourceVersion other);
/// <summary>
/// Gets the changes from this checkpoint to the other checkpoint.
@ -141,12 +136,12 @@ namespace ICSharpCode.Editor @@ -141,12 +136,12 @@ namespace ICSharpCode.Editor
/// </summary>
/// <remarks>This method is thread-safe.</remarks>
/// <exception cref="ArgumentException">Raised if 'other' belongs to a different document than this checkpoint.</exception>
IEnumerable<TextChangeEventArgs> GetChangesTo(ITextBufferVersion other);
IEnumerable<TextChangeEventArgs> GetChangesTo(ITextSourceVersion other);
/// <summary>
/// Calculates where the offset has moved in the other buffer version.
/// </summary>
/// <exception cref="ArgumentException">Raised if 'other' belongs to a different document than this checkpoint.</exception>
int MoveOffsetTo(ITextBufferVersion other, int oldOffset, AnchorMovementType movement);
int MoveOffsetTo(ITextSourceVersion other, int oldOffset, AnchorMovementType movement);
}
}
}

31
ICSharpCode.Editor/Properties/AssemblyInfo.cs

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
#region Using directives
using System;
using System.Reflection;
using System.Runtime.InteropServices;
#endregion
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ICSharpCode.Editor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ICSharpCode.Editor")]
[assembly: AssemblyCopyright("Copyright 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]

14
ICSharpCode.Editor/ReadOnlyDocument.cs

@ -11,7 +11,7 @@ namespace ICSharpCode.Editor @@ -11,7 +11,7 @@ namespace ICSharpCode.Editor
/// </summary>
public sealed class ReadOnlyDocument : IDocument
{
readonly ITextBuffer textBuffer;
readonly ITextSource textBuffer;
int[] lines;
static readonly char[] newline = { '\r', '\n' };
@ -19,7 +19,7 @@ namespace ICSharpCode.Editor @@ -19,7 +19,7 @@ namespace ICSharpCode.Editor
/// <summary>
/// Creates a new ReadOnlyDocument from the given text buffer.
/// </summary>
public ReadOnlyDocument(ITextBuffer textBuffer)
public ReadOnlyDocument(ITextSource textBuffer)
{
if (textBuffer == null)
throw new ArgumentNullException("textBuffer");
@ -43,7 +43,7 @@ namespace ICSharpCode.Editor @@ -43,7 +43,7 @@ namespace ICSharpCode.Editor
/// Creates a new ReadOnlyDocument from the given string.
/// </summary>
public ReadOnlyDocument(string text)
: this(new StringTextBuffer(text))
: this(new StringTextSource(text))
{
}
@ -178,7 +178,7 @@ namespace ICSharpCode.Editor @@ -178,7 +178,7 @@ namespace ICSharpCode.Editor
get { return lines.Length; }
}
ITextBufferVersion ITextBuffer.Version {
ITextSourceVersion ITextSource.Version {
get { return null; }
}
@ -191,7 +191,7 @@ namespace ICSharpCode.Editor @@ -191,7 +191,7 @@ namespace ICSharpCode.Editor
event EventHandler<TextChangeEventArgs> IDocument.Changed { add {} remove {} }
event EventHandler ITextBuffer.TextChanged { add {} remove {} }
event EventHandler IDocument.TextChanged { add {} remove {} }
void IDocument.Insert(int offset, string text)
{
@ -271,13 +271,13 @@ namespace ICSharpCode.Editor @@ -271,13 +271,13 @@ namespace ICSharpCode.Editor
}
/// <inheritdoc/>
public ITextBuffer CreateSnapshot()
public ITextSource CreateSnapshot()
{
return textBuffer; // textBuffer is immutable
}
/// <inheritdoc/>
public ITextBuffer CreateSnapshot(int offset, int length)
public ITextSource CreateSnapshot(int offset, int length)
{
return textBuffer.CreateSnapshot(offset, length);
}

18
ICSharpCode.Editor/StringTextBuffer.cs → ICSharpCode.Editor/StringTextSource.cs

@ -7,26 +7,24 @@ using System.IO; @@ -7,26 +7,24 @@ using System.IO;
namespace ICSharpCode.Editor
{
/// <summary>
/// Implements the ITextBuffer interface using a string.
/// Implements the ITextSource interface using a string.
/// </summary>
[Serializable]
public class StringTextBuffer : ITextBuffer
public class StringTextSource : ITextSource
{
readonly string text;
/// <summary>
/// Creates a new StringTextBuffer with the given text.
/// Creates a new StringTextSource with the given text.
/// </summary>
public StringTextBuffer(string text)
public StringTextSource(string text)
{
if (text == null)
throw new ArgumentNullException("text");
this.text = text;
}
event EventHandler ITextBuffer.TextChanged { add {} remove {} }
ITextBufferVersion ITextBuffer.Version {
ITextSourceVersion ITextSource.Version {
get { return null; }
}
@ -41,15 +39,15 @@ namespace ICSharpCode.Editor @@ -41,15 +39,15 @@ namespace ICSharpCode.Editor
}
/// <inheritdoc/>
public ITextBuffer CreateSnapshot()
public ITextSource CreateSnapshot()
{
return this; // StringTextBuffer is immutable
}
/// <inheritdoc/>
public ITextBuffer CreateSnapshot(int offset, int length)
public ITextSource CreateSnapshot(int offset, int length)
{
return new StringTextBuffer(text.Substring(offset, length));
return new StringTextSource(text.Substring(offset, length));
}
/// <inheritdoc/>
Loading…
Cancel
Save