From 3d6181aefe33511513af9f16ac668a7fdfb6e2c4 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 7 Nov 2009 23:31:44 +0000 Subject: [PATCH] Remove unused code (integration of ICSharpCode.TextEditor into SharpDevelop) git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5236 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- AddIns/ICSharpCode.SharpDevelop.addin | 5 - .../Boo/BooBinding/Project/BooBinding.addin | 12 - .../CodeCompletion/BooAdvancedHighlighter.cs | 2 + .../Test/FromImportCompletion.cs | 7 +- .../Test/ImportCompletionTestFixture.cs | 11 +- .../Parsing/ParseClassWithCtorTestFixture.cs | 33 +- .../ParseClassWithMethodTestFixture.cs | 37 +- .../ParseMethodsWithNoClassTestFixture.cs | 34 +- .../Project/Src/VBNetCompletionBinding.cs | 10 +- .../Project/ICSharpCode.SharpDevelop.csproj | 31 - .../Resources/BehaviorTextEditorPanel.xfrm | 142 ----- .../Resources/GeneralTextEditorPanel.xfrm | 134 ----- .../Resources/MarkersTextEditorPanel.xfrm | 136 ----- .../AvalonEdit/AvalonEditTextEditorAdapter.cs | 5 - .../CodeCompletionItemProvider.cs | 95 ++- .../CodeCompletion/MethodInsightItem.cs | 2 +- .../CodeCompletion/OverrideCompletionItem.cs | 2 +- .../Base/Project/Src/Editor/ITextEditor.cs | 3 - .../Src/Gui/Pads/TaskList/TaskListPad.cs | 20 +- .../Src/Services/Debugger/DebuggerService.cs | 2 +- .../RefactoringService/RefactoringService.cs | 5 - .../Base/Project/Src/TextEditor/Actions.cs | 70 --- .../Src/TextEditor/Codons/EditActionDoozer.cs | 63 -- .../Commands/CommentRegionCommand.cs | 30 - .../Src/TextEditor/Commands/FormatCommands.cs | 141 ----- .../TextEditor/Commands/NavigationCommands.cs | 22 - .../Src/TextEditor/Commands/SearchCommands.cs | 9 - .../Commands/TextAreaContextmenuCommands.cs | 70 --- .../Gui/Editor/AdvancedHighlighter.cs | 203 ------- .../Editor/AdvancedHighlightingStrategy.cs | 49 -- .../Gui/Editor/CommandPromptControl.cs | 148 ----- .../AbstractCompletionDataProvider.cs | 128 +--- .../CachedCompletionDataProvider.cs | 71 --- .../CompletionWindow/CodeCompletionData.cs | 89 +-- .../CodeCompletionDataProvider.cs | 80 --- .../Src/TextEditor/Gui/Editor/ErrorDrawer.cs | 195 ------- .../IndexerInsightDataProvider.cs | 41 -- .../MethodInsightDataProvider.cs | 253 -------- .../Gui/Editor/ParserFoldingStrategy.cs | 114 ---- .../Gui/Editor/SharpDevelopTextAreaControl.cs | 420 -------------- .../Gui/Editor/TextEditorDisplayBinding.cs | 547 ------------------ .../OptionPanels/BehaviorTextEditorPanel.cs | 93 --- .../OptionPanels/GeneralTextEditorPanel.cs | 132 ----- .../OptionPanels/MarkersTextEditorPanel.cs | 86 --- .../Src/TextEditor/Gui/TextEditorAdapter.cs | 41 +- 45 files changed, 193 insertions(+), 3630 deletions(-) delete mode 100644 src/Main/Base/Project/Resources/BehaviorTextEditorPanel.xfrm delete mode 100644 src/Main/Base/Project/Resources/GeneralTextEditorPanel.xfrm delete mode 100644 src/Main/Base/Project/Resources/MarkersTextEditorPanel.xfrm delete mode 100644 src/Main/Base/Project/Src/TextEditor/Actions.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Codons/EditActionDoozer.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Commands/CommentRegionCommand.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Commands/FormatCommands.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Commands/NavigationCommands.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Commands/TextAreaContextmenuCommands.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Gui/Editor/AdvancedHighlighter.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Gui/Editor/AdvancedHighlightingStrategy.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Gui/Editor/CommandPromptControl.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CachedCompletionDataProvider.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataProvider.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Gui/Editor/ErrorDrawer.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/IndexerInsightDataProvider.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/MethodInsightDataProvider.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Gui/Editor/ParserFoldingStrategy.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/BehaviorTextEditorPanel.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/GeneralTextEditorPanel.cs delete mode 100644 src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/MarkersTextEditorPanel.cs diff --git a/AddIns/ICSharpCode.SharpDevelop.addin b/AddIns/ICSharpCode.SharpDevelop.addin index d7ee908cd8..69ae937dac 100644 --- a/AddIns/ICSharpCode.SharpDevelop.addin +++ b/AddIns/ICSharpCode.SharpDevelop.addin @@ -41,7 +41,6 @@ - @@ -1709,10 +1708,6 @@ - - - > declarations; @@ -148,4 +149,5 @@ namespace Grunwald.BooBinding.CodeCompletion } } } + */ } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/FromImportCompletion.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/FromImportCompletion.cs index c18d42af01..a8d811f0cb 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/FromImportCompletion.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/FromImportCompletion.cs @@ -9,7 +9,7 @@ using ICSharpCode.SharpDevelop; using System; using ICSharpCode.Core; using ICSharpCode.PythonBinding; -using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; +using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Dom; using NUnit.Framework; using PythonBinding.Tests.Utils; @@ -25,15 +25,14 @@ namespace PythonBinding.Tests { DerivedPythonCodeCompletionBinding codeCompletionBinding; bool handlesImportKeyword; - SharpDevelopTextAreaControl textAreaControl; [TestFixtureSetUp] public void SetUpFixture() { PropertyService.InitializeServiceForUnitTests(); - textAreaControl = new SharpDevelopTextAreaControl(); codeCompletionBinding = new DerivedPythonCodeCompletionBinding(); - handlesImportKeyword = codeCompletionBinding.HandleKeyword(new TextEditorAdapter(textAreaControl), "from"); + var editor = new AvalonEditTextEditorAdapter(new ICSharpCode.AvalonEdit.TextEditor()); + handlesImportKeyword = codeCompletionBinding.HandleKeyword(editor, "from"); } [Test] diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/ImportCompletionTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/ImportCompletionTestFixture.cs index c8d9717551..d443d666df 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/ImportCompletionTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/ImportCompletionTestFixture.cs @@ -5,12 +5,13 @@ // $Revision$ // -using ICSharpCode.SharpDevelop; using System; using ICSharpCode.Core; using ICSharpCode.PythonBinding; +using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using NUnit.Framework; using PythonBinding.Tests.Utils; @@ -22,18 +23,16 @@ namespace PythonBinding.Tests [TestFixture] public class ImportCompletionTestFixture { + ICSharpCode.SharpDevelop.Editor.ITextEditor textEditor; DerivedPythonCodeCompletionBinding codeCompletionBinding; bool handlesImportKeyword; - SharpDevelopTextAreaControl textAreaControl; - TextEditorAdapter textEditor; [TestFixtureSetUp] public void SetUpFixture() { PropertyService.InitializeServiceForUnitTests(); - textAreaControl = new SharpDevelopTextAreaControl(); - textEditor = new TextEditorAdapter(textAreaControl); codeCompletionBinding = new DerivedPythonCodeCompletionBinding(); + textEditor = new AvalonEditTextEditorAdapter(new ICSharpCode.AvalonEdit.TextEditor()); handlesImportKeyword = codeCompletionBinding.HandleKeyword(textEditor, "import"); } @@ -77,7 +76,7 @@ namespace PythonBinding.Tests [Ignore("Broken since ITextEditor introduction")] public void TextAreaControlUsedToDisplayCodeCompletionWindow() { - Assert.AreSame(textAreaControl, codeCompletionBinding.TextAreaControlUsedToShowCompletionWindow); + Assert.AreSame(textEditor, codeCompletionBinding.TextAreaControlUsedToShowCompletionWindow); } [Test] diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseClassWithCtorTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseClassWithCtorTestFixture.cs index 227dd3bd78..cce27f5590 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseClassWithCtorTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseClassWithCtorTestFixture.cs @@ -28,8 +28,8 @@ namespace PythonBinding.Tests.Parsing ICompilationUnit compilationUnit; IClass c; IMethod method; - FoldMarker methodMarker; - FoldMarker classMarker; +// FoldMarker methodMarker; +// FoldMarker classMarker; [TestFixtureSetUp] public void SetUpFixture() @@ -47,19 +47,19 @@ namespace PythonBinding.Tests.Parsing method = c.Methods[0]; } - // Get folds. - ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy(); - ParseInformation parseInfo = new ParseInformation(compilationUnit); - - DocumentFactory docFactory = new DocumentFactory(); - IDocument doc = docFactory.CreateDocument(); - doc.TextContent = python; - List markers = foldingStrategy.GenerateFoldMarkers(doc, @"C:\Temp\test.py", parseInfo); - - if (markers.Count > 1) { - classMarker = markers[0]; - methodMarker = markers[1]; - } +// // Get folds. +// ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy(); +// ParseInformation parseInfo = new ParseInformation(compilationUnit); +// +// DocumentFactory docFactory = new DocumentFactory(); +// IDocument doc = docFactory.CreateDocument(); +// doc.TextContent = python; +// List markers = foldingStrategy.GenerateFoldMarkers(doc, @"C:\Temp\test.py", parseInfo); +// +// if (markers.Count > 1) { +// classMarker = markers[0]; +// methodMarker = markers[1]; +// } } } @@ -75,9 +75,10 @@ namespace PythonBinding.Tests.Parsing } [Test] + [IgnoreAttribute] public void MethodFoldMarkerInnerText() { - Assert.AreEqual("\r\n\t\tpass", methodMarker.InnerText); + //Assert.AreEqual("\r\n\t\tpass", methodMarker.InnerText); } [Test] diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseClassWithMethodTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseClassWithMethodTestFixture.cs index f89fce0542..97b6736bfa 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseClassWithMethodTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseClassWithMethodTestFixture.cs @@ -23,8 +23,8 @@ namespace PythonBinding.Tests.Parsing ICompilationUnit compilationUnit; IClass c; IMethod method; - FoldMarker methodMarker; - FoldMarker classMarker; + FoldMarker methodMarker = null; + FoldMarker classMarker = null; [TestFixtureSetUp] public void SetUpFixture() @@ -42,21 +42,21 @@ namespace PythonBinding.Tests.Parsing method = c.Methods[0]; } - // Get folds. - ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy(); - ParseInformation parseInfo = new ParseInformation(compilationUnit); - - DocumentFactory docFactory = new DocumentFactory(); - IDocument doc = docFactory.CreateDocument(); - doc.TextContent = python; - List markers = foldingStrategy.GenerateFoldMarkers(doc, @"C:\Temp\test.py", parseInfo); - - if (markers.Count > 0) { - classMarker = markers[0]; - } - if (markers.Count > 1) { - methodMarker = markers[1]; - } +// // Get folds. +// ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy(); +// ParseInformation parseInfo = new ParseInformation(compilationUnit); +// +// DocumentFactory docFactory = new DocumentFactory(); +// IDocument doc = docFactory.CreateDocument(); +// doc.TextContent = python; +// List markers = foldingStrategy.GenerateFoldMarkers(doc, @"C:\Temp\test.py", parseInfo); +// +// if (markers.Count > 0) { +// classMarker = markers[0]; +// } +// if (markers.Count > 1) { +// methodMarker = markers[1]; +// } } } @@ -130,12 +130,14 @@ namespace PythonBinding.Tests.Parsing } [Test] + [Ignore] public void MethodFoldMarkerStartColumn() { Assert.AreEqual(15, methodMarker.StartColumn); } [Test] + [Ignore] public void MethodFoldMarkerInnerText() { Assert.AreEqual("\r\n\t\tpass", methodMarker.InnerText); @@ -155,6 +157,7 @@ namespace PythonBinding.Tests.Parsing } [Test] + [Ignore] public void ClassFoldMarkerStartColumn() { Assert.AreEqual(11, classMarker.StartColumn); diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseMethodsWithNoClassTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseMethodsWithNoClassTestFixture.cs index ad85d29604..81e1bad1cb 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseMethodsWithNoClassTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseMethodsWithNoClassTestFixture.cs @@ -25,8 +25,8 @@ namespace PythonBinding.Tests.Parsing public class ParseMethodsWithNoClassTestFixture { ICompilationUnit compilationUnit; - FoldMarker fooMethodMarker; - FoldMarker barMethodMarker; + FoldMarker fooMethodMarker = null; + FoldMarker barMethodMarker = null; IClass globalClass; IMethod fooMethod; IMethod barMethod; @@ -52,19 +52,19 @@ namespace PythonBinding.Tests.Parsing } } - // Get folds. - ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy(); - ParseInformation parseInfo = new ParseInformation(compilationUnit); - - DocumentFactory docFactory = new DocumentFactory(); - IDocument doc = docFactory.CreateDocument(); - doc.TextContent = python; - List markers = foldingStrategy.GenerateFoldMarkers(doc, @"C:\Temp\test.py", parseInfo); - - if (markers.Count > 1) { - fooMethodMarker = markers[0]; - barMethodMarker = markers[1]; - } +// // Get folds. +// ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy(); +// ParseInformation parseInfo = new ParseInformation(compilationUnit); +// +// DocumentFactory docFactory = new DocumentFactory(); +// IDocument doc = docFactory.CreateDocument(); +// doc.TextContent = python; +// List markers = foldingStrategy.GenerateFoldMarkers(doc, @"C:\Temp\test.py", parseInfo); +// +// if (markers.Count > 1) { +// fooMethodMarker = markers[0]; +// barMethodMarker = markers[1]; +// } } [Test] @@ -172,24 +172,28 @@ namespace PythonBinding.Tests.Parsing } [Test] + [Ignore] public void FooMethodFoldMarkerInnerText() { Assert.AreEqual("\r\n\tpass", fooMethodMarker.InnerText); } [Test] + [Ignore] public void BarMethodFoldMarkerInnerText() { Assert.AreEqual("\r\n\tpass", barMethodMarker.InnerText); } [Test] + [Ignore] public void FooMethodCollapsedFoldText() { Assert.AreEqual("...", fooMethodMarker.FoldText); } [Test] + [Ignore] public void BarMethodCollapsedFoldText() { Assert.AreEqual("...", barMethodMarker.FoldText); diff --git a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetCompletionBinding.cs b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetCompletionBinding.cs index 4a86ca30f3..430b79a167 100644 --- a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetCompletionBinding.cs +++ b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetCompletionBinding.cs @@ -50,6 +50,14 @@ namespace VBNetBinding return ef.FilterComments(editor.Document.GetText(0, cursor + 1), ref cursor) == null; } + sealed class GlobalCompletionItemProvider : CodeCompletionItemProvider + { + public override ExpressionResult GetExpression(ITextEditor editor) + { + return new ExpressionResult("Global", ExpressionContext.Importable); + } + } + public override bool HandleKeyword(ITextEditor editor, string word) { // TODO: Assistance writing Methods/Fields/Properties/Events: @@ -58,7 +66,7 @@ namespace VBNetBinding switch (word.ToLowerInvariant()) { case "imports": if (IsInComment(editor)) return false; - editor.ShowCompletionWindow(new CodeCompletionDataProvider(new ExpressionResult("Global", ExpressionContext.Importable)), ' '); + new GlobalCompletionItemProvider().ShowCompletion(editor); return true; case "as": if (IsInComment(editor)) return false; diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index 93f5779fff..ab51a88d22 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -559,9 +559,6 @@ - - - @@ -575,7 +572,6 @@ - @@ -591,43 +587,19 @@ - - Form - - - - - - - - - UserControl - - - - UserControl - - - UserControl - - - UserControl - - - @@ -667,7 +639,6 @@ - @@ -742,8 +713,6 @@ - - diff --git a/src/Main/Base/Project/Resources/BehaviorTextEditorPanel.xfrm b/src/Main/Base/Project/Resources/BehaviorTextEditorPanel.xfrm deleted file mode 100644 index af899f2067..0000000000 --- a/src/Main/Base/Project/Resources/BehaviorTextEditorPanel.xfrm +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Main/Base/Project/Resources/GeneralTextEditorPanel.xfrm b/src/Main/Base/Project/Resources/GeneralTextEditorPanel.xfrm deleted file mode 100644 index abebbe3059..0000000000 --- a/src/Main/Base/Project/Resources/GeneralTextEditorPanel.xfrm +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Main/Base/Project/Resources/MarkersTextEditorPanel.xfrm b/src/Main/Base/Project/Resources/MarkersTextEditorPanel.xfrm deleted file mode 100644 index 0f121b4f28..0000000000 --- a/src/Main/Base/Project/Resources/MarkersTextEditorPanel.xfrm +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditTextEditorAdapter.cs b/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditTextEditorAdapter.cs index 7e56b4a59c..1b6c9f2412 100644 --- a/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditTextEditorAdapter.cs +++ b/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditTextEditorAdapter.cs @@ -227,11 +227,6 @@ namespace ICSharpCode.SharpDevelop.Editor.AvalonEdit return null; } - - void ITextEditor.ShowCompletionWindow(ICSharpCode.TextEditor.Gui.CompletionWindow.ICompletionDataProvider provider, char ch) - { - } - public virtual ICompletionListWindow ActiveCompletionWindow { get { return null; diff --git a/src/Main/Base/Project/Src/Editor/CodeCompletion/CodeCompletionItemProvider.cs b/src/Main/Base/Project/Src/Editor/CodeCompletion/CodeCompletionItemProvider.cs index 410fb06d3d..173581e1b5 100644 --- a/src/Main/Base/Project/Src/Editor/CodeCompletion/CodeCompletionItemProvider.cs +++ b/src/Main/Base/Project/Src/Editor/CodeCompletion/CodeCompletionItemProvider.cs @@ -8,6 +8,9 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Dom; @@ -243,9 +246,99 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion } } + static readonly Regex whitespace = new Regex(@"\s+"); + + /// + /// Converts the xml documentation string into a plain text string. + /// public static string ConvertDocumentation(string xmlDocumentation) { - return ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.CodeCompletionData.ConvertDocumentation(xmlDocumentation); + if (string.IsNullOrEmpty(xmlDocumentation)) + return string.Empty; + + System.IO.StringReader reader = new System.IO.StringReader("" + xmlDocumentation + ""); + XmlTextReader xml = new XmlTextReader(reader); + StringBuilder ret = new StringBuilder(); + ////Regex whitespace = new Regex(@"\s+"); + + try { + xml.Read(); + do { + if (xml.NodeType == XmlNodeType.Element) { + string elname = xml.Name.ToLowerInvariant(); + switch (elname) { + case "filterpriority": + xml.Skip(); + break; + case "remarks": + ret.Append(Environment.NewLine); + ret.Append("Remarks:"); + ret.Append(Environment.NewLine); + break; + case "example": + ret.Append(Environment.NewLine); + ret.Append("Example:"); + ret.Append(Environment.NewLine); + break; + case "exception": + ret.Append(Environment.NewLine); + ret.Append(GetCref(xml["cref"])); + ret.Append(": "); + break; + case "returns": + ret.Append(Environment.NewLine); + ret.Append("Returns: "); + break; + case "see": + ret.Append(GetCref(xml["cref"])); + ret.Append(xml["langword"]); + break; + case "seealso": + ret.Append(Environment.NewLine); + ret.Append("See also: "); + ret.Append(GetCref(xml["cref"])); + break; + case "paramref": + ret.Append(xml["name"]); + break; + case "param": + ret.Append(Environment.NewLine); + ret.Append(whitespace.Replace(xml["name"].Trim()," ")); + ret.Append(": "); + break; + case "value": + ret.Append(Environment.NewLine); + ret.Append("Value: "); + ret.Append(Environment.NewLine); + break; + case "br": + case "para": + ret.Append(Environment.NewLine); + break; + } + } else if (xml.NodeType == XmlNodeType.Text) { + ret.Append(whitespace.Replace(xml.Value, " ")); + } + } while(xml.Read()); + } catch (Exception ex) { + LoggingService.Debug("Invalid XML documentation: " + ex.Message); + return xmlDocumentation; + } + return ret.ToString(); + } + + static string GetCref(string cref) + { + if (cref == null || cref.Trim().Length==0) { + return ""; + } + if (cref.Length < 2) { + return cref; + } + if (cref.Substring(1, 1) == ":") { + return cref.Substring(2, cref.Length - 2); + } + return cref; } #endregion } diff --git a/src/Main/Base/Project/Src/Editor/CodeCompletion/MethodInsightItem.cs b/src/Main/Base/Project/Src/Editor/CodeCompletion/MethodInsightItem.cs index a0a829ea2e..09040d2ca9 100644 --- a/src/Main/Base/Project/Src/Editor/CodeCompletion/MethodInsightItem.cs +++ b/src/Main/Base/Project/Src/Editor/CodeCompletion/MethodInsightItem.cs @@ -48,7 +48,7 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion if (!descriptionCreated) { string entityDoc = entity.Documentation; if (!string.IsNullOrEmpty(entityDoc)) { - description = ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.CodeCompletionData.ConvertDocumentation(entityDoc); + description = CodeCompletionItem.ConvertDocumentation(entityDoc); } descriptionCreated = true; } diff --git a/src/Main/Base/Project/Src/Editor/CodeCompletion/OverrideCompletionItem.cs b/src/Main/Base/Project/Src/Editor/CodeCompletion/OverrideCompletionItem.cs index 37b8eb61bf..9048bde6fd 100644 --- a/src/Main/Base/Project/Src/Editor/CodeCompletion/OverrideCompletionItem.cs +++ b/src/Main/Base/Project/Src/Editor/CodeCompletion/OverrideCompletionItem.cs @@ -41,7 +41,7 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion return "override " + GetName(member, ConversionFlags.ShowReturnType | ConversionFlags.ShowParameterList | ConversionFlags.ShowAccessibility) - + "\n\n" + CodeCompletionData.ConvertDocumentation(member.Documentation); + + "\n\n" + CodeCompletionItem.ConvertDocumentation(member.Documentation); } } diff --git a/src/Main/Base/Project/Src/Editor/ITextEditor.cs b/src/Main/Base/Project/Src/Editor/ITextEditor.cs index 77ad5d16cc..e686af9c24 100644 --- a/src/Main/Base/Project/Src/Editor/ITextEditor.cs +++ b/src/Main/Base/Project/Src/Editor/ITextEditor.cs @@ -121,9 +121,6 @@ namespace ICSharpCode.SharpDevelop.Editor /// Gets the list of available code snippets. /// IEnumerable GetSnippets(); - - [Obsolete("Use the overload taking ICompletionItemList")] - void ShowCompletionWindow(ICSharpCode.TextEditor.Gui.CompletionWindow.ICompletionDataProvider provider, char ch); } public interface ITextEditorOptions diff --git a/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs b/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs index 8f45ab8f38..7ca2998fce 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs @@ -13,6 +13,7 @@ using ICSharpCode.Core; using ICSharpCode.Core.WinForms; using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Project; namespace ICSharpCode.SharpDevelop.Gui @@ -75,12 +76,7 @@ namespace ICSharpCode.SharpDevelop.Gui if (WorkbenchSingleton.Workbench.ActiveViewContent != null) { UpdateItems(); - - if (WorkbenchSingleton.Workbench.ActiveViewContent.Control is SharpDevelopTextAreaControl) { - SharpDevelopTextAreaControl ctrl = WorkbenchSingleton.Workbench.ActiveViewContent.Control as SharpDevelopTextAreaControl; - - ctrl.ActiveTextAreaControl.Caret.PositionChanged += new EventHandler(CaretPositionChanged); - } + WorkbenchActiveViewContentChanged(null, null); } ProjectService.SolutionLoaded += OnSolutionOpen; @@ -98,15 +94,15 @@ namespace ICSharpCode.SharpDevelop.Gui void WorkbenchActiveViewContentChanged(object sender, EventArgs e) { - if (WorkbenchSingleton.Workbench.ActiveViewContent == null) - return; if (isInitialized) UpdateItems(); - if (WorkbenchSingleton.Workbench.ActiveViewContent.Control is SharpDevelopTextAreaControl) { - SharpDevelopTextAreaControl ctrl = WorkbenchSingleton.Workbench.ActiveViewContent.Control as SharpDevelopTextAreaControl; - - ctrl.ActiveTextAreaControl.Caret.PositionChanged += new EventHandler(CaretPositionChanged); + ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider; + + if (provider != null) { + // ensure we don't attach multiple times to the same editor + provider.TextEditor.Caret.PositionChanged -= CaretPositionChanged; + provider.TextEditor.Caret.PositionChanged += CaretPositionChanged; } } diff --git a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs index 04a23b4d63..4e6c12cd3d 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs @@ -404,7 +404,7 @@ namespace ICSharpCode.SharpDevelop.Debugging string documentation = member.Documentation; if (documentation != null && documentation.Length > 0) { text.Append('\n'); - text.Append(ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.CodeCompletionData.ConvertDocumentation(documentation)); + text.Append(ICSharpCode.SharpDevelop.Editor.CodeCompletion.CodeCompletionItem.ConvertDocumentation(documentation)); } return text.ToString(); } diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs b/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs index b1391a5d29..7b7e26ed12 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs @@ -158,11 +158,6 @@ namespace ICSharpCode.SharpDevelop.Refactoring if (progressMonitor != null) { progressMonitor.BeginTask("${res:SharpDevelop.Refactoring.FindingReferences}", files.Count, true); } - #if DEBUG - if (System.Windows.Forms.Control.ModifierKeys == DefaultEditor.Gui.Editor.SharpDevelopTextAreaControl.DebugBreakModifiers) { - System.Diagnostics.Debugger.Break(); - } - #endif int index = 0; foreach (ProjectItem item in files) { var entry = finder.Create(item); diff --git a/src/Main/Base/Project/Src/TextEditor/Actions.cs b/src/Main/Base/Project/Src/TextEditor/Actions.cs deleted file mode 100644 index 089400ccd4..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Actions.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.TextEditor; -using ICSharpCode.TextEditor.Actions; -using ICSharpCode.TextEditor.Document; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Actions -{ - public class CodeCompletionPopup : AbstractEditAction - { - public override void Execute(TextArea textArea) - { - SharpDevelopTextAreaControl sdtac = (SharpDevelopTextAreaControl)textArea.MotherTextEditorControl; - sdtac.StartCtrlSpaceCompletion(); - } - } - - public class ExpandTemplateAction : Tab - { - public override void Execute(TextArea textArea) - { - SharpDevelopTextAreaControl sdtac = (SharpDevelopTextAreaControl)textArea.MotherTextEditorControl; - if (!sdtac.ExpandTemplateOnTab()) - base.Execute(textArea); - } - } - - public class GoToDefinition : AbstractEditAction - { - public override void Execute(TextArea textArea) - { - TextEditorControl textEditorControl = textArea.MotherTextEditorControl; - IDocument document = textEditorControl.Document; - string textContent = document.TextContent; - - int caretLineNumber = document.GetLineNumberForOffset(textEditorControl.ActiveTextAreaControl.Caret.Offset) + 1; - int caretColumn = textEditorControl.ActiveTextAreaControl.Caret.Offset - document.GetLineSegment(caretLineNumber - 1).Offset + 1; - - IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(textEditorControl.FileName); - if (expressionFinder == null) - return; - ExpressionResult expression = expressionFinder.FindFullExpression(textContent, textEditorControl.ActiveTextAreaControl.Caret.Offset); - if (expression.Expression == null || expression.Expression.Length == 0) - return; - ResolveResult result = ParserService.Resolve(expression, caretLineNumber, caretColumn, textEditorControl.FileName, textContent); - if (result != null) { - FilePosition pos = result.GetDefinitionPosition(); - if (pos.IsEmpty == false) { - try { - if (pos.Position.IsEmpty) - FileService.OpenFile(pos.FileName); - else - FileService.JumpToFilePosition(pos.FileName, pos.Line, pos.Column); - } catch (Exception ex) { - MessageService.ShowException(ex, "Error jumping to '" + pos.FileName + "'."); - } - } - } - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Codons/EditActionDoozer.cs b/src/Main/Base/Project/Src/TextEditor/Codons/EditActionDoozer.cs deleted file mode 100644 index 380c2c271b..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Codons/EditActionDoozer.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections; -using System.Reflection; -using System.Windows.Forms; - -using ICSharpCode.Core; -using ICSharpCode.TextEditor.Actions; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Codons -{ - /// - /// Creates IEditAction objects for the text editor. - /// - /// - /// Comma-separated list of keyboard shortcuts that activate the edit action. - /// E.g. "Control|C,Control|Insert" - /// - /// - /// Name of the IEditAction class. - /// - /// Only in /AddIns/DefaultTextEditor/EditActions - /// - /// An IEditAction object. - /// - public class EditActionDoozer : IDoozer - { - /// - /// Gets if the doozer handles codon conditions on its own. - /// If this property return false, the item is excluded when the condition is not met. - /// - public bool HandleConditions { - get { - return false; - } - } - - public object BuildItem(object caller, Codon codon, ArrayList subItems) - { - IEditAction editAction = (IEditAction)codon.AddIn.CreateObject(codon.Properties["class"]); - string[] keys = codon.Properties["keys"].Split(','); - - Keys[] actionKeys = new Keys[keys.Length]; - for (int j = 0; j < keys.Length; ++j) { - string[] keydescr = keys[j].Split('|'); - Keys key = (Keys)((System.Windows.Forms.Keys.Space.GetType()).InvokeMember(keydescr[0], BindingFlags.GetField, null, System.Windows.Forms.Keys.Space, new object[0])); - for (int k = 1; k < keydescr.Length; ++k) { - key |= (Keys)((System.Windows.Forms.Keys.Space.GetType()).InvokeMember(keydescr[k], BindingFlags.GetField, null, System.Windows.Forms.Keys.Space, new object[0])); - } - actionKeys[j] = key; - } - editAction.Keys = actionKeys; - - return editAction; - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Commands/CommentRegionCommand.cs b/src/Main/Base/Project/Src/TextEditor/Commands/CommentRegionCommand.cs deleted file mode 100644 index f4954477b3..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Commands/CommentRegionCommand.cs +++ /dev/null @@ -1,30 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; -using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.TextEditor; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands -{ - public class CommentRegion : AbstractMenuCommand - { - public override void Run() - { - IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent; - - if (viewContent == null || !(viewContent is ITextEditorControlProvider)) { - return; - } - - TextEditorControl textarea = ((ITextEditorControlProvider)viewContent).TextEditorControl; - new ICSharpCode.TextEditor.Actions.ToggleComment().Execute(textarea.ActiveTextAreaControl.TextArea); - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Commands/FormatCommands.cs b/src/Main/Base/Project/Src/TextEditor/Commands/FormatCommands.cs deleted file mode 100644 index 9436a77c0e..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Commands/FormatCommands.cs +++ /dev/null @@ -1,141 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections; -using System.Windows.Forms; - -using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; -using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.TextEditor; -using ICSharpCode.TextEditor.Actions; -using ICSharpCode.TextEditor.Document; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands -{ - public abstract class AbstractEditActionMenuCommand : AbstractMenuCommand - { - public abstract IEditAction EditAction { - get; - } - - public override void Run() - { - IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent; - - if (viewContent == null || !(viewContent is ITextEditorControlProvider)) { - return; - } - TextEditorControl textEditor = ((ITextEditorControlProvider)viewContent).TextEditorControl; - EditAction.Execute(textEditor.ActiveTextAreaControl.TextArea); - } - } - - public class RemoveLeadingWS : AbstractEditActionMenuCommand - { - public override IEditAction EditAction { - get { - return new ICSharpCode.TextEditor.Actions.RemoveLeadingWS(); - } - } - } - - public class RemoveTrailingWS : AbstractEditActionMenuCommand - { - public override IEditAction EditAction { - get { - return new ICSharpCode.TextEditor.Actions.RemoveTrailingWS(); - } - } - } - - - public class ToUpperCase : AbstractEditActionMenuCommand - { - public override IEditAction EditAction { - get { - return new ICSharpCode.TextEditor.Actions.ToUpperCase(); - } - } - } - - public class ToLowerCase : AbstractEditActionMenuCommand - { - public override IEditAction EditAction { - get { - return new ICSharpCode.TextEditor.Actions.ToLowerCase(); - } - } - } - - public class InvertCaseAction : AbstractEditActionMenuCommand - { - public override IEditAction EditAction { - get { - return new ICSharpCode.TextEditor.Actions.InvertCaseAction(); - } - } - } - - public class CapitalizeAction : AbstractEditActionMenuCommand - { - public override IEditAction EditAction { - get { - return new ICSharpCode.TextEditor.Actions.CapitalizeAction(); - } - } - } - - public class ConvertTabsToSpaces : AbstractEditActionMenuCommand - { - public override IEditAction EditAction { - get { - return new ICSharpCode.TextEditor.Actions.ConvertTabsToSpaces(); - } - } - } - - public class ConvertSpacesToTabs : AbstractEditActionMenuCommand - { - public override IEditAction EditAction { - get { - return new ICSharpCode.TextEditor.Actions.ConvertSpacesToTabs(); - } - } - } - - public class ConvertLeadingTabsToSpaces : AbstractEditActionMenuCommand - { - public override IEditAction EditAction { - get { - return new ICSharpCode.TextEditor.Actions.ConvertLeadingTabsToSpaces(); - } - } - } - - public class ConvertLeadingSpacesToTabs : AbstractEditActionMenuCommand - { - public override IEditAction EditAction { - get { - return new ICSharpCode.TextEditor.Actions.ConvertLeadingSpacesToTabs(); - } - } - } - - /// - /// This is a sample editaction plugin, it indents the selected area. - /// - public class IndentSelection : AbstractEditActionMenuCommand - { - public override IEditAction EditAction { - get { - return new ICSharpCode.TextEditor.Actions.IndentSelection(); - } - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Commands/NavigationCommands.cs b/src/Main/Base/Project/Src/TextEditor/Commands/NavigationCommands.cs deleted file mode 100644 index a1434eeaef..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Commands/NavigationCommands.cs +++ /dev/null @@ -1,22 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using ICSharpCode.TextEditor.Actions; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands -{ - public class GoToDefinition : AbstractEditActionMenuCommand - { - public override IEditAction EditAction { - get { - // TODO: use click position instead of cursor position - return new ICSharpCode.SharpDevelop.DefaultEditor.Actions.GoToDefinition(); - } - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Commands/SearchCommands.cs b/src/Main/Base/Project/Src/TextEditor/Commands/SearchCommands.cs index 435da325d5..48cf44f810 100644 --- a/src/Main/Base/Project/Src/TextEditor/Commands/SearchCommands.cs +++ b/src/Main/Base/Project/Src/TextEditor/Commands/SearchCommands.cs @@ -21,15 +21,6 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands } } - public class GotoMatchingBrace : AbstractEditActionMenuCommand - { - public override IEditAction EditAction { - get { - return new ICSharpCode.TextEditor.Actions.GotoMatchingBrace(); - } - } - } - /* public class RunIncrementalSearch : AbstractMenuCommand { diff --git a/src/Main/Base/Project/Src/TextEditor/Commands/TextAreaContextmenuCommands.cs b/src/Main/Base/Project/Src/TextEditor/Commands/TextAreaContextmenuCommands.cs deleted file mode 100644 index 344b54da08..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Commands/TextAreaContextmenuCommands.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using ICSharpCode.SharpDevelop.Gui; -using System; -using System.Collections; -using System.Windows.Forms; -using ICSharpCode.Core; -using ICSharpCode.Core.WinForms; -using ICSharpCode.SharpDevelop.Commands; -using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; -using ICSharpCode.TextEditor; -using ICSharpCode.TextEditor.Document; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands -{ - public class ShowBufferOptions : AbstractMenuCommand - { - public override void Run() - { - OptionsCommand.ShowTabbedOptions( - ResourceService.GetString("Dialog.Options.BufferOptions"), - AddInTree.GetTreeNode("/SharpDevelop/ViewContent/DefaultTextEditor/OptionsDialog")); - } - } - - - public class HighlightingTypeBuilder : ISubmenuBuilder - { - TextEditorControl control = null; - ToolStripItem[] menuCommands = null; - - public ToolStripItem[] BuildSubmenu(Codon codon, object owner) - { - control = (TextEditorControl)owner; - - ArrayList menuItems = new ArrayList(); - - foreach (DictionaryEntry entry in HighlightingManager.Manager.HighlightingDefinitions) { - MenuCheckBox item = new MenuCheckBox(entry.Key.ToString()); - item.Click += new EventHandler(ChangeSyntax); - item.Checked = control.Document.HighlightingStrategy.Name == entry.Key.ToString(); - menuItems.Add(item); - } - menuCommands = (ToolStripItem[])menuItems.ToArray(typeof(ToolStripItem)); - return menuCommands; - } - - void ChangeSyntax(object sender, EventArgs e) - { - if (control != null) { - MenuCheckBox item = (MenuCheckBox)sender; - foreach (MenuCheckBox i in menuCommands) { - i.Checked = false; - } - item.Checked = true; - try { - control.SetHighlighting(item.Text); - } catch (HighlightingDefinitionInvalidException ex) { - MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - control.Refresh(); - } - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/AdvancedHighlighter.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/AdvancedHighlighter.cs deleted file mode 100644 index 1c5960e51a..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/AdvancedHighlighter.cs +++ /dev/null @@ -1,203 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections.Generic; -using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.TextEditor; -using ICSharpCode.TextEditor.Document; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor -{ - /// - /// Interface for advanced syntax highlighters. - /// - public interface IAdvancedHighlighter : IDisposable - { - /// - /// Is called once after creating the highlighter. Gives your highlighter a chance - /// to register events on the text editor. - /// - void Initialize(TextEditorControl textEditor); - - void BeginUpdate(IDocument document, IList inputLines); - void EndUpdate(); - - /// - /// Gives your highlighter the chance to change the highlighting of the words. - /// - void MarkLine(int lineNumber, LineSegment currentLine, List words); - } - - /// - /// Advanced syntax highlighter that stores a list of changed lines and can mark them - /// later by calling . - /// - public abstract class AsynchronousAdvancedHighlighter : IAdvancedHighlighter - { - protected abstract void MarkWords(int lineNumber, LineSegment currentLine, List words); - - readonly object lockObject = new object(); - Dictionary> outstanding = new Dictionary>(); - TextEditorControl textEditor; - IDocument document; - - #region Settings - public TextEditorControl TextEditor { - get { - return textEditor; - } - } - - public IDocument Document { - get { - return document; - } - } - - int immediateMarkLimit = 3; - - /// - /// Maximum number of changed lines to immediately mark the changes. - /// - protected int ImmediateMarkLimit { - get { - return immediateMarkLimit; - } - set { - if (value < 0) throw new ArgumentOutOfRangeException("value", value, "value must be >= 0"); - immediateMarkLimit = value; - } - } - - bool markVisibleOnly = true; - /// - /// Gets/Sets whether to only mark lines in the visible region of the text area. - /// - protected bool MarkVisibleOnly { - get { - return markVisibleOnly; - } - set { - if (markVisibleOnly != value) { - if (textEditor != null) - throw new InvalidOperationException("Cannot change value after initialization"); - markVisibleOnly = value; - } - } - } - int markVisibleAdditional = 5; - /// - /// Number of additional lines around the visible region that should be marked. - /// - public int MarkVisibleAdditional { - get { - return markVisibleAdditional; - } - set { - if (value < 0) throw new ArgumentOutOfRangeException("value", value, "value must be >= 0"); - markVisibleAdditional = value; - } - } - #endregion - - public virtual void Initialize(TextEditorControl textEditor) - { - if (textEditor == null) - throw new ArgumentNullException("textEditor"); - if (this.textEditor != null) - throw new InvalidOperationException("Already initialized"); - this.textEditor = textEditor; - this.document = textEditor.Document; - } - - public virtual void Dispose() - { - textEditor = null; - document = null; - } - - int directMark; - - public virtual void BeginUpdate(IDocument document, IList inputLines) - { - if (this.document == null) - throw new InvalidOperationException("Not initialized"); - if (document != this.document) - throw new InvalidOperationException("document != this.document"); - if (inputLines == null) { - lock (lockObject) { - outstanding.Clear(); - } - } else { - directMark = inputLines.Count > immediateMarkLimit ? 0 : inputLines.Count; - } - } - - public virtual void EndUpdate() - { - } - - void IAdvancedHighlighter.MarkLine(int lineNumber, LineSegment currentLine, List words) - { - if (directMark > 0) { - directMark--; - MarkWords(lineNumber, currentLine, words); - } else { - lock (lockObject) { - outstanding[currentLine] = words; - } - } - } - - protected virtual void MarkOutstanding() - { - if (WorkbenchSingleton.InvokeRequired) { - // TODO: allow calling MarkOutstanding in separate threads - throw new InvalidOperationException("Invoke required"); - } - - IEnumerable>> oldOutstanding; - lock (lockObject) { - oldOutstanding = outstanding; - outstanding = new Dictionary>(); - } - // We cannot call MarkLine inside lock(lockObject) because then the main - // thread could deadlock with the highlighter thread. - foreach (KeyValuePair> pair in oldOutstanding) { - if (pair.Key.IsDeleted) - continue; - int offset = pair.Key.Offset; - if (offset < 0 || offset >= document.TextLength) - continue; - int lineNumber = document.GetLineNumberForOffset(offset); - if (markVisibleOnly && IsVisible(lineNumber) == false) { - lock (lockObject) { - outstanding[pair.Key] = pair.Value; - } - } else { - MarkWords(lineNumber, pair.Key, pair.Value); - } - } - } - - bool IsVisible(int lineNumber) - { - TextView textView = textEditor.ActiveTextAreaControl.TextArea.TextView; - int firstLine = textView.FirstVisibleLine; - if (lineNumber < firstLine - markVisibleAdditional) { - return false; - } - int lastLine = document.GetFirstLogicalLine(textView.FirstPhysicalLine + textView.VisibleLineCount); - if (lineNumber > lastLine + markVisibleAdditional) { - return false; - } - // line is visible if it is not folded away - return document.GetVisibleLine(lineNumber) != document.GetVisibleLine(lineNumber - 1); - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/AdvancedHighlightingStrategy.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/AdvancedHighlightingStrategy.cs deleted file mode 100644 index 00867c889a..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/AdvancedHighlightingStrategy.cs +++ /dev/null @@ -1,49 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections.Generic; -using ICSharpCode.TextEditor.Document; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor -{ - /// - /// Modifies the TextEditor's IHighlightingStrategy to be able to plug in - /// an . - /// - internal class AdvancedHighlightingStrategy : DefaultHighlightingStrategy - { - readonly IAdvancedHighlighter highlighter; - - public AdvancedHighlightingStrategy(DefaultHighlightingStrategy baseStrategy, IAdvancedHighlighter highlighter) - { - if (highlighter == null) - throw new ArgumentNullException("highlighter"); - ImportSettingsFrom(baseStrategy); - this.highlighter = highlighter; - } - - public override void MarkTokens(IDocument document) - { - highlighter.BeginUpdate(document, null); - base.MarkTokens(document); - highlighter.EndUpdate(); - } - - public override void MarkTokens(IDocument document, List inputLines) - { - highlighter.BeginUpdate(document, inputLines); - base.MarkTokens(document, inputLines); - highlighter.EndUpdate(); - } - - protected override void OnParsedLine(IDocument document, LineSegment currentLine, List words) - { - highlighter.MarkLine(currentLineNumber, currentLine, words); - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CommandPromptControl.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CommandPromptControl.cs deleted file mode 100644 index a56f85bb8f..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CommandPromptControl.cs +++ /dev/null @@ -1,148 +0,0 @@ -// -// -// -// -// $Revision$ -// -using System; -using System.Collections.Generic; -using System.Windows.Forms; - -using ICSharpCode.TextEditor; -using ICSharpCode.TextEditor.Document; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor -{ - /// - /// A text area used for an interactive command prompt. - /// - public abstract class CommandPromptControl : SharpDevelopTextAreaControl - { - TextMarker readOnlyMarker; - int promptStartOffset; - int promptEndOffset; - IList history; - int historyPointer; - - public CommandPromptControl() - : base(false, false) - { - this.TextEditorProperties.SupportReadOnlySegments = true; - this.TextEditorProperties.ShowLineNumbers = false; - this.history = new List(); - base.contextMenuPath = null; - } - - protected void PrintPrompt() - { - promptStartOffset = this.Document.TextLength; - PrintPromptInternal(); - promptEndOffset = this.Document.TextLength; - MakeReadOnly(); - } - - protected virtual void Clear() - { - if (readOnlyMarker != null) - this.Document.MarkerStrategy.RemoveMarker(readOnlyMarker); - this.Document.Remove(0, this.Document.TextLength); - this.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea)); - this.Document.CommitUpdate(); - readOnlyMarker = null; - promptStartOffset = 0; - promptEndOffset = 0; - } - - protected abstract void PrintPromptInternal(); - - /// - /// Makes the current control content read-only (but still allows appending more content at the end). - /// - protected void MakeReadOnly() - { - if (this.Document.TextLength == 0) - return; - this.ActiveTextAreaControl.Caret.Position = this.Document.OffsetToPosition(this.Document.TextLength); - if (readOnlyMarker == null) { - readOnlyMarker = new TextMarker(0, this.Document.TextLength, TextMarkerType.Invisible) { IsReadOnly = true }; - this.Document.MarkerStrategy.AddMarker(readOnlyMarker); - } - readOnlyMarker.Offset = 0; - readOnlyMarker.Length = this.Document.TextLength; - this.Document.UndoStack.ClearAll(); // prevent user from undoing the prompt insertion - } - - protected override void InitializeTextAreaControl(TextAreaControl newControl) - { - newControl.TextArea.DoProcessDialogKey += HandleDialogKey; - } - - /// - /// Gets the current command (text from end of prompt to end of document) - /// - protected string GetCommand() - { - return this.Document.GetText(promptEndOffset, this.Document.TextLength - promptEndOffset); - } - - /// - /// Sets the current command - /// - protected void SetCommand(string cmd) - { - this.Document.Replace(promptEndOffset, this.Document.TextLength - promptEndOffset, cmd); - this.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, this.Document.GetLineNumberForOffset(promptEndOffset))); - this.Document.CommitUpdate(); - this.ActiveTextAreaControl.Caret.Position = this.Document.OffsetToPosition(this.Document.TextLength); - } - - bool HandleDialogKey(Keys keys) - { - switch (keys) { - case Keys.Enter: - history.Add(GetCommand()); - historyPointer = history.Count; - AcceptCommand(GetCommand()); - return true; - case Keys.Up: - historyPointer = Math.Max(historyPointer - 1, 0); - SetCommand(history[historyPointer]); - return true; - case Keys.Down: - historyPointer = Math.Min(historyPointer + 1, history.Count); - if (historyPointer == history.Count) - SetCommand(string.Empty); - else - SetCommand(history[historyPointer]); - return true; - } - return false; - } - - /// - /// Causes evaluation of a command when the user presses Enter. - /// - /// The command to evaluate. - protected abstract void AcceptCommand(string command); - - /// - /// Appends text at the end of the document. - /// - protected void Append(string text) - { - this.Document.Insert(this.Document.TextLength, text); - } - - protected void InsertLineBeforePrompt(string text) - { - text += Environment.NewLine; - this.Document.Insert(promptStartOffset, text); - promptStartOffset += text.Length; - promptEndOffset += text.Length; - if (readOnlyMarker != null) { - readOnlyMarker.Offset = 0; - readOnlyMarker.Length = promptEndOffset; - } - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/AbstractCompletionDataProvider.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/AbstractCompletionDataProvider.cs index faae7a11b2..484ede2481 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/AbstractCompletionDataProvider.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/AbstractCompletionDataProvider.cs @@ -17,6 +17,7 @@ using ICSharpCode.TextEditor.Gui.CompletionWindow; namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor { + [Obsolete] public abstract class AbstractCompletionDataProvider : ICompletionDataProvider { public virtual ImageList ImageList { @@ -96,131 +97,4 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor /// public abstract ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped); } - - public abstract class AbstractCodeCompletionDataProvider : AbstractCompletionDataProvider - { - Hashtable insertedElements = new Hashtable(); - Hashtable insertedPropertiesElements = new Hashtable(); - Hashtable insertedEventElements = new Hashtable(); - - protected int caretLineNumber; - protected int caretColumn; - protected string fileName; - - protected List completionData = null; - protected ExpressionContext overrideContext; - - /// - /// Generates the completion data. This method is called by the text editor control. - /// - public override ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped) - { - completionData = new List(); - this.fileName = fileName; - IDocument document = textArea.Document; - - // the parser works with 1 based coordinates - caretLineNumber = document.GetLineNumberForOffset(textArea.Caret.Offset) + 1; - caretColumn = textArea.Caret.Offset - document.GetLineSegment(caretLineNumber - 1).Offset + 1; - - GenerateCompletionData(textArea, charTyped); - - return completionData.ToArray(); - } - - protected virtual ExpressionResult GetExpression(TextArea textArea) - { - IDocument document = textArea.Document; - IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(fileName); - if (expressionFinder == null) { - return new ExpressionResult(TextUtilities.GetExpressionBeforeOffset(textArea, textArea.Caret.Offset)); - } else { - ExpressionResult res = expressionFinder.FindExpression(document.GetText(0, textArea.Caret.Offset), textArea.Caret.Offset); - if (overrideContext != null) - res.Context = overrideContext; - return res; - } - } - - protected abstract void GenerateCompletionData(TextArea textArea, char charTyped); - - protected void AddResolveResults(ICollection list, ExpressionContext context) - { - if (list == null) { - return; - } - completionData.Capacity += list.Count; - CodeCompletionData suggestedData = null; - foreach (ICompletionEntry o in list) { - if (context != null && !context.ShowEntry(o)) - continue; - CodeCompletionData ccd = CreateItem(o, context); - if (object.Equals(o, context.SuggestedItem)) - suggestedData = ccd; - if (ccd != null) - completionData.Add(ccd); - } - if (context.SuggestedItem != null) { - if (suggestedData == null) { - suggestedData = CreateItem(context.SuggestedItem, context); - if (suggestedData != null) { - completionData.Add(suggestedData); - } - } - if (suggestedData != null) { - completionData.Sort(DefaultCompletionData.Compare); - this.DefaultIndex = completionData.IndexOf(suggestedData); - } - } - } - - CodeCompletionData CreateItem(object o, ExpressionContext context) - { - if (o is string) { - return new CodeCompletionData(o.ToString(), ClassBrowserIconService.Namespace.ImageIndex); - } else if (o is IClass) { - return new CodeCompletionData((IClass)o); - } else if (o is IProperty) { - IProperty property = (IProperty)o; - if (property.Name != null && insertedPropertiesElements[property.Name] == null) { - insertedPropertiesElements[property.Name] = property; - return new CodeCompletionData(property); - } - } else if (o is IMethod) { - IMethod method = (IMethod)o; - if (method.Name != null) { - CodeCompletionData ccd = new CodeCompletionData(method); - if (insertedElements[method.Name] == null) { - insertedElements[method.Name] = ccd; - return ccd; - } else { - CodeCompletionData oldMethod = (CodeCompletionData)insertedElements[method.Name]; - ++oldMethod.Overloads; - } - } - } else if (o is IField) { - return new CodeCompletionData((IField)o); - } else if (o is IEvent) { - IEvent e = (IEvent)o; - if (e.Name != null && insertedEventElements[e.Name] == null) { - insertedEventElements[e.Name] = e; - return new CodeCompletionData(e); - } - } else { - throw new ApplicationException("Unknown object: " + o); - } - return null; - } - - protected void AddResolveResults(ResolveResult results, ExpressionContext context) - { - insertedElements.Clear(); - insertedPropertiesElements.Clear(); - insertedEventElements.Clear(); - - if (results != null) { - AddResolveResults(results.GetCompletionData(ParserService.CurrentProjectContent), context); - } - } - } } diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CachedCompletionDataProvider.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CachedCompletionDataProvider.cs deleted file mode 100644 index 96b3002430..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CachedCompletionDataProvider.cs +++ /dev/null @@ -1,71 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Windows.Forms; -using ICSharpCode.TextEditor; -using ICSharpCode.TextEditor.Gui.CompletionWindow; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor -{ - public class CachedCompletionDataProvider : AbstractCompletionDataProvider - { - ICompletionDataProvider baseProvider; - - public CachedCompletionDataProvider(ICompletionDataProvider baseProvider) - { - this.baseProvider = baseProvider; - } - - ICompletionData[] completionData; - - public ICompletionData[] CompletionData { - get { - return completionData; - } - set { - completionData = value; - } - } - - public override ImageList ImageList { - get { - return baseProvider.ImageList; - } - } - - public override CompletionDataProviderKeyResult ProcessKey(char key) - { - return baseProvider.ProcessKey(key); - } - - public override bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key) - { - return baseProvider.InsertAction(data, textArea, insertionOffset, key); - } - - public override ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped) - { - if (completionData == null) { - completionData = baseProvider.GenerateCompletionData(fileName, textArea, charTyped) ?? new ICompletionData[0]; - preSelection = baseProvider.PreSelection; - this.DefaultIndex = baseProvider.DefaultIndex; - } - return completionData; - } - - [Obsolete("Cannot use InsertSpace on CachedCompletionDataProvider, please set it on the underlying provider!")] - public new bool InsertSpace { - get { - return false; - } - set { - throw new NotSupportedException(); - } - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionData.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionData.cs index db0acee142..59445797e2 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionData.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionData.cs @@ -19,6 +19,7 @@ using ICSharpCode.TextEditor.Gui.CompletionWindow; namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor { + [Obsolete] public class CodeCompletionData : ICompletionData { IEntity entity; @@ -202,99 +203,13 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor return false; } - static readonly Regex whitespace = new Regex(@"\s+"); /// /// Converts the xml documentation string into a plain text string. /// public static string ConvertDocumentation(string doc) { - if (string.IsNullOrEmpty(doc)) - return string.Empty; - - System.IO.StringReader reader = new System.IO.StringReader("" + doc + ""); - XmlTextReader xml = new XmlTextReader(reader); - StringBuilder ret = new StringBuilder(); - ////Regex whitespace = new Regex(@"\s+"); - - try { - xml.Read(); - do { - if (xml.NodeType == XmlNodeType.Element) { - string elname = xml.Name.ToLowerInvariant(); - switch (elname) { - case "filterpriority": - xml.Skip(); - break; - case "remarks": - ret.Append(Environment.NewLine); - ret.Append("Remarks:"); - ret.Append(Environment.NewLine); - break; - case "example": - ret.Append(Environment.NewLine); - ret.Append("Example:"); - ret.Append(Environment.NewLine); - break; - case "exception": - ret.Append(Environment.NewLine); - ret.Append(GetCref(xml["cref"])); - ret.Append(": "); - break; - case "returns": - ret.Append(Environment.NewLine); - ret.Append("Returns: "); - break; - case "see": - ret.Append(GetCref(xml["cref"])); - ret.Append(xml["langword"]); - break; - case "seealso": - ret.Append(Environment.NewLine); - ret.Append("See also: "); - ret.Append(GetCref(xml["cref"])); - break; - case "paramref": - ret.Append(xml["name"]); - break; - case "param": - ret.Append(Environment.NewLine); - ret.Append(whitespace.Replace(xml["name"].Trim()," ")); - ret.Append(": "); - break; - case "value": - ret.Append(Environment.NewLine); - ret.Append("Value: "); - ret.Append(Environment.NewLine); - break; - case "br": - case "para": - ret.Append(Environment.NewLine); - break; - } - } else if (xml.NodeType == XmlNodeType.Text) { - ret.Append(whitespace.Replace(xml.Value, " ")); - } - } while(xml.Read()); - } catch (Exception ex) { - LoggingService.Debug("Invalid XML documentation: " + ex.Message); - return doc; - } - return ret.ToString(); - } - - static string GetCref(string cref) - { - if (cref == null || cref.Trim().Length==0) { - return ""; - } - if (cref.Length < 2) { - return cref; - } - if (cref.Substring(1, 1) == ":") { - return cref.Substring(2, cref.Length - 2); - } - return cref; + return CodeCompletionItem.ConvertDocumentation(doc); } } } diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataProvider.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataProvider.cs deleted file mode 100644 index 3b76322fb7..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataProvider.cs +++ /dev/null @@ -1,80 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Diagnostics; -using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.TextEditor; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor -{ - /// - /// Data provider for code completion. - /// - public class CodeCompletionDataProvider : AbstractCodeCompletionDataProvider - { - /// - /// Initialize a CodeCompletionDataProvider that reads the expression from the text area. - /// - public CodeCompletionDataProvider() - { - } - - /// - /// Initalize a CodeCompletionDataProvider with a fixed expression. - /// - public CodeCompletionDataProvider(ExpressionResult expression) - { - this.fixedExpression = expression; - } - - ExpressionResult fixedExpression; - - protected override void GenerateCompletionData(TextArea textArea, char charTyped) - { - #if DEBUG - if (DebugMode) { - Debugger.Break(); - } - #endif - preSelection = null; - if (fixedExpression.Expression == null) - GenerateCompletionData(textArea, GetExpression(textArea)); - else - GenerateCompletionData(textArea, fixedExpression); - } - - #if DEBUG - internal bool DebugMode = false; - #endif - - protected void GenerateCompletionData(TextArea textArea, ExpressionResult expressionResult) - { - // allow empty string as expression (for VB 'With' statements) - if (expressionResult.Expression == null) { - return; - } - if (LoggingService.IsDebugEnabled) { - if (expressionResult.Context == ExpressionContext.Default) - LoggingService.DebugFormatted("GenerateCompletionData for >>{0}<<", expressionResult.Expression); - else - LoggingService.DebugFormatted("GenerateCompletionData for >>{0}<<, context={1}", expressionResult.Expression, expressionResult.Context); - } - string textContent = textArea.Document.TextContent; - ResolveResult rr = Resolve(expressionResult, caretLineNumber, caretColumn, fileName, textContent); - AddResolveResults(rr, expressionResult.Context); - } - - protected virtual ResolveResult Resolve(ExpressionResult expressionResult, - int caretLineNumber, int caretColumn, - string fileName, string fileContent) - { - return ParserService.Resolve(expressionResult, caretLineNumber, caretColumn, fileName, fileContent); - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ErrorDrawer.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ErrorDrawer.cs deleted file mode 100644 index 5d12485cef..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ErrorDrawer.cs +++ /dev/null @@ -1,195 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Drawing; -using ICSharpCode.Core; -using ICSharpCode.TextEditor; -using ICSharpCode.TextEditor.Document; -using ICSharpCode.SharpDevelop.Debugging; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor -{ - /// - /// reperesents a visual error, this class is needed by the errordrawer. - /// - public class VisualError : TextMarker - { - Task task; - - public Task Task { - get { - return task; - } - } - - public VisualError(int offset, int length, Task task) - : base(offset, length, TextMarkerType.WaveLine, (task.TaskType == TaskType.Error) ? Color.Red : Color.Orange) - { - this.task = task; - base.ToolTip = task.Description; - } - } - - /// - /// This class draws error underlines. - /// - public class ErrorDrawer : IDisposable - { - TextEditorControl textEditor; - - public ErrorDrawer(TextEditorControl textEditor) - { - this.textEditor = textEditor; - - TaskService.Added += new TaskEventHandler(OnAdded); - TaskService.Removed += new TaskEventHandler(OnRemoved); - TaskService.Cleared += new EventHandler(OnCleared); - TaskService.InUpdateChanged += OnInUpdateChanged; - DebuggerService.DebugStarted += OnDebugStarted; - DebuggerService.DebugStopped += OnDebugStopped; - } - - bool isDisposed; - bool requireTextEditorRefresh; - - void RefreshTextEditor() - { - if (TaskService.InUpdate) { - requireTextEditorRefresh = true; - } else { - textEditor.Refresh(); - } - } - - void OnInUpdateChanged(object sender, EventArgs e) - { - if (requireTextEditorRefresh) { - requireTextEditorRefresh = false; - textEditor.Refresh(); - } - } - - /// - /// Deregisters the event handlers so the error drawer (and associated TextEditorControl) - /// can be garbage collected. - /// - public void Dispose() - { - if (isDisposed) - return; - isDisposed = true; - TaskService.Added -= new TaskEventHandler(OnAdded); - TaskService.Removed -= new TaskEventHandler(OnRemoved); - TaskService.Cleared -= new EventHandler(OnCleared); - TaskService.InUpdateChanged -= OnInUpdateChanged; - DebuggerService.DebugStarted -= OnDebugStarted; - DebuggerService.DebugStopped -= OnDebugStopped; - ClearErrors(); - } - - void OnDebugStarted(object sender, EventArgs e) - { - ClearErrors(); - } - - void OnDebugStopped(object sender, EventArgs e) - { - foreach (Task task in TaskService.Tasks) { - AddTask(task, false); - } - textEditor.Refresh(); - } - - void OnAdded(object sender, TaskEventArgs e) - { - AddTask(e.Task, true); - } - - void OnRemoved(object sender, TaskEventArgs e) - { - Task t = e.Task; - foreach (TextMarker marker in textEditor.Document.MarkerStrategy.TextMarker) { - VisualError ve = marker as VisualError; - if (ve != null && ve.Task == t) { - textEditor.Document.MarkerStrategy.RemoveMarker(marker); - RefreshTextEditor(); - break; - } - } - } - - void OnCleared(object sender, EventArgs e) - { - if (ClearErrors()) { - RefreshTextEditor(); - } - } - - /// - /// Clears all TextMarkers representing errors. - /// - /// Returns true when there were markers deleted, false when there were no error markers. - bool ClearErrors() - { - bool removed = false; - textEditor.Document.MarkerStrategy.RemoveAll(delegate (TextMarker marker) { - if (marker is VisualError) { - removed = true; - return true; - } - return false;}); - return removed; - } - - bool CheckTask(Task task) - { - if (textEditor.FileName == null) - return false; - if (task.FileName == null || task.Column < 0) - return false; - if (task.TaskType != TaskType.Warning && task.TaskType != TaskType.Error) - return false; - return FileUtility.IsEqualFileName(task.FileName, textEditor.FileName); - } - - void AddTask(Task task, bool refresh) - { - if (!CheckTask(task)) return; - if (task.Line >= 0 && task.Line < textEditor.Document.TotalNumberOfLines) { - LineSegment line = textEditor.Document.GetLineSegment(task.Line); - int offset = line.Offset + task.Column - 1; - int length = 1; - if (line.Words != null) { - foreach (TextWord tw in line.Words) { - if (task.Column - 1 == tw.Offset) { - length = tw.Length; - break; - } - } - } - if (length == 1 && task.Column - 1 < line.Length) { - length = 2; // use minimum length - } - textEditor.Document.MarkerStrategy.AddMarker(new VisualError(offset, length, task)); - if (refresh) RefreshTextEditor(); - } - } - - /// - /// Clears all errors and adds them again. - /// - public void UpdateErrors() - { - ClearErrors(); - foreach (Task task in TaskService.Tasks) { - AddTask(task, false); - } - textEditor.Refresh(); - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/IndexerInsightDataProvider.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/IndexerInsightDataProvider.cs deleted file mode 100644 index b8d89e9f57..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/IndexerInsightDataProvider.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.TextEditor.Document; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor -{ - public class IndexerInsightDataProvider : MethodInsightDataProvider - { - /// - /// Creates a IndexerInsightDataProvider looking at the caret position. - /// - public IndexerInsightDataProvider() {} - - /// - /// Creates a IndexerInsightDataProvider looking at the specified position. - /// - public IndexerInsightDataProvider(int lookupOffset, bool setupOnlyOnce) : base(lookupOffset, setupOnlyOnce) {} - - protected override void SetupDataProvider(string fileName, IDocument document, ExpressionResult expressionResult, int caretLineNumber, int caretColumn) - { - ResolveResult result = ParserService.Resolve(expressionResult, caretLineNumber, caretColumn, fileName, document.TextContent); - if (result == null) - return; - IReturnType type = result.ResolvedType; - if (type == null) - return; - foreach (IProperty i in type.GetProperties()) { - if (i.IsIndexer) { - methods.Add(i); - } - } - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/MethodInsightDataProvider.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/MethodInsightDataProvider.cs deleted file mode 100644 index 96fa0f47c3..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/MethodInsightDataProvider.cs +++ /dev/null @@ -1,253 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; - -using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.TextEditor; -using ICSharpCode.TextEditor.Document; -using ICSharpCode.TextEditor.Gui.InsightWindow; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor -{ - public class MethodInsightDataProvider : IInsightDataProvider - { - string fileName = null; - IDocument document = null; - TextArea textArea = null; - protected List methods = new List(); - - public List Methods { - get { - return methods; - } - } - - public int InsightDataCount { - get { - return methods.Count; - } - } - - int defaultIndex = -1; - - public int DefaultIndex { - get { - return defaultIndex; - } - set { - defaultIndex = value; - } - } - - public string GetInsightData(int number) - { - IMember method = methods[number]; - IAmbience conv = AmbienceService.GetCurrentAmbience(); - conv.ConversionFlags = ConversionFlags.StandardConversionFlags| ConversionFlags.UseFullyQualifiedMemberNames; - string documentation = method.Documentation; - string text = conv.Convert(method); - return text + "\n" + CodeCompletionData.ConvertDocumentation(documentation); - } - - int lookupOffset; - bool setupOnlyOnce; - - /// - /// Creates a MethodInsightDataProvider looking at the caret position. - /// - public MethodInsightDataProvider() - { - this.lookupOffset = -1; - } - - /// - /// Creates a MethodInsightDataProvider looking at the specified position. - /// - public MethodInsightDataProvider(int lookupOffset, bool setupOnlyOnce) - { - this.lookupOffset = lookupOffset; - this.setupOnlyOnce = setupOnlyOnce; - } - - int initialOffset; - - public void SetupDataProvider(string fileName, TextArea textArea) - { - if (setupOnlyOnce && this.textArea != null) return; - IDocument document = textArea.Document; - this.fileName = fileName; - this.document = document; - this.textArea = textArea; - int useOffset = (lookupOffset < 0) ? textArea.Caret.Offset : lookupOffset; - initialOffset = useOffset; - - - IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(fileName); - ExpressionResult expressionResult; - if (expressionFinder == null) - expressionResult = new ExpressionResult(TextUtilities.GetExpressionBeforeOffset(textArea, useOffset)); - else - expressionResult = expressionFinder.FindExpression(textArea.Document.TextContent, useOffset); - - if (expressionResult.Expression == null) // expression is null when cursor is in string/comment - return; - expressionResult.Expression = expressionResult.Expression.Trim(); - - if (LoggingService.IsDebugEnabled) { - if (expressionResult.Context == ExpressionContext.Default) - LoggingService.DebugFormatted("ShowInsight for >>{0}<<", expressionResult.Expression); - else - LoggingService.DebugFormatted("ShowInsight for >>{0}<<, context={1}", expressionResult.Expression, expressionResult.Context); - } - - int caretLineNumber = document.GetLineNumberForOffset(useOffset); - int caretColumn = useOffset - document.GetLineSegment(caretLineNumber).Offset; - // the parser works with 1 based coordinates - SetupDataProvider(fileName, document, expressionResult, caretLineNumber + 1, caretColumn + 1); - } - - protected virtual void SetupDataProvider(string fileName, IDocument document, ExpressionResult expressionResult, int caretLineNumber, int caretColumn) - { - bool constructorInsight = false; - if (expressionResult.Context == ExpressionContext.Attribute) { - constructorInsight = true; - } else if (expressionResult.Context.IsObjectCreation) { - constructorInsight = true; - expressionResult.Context = ExpressionContext.Type; - } else if (expressionResult.Context == ExpressionContext.BaseConstructorCall) { - constructorInsight = true; - } - - ResolveResult results = ParserService.Resolve(expressionResult, caretLineNumber, caretColumn, fileName, document.TextContent); - if (results == null) - return; - LanguageProperties language = ParserService.CurrentProjectContent.Language; - TypeResolveResult trr = results as TypeResolveResult; - if (trr == null && language.AllowObjectConstructionOutsideContext) { - if (results is MixedResolveResult) - trr = (results as MixedResolveResult).TypeResult; - } - if (trr != null && !constructorInsight) { - if (language.AllowObjectConstructionOutsideContext) - constructorInsight = true; - } - if (constructorInsight) { - if (trr != null || expressionResult.Context == ExpressionContext.BaseConstructorCall) { - if (results.ResolvedType != null) { - methods.AddRange(GetConstructorMethods(results.ResolvedType.GetMethods())); - } - } - } else { - MethodGroupResolveResult result = results as MethodGroupResolveResult; - if (result == null) - return; - bool classIsInInheritanceTree = false; - if (result.CallingClass != null) - classIsInInheritanceTree = result.CallingClass.IsTypeInInheritanceTree(result.ContainingType.GetUnderlyingClass()); - - foreach (IMethod method in result.ContainingType.GetMethods()) { - if (language.NameComparer.Equals(method.Name, result.Name)) { - if (method.IsAccessible(result.CallingClass, classIsInInheritanceTree)) { - methods.Add(method); - } - } - } - if (methods.Count == 0 && result.CallingClass != null && language.SupportsExtensionMethods) { - List list = new List(); - ResolveResult.AddExtensions(language, list.Add, result.CallingClass, result.ContainingType); - foreach (IMethodOrProperty mp in list) { - if (language.NameComparer.Equals(mp.Name, result.Name) && mp is IMethod) { - DefaultMethod m = (DefaultMethod)mp.CreateSpecializedMember(); - // for the insight window, remove first parameter and mark the - // method as normal - this is required to show the list of - // parameters the method expects. - m.IsExtensionMethod = false; - m.Parameters.RemoveAt(0); - methods.Add(m); - } - } - } - } - } - - IEnumerable GetConstructorMethods(List methods) - { - return from method in methods - where method.IsConstructor && !method.IsStatic - select (IMethodOrProperty)method; - } - - public bool CaretOffsetChanged() - { - bool closeDataProvider = textArea.Caret.Offset <= initialOffset; - int brackets = 0; - int curlyBrackets = 0; - if (!closeDataProvider) { - bool insideChar = false; - bool insideString = false; - for (int offset = initialOffset; offset < Math.Min(textArea.Caret.Offset, document.TextLength); ++offset) { - char ch = document.GetCharAt(offset); - switch (ch) { - case '\'': - insideChar = !insideChar; - break; - case '(': - if (!(insideChar || insideString)) { - ++brackets; - } - break; - case ')': - if (!(insideChar || insideString)) { - --brackets; - } - if (brackets <= 0) { - return true; - } - break; - case '"': - insideString = !insideString; - break; - case '}': - if (!(insideChar || insideString)) { - --curlyBrackets; - } - if (curlyBrackets < 0) { - return true; - } - break; - case '{': - if (!(insideChar || insideString)) { - ++curlyBrackets; - } - break; - case ';': - if (!(insideChar || insideString)) { - return true; - } - break; - } - } - } - - return closeDataProvider; - } - - public bool CharTyped() - { -// int offset = document.Caret.Offset - 1; -// if (offset >= 0) { -// return document.GetCharAt(offset) == ')'; -// } - return false; - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ParserFoldingStrategy.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ParserFoldingStrategy.cs deleted file mode 100644 index 4cb723bd97..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ParserFoldingStrategy.cs +++ /dev/null @@ -1,114 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections.Generic; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.TextEditor.Document; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor -{ - public class ParserFoldingStrategy : IFoldingStrategy - { - /* - void AddClassMembers(IClass c, List foldMarkers, IDocument document) - { - if (c.ClassType == ClassType.Delegate) { - return; - } - DomRegion cRegion = c.BodyRegion; - if (cRegion.IsEmpty) cRegion = c.Region; - if (cRegion.BeginLine < cRegion.EndLine) { - FoldMarker newFoldMarker = new FoldMarker(document, cRegion.BeginLine - 1, cRegion.BeginColumn - 1, - cRegion.EndLine - 1, cRegion.EndColumn, c.ClassType == ClassType.Enum ? FoldType.MemberBody : FoldType.TypeBody); - if (newFoldMarker.Length > 0) { - foldMarkers.Add(newFoldMarker); - } - } - foreach (IClass innerClass in c.InnerClasses) { - AddClassMembers(innerClass, foldMarkers, document); - } - - foreach (IMethod m in c.Methods) { - if (m.Region.EndLine < m.BodyRegion.EndLine) { - foldMarkers.Add(new FoldMarker(document, m.Region.EndLine - 1, m.Region.EndColumn - 1, - m.BodyRegion.EndLine - 1, m.BodyRegion.EndColumn - 1, FoldType.MemberBody)); - } - } - - foreach (IProperty p in c.Properties) { - if (p.Region.EndLine < p.BodyRegion.EndLine) { - foldMarkers.Add(new FoldMarker(document, p.Region.EndLine - 1, p.Region.EndColumn - 1, - p.BodyRegion.EndLine- 1, p.BodyRegion.EndColumn - 1, FoldType.MemberBody)); - } - } - - foreach (IEvent evt in c.Events) { - if (evt.Region.EndLine < evt.BodyRegion.EndLine) { - if (!evt.BodyRegion.IsEmpty) { - foldMarkers.Add(new FoldMarker(document, evt.Region.EndLine - 1, evt.Region.EndColumn - 1, - evt.BodyRegion.EndLine- 1, evt.BodyRegion.EndColumn - 1, FoldType.MemberBody)); - } - } - } - } - - /// - /// Calculates the fold level of a specific line. - /// - public List GenerateFoldMarkers(IDocument document, string fileName, object parseInfo) - { - ParseInformation parseInformation = parseInfo as ParseInformation; - if (parseInformation == null || parseInformation.MostRecentCompilationUnit == null) { - return null; - } - List foldMarkers = GetFoldMarkers(document, parseInformation.MostRecentCompilationUnit); - if (parseInformation.BestCompilationUnit != parseInformation.MostRecentCompilationUnit) { - List oldFoldMarkers = GetFoldMarkers(document, parseInformation.BestCompilationUnit); - int lastLine = (foldMarkers.Count == 0) ? 0 : foldMarkers[foldMarkers.Count - 1].EndLine; - int totalNumberOfLines = document.TotalNumberOfLines; - foreach (FoldMarker marker in oldFoldMarkers) { - if (marker.StartLine > lastLine && marker.EndLine < totalNumberOfLines) - foldMarkers.Add(marker); - } - } - return foldMarkers; - } - - List GetFoldMarkers(IDocument document, ICompilationUnit cu) - { - List foldMarkers = new List(); - - bool firstTime = document.FoldingManager.FoldMarker.Count == 0; - foreach (FoldingRegion foldingRegion in cu.FoldingRegions) { - foldMarkers.Add(new FoldMarker(document, foldingRegion.Region.BeginLine - 1, foldingRegion.Region.BeginColumn - 1, - foldingRegion.Region.EndLine - 1, foldingRegion.Region.EndColumn - 1, FoldType.Region, foldingRegion.Name, firstTime)); - - } - foreach (IClass c in cu.Classes) { - AddClassMembers(c, foldMarkers, document); - } - - if (cu.DokuComments != null) { - foreach (IComment c in cu.DokuComments) { - foldMarkers.Add(new FoldMarker(document, c.Region.BeginLine - 1, c.Region.BeginColumn - 1, - c.Region.EndLine - 1, c.Region.EndColumn - 1)); - } - } - return foldMarkers; - } - */ - - /// - /// Calculates the fold level of a specific line. - /// - public List GenerateFoldMarkers(IDocument document, string fileName, object parseInfo) - { - return null; - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs deleted file mode 100644 index d3910bc98d..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs +++ /dev/null @@ -1,420 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using ICSharpCode.SharpDevelop.Editor.CodeCompletion; -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using ICSharpCode.Core; -using ICSharpCode.Core.WinForms; -using ICSharpCode.SharpDevelop.DefaultEditor.Actions; -using ICSharpCode.SharpDevelop.Editor; -using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.SharpDevelop.Internal.Templates; -using ICSharpCode.TextEditor; -using ICSharpCode.TextEditor.Actions; -using ICSharpCode.TextEditor.Document; -using ICSharpCode.TextEditor.Gui.CompletionWindow; -using ICSharpCode.TextEditor.Gui.InsightWindow; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor -{ - public class SharpDevelopTextAreaControl : TextEditorControl - { - protected string contextMenuPath = "/SharpDevelop/ViewContent/DefaultTextEditor/ContextMenu"; - const string editActionsPath = "/AddIns/DefaultTextEditor/EditActions"; - const string formatingStrategyPath = "/AddIns/DefaultTextEditor/Formatter"; - const string advancedHighlighterPath = "/AddIns/DefaultTextEditor/AdvancedHighlighter"; - - readonly TextEditorAdapter adapter; - - public TextEditorAdapter Adapter { - get { return adapter; } - } - - ErrorDrawer errorDrawer; - IAdvancedHighlighter advancedHighlighter; - - public SharpDevelopTextAreaControl() - : this(true, true) - { - GenerateEditActions(); - - TextEditorProperties = SharpDevelopTextEditorProperties.Instance; - } - - protected SharpDevelopTextAreaControl(bool enableFolding, bool sdBookmarks) - { - adapter = new TextEditorAdapter(this); - - Document.FoldingManager.FoldingStrategy = new ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.ParserFoldingStrategy(); -// Document.BookmarkManager.Factory = new Bookmarks.SDBookmarkFactory(Document.BookmarkManager); -// Document.BookmarkManager.Added += new BookmarkEventHandler(BookmarkAdded); -// Document.BookmarkManager.Removed += new BookmarkEventHandler(BookmarkRemoved); -// Document.LineCountChanged += BookmarkLineCountChanged; - } - - /* - void BookmarkAdded(object sender, BookmarkEventArgs e) - { - Bookmarks.SDBookmark b = e.Bookmark as Bookmarks.SDBookmark; - if (b != null) { - Bookmarks.BookmarkManager.AddMark(b); - } - } - - void BookmarkRemoved(object sender, BookmarkEventArgs e) - { - Bookmarks.SDBookmark b = e.Bookmark as Bookmarks.SDBookmark; - if (b != null) { - Bookmarks.BookmarkManager.RemoveMark(b); - } - } - - void BookmarkLineCountChanged(object sender, LineCountChangeEventArgs e) - { - foreach (Bookmark b in Document.BookmarkManager.Marks) { - if (b.LineNumber >= e.LineStart) { - Bookmarks.SDBookmark sdb = b as Bookmarks.SDBookmark; - if (sdb != null) { - sdb.RaiseLineNumberChanged(); - } - } - } - }*/ - - protected override void InitializeTextAreaControl(TextAreaControl newControl) - { - base.InitializeTextAreaControl(newControl); - - newControl.ShowContextMenu += delegate(object sender, MouseEventArgs e) { - if (contextMenuPath != null) { - MenuService.ShowContextMenu(this, contextMenuPath, (Control)sender, e.X, e.Y); - } - }; - newControl.TextArea.KeyEventHandler += new ICSharpCode.TextEditor.KeyEventHandler(HandleKeyPress); - newControl.TextArea.ClipboardHandler.CopyText += new CopyTextEventHandler(ClipboardHandlerCopyText); - -// newControl.TextArea.IconBarMargin.Painted += new MarginPaintEventHandler(PaintIconBarBreakPoints); -// newControl.TextArea.IconBarMargin.MouseDown += new MarginMouseEventHandler(IconBarMouseDown); - - newControl.MouseWheel += new MouseEventHandler(TextAreaMouseWheel); - newControl.DoHandleMousewheel = false; - } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - if (disposing) { - if (errorDrawer != null) { - errorDrawer.Dispose(); - errorDrawer = null; - } - if (advancedHighlighter != null) { - advancedHighlighter.Dispose(); - advancedHighlighter = null; - } - CloseCodeCompletionWindow(this, EventArgs.Empty); - CloseInsightWindow(this, EventArgs.Empty); - } - } - - void CloseCodeCompletionWindow(object sender, EventArgs e) - { - if (codeCompletionWindow != null) { - codeCompletionWindow.Closed -= new EventHandler(CloseCodeCompletionWindow); - codeCompletionWindow.Dispose(); - codeCompletionWindow = null; - } - } - - void CloseInsightWindow(object sender, EventArgs e) - { - if (insightWindow != null) { - insightWindow.Closed -= new EventHandler(CloseInsightWindow); - insightWindow.Dispose(); - insightWindow = null; - } - } - - void TextAreaMouseWheel(object sender, MouseEventArgs e) - { - TextAreaControl textAreaControl = (TextAreaControl)sender; - if (insightWindow != null && !insightWindow.IsDisposed && insightWindow.Visible) { - insightWindow.HandleMouseWheel(e); - } else if (codeCompletionWindow != null && !codeCompletionWindow.IsDisposed && codeCompletionWindow.Visible) { - codeCompletionWindow.HandleMouseWheel(e); - } else { - textAreaControl.HandleMouseWheel(e); - } - } - - void ClipboardHandlerCopyText(object sender, CopyTextEventArgs e) - { - TextEditorSideBar.Instance.PutInClipboardRing(e.Text); - } - - public override void OptionsChanged() - { - base.OptionsChanged(); - SharpDevelopTextEditorProperties sdtep = base.TextEditorProperties as SharpDevelopTextEditorProperties; - - if (sdtep != null) { - if (sdtep.UnderlineErrors) { - if (errorDrawer == null) { - errorDrawer = new ErrorDrawer(this); - } - } else { - if (errorDrawer != null) { - errorDrawer.Dispose(); - errorDrawer = null; - } - } - } - } - - internal void FileLoaded() - { - if (errorDrawer != null) { - errorDrawer.UpdateErrors(); - } - } - - #if DEBUG - internal const Keys DebugBreakModifiers = Keys.Control | Keys.Shift | Keys.Alt; - #endif - - void GenerateEditActions() - { - try { - IEditAction[] actions = (IEditAction[])(AddInTree.GetTreeNode(editActionsPath).BuildChildItems(this)).ToArray(typeof(IEditAction)); - - foreach (IEditAction action in actions) { - foreach (Keys key in action.Keys) { - editactions[key] = action; - } - } - } catch (TreePathNotFoundException) { - LoggingService.Warn("EditAction " + editActionsPath + " doesn't exists in the AddInTree"); - } - } - - public void ActivateQuickClassBrowserOnDemand() - { - - } - - protected override void OnFileNameChanged(EventArgs e) - { - base.OnFileNameChanged(e); - ActivateQuickClassBrowserOnDemand(); - } - - static ICodeCompletionBinding[] codeCompletionBindings; - - public static ICodeCompletionBinding[] CodeCompletionBindings { - get { - if (codeCompletionBindings == null) { - try { - codeCompletionBindings = (ICodeCompletionBinding[])(AddInTree.GetTreeNode("/AddIns/DefaultTextEditor/CodeCompletion").BuildChildItems(null)).ToArray(typeof(ICodeCompletionBinding)); - } catch (TreePathNotFoundException) { - codeCompletionBindings = new ICodeCompletionBinding[] {}; - } - } - return codeCompletionBindings; - } - } - - InsightWindow insightWindow = null; - CodeCompletionWindow codeCompletionWindow = null; - bool inHandleKeyPress; - - bool HandleKeyPress(char ch) - { - if (inHandleKeyPress) - return false; - inHandleKeyPress = true; - try { - if (codeCompletionWindow != null && !codeCompletionWindow.IsDisposed) { - if (codeCompletionWindow.ProcessKeyEvent(ch)) { - return true; - } - if (codeCompletionWindow != null && !codeCompletionWindow.IsDisposed) { - // code-completion window is still opened but did not want to handle - // the keypress -> don't try to restart code-completion - return false; - } - } - - if (CodeCompletionOptions.EnableCodeCompletion) { - foreach (ICodeCompletionBinding ccBinding in CodeCompletionBindings) { - CodeCompletionKeyPressResult result = ccBinding.HandleKeyPress(adapter, ch); - if (result == CodeCompletionKeyPressResult.Completed) - return false; - else if (result == CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion) - return false; - else if (result == CodeCompletionKeyPressResult.EatKey) - return true; - } - if (ch == '\n') - StartDelayedReparse(); - } - } catch (Exception ex) { - LogException(ex); - } finally { - inHandleKeyPress = false; - } - return false; - } - - bool startedDelayedReparse; - - void StartDelayedReparse() - { - if (startedDelayedReparse) - return; - startedDelayedReparse = true; - WorkbenchSingleton.SafeThreadAsyncCall( - delegate { - startedDelayedReparse = false; - if (!this.IsDisposed) { - ParserService.BeginParse(this.FileName, this.adapter.Document); - } - }); - } - - public void StartCtrlSpaceCompletion() - { - foreach (ICodeCompletionBinding ccBinding in CodeCompletionBindings) { - if (ccBinding.CtrlSpace(adapter)) - return; - } - } - - internal bool ExpandTemplateOnTab() - { - string word = GetWordBeforeCaret(); - if (word != null) { - /*CodeTemplateGroup templateGroup = CodeTemplateLoader.GetTemplateGroupPerFilename(FileName); - if (templateGroup != null) { - foreach (CodeTemplate template in templateGroup.Templates) { - if (template.Shortcut == word) { - if (word.Length > 0) { - int newCaretOffset = DeleteWordBeforeCaret(); - //// set new position in text area - ActiveTextAreaControl.TextArea.Caret.Position = Document.OffsetToPosition(newCaretOffset); - } - - InsertTemplate(template); - return true; - } - } - }*/ - } - return false; - } - - public void ShowInsightWindow(IInsightDataProvider insightDataProvider) - { - if (insightWindow == null || insightWindow.IsDisposed) { - insightWindow = new InsightWindow(WorkbenchSingleton.MainWin32Window, this); - insightWindow.Closed += new EventHandler(CloseInsightWindow); - } - insightWindow.AddInsightDataProvider(insightDataProvider, this.FileName); - insightWindow.ShowInsightWindow(); - } - - public bool InsightWindowVisible { - get { - return insightWindow != null; - } - } - - public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char ch) - { - codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(WorkbenchSingleton.MainWin32Window, this, this.FileName, completionDataProvider, ch); - if (codeCompletionWindow != null) { - codeCompletionWindow.Closed += new EventHandler(CloseCodeCompletionWindow); - } - } - - private void LogException(Exception ex) - { - ICSharpCode.Core.MessageService.ShowException(ex); - } - - public string GetWordBeforeCaret() - { - int start = TextUtilities.FindPrevWordStart(Document, ActiveTextAreaControl.TextArea.Caret.Offset); - return Document.GetText(start, ActiveTextAreaControl.TextArea.Caret.Offset - start); - } - - public int DeleteWordBeforeCaret() - { - int start = TextUtilities.FindPrevWordStart(Document, ActiveTextAreaControl.TextArea.Caret.Offset); - Document.Remove(start, ActiveTextAreaControl.TextArea.Caret.Offset - start); - return start; - } - - protected override void OnReloadHighlighting(object sender, EventArgs e) - { - base.OnReloadHighlighting(sender, e); - InitializeAdvancedHighlighter(); - } - - public bool HighlightingExplicitlySet { get; set; } - - /// - /// Explicitly set the highlighting to use. Will be persisted. - /// - public override void SetHighlighting(string name) - { - base.SetHighlighting(name); - this.HighlightingExplicitlySet = true; - InitializeAdvancedHighlighter(); - } - - public void InitializeAdvancedHighlighter() - { - if (advancedHighlighter != null) { - advancedHighlighter.Dispose(); - advancedHighlighter = null; - } - string highlighterPath = advancedHighlighterPath + "/" + Document.HighlightingStrategy.Name; - if (AddInTree.ExistsTreeNode(highlighterPath)) { - IList highlighter = AddInTree.BuildItems(highlighterPath, this); - if (highlighter != null && highlighter.Count > 0) { - advancedHighlighter = highlighter[0]; - advancedHighlighter.Initialize(this); - Document.HighlightingStrategy = new AdvancedHighlightingStrategy((DefaultHighlightingStrategy)Document.HighlightingStrategy, advancedHighlighter); - } - } - } - - public void InitializeFormatter() - { - string formatterPath = formatingStrategyPath + "/" + Document.HighlightingStrategy.Name; - var formatter = AddInTree.BuildItems(formatterPath, this, false); - if (formatter != null && formatter.Count > 0) { - //Document.FormattingStrategy = formatter[0]; - } - } - - public override string GetRangeDescription(int selectedItem, int itemCount) - { - return StringParser.Parse("${res:ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.InsightWindow.NumberOfText}", - new StringTagPair("CurrentMethodNumber", selectedItem.ToString("##")), - new StringTagPair("NumberOfTotalMethods", itemCount.ToString("##"))); - } - -// public override IDeclarationViewWindow CreateDeclarationViewWindow() -// { -// return new HtmlDeclarationViewWindow(); -// } - // - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs deleted file mode 100644 index 963de48f1b..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs +++ /dev/null @@ -1,547 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Diagnostics; -using System.Drawing.Printing; -using System.IO; -using System.Windows.Forms; -using ICSharpCode.Core; -using ICSharpCode.Core.Presentation; -using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.SharpDevelop.Refactoring; -using ICSharpCode.TextEditor; -using ICSharpCode.TextEditor.Document; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor -{ - public class TextEditorDisplayBinding : IDisplayBinding - { - static TextEditorDisplayBinding() - { - // ConfigDirectory is null during unit tests - if (PropertyService.ConfigDirectory != null) { - // load #D-specific syntax highlighting files here - string modeDir = Path.Combine(PropertyService.ConfigDirectory, "modes"); - if (!Directory.Exists(modeDir)) { - Directory.CreateDirectory(modeDir); - } - - HighlightingManager.Manager.AddSyntaxModeFileProvider(new ICSharpCode.SharpDevelop.DefaultEditor.Codons.AddInTreeSyntaxModeProvider()); - HighlightingManager.Manager.AddSyntaxModeFileProvider(new FileSyntaxModeProvider(Path.Combine(PropertyService.DataDirectory, "modes"))); - HighlightingManager.Manager.AddSyntaxModeFileProvider(new FileSyntaxModeProvider(modeDir)); - } - ClipboardHandling.Initialize(); - } - - /// - /// Force static constructor to be called. Otherwise other editor's such as the XML editor do not - /// use custom syntax highlighting. - /// - public static void InitializeSyntaxModes() - { - } - - public virtual bool CanCreateContentForFile(string fileName) - { - return true; - } - - protected virtual TextEditorDisplayBindingWrapper CreateWrapper(OpenedFile file) - { - return new TextEditorDisplayBindingWrapper(file); - } - - public virtual IViewContent CreateContentForFile(OpenedFile file) - { - TextEditorDisplayBindingWrapper b2 = CreateWrapper(file); - file.ForceInitializeView(b2); // load file to initialize folding etc. - - b2.textEditorControl.Dock = DockStyle.Fill; - try { - b2.textEditorControl.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategyForFile(file.FileName); - b2.textEditorControl.InitializeAdvancedHighlighter(); - } catch (HighlightingDefinitionInvalidException ex) { - b2.textEditorControl.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(); - MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - b2.textEditorControl.InitializeFormatter(); - b2.textEditorControl.ActivateQuickClassBrowserOnDemand(); - - return b2; - } - } - - public class TextEditorDisplayBindingWrapper : AbstractViewContent, IMementoCapable, IPrintable, IEditable, IUndoHandler, IPositionable, ITextEditorControlProvider, IParseInformationListener, IClipboardHandler, IContextHelpProvider, IToolsHost - { - internal readonly SharpDevelopTextAreaControl textEditorControl; - - public TextEditorControl TextEditorControl { - get { - return textEditorControl; - } - } - - public ICSharpCode.SharpDevelop.Editor.ITextEditor TextEditor { - get { return textEditorControl.Adapter; } - } - - public ICSharpCode.SharpDevelop.Editor.IDocument GetDocumentForFile(OpenedFile file) - { - if (file == this.PrimaryFile) { - return this.TextEditor.Document; - } else { - return null; - } - } - - public bool EnableUndo { - get { - return textEditorControl.EnableUndo; - } - } - public bool EnableRedo { - get { - return textEditorControl.EnableRedo; - } - } - - // ParserUpdateThread uses the text property via IEditable, I had an exception - // because multiple threads were accessing the GapBufferStrategy at the same time. - - string GetText() - { - return textEditorControl.Document.TextContent; - } - - void SetText(string value) - { - textEditorControl.Document.Replace(0, textEditorControl.Document.TextLength, value); - } - - /// - /// Creates a snapshot of the editor content. - /// This method is thread-safe. - /// - public ITextBuffer CreateSnapshot() - { - string content = WorkbenchSingleton.SafeThreadFunction(GetText); - return new StringTextBuffer(content); - } - - string IEditable.Text { - get { - if (WorkbenchSingleton.InvokeRequired) - return WorkbenchSingleton.SafeThreadFunction(GetText); - else - return GetText(); - } - } - - public PrintDocument PrintDocument { - get { - return textEditorControl.PrintDocument; - } - } - - public override object Control { - get { - return textEditorControl; - } - } - - public void Undo() - { - this.textEditorControl.Undo(); - } - - public void Redo() - { - this.textEditorControl.Redo(); - } - - protected virtual SharpDevelopTextAreaControl CreateSharpDevelopTextAreaControl() - { - return new SharpDevelopTextAreaControl(); - } - - public TextEditorDisplayBindingWrapper(OpenedFile file) : base(file) - { - this.TabPageText = "${res:FormsDesigner.DesignTabPages.SourceTabPage}"; - - textEditorControl = CreateSharpDevelopTextAreaControl(); - textEditorControl.RightToLeft = RightToLeft.No; - textEditorControl.Document.DocumentChanged += new DocumentEventHandler(TextAreaChangedEvent); - textEditorControl.ActiveTextAreaControl.Caret.CaretModeChanged += new EventHandler(CaretModeChanged); - textEditorControl.ActiveTextAreaControl.Enter += new EventHandler(CaretUpdate); - textEditorControl.ActiveTextAreaControl.Caret.PositionChanged += CaretUpdate; - - textEditorControl.FileName = file.FileName; - } - - public void ShowHelp() - { - // Resolve expression at cursor and show help - TextArea textArea = textEditorControl.ActiveTextAreaControl.TextArea; - IDocument doc = textArea.Document; - IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(textArea.MotherTextEditorControl.FileName); - if (expressionFinder == null) - return; - LineSegment seg = doc.GetLineSegment(textArea.Caret.Line); - string textContent = doc.TextContent; - ExpressionResult expressionResult = expressionFinder.FindFullExpression(textContent, seg.Offset + textArea.Caret.Column); - string expression = expressionResult.Expression; - if (expression != null && expression.Length > 0) { - ResolveResult result = ParserService.Resolve(expressionResult, textArea.Caret.Line + 1, textArea.Caret.Column + 1, textEditorControl.FileName, textContent); - TypeResolveResult trr = result as TypeResolveResult; - if (trr != null) { - HelpProvider.ShowHelp(trr.ResolvedClass); - } - MemberResolveResult mrr = result as MemberResolveResult; - if (mrr != null) { - HelpProvider.ShowHelp(mrr.ResolvedMember); - } - } - } - - void TextAreaChangedEvent(object sender, DocumentEventArgs e) - { - this.PrimaryFile.MakeDirty(); - NavigationService.ContentChanging(this.textEditorControl, e); - } - - public override void Dispose() - { - if (this.PrimaryFile.IsUntitled) { - ParserService.ClearParseInformation(this.PrimaryFile.FileName); - } - textEditorControl.Dispose(); - base.Dispose(); - } - - public override bool IsReadOnly { - get { - return textEditorControl.IsReadOnly; - } - } - - public override void Save(OpenedFile file, Stream stream) - { - if (file != PrimaryFile) - throw new ArgumentException("file != PrimaryFile"); - - if (!textEditorControl.CanSaveWithCurrentEncoding()) { - if (MessageService.AskQuestion("The file cannot be saved with the current encoding " + - textEditorControl.Encoding.EncodingName + " without losing data." + - "\nDo you want to save it using UTF-8 instead?")) { - textEditorControl.Encoding = System.Text.Encoding.UTF8; - } - } - - textEditorControl.SaveFile(stream); - } - - public override void Load(OpenedFile file, Stream stream) - { - if (file != PrimaryFile) - throw new ArgumentException("file != PrimaryFile"); - - if (!file.IsUntitled) { - textEditorControl.IsReadOnly = (File.GetAttributes(file.FileName) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly; - } - - bool autodetectEncoding = true; - textEditorControl.LoadFile(file.FileName, stream, true, autodetectEncoding); - textEditorControl.FileLoaded(); -// foreach (Bookmarks.SDBookmark mark in Bookmarks.BookmarkManager.GetBookmarks(file.FileName)) { -// mark.Document = textEditorControl.Document; -// textEditorControl.Document.BookmarkManager.AddMark(mark); -// } - ForceFoldingUpdate(); - } - - public Properties CreateMemento() - { - Properties properties = new Properties(); - properties.Set("CaretOffset", textEditorControl.ActiveTextAreaControl.Caret.Offset); - properties.Set("VisibleLine", textEditorControl.ActiveTextAreaControl.TextArea.TextView.FirstVisibleLine); - if (textEditorControl.HighlightingExplicitlySet) { - properties.Set("HighlightingLanguage", textEditorControl.Document.HighlightingStrategy.Name); - } - return properties; - } - - public void SetMemento(Properties properties) - { - textEditorControl.ActiveTextAreaControl.Caret.Position = textEditorControl.Document.OffsetToPosition(Math.Min(textEditorControl.Document.TextLength, Math.Max(0, properties.Get("CaretOffset", textEditorControl.ActiveTextAreaControl.Caret.Offset)))); -// textAreaControl.SetDesiredColumn(); - - string highlightingName = properties.Get("HighlightingLanguage", string.Empty); - if (!string.IsNullOrEmpty(highlightingName)) { - if (highlightingName == textEditorControl.Document.HighlightingStrategy.Name) { - textEditorControl.HighlightingExplicitlySet = true; - } else { - IHighlightingStrategy highlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(highlightingName); - if (highlightingStrategy != null) { - textEditorControl.HighlightingExplicitlySet = true; - textEditorControl.Document.HighlightingStrategy = highlightingStrategy; - } - } - } - textEditorControl.ActiveTextAreaControl.TextArea.TextView.FirstVisibleLine = properties.Get("VisibleLine", 0); - -// // insane check for cursor position, may be required for document reload. -// int lineNr = textAreaControl.Document.GetLineNumberForOffset(textAreaControl.Document.Caret.Offset); -// LineSegment lineSegment = textAreaControl.Document.GetLineSegment(lineNr); -// textAreaControl.Document.Caret.Offset = Math.Min(lineSegment.Offset + lineSegment.Length, textAreaControl.Document.Caret.Offset); -// -// textAreaControl.OptionsChanged(); -// textAreaControl.Refresh(); - } - - public override INavigationPoint BuildNavPoint() - { - int lineNumber = this.Line; - LineSegment lineSegment = textEditorControl.Document.GetLineSegment(lineNumber); - string txt = textEditorControl.Document.GetText(lineSegment); - return new TextNavigationPoint(this.PrimaryFileName, lineNumber, this.Column, txt); - } - - void CaretUpdate(object sender, EventArgs e) - { - CaretChanged(null, null); - CaretModeChanged(null, null); - } - - void CaretChanged(object sender, EventArgs e) - { - TextAreaControl activeTextAreaControl = textEditorControl.ActiveTextAreaControl; - int line = activeTextAreaControl.Caret.Line; - int col = activeTextAreaControl.Caret.Column; - StatusBarService.SetCaretPosition(activeTextAreaControl.TextArea.TextView.GetVisualColumn(line, col) + 1, line + 1, col + 1); - NavigationService.Log(this.BuildNavPoint()); - } - - void CaretModeChanged(object sender, EventArgs e) - { - StatusBarService.SetInsertMode(textEditorControl.ActiveTextAreaControl.Caret.CaretMode == CaretMode.InsertMode); - } - - protected override void OnFileNameChanged(OpenedFile file) - { - base.OnFileNameChanged(file); - Debug.Assert(file == this.Files[0]); - - string oldFileName = textEditorControl.FileName; - string newFileName = file.FileName; - - if (Path.GetExtension(oldFileName) != Path.GetExtension(newFileName)) { - if (textEditorControl.Document.HighlightingStrategy != null) { - textEditorControl.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategyForFile(newFileName); - textEditorControl.Refresh(); - } - } - - SetIcon(); - - ParserService.ClearParseInformation(oldFileName); - textEditorControl.FileName = newFileName; - ParserService.ParseViewContent(this); - } - - protected override void OnWorkbenchWindowChanged() - { - base.OnWorkbenchWindowChanged(); - SetIcon(); - } - - void SetIcon() - { - if (this.WorkbenchWindow != null) { - var icon = PresentationResourceService.GetBitmapSource(IconService.GetImageForFile(this.PrimaryFileName)); - if (icon != null) { - this.WorkbenchWindow.Icon = icon; - } - } - } - - #region IPositionable implementation - public void JumpTo(int line, int column) - { - textEditorControl.ActiveTextAreaControl.JumpTo(line, column); - - // we need to delay this call here because the text editor does not know its height if it was just created - WorkbenchSingleton.SafeThreadAsyncCall( - delegate { - textEditorControl.ActiveTextAreaControl.CenterViewOn( - line, (int)(0.3 * textEditorControl.ActiveTextAreaControl.TextArea.TextView.VisibleLineCount)); - }); - } - - public int Line { - get { - return textEditorControl.ActiveTextAreaControl.Caret.Line; - } - } - - public int Column { - get { - return textEditorControl.ActiveTextAreaControl.Caret.Column; - } - } - - #endregion - - public void ForceFoldingUpdate() - { - if (textEditorControl.TextEditorProperties.EnableFolding) { - string fileName = textEditorControl.FileName; - ParseInformation parseInfo = ParserService.GetParseInformation(fileName); - if (parseInfo == null) { - parseInfo = ParserService.ParseFile(fileName, - new StringTextBuffer(textEditorControl.Document.TextContent)); - } - textEditorControl.Document.FoldingManager.UpdateFoldings(fileName, parseInfo); - //UpdateClassMemberBookmarks(parseInfo); - } - } - - public void ParseInformationUpdated(ParseInformation parseInfo) - { - if (textEditorControl.TextEditorProperties.EnableFolding) { - WorkbenchSingleton.SafeThreadAsyncCall(ParseInformationUpdatedInvoked, parseInfo); - } - } - - void ParseInformationUpdatedInvoked(ParseInformation parseInfo) - { - try { - textEditorControl.Document.FoldingManager.UpdateFoldings(TitleName, parseInfo); - //UpdateClassMemberBookmarks(parseInfo); - textEditorControl.ActiveTextAreaControl.TextArea.Refresh(textEditorControl.ActiveTextAreaControl.TextArea.FoldMargin); - textEditorControl.ActiveTextAreaControl.TextArea.Refresh(textEditorControl.ActiveTextAreaControl.TextArea.IconBarMargin); - } catch (Exception ex) { - MessageService.ShowException(ex); - } - } - - /* - void UpdateClassMemberBookmarks(ParseInformation parseInfo) - { - BookmarkManager bm = textEditorControl.Document.BookmarkManager; - bm.RemoveMarks(new Predicate(IsClassMemberBookmark)); - if (parseInfo == null) return; - Debug.Assert(textEditorControl.Document.TotalNumberOfLines >= 1); - if (textEditorControl.Document.TotalNumberOfLines < 1) { - return; - } - foreach (IClass c in parseInfo.MostRecentCompilationUnit.Classes) { - AddClassMemberBookmarks(bm, c); - } - } - - void AddClassMemberBookmarks(BookmarkManager bm, IClass c) - { - if (c.IsSynthetic) return; - if (!c.Region.IsEmpty) { - bm.AddMark(new Bookmarks.ClassBookmark(c)); - } - foreach (IClass innerClass in c.InnerClasses) { - AddClassMemberBookmarks(bm, innerClass); - } - foreach (IMethod m in c.Methods) { - if (m.Region.IsEmpty || m.IsSynthetic) continue; - bm.AddMark(new Bookmarks.MethodBookmark(m)); - } - foreach (IProperty m in c.Properties) { - if (m.Region.IsEmpty || m.IsSynthetic) continue; - bm.AddMark(new Bookmarks.PropertyBookmark(m)); - } - foreach (IField f in c.Fields) { - if (f.Region.IsEmpty || f.IsSynthetic) continue; - bm.AddMark(new Bookmarks.FieldBookmark(f)); - } - foreach (IEvent e in c.Events) { - if (e.Region.IsEmpty || e.IsSynthetic) continue; - bm.AddMark(new Bookmarks.EventBookmark(e)); - } - } - - bool IsClassMemberBookmark(Bookmark b) - { - return b is Bookmarks.ClassMemberBookmark || b is Bookmarks.ClassBookmark; - } - */ - - #region ICSharpCode.SharpDevelop.Gui.IClipboardHandler interface implementation - public bool EnableCut { - get { - return !this.IsDisposed && textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableCut; - } - } - - public bool EnableCopy { - get { - return !this.IsDisposed && textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableCopy; - } - } - - public bool EnablePaste { - get { - return !this.IsDisposed && textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnablePaste; - } - } - - public bool EnableDelete { - get { - return !this.IsDisposed && textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableDelete; - } - } - - public bool EnableSelectAll { - get { - return !this.IsDisposed && textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableSelectAll; - } - } - - public void SelectAll() - { - textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.SelectAll(null, null); - } - - public void Delete() - { - textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.Delete(null, null); - } - - public void Paste() - { - textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.Paste(null, null); - } - - public void Copy() - { - textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.Copy(null, null); - } - - public void Cut() - { - textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.Cut(null, null); - } - #endregion - - object IToolsHost.ToolsContent { - get { return TextEditorSideBar.Instance; } - } - - public override string ToString() - { - return "[" + GetType().Name + " " + this.PrimaryFileName + "]"; - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/BehaviorTextEditorPanel.cs b/src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/BehaviorTextEditorPanel.cs deleted file mode 100644 index fdbbde59f0..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/BehaviorTextEditorPanel.cs +++ /dev/null @@ -1,93 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using ICSharpCode.SharpDevelop.Gui.OptionPanels; -using System; -using System.Windows.Forms; -using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; -using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.TextEditor; -using ICSharpCode.TextEditor.Document; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.OptionPanels -{ - /// - /// Summary description for Form8. - /// - public class BehaviorTextEditorPanel : XmlFormsOptionPanel - { - public override void LoadPanelContents() - { - SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.BehaviorTextEditorPanel.xfrm")); - - SharpDevelopTextEditorProperties properties = SharpDevelopTextEditorProperties.Instance; - - ((CheckBox)ControlDictionary["autoinsertCurlyBraceCheckBox"]).Checked = properties.AutoInsertCurlyBracket; - ((CheckBox)ControlDictionary["hideMouseCursorCheckBox"]).Checked = properties.HideMouseCursor; - ((CheckBox)ControlDictionary["caretBehindEOLCheckBox"]).Checked = properties.AllowCaretBeyondEOL; - ((CheckBox)ControlDictionary["auotInsertTemplatesCheckBox"]).Checked = properties.AutoInsertTemplates; - ((CheckBox)ControlDictionary["cutCopyWholeLine"]).Checked = properties.CutCopyWholeLine; - - ((CheckBox)ControlDictionary["convertTabsToSpacesCheckBox"]).Checked = properties.ConvertTabsToSpaces; - - ControlDictionary["tabSizeTextBox"].Text = properties.TabIndent.ToString(); - ControlDictionary["indentSizeTextBox"].Text = properties.IndentationSize.ToString(); - - ((ComboBox)ControlDictionary["indentStyleComboBox"]).Items.Add(StringParser.Parse("${res:Dialog.Options.IDEOptions.TextEditor.Behaviour.IndentStyle.None}")); - ((ComboBox)ControlDictionary["indentStyleComboBox"]).Items.Add(StringParser.Parse("${res:Dialog.Options.IDEOptions.TextEditor.Behaviour.IndentStyle.Automatic}")); - ((ComboBox)ControlDictionary["indentStyleComboBox"]).Items.Add(StringParser.Parse("${res:Dialog.Options.IDEOptions.TextEditor.Behaviour.IndentStyle.Smart}")); - - ((ComboBox)ControlDictionary["indentStyleComboBox"]).SelectedIndex = (int)properties.IndentStyle; - - ((ComboBox)ControlDictionary["mouseWhellDirectionComboBox"]).Items.Add(StringParser.Parse("${res:Dialog.Options.IDEOptions.TextEditor.Behaviour.NormalMouseDirectionRadioButton}")); - ((ComboBox)ControlDictionary["mouseWhellDirectionComboBox"]).Items.Add(StringParser.Parse("${res:Dialog.Options.IDEOptions.TextEditor.Behaviour.ReverseMouseDirectionRadioButton}")); - ((ComboBox)ControlDictionary["mouseWhellDirectionComboBox"]).SelectedIndex = properties.MouseWheelScrollDown ? 0 : 1; - } - - public override bool StorePanelContents() - { - SharpDevelopTextEditorProperties properties = SharpDevelopTextEditorProperties.Instance; - - properties.ConvertTabsToSpaces = ((CheckBox)ControlDictionary["convertTabsToSpacesCheckBox"]).Checked; - properties.MouseWheelScrollDown = ((ComboBox)ControlDictionary["mouseWhellDirectionComboBox"]).SelectedIndex == 0; - - properties.AutoInsertCurlyBracket = ((CheckBox)ControlDictionary["autoinsertCurlyBraceCheckBox"]).Checked; - properties.HideMouseCursor = ((CheckBox)ControlDictionary["hideMouseCursorCheckBox"]).Checked; - properties.AllowCaretBeyondEOL = ((CheckBox)ControlDictionary["caretBehindEOLCheckBox"]).Checked; - properties.AutoInsertTemplates = ((CheckBox)ControlDictionary["auotInsertTemplatesCheckBox"]).Checked; - properties.CutCopyWholeLine = ((CheckBox)ControlDictionary["cutCopyWholeLine"]).Checked; - - properties.IndentStyle = (IndentStyle)((ComboBox)ControlDictionary["indentStyleComboBox"]).SelectedIndex; - - try { - int tabSize = Int32.Parse(ControlDictionary["tabSizeTextBox"].Text); - - // FIX: don't allow to set tab size to zero as this will cause divide by zero exceptions in the text control. - // Zero isn't a setting that makes sense, anyway. - if (tabSize > 0) { - properties.TabIndent = tabSize; - } - } catch (Exception) { - } - - try { - properties.IndentationSize = Int32.Parse(ControlDictionary["indentSizeTextBox"].Text); - } catch (Exception) { - } - - IViewContent activeViewContent = WorkbenchSingleton.Workbench.ActiveViewContent; - - if (activeViewContent is ITextEditorControlProvider) { - TextEditorControl textarea = ((ITextEditorControlProvider)activeViewContent).TextEditorControl; - textarea.OptionsChanged(); - } - - return true; - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/GeneralTextEditorPanel.cs b/src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/GeneralTextEditorPanel.cs deleted file mode 100644 index 7d59bab7e9..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/GeneralTextEditorPanel.cs +++ /dev/null @@ -1,132 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using ICSharpCode.SharpDevelop.Gui.OptionPanels; -using System; -using System.Drawing; -using System.Drawing.Text; -using System.Text; -using System.Windows.Forms; -using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; -using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.TextEditor; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.OptionPanels -{ - /// - /// General texteditor options panel. - /// - public class GeneralTextEditorPanel : XmlFormsOptionPanel - { - ComboBox fontListComboBox, fontSizeComboBox; - FontSelectionPanelHelper helper; - - public override void LoadPanelContents() - { - SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.GeneralTextEditorPanel.xfrm")); - - fontListComboBox = ((ComboBox)ControlDictionary["fontListComboBox"]); - fontSizeComboBox = ((ComboBox)ControlDictionary["fontSizeComboBox"]); - - SharpDevelopTextEditorProperties properties = SharpDevelopTextEditorProperties.Instance; - - ((CheckBox)ControlDictionary["enableFoldingCheckBox"]).Checked = properties.EnableFolding; - ((CheckBox)ControlDictionary["showQuickClassBrowserCheckBox"]).Checked = properties.ShowQuickClassBrowserPanel; - - if (IsClearTypeEnabled) { - // Somehow, SingleBitPerPixelGridFit still renders as Cleartype if cleartype is enabled - // and we're using the TextRenderer for rendering. - // So we cannot support not using antialiasing if system-wide font smoothening is enabled. - ((CheckBox)ControlDictionary["enableAAFontRenderingCheckBox"]).Checked = true; - ((CheckBox)ControlDictionary["enableAAFontRenderingCheckBox"]).Enabled = false; - } else { - ((CheckBox)ControlDictionary["enableAAFontRenderingCheckBox"]).Checked = - (properties.TextRenderingHint == TextRenderingHint.AntiAliasGridFit || properties.TextRenderingHint == TextRenderingHint.ClearTypeGridFit); - } - - ((CheckBox)ControlDictionary["mouseWheelZoomCheckBox"]).Checked = properties.MouseWheelTextZoom; - - foreach (String name in CharacterEncodings.Names) { - ((ComboBox)ControlDictionary["textEncodingComboBox"]).Items.Add(name); - } - int encodingIndex = 0; - try { - encodingIndex = CharacterEncodings.GetEncodingIndex(properties.EncodingCodePage); - } catch { - encodingIndex = CharacterEncodings.GetEncodingIndex(Encoding.UTF8.CodePage); - } - ((ComboBox)ControlDictionary["textEncodingComboBox"]).SelectedIndex = encodingIndex; - - for (int i = 6; i <= 24; ++i) { - fontSizeComboBox.Items.Add(i); - } - - fontSizeComboBox.TextChanged += new EventHandler(UpdateFontPreviewLabel); - fontSizeComboBox.Enabled = false; - - fontListComboBox.Enabled = false; - fontListComboBox.TextChanged += new EventHandler(UpdateFontPreviewLabel); - fontListComboBox.SelectedIndexChanged += new EventHandler(UpdateFontPreviewLabel); - - Font currentFont = FontSelectionPanel.ParseFont(properties.FontContainer.DefaultFont.ToString()); - helper = new FontSelectionPanelHelper(fontSizeComboBox, fontListComboBox, currentFont); - - fontListComboBox.MeasureItem += new System.Windows.Forms.MeasureItemEventHandler(helper.MeasureComboBoxItem); - fontListComboBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(helper.ComboBoxDrawItem); - - UpdateFontPreviewLabel(null, null); - helper.StartThread(); - } - - Font CurrentFont { - get { - return helper.GetSelectedFont(); - } - } - - bool IsClearTypeEnabled { - get { - return SystemInformation.IsFontSmoothingEnabled && SystemInformation.FontSmoothingType >= 2; - } - } - - void UpdateFontPreviewLabel(object sender, EventArgs e) - { - helper.UpdateFontPreviewLabel(ControlDictionary["fontPreviewLabel"]); - } - - public override bool StorePanelContents() - { - SharpDevelopTextEditorProperties properties = SharpDevelopTextEditorProperties.Instance; - - if (((CheckBox)ControlDictionary["enableAAFontRenderingCheckBox"]).Enabled) { - properties.TextRenderingHint = ((CheckBox)ControlDictionary["enableAAFontRenderingCheckBox"]).Checked - ? TextRenderingHint.ClearTypeGridFit : TextRenderingHint.SystemDefault; - } else { - properties.TextRenderingHint = TextRenderingHint.SystemDefault; - } - properties.MouseWheelTextZoom = ((CheckBox)ControlDictionary["mouseWheelZoomCheckBox"]).Checked; - //((Properties)CustomizationObject).Set("EnableCodeCompletion", ((CheckBox)ControlDictionary["enableCodeCompletionCheckBox"]).Checked); - properties.EnableFolding = ((CheckBox)ControlDictionary["enableFoldingCheckBox"]).Checked; - Font currentFont = CurrentFont; - if (currentFont != null) { - properties.Font = currentFont; - } - properties.EncodingCodePage = CharacterEncodings.GetCodePageByIndex(((ComboBox)ControlDictionary["textEncodingComboBox"]).SelectedIndex); - properties.ShowQuickClassBrowserPanel = ((CheckBox)ControlDictionary["showQuickClassBrowserCheckBox"]).Checked; - - IViewContent activeViewContent = WorkbenchSingleton.Workbench.ActiveViewContent; - - if (activeViewContent is ITextEditorControlProvider) { - TextEditorControl textarea = ((ITextEditorControlProvider)activeViewContent).TextEditorControl; - textarea.OptionsChanged(); - } - return true; - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/MarkersTextEditorPanel.cs b/src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/MarkersTextEditorPanel.cs deleted file mode 100644 index ff1c300bfd..0000000000 --- a/src/Main/Base/Project/Src/TextEditor/Gui/OptionPanels/MarkersTextEditorPanel.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using ICSharpCode.SharpDevelop.Gui.OptionPanels; -using System; -using System.Windows.Forms; -using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; -using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.TextEditor; -using ICSharpCode.TextEditor.Document; - -namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.OptionPanels -{ - /// - /// Summary description for Form9. - /// - public class MarkersTextEditorPanel : XmlFormsOptionPanel - { - public override void LoadPanelContents() - { - SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.MarkersTextEditorPanel.xfrm")); - - SharpDevelopTextEditorProperties properties = SharpDevelopTextEditorProperties.Instance; - ((CheckBox)ControlDictionary["showLineNumberCheckBox"]).Checked = properties.ShowLineNumbers; - ((CheckBox)ControlDictionary["showInvalidLinesCheckBox"]).Checked = properties.ShowInvalidLines; - ((CheckBox)ControlDictionary["showBracketHighlighterCheckBox"]).Checked = properties.ShowMatchingBracket; - ((CheckBox)ControlDictionary["showErrorsCheckBox"]).Checked = properties.UnderlineErrors; - ((CheckBox)ControlDictionary["showHRulerCheckBox"]).Checked = properties.ShowHorizontalRuler; - ((CheckBox)ControlDictionary["showEOLMarkersCheckBox"]).Checked = properties.ShowEOLMarker; - ((CheckBox)ControlDictionary["showVRulerCheckBox"]).Checked = properties.ShowVerticalRuler; - ((CheckBox)ControlDictionary["showTabCharsCheckBox"]).Checked = properties.ShowTabs; - ((CheckBox)ControlDictionary["showSpaceCharsCheckBox"]).Checked = properties.ShowSpaces; - ((CheckBox)ControlDictionary["showCaretLineCheckBox"]).Checked = properties.CaretLine; - - ControlDictionary["vRulerRowTextBox"].Text = properties.VerticalRulerRow.ToString(); - - - ((ComboBox)ControlDictionary["lineMarkerStyleComboBox"]).Items.Add(ResourceService.GetString("Dialog.Options.IDEOptions.TextEditor.Markers.LineViewerStyle.None")); - ((ComboBox)ControlDictionary["lineMarkerStyleComboBox"]).Items.Add(ResourceService.GetString("Dialog.Options.IDEOptions.TextEditor.Markers.LineViewerStyle.FullRow")); - ((ComboBox)ControlDictionary["lineMarkerStyleComboBox"]).SelectedIndex = (int)properties.LineViewerStyle; - - - - ((ComboBox)ControlDictionary["bracketMatchingStyleComboBox"]).Items.Add(ResourceService.GetString("Dialog.Options.IDEOptions.TextEditor.Markers.BracketMatchingStyle.BeforeCaret")); - ((ComboBox)ControlDictionary["bracketMatchingStyleComboBox"]).Items.Add(ResourceService.GetString("Dialog.Options.IDEOptions.TextEditor.Markers.BracketMatchingStyle.AfterCaret")); - ((ComboBox)ControlDictionary["bracketMatchingStyleComboBox"]).SelectedIndex = (int)properties.BracketMatchingStyle; - } - - public override bool StorePanelContents() - { - SharpDevelopTextEditorProperties properties = SharpDevelopTextEditorProperties.Instance; - properties.ShowInvalidLines = ((CheckBox)ControlDictionary["showInvalidLinesCheckBox"]).Checked; - properties.ShowLineNumbers = ((CheckBox)ControlDictionary["showLineNumberCheckBox"]).Checked; - properties.ShowMatchingBracket = ((CheckBox)ControlDictionary["showBracketHighlighterCheckBox"]).Checked; - properties.UnderlineErrors = ((CheckBox)ControlDictionary["showErrorsCheckBox"]).Checked; - properties.ShowHorizontalRuler = ((CheckBox)ControlDictionary["showHRulerCheckBox"]).Checked; - properties.ShowEOLMarker = ((CheckBox)ControlDictionary["showEOLMarkersCheckBox"]).Checked; - properties.ShowVerticalRuler = ((CheckBox)ControlDictionary["showVRulerCheckBox"]).Checked; - properties.ShowTabs = ((CheckBox)ControlDictionary["showTabCharsCheckBox"]).Checked; - properties.ShowSpaces = ((CheckBox)ControlDictionary["showSpaceCharsCheckBox"]).Checked; - properties.CaretLine = ((CheckBox)ControlDictionary["showCaretLineCheckBox"]).Checked; - - try { - properties.VerticalRulerRow = Int32.Parse(ControlDictionary["vRulerRowTextBox"].Text); - } catch (Exception) { - } - - properties.LineViewerStyle = (LineViewerStyle)((ComboBox)ControlDictionary["lineMarkerStyleComboBox"]).SelectedIndex; - properties.BracketMatchingStyle = (BracketMatchingStyle)((ComboBox)ControlDictionary["bracketMatchingStyleComboBox"]).SelectedIndex; - - IViewContent activeViewContent = WorkbenchSingleton.Workbench.ActiveViewContent; - - if (activeViewContent is ITextEditorControlProvider) { - TextEditorControl textarea = ((ITextEditorControlProvider)activeViewContent).TextEditorControl; - textarea.OptionsChanged(); - } - - return true; - } - } -} diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/TextEditorAdapter.cs b/src/Main/Base/Project/Src/TextEditor/Gui/TextEditorAdapter.cs index 942f215df3..493b0b79fa 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/TextEditorAdapter.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/TextEditorAdapter.cs @@ -24,7 +24,6 @@ namespace ICSharpCode.SharpDevelop { public class TextEditorAdapter : ITextEditor { - readonly SharpDevelopTextAreaControl sdtac; readonly TextEditorControl editor; public TextEditorAdapter(TextEditorControl editor) @@ -32,7 +31,6 @@ namespace ICSharpCode.SharpDevelop if (editor == null) throw new ArgumentNullException("editor"); this.editor = editor; - this.sdtac = editor as SharpDevelopTextAreaControl; this.Document = new TextEditorDocument(editor.Document); this.Caret = new CaretAdapter(this, editor.ActiveTextAreaControl.Caret); this.Options = new OptionsAdapter(editor.TextEditorProperties); @@ -147,19 +145,6 @@ namespace ICSharpCode.SharpDevelop get { return FileName.Create(editor.FileName); } } - public void ShowInsightWindow(ICSharpCode.TextEditor.Gui.InsightWindow.IInsightDataProvider provider) - { - if (sdtac != null) - sdtac.ShowInsightWindow(provider); - } - - public void ShowCompletionWindow(ICompletionDataProvider provider, char ch) - { - if (sdtac != null) { - sdtac.ShowCompletionWindow(provider, ch); - } - } - public ICompletionListWindow ActiveCompletionWindow { get { return null; @@ -168,31 +153,25 @@ namespace ICSharpCode.SharpDevelop public ICompletionListWindow ShowCompletionWindow(ICompletionItemList items) { - if (sdtac != null) { - sdtac.ShowCompletionWindow(new CompletionItemListAdapter(items), '.'); - } return null; } public string GetWordBeforeCaret() { - if (sdtac != null) - return sdtac.GetWordBeforeCaret(); - else - return ""; + return ""; } public object GetService(Type serviceType) { if (serviceType == typeof(TextArea)) - return sdtac.ActiveTextAreaControl.TextArea; + return editor.ActiveTextAreaControl.TextArea; else return null; } public int SelectionStart { get { - var sel = sdtac.ActiveTextAreaControl.SelectionManager; + var sel = editor.ActiveTextAreaControl.SelectionManager; if (sel.HasSomethingSelected) return sel.SelectionCollection[0].Offset; else @@ -202,7 +181,7 @@ namespace ICSharpCode.SharpDevelop public int SelectionLength { get { - var sel = sdtac.ActiveTextAreaControl.SelectionManager; + var sel = editor.ActiveTextAreaControl.SelectionManager; if (sel.HasSomethingSelected) return sel.SelectionCollection[0].Length; else @@ -212,7 +191,7 @@ namespace ICSharpCode.SharpDevelop public string SelectedText { get { - var sel = sdtac.ActiveTextAreaControl.SelectionManager; + var sel = editor.ActiveTextAreaControl.SelectionManager; return sel.SelectedText; } set { @@ -226,20 +205,20 @@ namespace ICSharpCode.SharpDevelop } public event EventHandler SelectionChanged { - add { sdtac.ActiveTextAreaControl.SelectionManager.SelectionChanged += value; } - remove { sdtac.ActiveTextAreaControl.SelectionManager.SelectionChanged -= value; } + add { editor.ActiveTextAreaControl.SelectionManager.SelectionChanged += value; } + remove { editor.ActiveTextAreaControl.SelectionManager.SelectionChanged -= value; } } public void Select(int selectionStart, int selectionLength) { - var doc = sdtac.Document; - sdtac.ActiveTextAreaControl.SelectionManager.SetSelection( + var doc = editor.Document; + editor.ActiveTextAreaControl.SelectionManager.SetSelection( doc.OffsetToPosition(selectionStart), doc.OffsetToPosition(selectionStart + selectionLength)); } public void JumpTo(int line, int column) { - sdtac.ActiveTextAreaControl.JumpTo(line - 1, column - 1); + editor.ActiveTextAreaControl.JumpTo(line - 1, column - 1); } public IInsightWindow ActiveInsightWindow {