Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Krüger <mkrueger@xamarin.com>2014-07-18 10:39:51 +0400
committerMike Krüger <mkrueger@xamarin.com>2014-07-18 10:39:51 +0400
commitc8a0ba1624d9c02bd97d2b2b273e1d2d46e7fe21 (patch)
tree7aaa19a7bca95bbb083cc9326b71472770c4e180 /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content
parent81348b16c07d08c8fe449c510b1c4fd592b811e3 (diff)
parent22dfba593abd8c17ee5b7bbb390214e01362c76f (diff)
Merge branch 'xs6-editor' into retina-roslyn
Conflicts: .gitmodules main/src/addins/AspNet/MonoDevelop.AspNet.Mvc/MonoDevelop.AspNet.Mvc.csproj main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/DocumentReferenceManager.cs main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.addin.xml main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.csproj main/src/addins/AspNet/Razor/IRazorCompletionBuilder.cs main/src/addins/AspNet/Razor/RazorCSharpEditorExtension.cs main/src/addins/AspNet/Tests/Razor/RazorCompletionTesting.cs main/src/addins/AspNet/WebForms/ILanguageCompletionBuilder.cs main/src/addins/AspNet/WebForms/WebFormsEditorExtension.cs main/src/addins/CBinding/Gui/CTextEditorExtension.cs main/src/addins/CBinding/Gui/DataProvider.cs main/src/addins/CSharpBinding/AspNet/AspLanguageBuilder.cs main/src/addins/CSharpBinding/AspNet/CSharpBinding.AspNet.csproj main/src/addins/CSharpBinding/AspNet/RazorCSharpCompletionBuilder.cs main/src/addins/CSharpBinding/CSharpBinding.addin.xml main/src/addins/CSharpBinding/CSharpBinding.csproj main/src/addins/CSharpBinding/MonoDevelop.CSharp.ClassOutline/CSharpOutlineTextEditorExtension.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/AbstractGenerateAction.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/CodeGenerationOptions.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/ExportCodeGenerator.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeGeneration/WriteLineGenerator.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/AbstractParameterDataProvider.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/ArrayTypeParameterDataProvider.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/DelegateDataProvider.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/IndexerParameterDataProvider.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/MemberCompletionData.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/MethodParameterDataProvider.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/CSharpSyntaxMode.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/HighlightUsagesExtension.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/TypeSystemProvider.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring.CodeActions/ContextActionExtensions.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring.CodeActions/MDRefactoringContext.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring.CodeActions/MDRefactoringScript.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring.CodeActions/NRefactoryCodeAction.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring.CodeActions/NRefactoryCodeActionProvider.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring.CodeIssues/BaseNRefactoryIssueProvider.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring.CodeIssues/NRefactoryCodeIssueSource.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring.CodeIssues/NRefactoryIssueProvider.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpCodeGenerator.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpReferenceFinder.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.Tooltips/LanguageItemTooltipProvider.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp.UnitTests/UnitTestTextEditorExtension.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp/PathedDocumentTextEditorExtension.cs main/src/addins/CSharpBinding/MonoDevelop.CSharp/SignatureMarkupCreator.cs main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood.csproj main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/Commands.cs main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderWindow.cs main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.csproj main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/AnalysisCommands.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/FixableResult.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Fixes/GenericFix.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Fixes/RenameMemberFix.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Gui/ResultMarker.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Gui/ResultsEditorExtension.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Result.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Rules/Adaptors.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/AnalysisCodeAction.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeAction.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionProvider.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeAnalysisRunner.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssue.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssueAddinNode.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/CodeIssueProvider.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/BatchFixer.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeIssues/Pad/CodeAnalysisBatchRunner.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameItemDialog.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.addin.xml main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.csproj main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/Change.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/ExtensionMethods.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindDerivedClassesHandler.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindDerivedSymbolsHandler.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindExtensionMethodHandler.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindMemberOverloadsHandler.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindReferencesHandler.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/ImportSymbolHandler.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringOptions.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringService.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoryCommands.cs main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/ResolveCommandHandler.cs main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskOverviewMode.cs main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/AbstractUsagesExtension.cs main/src/addins/NUnit/Gui/AbstractUnitTestEditorExtension.cs main/src/addins/Xml/MonoDevelop.Xml.csproj main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchPopupWindow.cs main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionListWindow.cs main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWidget.cs main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWindow.cs main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ParameterHintingData.cs main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ParameterInformationWindowManager.cs main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/ExpansionObject.cs main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/CompletionTextEditorExtension.cs main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/ITextEditorResolver.cs main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/CodeGenerationService.cs main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/CodeGenerator.cs main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/ParsedDocument.cs main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs main/tests/UnitTests/MonoDevelop.CSharpBinding.Refactoring/ResolveNamespaceTests.cs main/tests/UnitTests/UnitTests.csproj
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/CompletionTextEditorExtension.cs518
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/DocumentStateTracker.cs19
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IEditableTextBuffer.cs70
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IEncodedTextContent.cs41
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IExtensibleTextEditor.cs43
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/ITextEditorResolver.cs8
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/TextEditorExtension.cs181
7 files changed, 13 insertions, 867 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/CompletionTextEditorExtension.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/CompletionTextEditorExtension.cs
deleted file mode 100644
index 2c6edf82f1..0000000000
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/CompletionTextEditorExtension.cs
+++ /dev/null
@@ -1,518 +0,0 @@
-// CompletionTextEditorExtension.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (c) 2007 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-//
-
-
-using System;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.CodeCompletion;
-using MonoDevelop.Components.Commands;
-using MonoDevelop.Ide.Commands;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.CodeTemplates;
-using ICSharpCode.NRefactory6.CSharp.Completion;
-
-namespace MonoDevelop.Ide.Gui.Content
-{
- public class CompletionTextEditorExtension: TextEditorExtension
- {
- CodeCompletionContext currentCompletionContext;
-
- bool autoHideCompletionWindow = true, autoHideParameterWindow = true;
-
- #region Completion related IDE
-// public readonly static PropertyWrapper<bool> EnableCodeCompletion = PropertyService.Wrap ("EnableCodeCompletion", true);
-// public readonly static PropertyWrapper<bool> EnableParameterInsight = PropertyService.Wrap ("EnableParameterInsight", true);
- public readonly static PropertyWrapper<bool> EnableAutoCodeCompletion = PropertyService.Wrap ("EnableAutoCodeCompletion", true);
- public readonly static PropertyWrapper<bool> AddImportedItemsToCompletionList = PropertyService.Wrap ("AddImportedItemsToCompletionList", false);
- public readonly static PropertyWrapper<bool> IncludeKeywordsInCompletionList = PropertyService.Wrap ("IncludeKeywordsInCompletionList", true);
- public readonly static PropertyWrapper<bool> IncludeCodeSnippetsInCompletionList = PropertyService.Wrap ("IncludeCodeSnippetsInCompletionList", true);
- public readonly static PropertyWrapper<bool> AddParenthesesAfterCompletion = PropertyService.Wrap ("AddParenthesesAfterCompletion", false);
- public readonly static PropertyWrapper<bool> AddOpeningOnly = PropertyService.Wrap ("AddOpeningOnly", false);
- public readonly static PropertyWrapper<int> CompletionListRows = PropertyService.Wrap ("CompletionListRows", 7);
-
- public readonly static PropertyWrapper<bool> FilterCompletionListByEditorBrowsable = PropertyService.Wrap ("FilterCompletionListByEditorBrowsable", true);
- public readonly static PropertyWrapper<bool> IncludeEditorBrowsableAdvancedMembers = PropertyService.Wrap ("IncludeEditorBrowsableAdvancedMembers", true);
-
- #endregion
-
- public ICompletionWidget CompletionWidget {
- get;
- set;
- }
-
-
- public virtual string CompletionLanguage {
- get {
- return "Other";
- }
- }
-
- public void ShowCompletion (ICompletionDataList completionList)
- {
- currentCompletionContext = CompletionWidget.CreateCodeCompletionContext (Document.Editor.Caret.Offset);
- int cpos, wlen;
- if (!GetCompletionCommandOffset (out cpos, out wlen)) {
- cpos = Document.Editor.Caret.Offset;
- wlen = 0;
- }
- currentCompletionContext.TriggerOffset = cpos;
- currentCompletionContext.TriggerWordLength = wlen;
-
- CompletionWindowManager.ShowWindow (this, '\0', completionList, CompletionWidget, currentCompletionContext);
- }
-
- // When a key is pressed, and before the key is processed by the editor, this method will be invoked.
- // Return true if the key press should be processed by the editor.
- public override bool KeyPress (Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
- {
- bool res;
- if (currentCompletionContext != null) {
- if (CompletionWindowManager.PreProcessKeyEvent (key, keyChar, modifier)) {
- CompletionWindowManager.PostProcessKeyEvent (key, keyChar, modifier);
- autoHideCompletionWindow = true;
- // in named parameter case leave the parameter window open.
- autoHideParameterWindow = keyChar != ':';
- if (!autoHideParameterWindow && ParameterInformationWindowManager.IsWindowVisible)
- ParameterInformationWindowManager.PostProcessKeyEvent (this, CompletionWidget, key, modifier);
-
- return false;
- }
- autoHideCompletionWindow = autoHideParameterWindow = false;
- }
-
- if (ParameterInformationWindowManager.IsWindowVisible) {
- if (ParameterInformationWindowManager.ProcessKeyEvent (this, CompletionWidget, key, modifier))
- return false;
- autoHideCompletionWindow = autoHideParameterWindow = false;
- }
-
- // int oldPos = Editor.CursorPosition;
- // int oldLen = Editor.TextLength;
- res = base.KeyPress (key, keyChar, modifier);
-
- CompletionWindowManager.PostProcessKeyEvent (key, keyChar, modifier);
-
- var ignoreMods = Gdk.ModifierType.ControlMask | Gdk.ModifierType.MetaMask
- | Gdk.ModifierType.Mod1Mask | Gdk.ModifierType.SuperMask;
- // Handle parameter completion
- if (ParameterInformationWindowManager.IsWindowVisible) {
- ParameterInformationWindowManager.PostProcessKeyEvent (this, CompletionWidget, key, modifier);
- }
-
- if ((modifier & ignoreMods) != 0)
- return res;
-
- // don't complete on block selection
- if (/*!EnableCodeCompletion ||*/ Document.Editor.SelectionMode == Mono.TextEditor.SelectionMode.Block)
- return res;
-
- // Handle code completion
- if (keyChar != '\0' && CompletionWidget != null && !CompletionWindowManager.IsVisible) {
- currentCompletionContext = CompletionWidget.CurrentCodeCompletionContext;
- int triggerWordLength = currentCompletionContext.TriggerWordLength;
- ICompletionDataList completionList = HandleCodeCompletion (currentCompletionContext, keyChar,
- ref triggerWordLength);
- if (triggerWordLength > 0 && (triggerWordLength < Editor.Caret.Offset
- || (triggerWordLength == 1 && Editor.Caret.Offset == 1))) {
- currentCompletionContext
- = CompletionWidget.CreateCodeCompletionContext (Editor.Caret.Offset - triggerWordLength);
- currentCompletionContext.TriggerWordLength = triggerWordLength;
- }
- if (completionList != null) {
- if (!CompletionWindowManager.ShowWindow (this, keyChar, completionList, CompletionWidget, currentCompletionContext))
- currentCompletionContext = null;
- } else {
- currentCompletionContext = null;
- }
- }
-
- if (/*EnableParameterInsight &&*/ CompletionWidget != null) {
- CodeCompletionContext ctx = CompletionWidget.CurrentCodeCompletionContext;
- var paramProvider = HandleParameterCompletion (ctx, keyChar);
- if (paramProvider != null)
- ParameterInformationWindowManager.ShowWindow (this, CompletionWidget, ctx, paramProvider);
- }
-/* autoHideCompletionWindow = true;
- autoHideParameterWindow = keyChar != ':';*/
- return res;
- }
-
- protected void ShowCompletion (ICompletionDataList completionList, int triggerWordLength, char keyChar)
- {
- if (Document.Editor.SelectionMode == Mono.TextEditor.SelectionMode.Block)
- return;
- if (CompletionWidget != null && currentCompletionContext == null) {
- currentCompletionContext = CompletionWidget.CurrentCodeCompletionContext;
- if (triggerWordLength > 0 && triggerWordLength < Editor.Caret.Offset) {
- currentCompletionContext =
- CompletionWidget.CreateCodeCompletionContext (Editor.Caret.Offset - triggerWordLength);
- currentCompletionContext.TriggerWordLength = triggerWordLength;
- }
- if (completionList != null)
- CompletionWindowManager.ShowWindow (this, keyChar, completionList, CompletionWidget, currentCompletionContext);
- else
- currentCompletionContext = null;
- }
- autoHideCompletionWindow = autoHideParameterWindow = true;
- }
-
- public virtual int GetCurrentParameterIndex (int startOffset)
- {
- return -1;
- }
-
-
- protected void OnCompletionContextChanged (object o, EventArgs a)
- {
- if (autoHideCompletionWindow)
- CompletionWindowManager.HideWindow ();
- if (autoHideParameterWindow)
- ParameterInformationWindowManager.HideWindow (this, CompletionWidget);
- ParameterInformationWindowManager.UpdateCursorPosition (this, CompletionWidget);
- }
-
- [CommandUpdateHandler (TextEditorCommands.ShowCompletionWindow)]
- internal void OnUpdateCompletionCommand (CommandInfo info)
- {
- info.Bypass = !CanRunCompletionCommand () && !CompletionWindowManager.IsVisible;
- }
-
- [CommandUpdateHandler (TextEditorCommands.ShowParameterCompletionWindow)]
- internal void OnUpdateParameterCompletionCommand (CommandInfo info)
- {
- info.Bypass = !CanRunParameterCompletionCommand ();
- }
-
- [CommandHandler (TextEditorCommands.ShowCompletionWindow)]
- public virtual void RunCompletionCommand ()
- {
- if (Document.Editor.SelectionMode == Mono.TextEditor.SelectionMode.Block)
- return;
-
- if (CompletionWindowManager.IsVisible) {
- CompletionWindowManager.Wnd.ToggleCategoryMode ();
- return;
- }
- ICompletionDataList completionList = null;
- int cpos, wlen;
- if (!GetCompletionCommandOffset (out cpos, out wlen)) {
- cpos = Editor.Caret.Offset;
- wlen = 0;
- }
- currentCompletionContext = CompletionWidget.CreateCodeCompletionContext (cpos);
- currentCompletionContext.TriggerWordLength = wlen;
- completionList = CodeCompletionCommand (currentCompletionContext);
- if (completionList != null)
- CompletionWindowManager.ShowWindow (this, (char)0, completionList, CompletionWidget, currentCompletionContext);
- else
- currentCompletionContext = null;
- }
-
- [CommandHandler (TextEditorCommands.ShowCodeTemplateWindow)]
- public virtual void RunShowCodeTemplatesWindow ()
- {
- ICompletionDataList completionList = null;
- int cpos, wlen;
- if (!GetCompletionCommandOffset (out cpos, out wlen)) {
- cpos = Editor.Caret.Offset;
- wlen = 0;
- }
-
- var ctx = CompletionWidget.CreateCodeCompletionContext (cpos);
- ctx.TriggerWordLength = wlen;
- completionList = Document.Editor.IsSomethingSelected ? ShowCodeSurroundingsCommand (ctx) : ShowCodeTemplatesCommand (ctx);
- if (completionList == null) {
- return;
- }
- var wnd = new CompletionListWindow (Gtk.WindowType.Toplevel);
- wnd.TypeHint = Gdk.WindowTypeHint.Dialog;
- wnd.SkipPagerHint = true;
- wnd.SkipTaskbarHint = true;
- wnd.Decorated = false;
- wnd.Extension = this;
- wnd.ShowListWindow ((char)0, completionList, CompletionWidget, ctx);
- }
-
- [CommandUpdateHandler (TextEditorCommands.ShowCodeTemplateWindow)]
- internal void OnUpdateShowCodeTemplatesWindow (CommandInfo info)
- {
- ICompletionDataList completionList = null;
- int cpos, wlen;
- if (!GetCompletionCommandOffset (out cpos, out wlen)) {
- cpos = Editor.Caret.Offset;
- wlen = 0;
- }
- try {
- var ctx = CompletionWidget.CreateCodeCompletionContext (cpos);
- ctx.TriggerWordLength = wlen;
- completionList = Document.Editor.IsSomethingSelected ? ShowCodeSurroundingsCommand (ctx) : ShowCodeTemplatesCommand (ctx);
-
- info.Bypass = completionList == null;
- info.Text = Document.Editor.IsSomethingSelected ? GettextCatalog.GetString ("_Surround With...") : GettextCatalog.GetString ("I_nsert Template...");
- } catch (Exception e) {
- LoggingService.LogError ("Error while update show code templates window", e);
- info.Bypass = true;
- }
- }
-
-
- [CommandHandler (TextEditorCommands.ShowParameterCompletionWindow)]
- public virtual void RunParameterCompletionCommand ()
- {
- if (Document.Editor.SelectionMode == Mono.TextEditor.SelectionMode.Block || CompletionWidget == null)
- return;
- ParameterHintingResult cp = null;
- int cpos = Editor.Caret.Offset;
- CodeCompletionContext ctx = CompletionWidget.CreateCodeCompletionContext (cpos);
- cp = ParameterCompletionCommand (ctx);
- if (cp != null) {
- ParameterInformationWindowManager.ShowWindow (this, CompletionWidget, ctx, cp);
- ParameterInformationWindowManager.PostProcessKeyEvent (this, CompletionWidget, Gdk.Key.F, Gdk.ModifierType.None);
- }
- }
-
- public virtual bool CanRunCompletionCommand ()
- {
- return (CompletionWidget != null && currentCompletionContext == null);
- }
-
- public virtual bool CanRunParameterCompletionCommand ()
- {
- return (CompletionWidget != null && !ParameterInformationWindowManager.IsWindowVisible);
- }
-
-
- public virtual ICompletionDataList HandleCodeCompletion (CodeCompletionContext completionContext,
- char completionChar, ref int triggerWordLength)
- {
- return null;
- }
-
- public virtual ParameterHintingResult HandleParameterCompletion (CodeCompletionContext completionContext, char completionChar)
- {
- return null;
- }
-
- // return false if completion can't be shown
- public virtual bool GetCompletionCommandOffset (out int cpos, out int wlen)
- {
- cpos = wlen = 0;
- int pos = Editor.Caret.Offset - 1;
- while (pos >= 0) {
- char c = Editor.GetCharAt (pos);
- if (!char.IsLetterOrDigit (c) && c != '_')
- break;
- pos--;
- }
- if (pos == -1)
- return false;
-
- pos++;
- cpos = pos;
- int len = Editor.Length;
-
- while (pos < len) {
- char c = Editor.GetCharAt (pos);
- if (!char.IsLetterOrDigit (c) && c != '_')
- break;
- pos++;
- }
- wlen = pos - cpos;
- return true;
- }
-
-
- public virtual ICompletionDataList ShowCodeSurroundingsCommand (CodeCompletionContext completionContext)
- {
- CompletionDataList list = new CompletionDataList ();
- list.AutoSelect = true;
- list.AutoCompleteEmptyMatch = true;
- list.CompletionSelectionMode = CompletionSelectionMode.OwnTextField;
- var templateWidget = Document.GetContent<ICodeTemplateContextProvider> ();
- CodeTemplateContext ctx = CodeTemplateContext.Standard;
- if (templateWidget != null)
- ctx = templateWidget.GetCodeTemplateContext ();
- foreach (CodeTemplate template in CodeTemplateService.GetCodeTemplatesForFile (Document.FileName)) {
- if ((template.CodeTemplateType & CodeTemplateType.SurroundsWith) == CodeTemplateType.SurroundsWith) {
- if (ctx == template.CodeTemplateContext)
- list.Add (new CodeTemplateCompletionData (Document, template));
- }
- }
- return list;
- }
-
- public virtual ICompletionDataList ShowCodeTemplatesCommand (CodeCompletionContext completionContext)
- {
- CompletionDataList list = new CompletionDataList ();
- list.AutoSelect = true;
- list.AutoCompleteEmptyMatch = true;
- list.CompletionSelectionMode = CompletionSelectionMode.OwnTextField;
- foreach (CodeTemplate template in CodeTemplateService.GetCodeTemplatesForFile (Document.FileName)) {
- if (template.CodeTemplateType != CodeTemplateType.SurroundsWith) {
- list.Add (new CodeTemplateCompletionData (Document, template));
- }
- }
- return list;
- }
-
-
- public virtual ICompletionDataList CodeCompletionCommand (CodeCompletionContext completionContext)
- {
- // This default implementation of CodeCompletionCommand calls HandleCodeCompletion providing
- // the char at the cursor position. If it returns a provider, just return it.
-
- int pos = completionContext.TriggerOffset;
- if (pos > 0) {
- char ch = Editor.GetCharAt (pos - 1);
- int triggerWordLength = completionContext.TriggerWordLength;
- ICompletionDataList completionList = HandleCodeCompletion (completionContext, ch, ref triggerWordLength);
- if (completionList != null)
- return completionList;
- }
- return null;
- }
-
- public virtual ParameterHintingResult ParameterCompletionCommand (CodeCompletionContext completionContext)
- {
- // This default implementation of ParameterCompletionCommand calls HandleParameterCompletion providing
- // the char at the cursor position. If it returns a provider, just return it.
-
- int pos = completionContext.TriggerOffset;
- if (pos <= 0)
- return null;
- var cp = HandleParameterCompletion (completionContext, Editor.Document.GetCharAt (pos - 1));
- if (cp != null)
- return cp;
- return null;
- }
-
- public virtual int GuessBestMethodOverload (ParameterHintingResult provider, int currentOverload)
- {
- int cparam = GetCurrentParameterIndex (provider.StartOffset);
-
- var currentHintingData = provider [currentOverload];
- if (cparam > currentHintingData.ParameterCount && !currentHintingData.IsParameterListAllowed) {
- // Look for an overload which has more parameters
- int bestOverload = -1;
- int bestParamCount = int.MaxValue;
- for (int n=0; n<provider.Count; n++) {
- int pc = provider[n].ParameterCount;
- if (pc < bestParamCount && pc >= cparam) {
- bestOverload = n;
- bestParamCount = pc;
- }
- }
- if (bestOverload == -1) {
- for (int n=0; n<provider.Count; n++) {
- if (provider[n].IsParameterListAllowed) {
- bestOverload = n;
- break;
- }
- }
- }
- return bestOverload;
- }
- return -1;
- }
-
- void HandlePaste (int insertionOffset, string text, int insertedChars)
- {
- ParameterInformationWindowManager.HideWindow (this, CompletionWidget);
- CompletionWindowManager.HideWindow ();
- }
-
- void HandleFocusOutEvent (object o, Gtk.FocusOutEventArgs args)
- {
- ParameterInformationWindowManager.HideWindow (this, CompletionWidget);
- CompletionWindowManager.HideWindow ();
- }
-
- public override void Initialize ()
- {
- base.Initialize ();
- CompletionWindowManager.WindowClosed += HandleWindowClosed;
- CompletionWidget = Document.GetContent <ICompletionWidget> ();
- if (CompletionWidget != null)
- CompletionWidget.CompletionContextChanged += OnCompletionContextChanged;
- document.Editor.Caret.PositionChanged += HandlePositionChanged;
- document.Editor.Paste += HandlePaste;
- if (document.Editor.Parent != null)
- document.Editor.Parent.TextArea.FocusOutEvent += HandleFocusOutEvent;
- }
-
- void HandlePositionChanged (object sender, Mono.TextEditor.DocumentLocationEventArgs e)
- {
- CompletionWindowManager.UpdateCursorPosition ();
- }
-
- void HandleWindowClosed (object sender, EventArgs e)
- {
- currentCompletionContext = null;
- }
-
- bool disposed = false;
- public override void Dispose ()
- {
- if (!disposed) {
- CompletionWindowManager.HideWindow ();
- ParameterInformationWindowManager.HideWindow (this, CompletionWidget);
-
- disposed = true;
- if (document.Editor.Parent != null)
- document.Editor.Parent.TextArea.FocusOutEvent -= HandleFocusOutEvent;
- document.Editor.Paste -= HandlePaste;
- document.Editor.Caret.PositionChanged -= HandlePositionChanged;
- CompletionWindowManager.WindowClosed -= HandleWindowClosed;
- if (CompletionWidget != null)
- CompletionWidget.CompletionContextChanged -= OnCompletionContextChanged;
- }
- base.Dispose ();
- }
- }
-
- public interface ITypeNameResolver
- {
- string ResolveName (string typeName);
- }
- class SimpleTypeNameResolver: ITypeNameResolver
- {
- // This simple resolver removes the namespace from all class names.
- // Used in ctrl+space, since all classes shown in the completion list
- // are in scope
-
- public static SimpleTypeNameResolver Instance = new SimpleTypeNameResolver ();
-
- public string ResolveName (string typeName)
- {
- int i = typeName.LastIndexOf ('.');
- if (i == -1)
- return typeName;
- else
- return typeName.Substring (i+1);
- }
- }
-}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/DocumentStateTracker.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/DocumentStateTracker.cs
index 45303e9457..b254fac993 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/DocumentStateTracker.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/DocumentStateTracker.cs
@@ -30,7 +30,8 @@
using System;
using System.Collections.Generic;
-using Mono.TextEditor;
+using MonoDevelop.Ide.Editor;
+using MonoDevelop.Core.Text;
namespace MonoDevelop.Ide.Gui.Content
{
@@ -40,25 +41,25 @@ namespace MonoDevelop.Ide.Gui.Content
T currentEngine;
Stack<T> cachedEngines = new Stack<T> ();
- TextEditorData editor;
+ TextEditor editor;
- public DocumentStateTracker (T engine, TextEditorData editor)
+ public DocumentStateTracker (T engine, TextEditor editor)
{
this.currentEngine = engine;
this.editor = editor;
- editor.Document.TextReplaced += textChanged;
+ editor.TextChanged += textChanged;
}
public void Dispose ()
{
- editor.Document.TextReplaced -= textChanged;
+ editor.TextChanged -= textChanged;
}
public T Engine {
get { return currentEngine; }
}
- void textChanged (object sender, DocumentChangeEventArgs args)
+ void textChanged (object sender, TextChangeEventArgs args)
{
if (args.Offset< currentEngine.Position)
ResetEngineToPosition (args.Offset);
@@ -85,7 +86,7 @@ namespace MonoDevelop.Ide.Gui.Content
}
public void UpdateEngine ()
{
- UpdateEngine (editor.Caret.Offset);
+ UpdateEngine (editor.CaretOffset);
}
//Makes sure that the smart indent engine's cursor has caught up with the
@@ -112,7 +113,7 @@ namespace MonoDevelop.Ide.Gui.Content
// get the engine caught up
int nextSave = (cachedEngines.Count == 0)? BUFFER_SIZE : cachedEngines.Peek ().Position + BUFFER_SIZE;
if (currentEngine.Position + 1 == position) {
- char ch = editor.Document.GetCharAt (currentEngine.Position);
+ char ch = editor.GetCharAt (currentEngine.Position);
currentEngine.Push (ch);
ConsoleWrite ("pushing character '{0}'", ch);
if (currentEngine.Position == nextSave)
@@ -124,7 +125,7 @@ namespace MonoDevelop.Ide.Gui.Content
int endCut = currentEngine.Position + BUFFER_SIZE;
if (endCut > position)
endCut = position;
- string buffer = editor.Document.GetTextBetween (currentEngine.Position, endCut);
+ string buffer = editor.GetTextBetween (currentEngine.Position, endCut);
ConsoleWrite ("getting buffer between {0} and {1}" /* '{2}'"*/, currentEngine.Position, endCut - 1, buffer);
foreach (char ch in buffer) {
currentEngine.Push (ch);
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IEditableTextBuffer.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IEditableTextBuffer.cs
deleted file mode 100644
index c606819800..0000000000
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IEditableTextBuffer.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-//
-// IEditableTextBuffer.cs
-//
-// Author:
-// Mike Krüger <mkrueger@novell.com>
-//
-// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using MonoDevelop.Projects.Text;
-
-namespace MonoDevelop.Ide.Gui.Content
-{
- public interface IEditableTextBuffer : ITextBuffer, IEditableTextFile, IUndoHandler
- {
- int LineCount { get; }
- void SetCaretTo (int line, int column);
- void SetCaretTo (int line, int column, bool highlightLine);
- void SetCaretTo (int line, int column, bool highlightLine, bool centerCaret);
- bool HasInputFocus { get; }
-
- void RunWhenLoaded (System.Action action);
-
- event EventHandler CaretPositionSet;
- event EventHandler<TextChangedEventArgs> TextChanged;
- }
-
- public class TextChangedEventArgs : System.EventArgs
- {
- int startIndex;
- public int StartIndex {
- get {
- return startIndex;
- }
- }
-
- int endIndex;
- public int EndIndex {
- get {
- return endIndex;
- }
- }
-
- public TextChangedEventArgs (int startIndex, int endIndex)
- {
- this.startIndex = startIndex;
- this.endIndex = endIndex;
- }
- }
-}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IEncodedTextContent.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IEncodedTextContent.cs
deleted file mode 100644
index 53f2e681e5..0000000000
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IEncodedTextContent.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// IEncodedTextContent.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Text;
-
-namespace MonoDevelop.Ide.Gui.Content
-{
- public interface IEncodedTextContent
- {
- void Load (string fileName, Encoding encoding);
- void Save (string fileName, Encoding encoding);
-
- Encoding SourceEncoding { get; }
- }
-}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IExtensibleTextEditor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IExtensibleTextEditor.cs
deleted file mode 100644
index 94df5d0c11..0000000000
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IExtensibleTextEditor.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-// IExtensibleTextEditor.cs
-//
-// Author:
-// Lluis Sanchez Gual <lluis@novell.com>
-//
-// Copyright (c) 2007 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-//
-
-using System;
-using MonoDevelop.Ide.CodeCompletion;
-
-namespace MonoDevelop.Ide.Gui.Content
-{
- public interface IExtensibleTextEditor: IEditableTextBuffer
- {
- ITextEditorExtension Extension {
- get;
- }
- // The provided parameter is the first object of the extension chain
- // This method should return the terminator ITextEditorExtension that
- // will execute the default behavior (if any)
- ITextEditorExtension AttachExtension (ITextEditorExtension extension);
- }
-}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/ITextEditorResolver.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/ITextEditorResolver.cs
index 6c7254fcf9..c2fab77d10 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/ITextEditorResolver.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/ITextEditorResolver.cs
@@ -26,10 +26,8 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
using System.Collections.Generic;
using System.Linq;
-using Mono.TextEditor;
using Mono.Addins;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.Semantics;
@@ -87,11 +85,11 @@ namespace MonoDevelop.Ide.Gui.Content
}
public static ResolveResult GetLanguageItem (this MonoDevelop.Ide.Gui.Document document, int offset, out DomRegion expressionRegion)
- {
- if (document == null)
+ {
+ if (document == null)
throw new System.ArgumentNullException ("document");
- var textEditorResolver = TextEditorResolverService.GetProvider (document.Editor.Document.MimeType);
+ var textEditorResolver = TextEditorResolverService.GetProvider (document.Editor.MimeType);
if (textEditorResolver != null) {
return textEditorResolver.GetLanguageItem (document, offset, out expressionRegion);
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/TextEditorExtension.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/TextEditorExtension.cs
deleted file mode 100644
index 276c61db99..0000000000
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/TextEditorExtension.cs
+++ /dev/null
@@ -1,181 +0,0 @@
-// TextEditorExtension.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (c) 2007 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-//
-
-
-using System;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide.CodeCompletion;
-using MonoDevelop.Components.Commands;
-using MonoDevelop.Ide.Commands;
-using MonoDevelop.Core;
-using Mono.TextEditor;
-using ICSharpCode.NRefactory.TypeSystem;
-using MonoDevelop.Ide.TypeSystem;
-
-namespace MonoDevelop.Ide.Gui.Content
-{
- public class TextEditorExtension : ITextEditorExtension, ICommandRouter
- {
- internal protected Document document;
-
- public void Initialize (Document document)
- {
- if (this.document != null)
- throw new InvalidOperationException ("Extension is already initialized.");
- this.document = document;
- Initialize ();
- }
-
- public ITextEditorExtension Next {
- get;
- set;
- }
-
- protected Document Document {
- get { return document; }
- }
-
- protected TextEditorData Editor {
- get { return document != null ? document.Editor : null; }
- }
-
- protected FilePath FileName {
- get {
- IViewContent view = document.Window.ViewContent;
- return view.IsUntitled ? view.UntitledName : view.ContentName;
- }
- }
-
- protected IProjectContent GetParserContext ()
- {
- CheckInitialized ();
-
- IViewContent view = document.Window.ViewContent;
- string file = view.IsUntitled ? view.UntitledName : view.ContentName;
- Project project = view.Project;
-
- if (project != null)
- return TypeSystemService.GetProjectContext (project);
- return TypeSystemService.GetContext (file, Document.Editor.Document.MimeType, Document.Editor.Text);
- }
-
- protected Ambience GetAmbience ()
- {
- CheckInitialized ();
-
- IViewContent view = document.Window.ViewContent;
- string file = view.IsUntitled ? view.UntitledName : view.ContentName;
- return AmbienceService.GetAmbienceForFile (file);
- }
-
- public virtual bool ExtendsEditor (Document doc, IEditableTextBuffer editor)
- {
- return true;
- }
-
- // When a key is pressed, and before the key is processed by the editor, this method will be invoked.
- // Return true if the key press should be processed by the editor.
- public virtual bool KeyPress (Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
- {
- CheckInitialized ();
-
- if (Next == null)
- return true;
- else
- return Next.KeyPress (key, keyChar, modifier);
- }
-
- public virtual void CursorPositionChanged ()
- {
- CheckInitialized ();
-
- if (Next != null)
- Next.CursorPositionChanged ();
- }
-
- public virtual void TextChanged (int startIndex, int endIndex)
- {
- if (Next != null)
- Next.TextChanged (startIndex, endIndex);
- }
-
- public virtual void Initialize ()
- {
- CheckInitialized ();
-
- TextEditorExtension next = Next as TextEditorExtension;
- if (next != null)
- next.Initialize ();
- }
-
- public virtual void Dispose ()
- {
- }
-
- void CheckInitialized ()
- {
- if (document == null)
- throw new InvalidOperationException ("Editor extension not yet initialized");
- }
-
- object ITextEditorExtension.GetExtensionCommandTarget ()
- {
- return this;
- }
-
- object ICommandRouter.GetNextCommandTarget ()
- {
- if (Next != null)
- return Next.GetExtensionCommandTarget ();
- else
- return null;
- }
- }
-
- public interface ITextEditorExtension : IDisposable
- {
- ITextEditorExtension Next {
- get;
- }
-
- bool KeyPress (Gdk.Key key, char keyChar, Gdk.ModifierType modifier);
- void CursorPositionChanged ();
- void TextChanged (int startIndex, int endIndex);
-
- // Return the object that is going to process commands, or null
- // if commands don't need custom processing
- object GetExtensionCommandTarget ();
- }
-
- class TextEditorExtensionMarker: TextEditorExtension
- {
- public override bool ExtendsEditor (Document doc, IEditableTextBuffer editor)
- {
- return false;
- }
- }
-}