Browse Source

make Document in SDRefactoringContext accessible from outside

newNRvisualizers
Siegfried Pammer 13 years ago
parent
commit
ba0bb353af
  1. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/IssueManager.cs
  2. 22
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SDRefactoringContext.cs

2
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/IssueManager.cs

@ -162,7 +162,7 @@ namespace CSharpBinding.Refactoring @@ -162,7 +162,7 @@ namespace CSharpBinding.Refactoring
{
int startOffset = InspectedVersion.MoveOffsetTo(document.Version, this.StartOffset, AnchorMovementType.Default);
int endOffset = InspectedVersion.MoveOffsetTo(document.Version, this.EndOffset, AnchorMovementType.Default);
if (startOffset >= endOffset)
if (this.StartOffset != this.EndOffset && startOffset >= endOffset)
return;
marker = markerService.Create(startOffset, endOffset - startOffset);
marker.ToolTip = this.Description;

22
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SDRefactoringContext.cs

@ -5,6 +5,7 @@ using System; @@ -5,6 +5,7 @@ using System;
using System.ComponentModel.Design;
using System.Threading;
using ICSharpCode.NRefactory.Utils;
using CSharpBinding.Parser;
using ICSharpCode.Core;
using ICSharpCode.NRefactory;
@ -100,6 +101,15 @@ namespace CSharpBinding.Refactoring @@ -100,6 +101,15 @@ namespace CSharpBinding.Refactoring
return new DocumentScript(document, formattingOptions, this.TextEditorOptions);
}
public IDocument Document {
get {
IDocument result = LazyInit.VolatileRead(ref document);
if (result != null)
return result;
return LazyInit.GetOrSet(ref document, new ReadOnlyDocument(textSource, resolver.UnresolvedFile.FileName));
}
}
public override TextLocation Location {
get { return location; }
}
@ -142,23 +152,17 @@ namespace CSharpBinding.Refactoring @@ -142,23 +152,17 @@ namespace CSharpBinding.Refactoring
public override IDocumentLine GetLineByOffset(int offset)
{
if (document == null)
document = new ReadOnlyDocument(textSource, resolver.UnresolvedFile.FileName);
return document.GetLineByOffset(offset);
return Document.GetLineByOffset(offset);
}
public override int GetOffset(TextLocation location)
{
if (document == null)
document = new ReadOnlyDocument(textSource, resolver.UnresolvedFile.FileName);
return document.GetOffset(location);
return Document.GetOffset(location);
}
public override TextLocation GetLocation(int offset)
{
if (document == null)
document = new ReadOnlyDocument(textSource, resolver.UnresolvedFile.FileName);
return document.GetLocation(offset);
return Document.GetLocation(offset);
}
public override AstType CreateShortType(IType fullType)

Loading…
Cancel
Save