Browse Source

Remove ICSharpCode.TextEditor references from SearchAndReplace.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4170 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts^2
Daniel Grunwald 17 years ago
parent
commit
510c0b2048
  1. 14
      src/AddIns/Misc/SearchAndReplace/Project/Engine/DocumentIterator/AllOpenDocumentIterator.cs
  2. 1
      src/AddIns/Misc/SearchAndReplace/Project/Engine/DocumentIterator/CurrentDocumentIterator.cs
  3. 17
      src/AddIns/Misc/SearchAndReplace/Project/Engine/DocumentIterator/DirectoryDocumentIterator.cs
  4. 17
      src/AddIns/Misc/SearchAndReplace/Project/Engine/DocumentIterator/WholeProjectDocumentIterator.cs
  5. 17
      src/AddIns/Misc/SearchAndReplace/Project/Engine/DocumentIterator/WholeSolutionDocumentIterator.cs
  6. 54
      src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchReplaceManager.cs
  7. 5
      src/AddIns/Misc/SearchAndReplace/Project/SearchAndReplace.csproj
  8. 1
      src/AddIns/Misc/SearchAndReplace/Test/FindNextWithCursorAtEndTestFixture.cs
  9. 1
      src/AddIns/Misc/SearchAndReplace/Test/ForwardIteratorWithEmptyTextBufferTestFixture.cs
  10. 1
      src/AddIns/Misc/SearchAndReplace/Test/ForwardTextIteratorPositionIsEndOffsetTestFixture.cs
  11. 4
      src/AddIns/Misc/SearchAndReplace/Test/SearchAndReplace.Tests.csproj
  12. 24
      src/Main/Base/Project/Src/Editor/Search/ProvidedDocumentInformation.cs
  13. 4
      src/Main/Base/Project/Src/Services/RefactoringService/FindReferencesAndRenameHelper.cs

14
src/AddIns/Misc/SearchAndReplace/Project/Engine/DocumentIterator/AllOpenDocumentIterator.cs

@ -5,15 +5,14 @@ @@ -5,15 +5,14 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.Editor.Search;
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.Linq;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Editor.Search;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Refactoring;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
namespace SearchAndReplace
{
@ -43,7 +42,7 @@ namespace SearchAndReplace @@ -43,7 +42,7 @@ namespace SearchAndReplace
GetCurIndex();
if (curIndex >= 0) {
IViewContent viewContent = WorkbenchSingleton.Workbench.ViewContentCollection.ToList()[curIndex];
if (viewContent is ITextEditorControlProvider) {
if (viewContent is ITextEditorProvider) {
return viewContent;
}
}
@ -54,11 +53,10 @@ namespace SearchAndReplace @@ -54,11 +53,10 @@ namespace SearchAndReplace
get {
IViewContent viewContent = GetCurrentTextEditorViewContent();
if (viewContent != null) {
TextEditorControl textEditor = (((ITextEditorControlProvider)viewContent).TextEditorControl);
TextEditorAdapter adapter = new TextEditorAdapter(textEditor);
return new ProvidedDocumentInformation(adapter.Document,
ITextEditor textEditor = (((ITextEditorProvider)viewContent).TextEditor);
return new ProvidedDocumentInformation(textEditor.Document,
CurrentFileName,
adapter);
textEditor);
}
return null;
}

1
src/AddIns/Misc/SearchAndReplace/Project/Engine/DocumentIterator/CurrentDocumentIterator.cs

@ -11,7 +11,6 @@ using ICSharpCode.SharpDevelop; @@ -11,7 +11,6 @@ using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Editor.Search;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.TextEditor;
namespace SearchAndReplace
{

17
src/AddIns/Misc/SearchAndReplace/Project/Engine/DocumentIterator/DirectoryDocumentIterator.cs

@ -5,15 +5,16 @@ @@ -5,15 +5,16 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.Editor.Search;
using ICSharpCode.SharpDevelop;
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.Search;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Refactoring;
using ICSharpCode.TextEditor.Document;
namespace SearchAndReplace
{
@ -59,20 +60,20 @@ namespace SearchAndReplace @@ -59,20 +60,20 @@ namespace SearchAndReplace
foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) {
if (content.PrimaryFileName != null &&
FileUtility.IsEqualFileName(content.PrimaryFileName, fileName) &&
content is ITextEditorControlProvider) {
document = ((ITextEditorControlProvider)content).TextEditorControl.Document;
return new ProvidedDocumentInformation(new TextEditorDocument(document),
content is ITextEditorProvider) {
document = ((ITextEditorProvider)content).TextEditor.Document;
return new ProvidedDocumentInformation(document,
fileName,
0);
}
}
ITextBufferStrategy strategy = null;
string fileContent;
try {
strategy = StringTextBufferStrategy.CreateTextBufferFromFile(fileName);
fileContent = ParserService.GetParseableFileContent(fileName);
} catch (Exception) {
return null;
}
return new ProvidedDocumentInformation(strategy,
return new ProvidedDocumentInformation(fileContent,
fileName,
0);
}

17
src/AddIns/Misc/SearchAndReplace/Project/Engine/DocumentIterator/WholeProjectDocumentIterator.cs

@ -5,16 +5,17 @@ @@ -5,16 +5,17 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.Editor.Search;
using ICSharpCode.SharpDevelop;
using System;
using System.Collections;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.Search;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Refactoring;
using ICSharpCode.TextEditor.Document;
namespace SearchAndReplace
{
@ -52,21 +53,21 @@ namespace SearchAndReplace @@ -52,21 +53,21 @@ namespace SearchAndReplace
foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) {
if (content.PrimaryFileName != null &&
FileUtility.IsEqualFileName(content.PrimaryFileName, fileName) &&
content is ITextEditorControlProvider)
content is ITextEditorProvider)
{
document = (((ITextEditorControlProvider)content).TextEditorControl).Document;
return new ProvidedDocumentInformation(new TextEditorDocument(document),
document = (((ITextEditorProvider)content).TextEditor).Document;
return new ProvidedDocumentInformation(document,
fileName,
0);
}
}
ITextBufferStrategy strategy = null;
string fileContent;
try {
strategy = StringTextBufferStrategy.CreateTextBufferFromFile(fileName);
fileContent = ParserService.GetParseableFileContent(fileName);
} catch (Exception) {
return null;
}
return new ProvidedDocumentInformation(strategy,
return new ProvidedDocumentInformation(fileContent,
fileName,
0);
}

17
src/AddIns/Misc/SearchAndReplace/Project/Engine/DocumentIterator/WholeSolutionDocumentIterator.cs

@ -5,16 +5,17 @@ @@ -5,16 +5,17 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.Editor.Search;
using ICSharpCode.SharpDevelop;
using System;
using System.Collections;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.Search;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Refactoring;
using ICSharpCode.TextEditor.Document;
namespace SearchAndReplace
{
@ -52,21 +53,21 @@ namespace SearchAndReplace @@ -52,21 +53,21 @@ namespace SearchAndReplace
foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) {
if (content.PrimaryFileName != null &&
FileUtility.IsEqualFileName(content.PrimaryFileName, fileName) &&
content is ITextEditorControlProvider)
content is ITextEditorProvider)
{
document = (((ITextEditorControlProvider)content).TextEditorControl).Document;
return new ProvidedDocumentInformation(new TextEditorDocument(document),
document = (((ITextEditorProvider)content).TextEditor).Document;
return new ProvidedDocumentInformation(document,
fileName,
0);
}
}
ITextBufferStrategy strategy = null;
string fileContent;
try {
strategy = StringTextBufferStrategy.CreateTextBufferFromFile(fileName);
fileContent = ParserService.GetParseableFileContent(fileName);
} catch (Exception) {
return null;
}
return new ProvidedDocumentInformation(strategy,
return new ProvidedDocumentInformation(fileContent,
fileName,
0);
}

54
src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchReplaceManager.cs

@ -14,8 +14,6 @@ using ICSharpCode.SharpDevelop; @@ -14,8 +14,6 @@ using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
namespace SearchAndReplace
{
@ -39,24 +37,21 @@ namespace SearchAndReplace @@ -39,24 +37,21 @@ namespace SearchAndReplace
public static void Replace(IProgressMonitor monitor)
{
SetSearchOptions();
if (lastResult != null && WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null) {
ITextEditorControlProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorControlProvider;
if (lastResult != null) {
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
if (provider != null) {
TextEditorControl textarea = provider.TextEditorControl;
SelectionManager selectionManager = textarea.ActiveTextAreaControl.TextArea.SelectionManager;
ITextEditor textarea = provider.TextEditor;
if (selectionManager.SelectionCollection.Count == 1
&& selectionManager.SelectionCollection[0].Offset == lastResult.Offset
&& selectionManager.SelectionCollection[0].Length == lastResult.Length
if (textarea.SelectionStart == lastResult.Offset
&& textarea.SelectionLength == lastResult.Length
&& lastResult.FileName == textarea.FileName)
{
string replacePattern = lastResult.TransformReplacePattern(SearchOptions.ReplacePattern);
textarea.BeginUpdate();
selectionManager.ClearSelection();
textarea.Document.Replace(lastResult.Offset, lastResult.Length, replacePattern);
textarea.ActiveTextAreaControl.Caret.Position = textarea.Document.OffsetToPosition(lastResult.Offset + replacePattern.Length);
textarea.EndUpdate();
using (textarea.Document.OpenUndoGroup()) {
textarea.Document.Replace(lastResult.Offset, lastResult.Length, replacePattern);
textarea.Select(lastResult.Offset + replacePattern.Length, 0); // clear selection and set caret position
}
}
}
}
@ -73,24 +68,21 @@ namespace SearchAndReplace @@ -73,24 +68,21 @@ namespace SearchAndReplace
public static bool ReplaceNextInSelection(IProgressMonitor monitor)
{
if (lastResult != null && WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null) {
ITextEditorControlProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorControlProvider;
if (lastResult != null) {
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
if (provider != null) {
TextEditorControl textarea = provider.TextEditorControl;
SelectionManager selectionManager = textarea.ActiveTextAreaControl.TextArea.SelectionManager;
ITextEditor textarea = provider.TextEditor;
if (selectionManager.SelectionCollection.Count == 1
&& selectionManager.SelectionCollection[0].Offset == lastResult.Offset
&& selectionManager.SelectionCollection[0].Length == lastResult.Length
if (textarea.SelectionStart == lastResult.Offset
&& textarea.SelectionLength == lastResult.Length
&& lastResult.FileName == textarea.FileName)
{
string replacePattern = lastResult.TransformReplacePattern(SearchOptions.ReplacePattern);
textarea.BeginUpdate();
selectionManager.ClearSelection();
textarea.Document.Replace(lastResult.Offset, lastResult.Length, replacePattern);
textarea.ActiveTextAreaControl.Caret.Position = textarea.Document.OffsetToPosition(lastResult.Offset + replacePattern.Length);
textarea.EndUpdate();
using (textarea.Document.OpenUndoGroup()) {
textarea.Document.Replace(lastResult.Offset, lastResult.Length, replacePattern);
textarea.Select(lastResult.Offset + replacePattern.Length, 0); // clear selection and set caret position
}
textSelection.Length -= lastResult.Length - replacePattern.Length;
}
@ -386,11 +378,11 @@ namespace SearchAndReplace @@ -386,11 +378,11 @@ namespace SearchAndReplace
static void ClearSelection()
{
if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null) {
ITextEditorControlProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorControlProvider;
if (provider != null) {
provider.TextEditorControl.ActiveTextAreaControl.TextArea.SelectionManager.ClearSelection();
}
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
if (provider != null) {
ITextEditor editor = provider.TextEditor;
if (editor.SelectionLength > 0)
editor.Select(editor.Caret.Offset, 0);
}
}
}

5
src/AddIns/Misc/SearchAndReplace/Project/SearchAndReplace.csproj

@ -107,11 +107,6 @@ @@ -107,11 +107,6 @@
<Folder Include="Engine\TextIterator" />
<Folder Include="Gui" />
<Folder Include="Resources" />
<ProjectReference Include="..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj">
<Project>{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}</Project>
<Name>ICSharpCode.TextEditor</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>

1
src/AddIns/Misc/SearchAndReplace/Test/FindNextWithCursorAtEndTestFixture.cs

@ -8,7 +8,6 @@ @@ -8,7 +8,6 @@
using ICSharpCode.SharpDevelop.Editor.Search;
using System;
using ICSharpCode.Core;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using SearchAndReplace;
using SearchAndReplace.Tests.Utils;

1
src/AddIns/Misc/SearchAndReplace/Test/ForwardIteratorWithEmptyTextBufferTestFixture.cs

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
using ICSharpCode.SharpDevelop.Editor.Search;
using System;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using SearchAndReplace;
using SearchAndReplace.Tests.Utils;

1
src/AddIns/Misc/SearchAndReplace/Test/ForwardTextIteratorPositionIsEndOffsetTestFixture.cs

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
using ICSharpCode.SharpDevelop.Editor.Search;
using System;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using SearchAndReplace;
using SearchAndReplace.Tests.Utils;

4
src/AddIns/Misc/SearchAndReplace/Test/SearchAndReplace.Tests.csproj

@ -47,10 +47,6 @@ @@ -47,10 +47,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj">
<Project>{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}</Project>
<Name>ICSharpCode.TextEditor</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
<Name>NRefactory</Name>

24
src/Main/Base/Project/Src/Editor/Search/ProvidedDocumentInformation.cs

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.AvalonEdit.Document;
using System;
using ICSharpCode.SharpDevelop.Refactoring;
@ -12,11 +13,11 @@ namespace ICSharpCode.SharpDevelop.Editor.Search @@ -12,11 +13,11 @@ namespace ICSharpCode.SharpDevelop.Editor.Search
{
public class ProvidedDocumentInformation
{
IDocument document;
ICSharpCode.TextEditor.Document.ITextBufferStrategy textBuffer;
string fileName;
int currentOffset;
ITextEditor textEditor;
IDocument document;
string textBuffer;
string fileName;
int currentOffset;
public string FileName {
get {
@ -27,8 +28,11 @@ namespace ICSharpCode.SharpDevelop.Editor.Search @@ -27,8 +28,11 @@ namespace ICSharpCode.SharpDevelop.Editor.Search
public IDocument Document {
get {
if (document == null) {
var factory = new ICSharpCode.TextEditor.Document.DocumentFactory();
document = new TextEditorDocument(factory.CreateFromTextBuffer(textBuffer));
TextDocument textDocument = new TextDocument();
textDocument.Text = textBuffer;
textDocument.UndoStack.ClearAll();
document = new AvalonEditDocumentAdapter(textDocument, null);
this.textBuffer = null;
}
return document;
}
@ -66,11 +70,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Search @@ -66,11 +70,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Search
public void Replace(int offset, int length, string pattern)
{
if (document != null) {
document.Replace(offset, length, pattern);
} else {
textBuffer.Replace(offset, length, pattern);
}
this.Document.Replace(offset, length, pattern);
if (offset <= CurrentOffset) {
CurrentOffset = CurrentOffset - length + pattern.Length;
@ -107,7 +107,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Search @@ -107,7 +107,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Search
this.endOffset = this.CurrentOffset;
}
public ProvidedDocumentInformation(ICSharpCode.TextEditor.Document.ITextBufferStrategy textBuffer, string fileName, int currentOffset)
public ProvidedDocumentInformation(string textBuffer, string fileName, int currentOffset)
{
this.textBuffer = textBuffer;
this.fileName = fileName;

4
src/Main/Base/Project/Src/Services/RefactoringService/FindReferencesAndRenameHelper.cs

@ -252,8 +252,8 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -252,8 +252,8 @@ namespace ICSharpCode.SharpDevelop.Refactoring
}
}
}
var strategy = ICSharpCode.TextEditor.Document.StringTextBufferStrategy.CreateTextBufferFromFile(fileName);
return new ProvidedDocumentInformation(strategy, fileName, 0);
string fileContent = ParserService.GetParseableFileContent(fileName);
return new ProvidedDocumentInformation(fileContent, fileName, 0);
}
public static bool IsReadOnly(IClass c)

Loading…
Cancel
Save