Browse Source

A few small API changes for NRefactory.

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
c61a9b1afd
  1. 22
      src/Libraries/NRefactory/ICSharpCode.Editor/ITextAnchor.cs
  2. 2
      src/Libraries/NRefactory/ICSharpCode.Editor/ReadOnlyDocument.cs
  3. 5
      src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Analysis/MinimalResolveContext.cs
  4. 11
      src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs
  5. 10
      src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/IProjectContent.cs
  6. 1
      src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleProjectContent.cs

22
src/Libraries/NRefactory/ICSharpCode.Editor/ITextAnchor.cs

@ -45,23 +45,45 @@ namespace ICSharpCode.Editor @@ -45,23 +45,45 @@ namespace ICSharpCode.Editor
/// <summary>
/// Controls how the anchor moves.
/// </summary>
/// <remarks>Anchor movement is ambiguous if text is inserted exactly at the anchor's location.
/// Does the anchor stay before the inserted text, or does it move after it?
/// The property <see cref="MovementType"/> will be used to determine which of these two options the anchor will choose.
/// The default value is <see cref="AnchorMovementType.Default"/>.</remarks>
AnchorMovementType MovementType { get; set; }
/// <summary>
/// <para>
/// Specifies whether the anchor survives deletion of the text containing it.
/// </para><para>
/// <c>false</c>: The anchor is deleted when the a selection that includes the anchor is deleted.
/// <c>true</c>: The anchor is not deleted.
/// </para>
/// </summary>
/// <remarks><inheritdoc cref="IsDeleted" /></remarks>
bool SurviveDeletion { get; set; }
/// <summary>
/// Gets whether the anchor was deleted.
/// </summary>
/// <remarks>
/// <para>When a piece of text containing an anchor is removed, then that anchor will be deleted.
/// First, the <see cref="IsDeleted"/> property is set to true on all deleted anchors,
/// then the <see cref="Deleted"/> events are raised.
/// You cannot retrieve the offset from an anchor that has been deleted.</para>
/// <para>This deletion behavior might be useful when using anchors for building a bookmark feature,
/// but in other cases you want to still be able to use the anchor. For those cases, set <c><see cref="SurviveDeletion"/> = true</c>.</para>
/// </remarks>
bool IsDeleted { get; }
/// <summary>
/// Occurs after the anchor was deleted.
/// </summary>
/// <remarks>
/// <inheritdoc cref="IsDeleted" />
/// <para>Due to the 'weak reference' nature of text anchors, you will receive
/// the Deleted event only while your code holds a reference to the TextAnchor object.
/// </para>
/// </remarks>
event EventHandler Deleted;
/// <summary>

2
src/Libraries/NRefactory/ICSharpCode.Editor/ReadOnlyDocument.cs

@ -156,7 +156,7 @@ namespace ICSharpCode.Editor @@ -156,7 +156,7 @@ namespace ICSharpCode.Editor
if (offset < 0 || offset > textSource.TextLength)
throw new ArgumentOutOfRangeException("offset", offset, "Value must be between 0 and " + textSource.TextLength);
int line = GetLineNumberForOffset(offset);
return new TextLocation(offset-GetStartOffset(line)+1, line);
return new TextLocation(line, offset-GetStartOffset(line)+1);
}
/// <inheritdoc/>

5
src/Libraries/NRefactory/ICSharpCode.NRefactory/CSharp/Analysis/MinimalResolveContext.cs

@ -123,5 +123,10 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis @@ -123,5 +123,10 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
return EmptyList<IParsedFile>.Instance;
}
}
void IProjectContent.UpdateProjectContent(IParsedFile oldFile, IParsedFile newFile)
{
throw new NotSupportedException();
}
}
}

11
src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs

@ -175,22 +175,27 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -175,22 +175,27 @@ namespace ICSharpCode.NRefactory.TypeSystem
return this;
}
public void Dispose()
void IDisposable.Dispose()
{
// Disposing the synchronization context has no effect
}
public IParsedFile GetFile(string fileName)
IParsedFile IProjectContent.GetFile(string fileName)
{
return null;
}
public IEnumerable<IParsedFile> Files {
IEnumerable<IParsedFile> IProjectContent.Files {
get {
return EmptyList<IParsedFile>.Instance;
}
}
void IProjectContent.UpdateProjectContent(IParsedFile oldFile, IParsedFile newFile)
{
throw new NotSupportedException();
}
string IDocumentationProvider.GetDocumentation(IEntity entity)
{
if (documentationProvider != null)

10
src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/IProjectContent.cs

@ -29,6 +29,16 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -29,6 +29,16 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Gets the list of all parsed files in the project content.
/// </summary>
IEnumerable<IParsedFile> Files { get; }
/// <summary>
/// Removes types and attributes from oldFile from the project, and adds those from newFile.
/// </summary>
/// <remarks>
/// It is not allowed to call this method from within a <c>using (var ctx = context.Synchronize())</c> block
/// that involves this project content: this method is a write operation and might (if implemented using locks)
/// wait until all read operations have finished, causing deadlocks within Synchronize blocks.
/// </remarks>
void UpdateProjectContent(IParsedFile oldFile, IParsedFile newFile);
}
#if WITH_CONTRACTS

1
src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleProjectContent.cs

@ -64,7 +64,6 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -64,7 +64,6 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
{
if (typeDefinition == null)
throw new ArgumentNullException("typeDefinition");
typeDefinition.Freeze(); // Type definition must be frozen before it can be added to a project content
if (typeDefinition.ProjectContent != this)
throw new ArgumentException("Cannot add a type definition that belongs to another project content");

Loading…
Cancel
Save