diff options
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content')
11 files changed, 26 insertions, 1005 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 87562cd44b..0000000000 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/CompletionTextEditorExtension.cs +++ /dev/null @@ -1,524 +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.NRefactory.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; - ParameterDataProvider cp = null; - int cpos; - if (!GetParameterCompletionCommandOffset (out cpos)) - 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 ParameterDataProvider 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 bool GetParameterCompletionCommandOffset (out int cpos) - { - cpos = 0; - return false; - } - - 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 ParameterDataProvider 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 (IParameterDataProvider provider, int currentOverload) - { - int cparam = GetCurrentParameterIndex (provider.StartOffset); - - if (cparam > provider.GetParameterCount (currentOverload) && !provider.AllowParameterList (currentOverload)) { - // 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.GetParameterCount (n); - if (pc < bestParamCount && pc >= cparam) { - bestOverload = n; - bestParamCount = pc; - } - } - if (bestOverload == -1) { - for (int n=0; n<provider.Count; n++) { - if (provider.AllowParameterList (n)) { - 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/IFoldable.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IFoldable.cs index 2e163bc941..2775cfd06e 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IFoldable.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IFoldable.cs @@ -30,7 +30,7 @@ using System; namespace MonoDevelop.Ide.Gui.Content { - public interface IFoldable + interface IFoldable { void ToggleAllFoldings (); void FoldDefinitions (); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IOpenNamedElementHandler.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IOpenNamedElementHandler.cs index 306e4b4fab..e7b6c33768 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IOpenNamedElementHandler.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IOpenNamedElementHandler.cs @@ -30,8 +30,9 @@ using System; namespace MonoDevelop.Ide.Gui.Content { - public interface IOpenNamedElementHandler + interface IOpenNamedElementHandler { - void Open (ICSharpCode.NRefactory.TypeSystem.INamedElement element); + void Open (Microsoft.CodeAnalysis.ISymbol element); + void Open (string documentationCommentId); } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/ISmartIndenter.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/ISmartIndenter.cs deleted file mode 100644 index dfeb37a083..0000000000 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/ISmartIndenter.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -// ISmartIndenter.cs -// -// Author: -// Michael Hutchinson <mhutchinson@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; - -namespace MonoDevelop.Ide.Gui.Content -{ - - public interface ISmartIndenter - { - Indent GetIndent (int line); - Indent GetAutoTriggeredReindent (int insertionOffset, int length); - } - - public struct Indent - { - int depth, alignment; - bool isRelative; - - public Indent (int depth, int alignment) - : this (depth, alignment, false) - { - } - - public Indent (int depth, int alignment, bool isRelative) - { - this.depth = depth; - this.alignment = alignment; - this.isRelative = isRelative; - } - - public int Depth { get { return depth; } } - public int Alignment { get { return alignment; } } - public bool IsRelativeToPreviousLine { get { return isRelative; } } - - public bool IsZero { get { return Depth == 0 && Alignment == 0; } } - } -} diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/ITextBuffer.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/ITextBuffer.cs deleted file mode 100644 index 02c2834d25..0000000000 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/ITextBuffer.cs +++ /dev/null @@ -1,46 +0,0 @@ -// -// ITextBuffer.cs -// -// Author: -// Lluis Sanchez Gual -// -// Copyright (C) 2005 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 MonoDevelop.Projects.Text; - -namespace MonoDevelop.Ide.Gui.Content -{ - public interface ITextBuffer: ITextFile - { - //FIXME: this should be a method, it's relatively expensive - string SelectedText { get; set; } - - int CursorPosition { get; set; } - - int SelectionStartPosition { get; } - int SelectionEndPosition { get; } - - void Select (int startPosition, int endPosition); - void ShowPosition (int position); - } -} 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 5c1006a192..6d6ec4ab16 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,39 +26,26 @@ // 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; -using MonoDevelop.Ide.TypeSystem; +using Microsoft.CodeAnalysis; +using MonoDevelop.Ide.Editor; namespace MonoDevelop.Ide.Gui.Content { public interface ITextEditorResolver { - ResolveResult GetLanguageItem (int offset); - ResolveResult GetLanguageItem (int offset, string expression); + ISymbol GetLanguageItem (int offset); + ISymbol GetLanguageItem (int offset, string expression); } public interface ITextEditorResolverProvider { - ResolveResult GetLanguageItem (MonoDevelop.Ide.Gui.Document document, int offset, out DomRegion expressionRegion); - ResolveResult GetLanguageItem (MonoDevelop.Ide.Gui.Document document, int offset, string identifier); - - string CreateTooltip (MonoDevelop.Ide.Gui.Document document, int offset, ResolveResult result, string errorInformations, Gdk.ModifierType modifierState); - - } - - public interface ITextEditorMemberPositionProvider - { - IUnresolvedTypeDefinition GetTypeAt (int offset); - IUnresolvedMember GetMemberAt (int offset); + ISymbol GetLanguageItem (Document document, int offset, out DocumentRegion expressionRegion); + ISymbol GetLanguageItem (Document document, int offset, string identifier); } - - + public static class TextEditorResolverService { static List<TextEditorResolverProviderCodon> providers = new List<TextEditorResolverProviderCodon> (); @@ -85,16 +72,16 @@ namespace MonoDevelop.Ide.Gui.Content return codon.CreateResolver (); } - public static ResolveResult GetLanguageItem (this MonoDevelop.Ide.Gui.Document document, int offset, out DomRegion expressionRegion) - {
- if (document == null)
+ public static ISymbol GetLanguageItem (this Document document, int offset, out DocumentRegion expressionRegion) + { + 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); } - expressionRegion = DomRegion.Empty; + expressionRegion = DocumentRegion.Empty; return null; } } 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; - } - } -} |