diff options
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion')
18 files changed, 639 insertions, 324 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CodeCompletionContextEventArgs.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CodeCompletionContextEventArgs.cs index a658f30b05..5d455b0bb3 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CodeCompletionContextEventArgs.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CodeCompletionContextEventArgs.cs @@ -29,7 +29,7 @@ namespace MonoDevelop.Ide.CodeCompletion { public class CodeCompletionContextEventArgs : EventArgs { - public ICompletionWidget Widget { + internal ICompletionWidget Widget { get; set; } @@ -44,7 +44,7 @@ namespace MonoDevelop.Ide.CodeCompletion set; } - public CodeCompletionContextEventArgs (ICompletionWidget widget, CodeCompletionContext codeCompletionContext, string completedWord) + internal CodeCompletionContextEventArgs (ICompletionWidget widget, CodeCompletionContext codeCompletionContext, string completedWord) { this.Widget = widget; this.CodeCompletionContext = codeCompletionContext; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionCategory.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionCategory.cs new file mode 100644 index 0000000000..fc88fd62b2 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionCategory.cs @@ -0,0 +1,50 @@ +// +// CompletionCategory.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc. (http://xamarin.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.CodeCompletion +{ + public abstract class CompletionCategory : IComparable<CompletionCategory> + { + public string DisplayText { get; set; } + + public string Icon { get; set; } + + protected CompletionCategory () + { + } + + protected CompletionCategory (string displayText, string icon) + { + this.DisplayText = displayText; + this.Icon = icon; + } + + public abstract int CompareTo (CompletionCategory other); + } + +} + diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionData.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionData.cs index 2303d06b5e..e93c4687d0 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionData.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionData.cs @@ -30,11 +30,11 @@ using System; using System.Collections.Generic; using System.Linq; using MonoDevelop.Core; -using ICSharpCode.NRefactory.Completion; +using MonoDevelop.Ide.Editor.Extension; namespace MonoDevelop.Ide.CodeCompletion { - public class CompletionData : ICompletionData, IComparable + public class CompletionData : IComparable { protected CompletionData () {} @@ -43,6 +43,13 @@ namespace MonoDevelop.Ide.CodeCompletion public virtual string Description { get; set; } public virtual string CompletionText { get; set; } + /// <summary> + /// int.MaxValue == highest prioriy, + /// -int.MaxValue == lowest priority + /// </summary> + /// <value>The priority group.</value> + public virtual int PriorityGroup { get { return 0; } } + public virtual string GetDisplayDescription (bool isSelected) { return null; @@ -70,13 +77,13 @@ namespace MonoDevelop.Ide.CodeCompletion } } - public virtual IEnumerable<ICompletionData> OverloadedData { + public virtual IReadOnlyList<CompletionData> OverloadedData { get { throw new InvalidOperationException (); } } - public virtual void AddOverload (ICompletionData data) + public virtual void AddOverload (CompletionData data) { throw new InvalidOperationException (); } @@ -102,7 +109,7 @@ namespace MonoDevelop.Ide.CodeCompletion return result; } - public virtual void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, Gdk.Key closeChar, char keyChar, Gdk.ModifierType modifier) + public virtual void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, KeyDescriptor descriptor) { var currentWord = GetCurrentWord (window); window.CompletionWidget.SetCompletionText (window.CodeCompletionContext, currentWord, CompletionText); @@ -117,12 +124,12 @@ namespace MonoDevelop.Ide.CodeCompletion public virtual int CompareTo (object obj) { - if (!(obj is ICompletionData)) + if (!(obj is CompletionData)) return 0; - return Compare (this, (ICompletionData)obj); + return Compare (this, (CompletionData)obj); } - public static int Compare (ICompletionData a, ICompletionData b) + public static int Compare (CompletionData a, CompletionData b) { var result = ((a.DisplayFlags & DisplayFlags.Obsolete) == (b.DisplayFlags & DisplayFlags.Obsolete)) ? StringComparer.OrdinalIgnoreCase.Compare (a.DisplayText, b.DisplayText) : (a.DisplayFlags & DisplayFlags.Obsolete) != 0 ? 1 : -1; if (result == 0) { @@ -133,7 +140,7 @@ namespace MonoDevelop.Ide.CodeCompletion if (aIsImport && !bIsImport) return 1; if (aIsImport && bIsImport) - return StringComparer.Ordinal.Compare (a.Description, b.Description); + return StringComparer.Ordinal.Compare (((CompletionData)a).Description, ((CompletionData)b).Description); var ca = a as CompletionData; var cb = b as CompletionData; if (ca != null && cb != null && !ca.Icon.IsNull && !cb.Icon.IsNull) { @@ -144,5 +151,19 @@ namespace MonoDevelop.Ide.CodeCompletion } #endregion + + protected string ApplyDiplayFlagsFormatting (string markup) + { + if (!HasOverloads && (DisplayFlags & DisplayFlags.Obsolete) != 0 || HasOverloads && OverloadedData.All (data => (data.DisplayFlags & DisplayFlags.Obsolete) != 0)) + return "<s>" + markup + "</s>"; + if ((DisplayFlags & DisplayFlags.MarkedBold) != 0) + return "<b>" + markup + "</b>"; + return markup; + } + + public virtual string GetDisplayTextMarkup () + { + return ApplyDiplayFlagsFormatting (GLib.Markup.EscapeText (DisplayText)); + } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionDataList.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionDataList.cs index 2311475497..e0c21b8177 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionDataList.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionDataList.cs @@ -30,12 +30,14 @@ using System; using System.Collections.Generic; using System.Linq; using MonoDevelop.Core; -using ICSharpCode.NRefactory.Completion; +using MonoDevelop.Ide.Editor.Extension; namespace MonoDevelop.Ide.CodeCompletion { - public interface ICompletionDataList : IList<ICompletionData> + public interface ICompletionDataList : IList<CompletionData> { + int TriggerWordLength { get; } + bool IsSorted { get; } bool AutoCompleteUniqueMatch { get; } bool AutoCompleteEmptyMatch { get; } @@ -44,8 +46,8 @@ namespace MonoDevelop.Ide.CodeCompletion bool AutoSelect { get; } string DefaultCompletionString { get; } CompletionSelectionMode CompletionSelectionMode { get; } - void Sort (Comparison<ICompletionData> comparison); - void Sort (IComparer<ICompletionData> comparison); + void Sort (Comparison<CompletionData> comparison); + void Sort (IComparer<CompletionData> comparison); IEnumerable<ICompletionKeyHandler> KeyHandler { get; } @@ -56,8 +58,8 @@ namespace MonoDevelop.Ide.CodeCompletion public interface ICompletionKeyHandler { - bool PreProcessKey (CompletionListWindow listWindow, Gdk.Key key, char keyChar, Gdk.ModifierType modifier, out KeyActions keyAction); - bool PostProcessKey (CompletionListWindow listWindow, Gdk.Key key, char keyChar, Gdk.ModifierType modifier, out KeyActions keyAction); + bool PreProcessKey (CompletionListWindow listWindow, KeyDescriptor descriptor, out KeyActions keyAction); + bool PostProcessKey (CompletionListWindow listWindow, KeyDescriptor descriptor, out KeyActions keyAction); } public enum CompletionSelectionMode { @@ -65,10 +67,12 @@ namespace MonoDevelop.Ide.CodeCompletion OwnTextField } - public class CompletionDataList : List<ICompletionData>, ICompletionDataList + public class CompletionDataList : List<CompletionData>, ICompletionDataList { + public int TriggerWordLength { get; set; } + public bool IsSorted { get; set; } - public IComparer<ICompletionData> Comparer { get; set; } + public IComparer<CompletionData> Comparer { get; set; } public bool AutoCompleteUniqueMatch { get; set; } public string DefaultCompletionString { get; set; } @@ -87,7 +91,7 @@ namespace MonoDevelop.Ide.CodeCompletion this.AutoSelect = true; } - public CompletionDataList (IEnumerable<ICompletionData> data) : base(data) + public CompletionDataList (IEnumerable<CompletionData> data) : base(data) { this.AutoSelect = true; } @@ -144,7 +148,7 @@ namespace MonoDevelop.Ide.CodeCompletion return false; } - public void RemoveWhere (Func<ICompletionData,bool> shouldRemove) + public void RemoveWhere (Func<CompletionData,bool> shouldRemove) { for (int i = 0; i < this.Count;) { if (shouldRemove (this[i])) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionListWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionListWindow.cs index 224fa14b54..d31732a305 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionListWindow.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionListWindow.cs @@ -32,8 +32,8 @@ using Gtk; using MonoDevelop.Core; using MonoDevelop.Components; using System.Linq; -using ICSharpCode.NRefactory.Completion; -using Mono.TextEditor.PopupWindow; +using MonoDevelop.Ide.Editor.Extension; +using System.ComponentModel; namespace MonoDevelop.Ide.CodeCompletion { @@ -42,11 +42,11 @@ namespace MonoDevelop.Ide.CodeCompletion const int declarationWindowMargin = 3; TooltipInformationWindow declarationviewwindow; - ICompletionData currentData; + CompletionData currentData; Widget parsingMessage; int initialWordLength; int previousWidth = -1, previousHeight = -1; - + public CodeCompletionContext CodeCompletionContext { get; set; @@ -60,7 +60,6 @@ namespace MonoDevelop.Ide.CodeCompletion } IMutableCompletionDataList mutableList; - ICompletionDataList completionDataList; public ICompletionDataList CompletionDataList { get { return completionDataList; } set { @@ -93,7 +92,7 @@ namespace MonoDevelop.Ide.CodeCompletion List.QueueDraw (); }; previewEntry.KeyPressEvent += delegate(object o, KeyPressEventArgs args) { - var keyAction = PreProcessKey (args.Event.Key, (char)args.Event.KeyValue, args.Event.State); + var keyAction = PreProcessKey (KeyDescriptor.FromGtk (args.Event.Key, (char)args.Event.KeyValue, args.Event.State)); if (keyAction.HasFlag (KeyActions.Complete)) CompleteWord (); @@ -189,61 +188,81 @@ namespace MonoDevelop.Ide.CodeCompletion base.OnDestroyed (); } - public void PostProcessKeyEvent (Gdk.Key key, char keyChar, Gdk.ModifierType modifier) + public void PostProcessKeyEvent (KeyDescriptor descriptor) { KeyActions ka = KeyActions.None; bool keyHandled = false; - foreach (var handler in CompletionDataList.KeyHandler) { - if (handler.PostProcessKey (this, key, keyChar, modifier, out ka)) { - keyHandled = true; - break; + if (CompletionDataList != null) { + foreach (var handler in CompletionDataList.KeyHandler) { + if (handler.PostProcessKey (this, descriptor, out ka)) { + keyHandled = true; + break; + } } } if (!keyHandled) - ka = PostProcessKey (key, keyChar, modifier); + ka = PostProcessKey (descriptor); if ((ka & KeyActions.Complete) != 0) - CompleteWord (ref ka, key, keyChar, modifier); - if ((ka & KeyActions.CloseWindow) != 0) + CompleteWord (ref ka, descriptor); + if ((ka & KeyActions.CloseWindow) != 0) { CompletionWindowManager.HideWindow (); + OnWindowClosed (EventArgs.Empty); + } + } + + /// <summary> + /// For unit test purposes. + /// </summary> + [EditorBrowsableAttribute(EditorBrowsableState.Never)] + internal event EventHandler WindowClosed; + + protected virtual void OnWindowClosed (EventArgs e) + { + var handler = WindowClosed; + if (handler != null) + handler (this, e); } public void ToggleCategoryMode () { - List.InCategoryMode = !List.InCategoryMode; + ListWidget.EnableCompletionCategoryMode.Set (!ListWidget.EnableCompletionCategoryMode.Value); + List.UpdateCategoryMode (); ResetSizes (); List.QueueDraw (); } - public bool PreProcessKeyEvent (Gdk.Key key, char keyChar, Gdk.ModifierType modifier) + public bool PreProcessKeyEvent (KeyDescriptor descriptor) { - if (key == Gdk.Key.Escape) { + if (descriptor.SpecialKey == SpecialKey.Escape) { CompletionWindowManager.HideWindow (); return true; } KeyActions ka = KeyActions.None; bool keyHandled = false; - foreach (ICompletionKeyHandler handler in CompletionDataList.KeyHandler) { - if (handler.PreProcessKey (this, key, keyChar, modifier, out ka)) { - keyHandled = true; - break; + if (CompletionDataList != null) { + foreach (ICompletionKeyHandler handler in CompletionDataList.KeyHandler) { + if (handler.PreProcessKey (this, descriptor, out ka)) { + keyHandled = true; + break; + } } } - if (!keyHandled) - ka = PreProcessKey (key, keyChar, modifier); + ka = PreProcessKey (descriptor); if ((ka & KeyActions.Complete) != 0) - CompleteWord (ref ka, key, keyChar, modifier); + CompleteWord (ref ka, descriptor); - if ((ka & KeyActions.CloseWindow) != 0) + if ((ka & KeyActions.CloseWindow) != 0) { CompletionWindowManager.HideWindow (); + OnWindowClosed (EventArgs.Empty); + } if ((ka & KeyActions.Ignore) != 0) return true; - if ((ka & KeyActions.Process) != 0) { - if (key == Gdk.Key.Left || key == Gdk.Key.Right) { + if (descriptor.SpecialKey == SpecialKey.Left || descriptor.SpecialKey == SpecialKey.Right) { // Close if there's a modifier active EXCEPT lock keys and Modifiers // Makes an exception for Mod1Mask (usually alt), shift, control, meta and super // This prevents the window from closing if the num/scroll/caps lock are active @@ -252,19 +271,21 @@ namespace MonoDevelop.Ide.CodeCompletion // if ((modifier & ~(Gdk.ModifierType.LockMask | (Gdk.ModifierType.ModifierMask & ~(Gdk.ModifierType.ShiftMask | Gdk.ModifierType.Mod1Mask | Gdk.ModifierType.ControlMask | Gdk.ModifierType.MetaMask | Gdk.ModifierType.SuperMask)))) != 0) { // this version doesn't work for my system - seems that I've a modifier active // that gdk doesn't know about. How about the 2nd version - should close on left/rigt + shift/mod1/control/meta/super - if ((modifier & (Gdk.ModifierType.ShiftMask | Gdk.ModifierType.Mod1Mask | Gdk.ModifierType.ControlMask | Gdk.ModifierType.MetaMask | Gdk.ModifierType.SuperMask)) != 0) { + if ((descriptor.ModifierKeys & (ModifierKeys.Shift | ModifierKeys.Alt | ModifierKeys.Control | ModifierKeys.Command)) != 0) { CompletionWindowManager.HideWindow (); + OnWindowClosed (EventArgs.Empty); return false; } if (declarationviewwindow != null && declarationviewwindow.Multiple) { - if (key == Gdk.Key.Left) + if (descriptor.SpecialKey == SpecialKey.Left) declarationviewwindow.OverloadLeft (); else declarationviewwindow.OverloadRight (); UpdateDeclarationView (); } else { CompletionWindowManager.HideWindow (); + OnWindowClosed (EventArgs.Empty); return false; } return true; @@ -286,8 +307,8 @@ namespace MonoDevelop.Ide.CodeCompletion { if (list == null) throw new ArgumentNullException ("list"); - if (completionContext == null) - throw new ArgumentNullException ("completionContext"); + if (completionWidget == null) + throw new ArgumentNullException ("completionWidget"); if (completionContext == null) throw new ArgumentNullException ("completionContext"); if (mutableList != null) { @@ -355,9 +376,9 @@ namespace MonoDevelop.Ide.CodeCompletion return false; } - class DataItemComparer : IComparer<ICompletionData> + class DataItemComparer : IComparer<CompletionData> { - public int Compare (ICompletionData a, ICompletionData b) + public int Compare (CompletionData a, CompletionData b) { if (a is IComparable && b is IComparable) return ((IComparable)a).CompareTo (b); @@ -365,7 +386,7 @@ namespace MonoDevelop.Ide.CodeCompletion } } - IComparer<ICompletionData> GetComparerForCompletionList (ICompletionDataList dataList) + IComparer<CompletionData> GetComparerForCompletionList (ICompletionDataList dataList) { var concrete = dataList as CompletionDataList; return concrete != null && concrete.Comparer != null ? concrete.Comparer : new DataItemComparer (); @@ -443,23 +464,40 @@ namespace MonoDevelop.Ide.CodeCompletion public bool CompleteWord () { KeyActions ka = KeyActions.None; - return CompleteWord (ref ka, (Gdk.Key)0, '\0', Gdk.ModifierType.None); + return CompleteWord (ref ka, KeyDescriptor.Empty); } - - public bool CompleteWord (ref KeyActions ka, Gdk.Key closeChar, char keyChar, Gdk.ModifierType modifier) + + internal bool IsInCompletion { get; set; } + + public bool CompleteWord (ref KeyActions ka, KeyDescriptor descriptor) { if (SelectedItem == -1 || completionDataList == null) return false; var item = completionDataList [SelectedItem]; if (item == null) return false; - // first close the completion list, then insert the text. - // this is required because that's the logical event chain, otherwise things could be messed up - CloseCompletionList (); - ((CompletionData)item).InsertCompletionText (this, ref ka, closeChar, keyChar, modifier); - AddWordToHistory (PartialWord, item.CompletionText); - OnWordCompleted (new CodeCompletionContextEventArgs (CompletionWidget, CodeCompletionContext, item.CompletionText)); - return true; + IsInCompletion = true; + try {
+ // first close the completion list, then insert the text.
+ // this is required because that's the logical event chain, otherwise things could be messed up
+ CloseCompletionList ();
+ /* var cdItem = (CompletionData)item; + cdItem.InsertCompletionText (this, ref ka, closeChar, keyChar, modifier); + AddWordToHistory (PartialWord, cdItem.CompletionText); + OnWordCompleted (new CodeCompletionContextEventArgs (CompletionWidget, CodeCompletionContext, cdItem.CompletionText)); + */
+ if (item.HasOverloads && declarationviewwindow.CurrentOverload >= 0 && declarationviewwindow.CurrentOverload < item.OverloadedData.Count) { + item.OverloadedData[declarationviewwindow.CurrentOverload].InsertCompletionText (this, ref ka, descriptor); + } else { + item.InsertCompletionText (this, ref ka, descriptor); + } + cache.CommitCompletionData (item); + OnWordCompleted (new CodeCompletionContextEventArgs (CompletionWidget, CodeCompletionContext, item.DisplayText)); + } finally { + IsInCompletion = false; + CompletionWindowManager.HideWindow (); + } + return true; } protected virtual void OnWordCompleted (CodeCompletionContextEventArgs e) @@ -587,17 +625,17 @@ namespace MonoDevelop.Ide.CodeCompletion return false; var data = completionDataList [selectedItem]; - IEnumerable<ICompletionData> filteredOverloads; + IEnumerable<CompletionData> filteredOverloads; if (data.HasOverloads) { filteredOverloads = data.OverloadedData; } else { - filteredOverloads = new ICompletionData[] { data }; + filteredOverloads = new CompletionData[] { data }; } EnsureDeclarationViewWindow (); if (data != currentData) { declarationviewwindow.Clear (); - var overloads = new List<ICompletionData> (filteredOverloads); + var overloads = new List<CompletionData> (filteredOverloads); foreach (var overload in overloads) { declarationviewwindow.AddOverload ((CompletionData)overload); } @@ -626,7 +664,7 @@ namespace MonoDevelop.Ide.CodeCompletion return false; } - protected override void ResetState () + protected internal override void ResetState () { StartOffset = 0; previousWidth = previousHeight = -1; @@ -663,28 +701,27 @@ namespace MonoDevelop.Ide.CodeCompletion bool IListDataProvider.HasMarkup (int n) { - return (completionDataList [n].DisplayFlags & (DisplayFlags.Obsolete | DisplayFlags.MarkedBold)) != 0; + return true; } //NOTE: we only ever return markup for items marked as obsolete string IListDataProvider.GetMarkup (int n) { var completionData = completionDataList[n]; - if (!completionData.HasOverloads && (completionData.DisplayFlags & DisplayFlags.Obsolete) != 0 || - completionData.HasOverloads && completionData.OverloadedData.All (data => (data.DisplayFlags & DisplayFlags.Obsolete) != 0)) - return "<s>" + GLib.Markup.EscapeText (completionDataList[n].DisplayText) + "</s>"; - - if ((completionData.DisplayFlags & DisplayFlags.MarkedBold) != 0) - return "<b>" + GLib.Markup.EscapeText (completionDataList[n].DisplayText) + "</b>"; - return GLib.Markup.EscapeText (completionDataList[n].DisplayText); + return completionData.GetDisplayTextMarkup (); } string IListDataProvider.GetCompletionText (int n) { - return completionDataList[n].CompletionText; + return ((CompletionData)completionDataList[n]).CompletionText; + } + + CompletionData IListDataProvider.GetCompletionData (int n) + { + return completionDataList[n]; } - IComparer<ICompletionData> defaultComparer; + IComparer<CompletionData> defaultComparer; int IListDataProvider.CompareTo (int n, int m) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionWindowManager.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionWindowManager.cs index ab723739b3..b383b7b65d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionWindowManager.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionWindowManager.cs @@ -27,6 +27,7 @@ using System; using MonoDevelop.Core; using MonoDevelop.Ide.Gui.Content; +using MonoDevelop.Ide.Editor.Extension; namespace MonoDevelop.Ide.CodeCompletion { @@ -80,20 +81,22 @@ namespace MonoDevelop.Ide.CodeCompletion } // ext may be null, but then parameter completion don't work - public static bool ShowWindow (CompletionTextEditorExtension ext, char firstChar, ICompletionDataList list, ICompletionWidget completionWidget, CodeCompletionContext completionContext) + internal static bool ShowWindow (CompletionTextEditorExtension ext, char firstChar, ICompletionDataList list, ICompletionWidget completionWidget, CodeCompletionContext completionContext) { try { if (ext != null) { - int inserted = ext.document.Editor.EnsureCaretIsNotVirtual (); + int inserted = ext.Editor.EnsureCaretIsNotVirtual (); if (inserted > 0) - completionContext.TriggerOffset = ext.document.Editor.Caret.Offset; + completionContext.TriggerOffset = ext.Editor.CaretOffset; } if (wnd == null) { wnd = new CompletionListWindow (); wnd.WordCompleted += HandleWndWordCompleted; } - if (ext != null) - wnd.TransientFor = ext.document.Editor.Parent.Toplevel as Gtk.Window; + if (ext != null) { + var widget = ext.Editor.GetNativeWidget<Gtk.Widget> (); + wnd.TransientFor = widget?.Parent?.Toplevel as Gtk.Window; + } wnd.Extension = ext; try { if (!wnd.ShowListWindow (firstChar, list, completionWidget, completionContext)) { @@ -136,21 +139,22 @@ namespace MonoDevelop.Ide.CodeCompletion OnWindowClosed (EventArgs.Empty); } - public static bool PreProcessKeyEvent (Gdk.Key key, char keyChar, Gdk.ModifierType modifier) + public static bool PreProcessKeyEvent (KeyDescriptor descriptor) { if (!IsVisible) return false; - if (keyChar != '\0') { + if (descriptor.KeyChar != '\0') { wnd.EndOffset = wnd.StartOffset + wnd.CurrentPartialWord.Length + 1; } - return wnd.PreProcessKeyEvent (key, keyChar, modifier); + return wnd.PreProcessKeyEvent (descriptor); } public static void UpdateCursorPosition () { if (!IsVisible) return; - + if (wnd.IsInCompletion) + return; var caretOffset = wnd.CompletionWidget.CaretOffset; if (caretOffset < wnd.StartOffset || caretOffset > wnd.EndOffset) HideWindow (); @@ -164,11 +168,11 @@ namespace MonoDevelop.Ide.CodeCompletion } } - public static void PostProcessKeyEvent (Gdk.Key key, char keyChar, Gdk.ModifierType modifier) + public static void PostProcessKeyEvent (KeyDescriptor descriptor) { if (!IsVisible) return; - wnd.PostProcessKeyEvent (key, keyChar, modifier); + wnd.PostProcessKeyEvent (descriptor); } public static void RepositionWindow () @@ -184,7 +188,7 @@ namespace MonoDevelop.Ide.CodeCompletion return; ParameterInformationWindowManager.UpdateWindow (wnd.Extension, wnd.CompletionWidget); if (wnd.Extension != null) - wnd.Extension.document.Editor.FixVirtualIndentation (); + wnd.Extension.Editor.FixVirtualIndentation (); wnd.HideWindow (); OnWindowClosed (EventArgs.Empty); //DestroyWindow (); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/DisplayFlags.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/DisplayFlags.cs new file mode 100644 index 0000000000..0450a0f7d2 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/DisplayFlags.cs @@ -0,0 +1,42 @@ +// +// DisplayFlags.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc. (http://xamarin.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.CodeCompletion +{ + [Flags] + public enum DisplayFlags + { + None = 0, + Hidden = 1, + Obsolete = 2, + DescriptionHasMarkup = 4, + NamedArgument = 8, + IsImportCompletion = 16, + MarkedBold = 32 + } +} diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ICompletionWidget.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ICompletionWidget.cs index 668359506a..1824432bb9 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ICompletionWidget.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ICompletionWidget.cs @@ -31,29 +31,33 @@ using Gtk; namespace MonoDevelop.Ide.CodeCompletion { - public interface ICompletionWidget + interface ICompletionWidget { - CodeCompletionContext CurrentCodeCompletionContext { + CodeCompletionContext CurrentCodeCompletionContext + { get; } - int CaretOffset { get;} + int CaretOffset { get; set; } int TextLength { get; } int SelectedLength { get; } string GetText (int startOffset, int endOffset); - + char GetChar (int offset); - + void Replace (int offset, int count, string text); - + Gtk.Style GtkStyle { get; } + double ZoomLevel { get; } CodeCompletionContext CreateCodeCompletionContext (int triggerOffset); string GetCompletionText (CodeCompletionContext ctx); void SetCompletionText (CodeCompletionContext ctx, string partial_word, string complete_word); - + void SetCompletionText (CodeCompletionContext ctx, string partial_word, string complete_word, int completeWordOffset); - + + void AddSkipChar (int cursorPosition, char c); + event EventHandler CompletionContextChanged; } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWidget.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWidget.cs index 0b607df034..72367422a9 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWidget.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWidget.cs @@ -30,12 +30,14 @@ using System.Linq; using Gdk; using Gtk; using Pango; -using ICSharpCode.NRefactory.Completion; -using Mono.TextEditor; -using Mono.TextEditor.Highlighting; +using ICSharpCode.NRefactory6.CSharp.Completion; using MonoDevelop.Components; using MonoDevelop.Ide.Fonts; -using MonoDevelop.Ide.Gui.Content;
+using MonoDevelop.Ide.Gui.Content; +using MonoDevelop.Ide.Editor; +using System.ComponentModel.Design; +using MonoDevelop.Ide.Editor.Highlighting; +using MonoDevelop.Ide.Editor.Extension; using MonoDevelop.Core; namespace MonoDevelop.Ide.CodeCompletion @@ -95,26 +97,27 @@ namespace MonoDevelop.Ide.CodeCompletion public bool CloseOnSquareBrackets { get; set; - }
-
- public readonly static PropertyWrapper<bool> EnableCompletionCategoryMode = PropertyService.Wrap("EnableCompletionCategoryMode", false);
-
+ } + + public readonly static PropertyWrapper<bool> EnableCompletionCategoryMode = PropertyService.Wrap("EnableCompletionCategoryMode", false); + public bool InCategoryMode { - get { return EnableCompletionCategoryMode; } - set { - EnableCompletionCategoryMode.Set(value); + get { return EnableCompletionCategoryMode && categories.Count > 1; } + } - CalcVisibleRows (); - if (value) - SelectFirstItemInCategory (); - } + internal void UpdateCategoryMode () + { + CalcVisibleRows (); + if (InCategoryMode) + SelectFirstItemInCategory (); } + public int CategoryCount { get { return this.categories.Count; } } ICompletionWidget completionWidget; - public ICompletionWidget CompletionWidget { + internal ICompletionWidget CompletionWidget { get { return completionWidget; } @@ -141,14 +144,11 @@ namespace MonoDevelop.Ide.CodeCompletion // TODO: Add font property to ICompletionWidget; if (itemFont != null) itemFont.Dispose (); - itemFont = FontService.GetFontDescription ("Editor").Copy (); - var provider = CompletionWidget as ITextEditorDataProvider; - if (provider != null) { - var newSize = (itemFont.Size * provider.GetTextEditorData ().Options.Zoom); - if (newSize > 0) { - itemFont.Size = (int)newSize; - layout.FontDescription = itemFont; - } + itemFont = FontService.MonospaceFont.Copy (); + var newSize = (itemFont.Size * (completionWidget != null ? this.completionWidget.ZoomLevel : 1)); + if (newSize > 0) { + itemFont.Size = (int)newSize; + layout.FontDescription = itemFont; } } @@ -380,9 +380,17 @@ namespace MonoDevelop.Ide.CodeCompletion public bool SelectionEnabled { get { - return AutoSelect && (AutoCompleteEmptyMatch || !string.IsNullOrEmpty (CompletionString)); + return AutoSelect && (AutoCompleteEmptyMatch || !IsEmptyMatch (CompletionString)); } } + + static bool IsEmptyMatch (string completionString) + { + if (string.IsNullOrEmpty (completionString)) + return true; + var ch = completionString [0]; + return char.IsDigit (ch); + } protected override bool OnButtonPressEvent (EventButton e) { @@ -656,7 +664,7 @@ namespace MonoDevelop.Ide.CodeCompletion }); categories = newCategories; - SelectFirstItemInCategory (); + //SelectFirstItemInCategory (); CalcVisibleRows (); SetAdjustments (); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWindow.cs index 97f12ae487..0a2edce515 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWindow.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWindow.cs @@ -25,21 +25,20 @@ // // -using Gtk; -using Gdk; -using Pango; using System; -using System.Xml; -using System.Linq; -using System.Text; using System.Collections.Generic; using MonoDevelop.Core.Text; -using ICSharpCode.NRefactory.Completion; -using Mono.TextEditor; +using ICSharpCode.NRefactory6.CSharp.Completion; using MonoDevelop.Ide.Gui.Content; +using System.Linq; +using Gdk; +using Gtk; +using MonoDevelop.Core.Text; using MonoDevelop.Components; -using Mono.TextEditor.Highlighting; -using MonoDevelop.Core; +using MonoDevelop.Ide.Gui.Content; +using MonoDevelop.Ide.Editor; +using MonoDevelop.Ide.Editor.Highlighting; +using MonoDevelop.Ide.Editor.Extension; namespace MonoDevelop.Ide.CodeCompletion { @@ -60,7 +59,9 @@ namespace MonoDevelop.Ide.CodeCompletion ListWidget list; Widget footer; protected VBox vbox; - + internal MruCache cache = new MruCache(); + protected ICompletionDataList completionDataList; + public CompletionTextEditorExtension Extension { get; set; @@ -129,7 +130,7 @@ namespace MonoDevelop.Ide.CodeCompletion /// This method is used to set the completion window to it's inital state. /// This is required for re-using the window object. /// </summary> - protected virtual void ResetState () + protected internal virtual void ResetState () { HideWhenWordDeleted = false; lastCommitCharEndoffset = -1; @@ -226,7 +227,7 @@ namespace MonoDevelop.Ide.CodeCompletion set; } - public ICompletionWidget CompletionWidget { + internal ICompletionWidget CompletionWidget { get { return list.CompletionWidget; } @@ -273,20 +274,21 @@ namespace MonoDevelop.Ide.CodeCompletion private set; } - public KeyActions PostProcessKey (Gdk.Key key, char keyChar, Gdk.ModifierType modifier) + public KeyActions PostProcessKey (KeyDescriptor descriptor) { - if (StartOffset > CompletionWidget.CaretOffset) + if (CompletionWidget == null || StartOffset > CompletionWidget.CaretOffset) // CompletionWidget == null may happen in unit tests. return KeyActions.CloseWindow | KeyActions.Process; if (HideWhenWordDeleted && StartOffset >= CompletionWidget.CaretOffset) return KeyActions.CloseWindow | KeyActions.Process; - switch (key) { - case Gdk.Key.BackSpace: + switch (descriptor.SpecialKey) { + case SpecialKey.BackSpace: ResetSizes (); UpdateWordSelection (); return KeyActions.Process; } - + var keyChar = descriptor.KeyChar; + const string commitChars = " <>()[]{}=+-*/%~&^|!.,;:"; if (keyChar == '[' && CloseOnSquareBrackets) return KeyActions.Process | KeyActions.CloseWindow; @@ -306,13 +308,13 @@ namespace MonoDevelop.Ide.CodeCompletion if (!text.ToUpper ().StartsWith (curword.ToUpper (), StringComparison.Ordinal)) match = -1; } - if (match >= 0 && !hasMismatches && keyChar != '<') { + if (match >= 0 && !hasMismatches && keyChar != '<' && keyChar != ' ') { ResetSizes (); UpdateWordSelection (); return KeyActions.Process; } - if (keyChar == '.') - list.AutoSelect = list.AutoCompleteEmptyMatch = true; +// if (keyChar == '.') +// list.AutoSelect = list.AutoCompleteEmptyMatch = true; lastCommitCharEndoffset = CompletionWidget.CaretOffset - 1; if (list.SelectionEnabled && CompletionCharacters.CompleteOn (keyChar)) { @@ -322,30 +324,47 @@ namespace MonoDevelop.Ide.CodeCompletion } return KeyActions.CloseWindow | KeyActions.Process; } - + + if (char.IsPunctuation (descriptor.KeyChar) && descriptor.KeyChar != '_') { + if (descriptor.KeyChar == ':') { + foreach (var item in FilteredItems) { + if (DataProvider.GetText (item).EndsWith (descriptor.KeyChar.ToString (), StringComparison.Ordinal)) { + list.SelectedItem = item; + return KeyActions.Complete | KeyActions.CloseWindow | KeyActions.Ignore; + } + } + } else { + var selectedItem = list.SelectedItem; + if (selectedItem < 0 || selectedItem >= DataProvider.ItemCount) + return KeyActions.CloseWindow; + if (!DataProvider.GetText (selectedItem).Substring (0, CurrentPartialWord.Length) .EndsWith (descriptor.KeyChar.ToString (), StringComparison.Ordinal)) + return KeyActions.Process | KeyActions.CloseWindow; + } + } return KeyActions.Process; } - public KeyActions PreProcessKey (Gdk.Key key, char keyChar, Gdk.ModifierType modifier) + public KeyActions PreProcessKey (KeyDescriptor descriptor) { - switch (key) { - case Gdk.Key.Home: - if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask) + switch (descriptor.SpecialKey) { + case SpecialKey.Home: + if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift) return KeyActions.Process; List.SelectionFilterIndex = 0; return KeyActions.Ignore; - case Gdk.Key.End: - if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask) + case SpecialKey.End: + if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift) return KeyActions.Process; List.SelectionFilterIndex = List.filteredItems.Count - 1; return KeyActions.Ignore; - case Gdk.Key.Up: - if ((modifier & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask) { + case SpecialKey.Up: + if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift) { if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/) AutoCompleteEmptyMatch = AutoSelect = true; if (!List.InCategoryMode) { - List.InCategoryMode = true; + ListWidget.EnableCompletionCategoryMode.Set (true); + List.UpdateCategoryMode (); return KeyActions.Ignore; } List.MoveToCategory (-1); @@ -360,25 +379,23 @@ namespace MonoDevelop.Ide.CodeCompletion } return KeyActions.Ignore; - case Gdk.Key.Tab: + case SpecialKey.Tab: //tab always completes current item even if selection is disabled if (!AutoSelect) AutoSelect = true; - goto case Gdk.Key.Return; + goto case SpecialKey.Return; - case Gdk.Key.Return: - case Gdk.Key.ISO_Enter: - case Gdk.Key.Key_3270_Enter: - case Gdk.Key.KP_Enter: + case SpecialKey.Return: lastCommitCharEndoffset = CompletionWidget.CaretOffset; - WasShiftPressed = (modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask; + WasShiftPressed = (descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift; return KeyActions.Complete | KeyActions.Ignore | KeyActions.CloseWindow; - case Gdk.Key.Down: - if ((modifier & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask) { + case SpecialKey.Down: + if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift) { if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/) AutoCompleteEmptyMatch = AutoSelect = true; if (!List.InCategoryMode) { - List.InCategoryMode = true; + ListWidget.EnableCompletionCategoryMode.Set (true); + List.UpdateCategoryMode (); return KeyActions.Ignore; } List.MoveToCategory (1); @@ -394,8 +411,8 @@ namespace MonoDevelop.Ide.CodeCompletion } return KeyActions.Ignore; - case Gdk.Key.Page_Up: - if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask) + case SpecialKey.PageUp: + if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift) return KeyActions.Process; if (list.filteredItems.Count < 2) return KeyActions.CloseWindow | KeyActions.Process; @@ -403,8 +420,8 @@ namespace MonoDevelop.Ide.CodeCompletion list.MoveCursor (-8); return KeyActions.Ignore; - case Gdk.Key.Page_Down: - if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask) + case SpecialKey.PageDown: + if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift) return KeyActions.Process; if (list.filteredItems.Count < 2) return KeyActions.CloseWindow | KeyActions.Process; @@ -412,42 +429,42 @@ namespace MonoDevelop.Ide.CodeCompletion list.MoveCursor (8); return KeyActions.Ignore; - case Gdk.Key.Left: + case SpecialKey.Left: //if (curPos == 0) return KeyActions.CloseWindow | KeyActions.Process; //curPos--; return KeyActions.Process; - case Gdk.Key.Right: + case SpecialKey.Right: //if (curPos == word.Length) return KeyActions.CloseWindow | KeyActions.Process; //curPos++; return KeyActions.Process; - case Gdk.Key.Caps_Lock: - case Gdk.Key.Num_Lock: - case Gdk.Key.Scroll_Lock: - return KeyActions.Ignore; - - case Gdk.Key.Control_L: - case Gdk.Key.Control_R: - case Gdk.Key.Alt_L: - case Gdk.Key.Alt_R: - case Gdk.Key.Shift_L: - case Gdk.Key.Shift_R: - case Gdk.Key.ISO_Level3_Shift: - // AltGr - return KeyActions.Process; +// case Gdk.Key.Caps_Lock: +// case Gdk.Key.Num_Lock: +// case Gdk.Key.Scroll_Lock: +// return KeyActions.Ignore; +// +// case Gdk.Key.Control_L: +// case Gdk.Key.Control_R: +// case Gdk.Key.Alt_L: +// case Gdk.Key.Alt_R: +// case Gdk.Key.Shift_L: +// case Gdk.Key.Shift_R: +// case Gdk.Key.ISO_Level3_Shift: +// // AltGr +// return KeyActions.Process; } - if (keyChar == '\0') + if (descriptor.KeyChar == '\0') return KeyActions.Process; - if (keyChar == ' ' && (modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask) + if (descriptor.KeyChar == ' ' && (descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift) return KeyActions.CloseWindow | KeyActions.Process; // special case end with punctuation like 'param:' -> don't input double punctuation, otherwise we would end up with 'param::' - if (char.IsPunctuation (keyChar) && keyChar != '_') { - if (keyChar == ':') { + if (char.IsPunctuation (descriptor.KeyChar) && descriptor.KeyChar != '_') { + if (descriptor.KeyChar == ':') { foreach (var item in FilteredItems) { - if (DataProvider.GetText (item).EndsWith (keyChar.ToString (), StringComparison.Ordinal)) { + if (DataProvider.GetText (item).EndsWith (descriptor.KeyChar.ToString (), StringComparison.Ordinal)) { list.SelectedItem = item; return KeyActions.Complete | KeyActions.CloseWindow | KeyActions.Ignore; } @@ -456,14 +473,12 @@ namespace MonoDevelop.Ide.CodeCompletion var selectedItem = list.SelectedItem; if (selectedItem < 0 || selectedItem >= DataProvider.ItemCount) return KeyActions.CloseWindow; - if (DataProvider.GetText (selectedItem).EndsWith (keyChar.ToString (), StringComparison.Ordinal)) { + if (DataProvider.GetText (selectedItem).EndsWith (descriptor.KeyChar.ToString (), StringComparison.Ordinal)) { return KeyActions.Complete | KeyActions.CloseWindow | KeyActions.Ignore; } } } - - /* //don't input letters/punctuation etc when non-shift modifiers are active bool nonShiftModifierActive = ((Gdk.ModifierType.ControlMask | Gdk.ModifierType.MetaMask | Gdk.ModifierType.Mod1Mask | Gdk.ModifierType.SuperMask) @@ -544,75 +559,69 @@ namespace MonoDevelop.Ide.CodeCompletion { // default - word with highest match rating in the list. hasMismatches = true; - if (partialWord == null) - return -1; - int idx = -1; - var matcher = CompletionMatcher.CreateCompletionMatcher (partialWord); - string bestWord = null; - int bestRank = int.MinValue; - int bestIndex = 0; + + StringMatcher matcher = null; if (!string.IsNullOrEmpty (partialWord)) { + matcher = CompletionMatcher.CreateCompletionMatcher (partialWord); + string bestWord = null; + int bestRank = int.MinValue; + int bestIndex = 0; + int bestIndexPriority = int.MinValue; for (int i = 0; i < list.filteredItems.Count; i++) { - int index = list.filteredItems[i]; - string text = DataProvider.GetText (index); + int index = list.filteredItems [i]; + var data = DataProvider.GetCompletionData (index); + if (bestIndexPriority > data.PriorityGroup) + continue; + string text = data.DisplayText; int rank; if (!matcher.CalcMatchRank (text, out rank)) continue; - if (rank > bestRank) { + if (rank > bestRank || data.PriorityGroup > bestIndexPriority) { bestWord = text; bestRank = rank; bestIndex = i; + bestIndexPriority = data.PriorityGroup; } } + + if (bestWord != null) { + idx = bestIndex; + hasMismatches = false; + // exact match found. + if (string.Compare (bestWord, partialWord ?? "", true) == 0) + return idx; + } } - if (bestWord != null) { - idx = bestIndex; - hasMismatches = false; - // exact match found. - if (string.Compare (bestWord, partialWord ?? "", true) == 0) - return idx; + + CompletionData currentData; + int bestMruIndex; + if (idx >= 0) { + currentData = completionDataList [list.filteredItems [idx]]; + bestMruIndex = cache.GetIndex (currentData); + } else { + bestMruIndex = int.MaxValue; + currentData = null; } - - if (string.IsNullOrEmpty (partialWord) || partialWord.Length <= 2) { - // Search for history matches. - string historyWord; - if (wordHistory.TryGetValue (partialWord, out historyWord)) { - for (int xIndex = 0; xIndex < list.filteredItems.Count; xIndex++) { - string currentWord = DataProvider.GetCompletionText (list.filteredItems[xIndex]); - if (currentWord == historyWord) { - idx = xIndex; - break; + + for (int i = 0; i < list.filteredItems.Count; i++) { + var mruData = completionDataList [list.filteredItems [i]]; + int curMruIndex = cache.GetIndex (mruData); + if (curMruIndex == 1) + continue; + if (curMruIndex < bestMruIndex) { + int r1 = 0, r2 = 0; + if (currentData == null || matcher != null && matcher.CalcMatchRank (mruData.DisplayText, out r1) && matcher.CalcMatchRank (currentData.DisplayText, out r2)) { + if (r1 >= r2) { + bestMruIndex = curMruIndex; + idx = i; + currentData = mruData; } } } } - return idx; - } - static Dictionary<string,string> wordHistory = new Dictionary<string,string> (); - static List<string> partalWordHistory = new List<string> (); - const int maxHistoryLength = 500; - protected void AddWordToHistory (string partialWord, string word) - { - if (!wordHistory.ContainsKey (partialWord)) { - wordHistory.Add (partialWord, word); - partalWordHistory.Add (partialWord); - while (partalWordHistory.Count > maxHistoryLength) { - string first = partalWordHistory [0]; - partalWordHistory.RemoveAt (0); - wordHistory.Remove (first); - } - } else { - partalWordHistory.Remove (partialWord); - partalWordHistory.Add (partialWord); - wordHistory [partialWord] = word; - } - } - public static void ClearHistory () - { - wordHistory.Clear (); - partalWordHistory.Clear (); + return idx; } void SelectEntry (int n) @@ -698,6 +707,7 @@ namespace MonoDevelop.Ide.CodeCompletion CompletionCategory GetCompletionCategory (int n); bool HasMarkup (int n); string GetCompletionText (int n); + CompletionData GetCompletionData (int n); string GetDescription (int n, bool isSelected); string GetRightSideDescription (int n, bool isSelected); Xwt.Drawing.Image GetIcon (int n); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/MemberCompletionData.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/MemberCompletionData.cs index f5c3cdc31e..1d33b4ee7b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/MemberCompletionData.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/MemberCompletionData.cs @@ -25,7 +25,6 @@ // THE SOFTWARE. using System; -using ICSharpCode.NRefactory.TypeSystem; namespace MonoDevelop.Ide.CodeCompletion { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/MruCache.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/MruCache.cs new file mode 100644 index 0000000000..90e679af3f --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/MruCache.cs @@ -0,0 +1,67 @@ +// +// MruCache.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc. (http://xamarin.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.Collections.Generic; + +namespace MonoDevelop.Ide.CodeCompletion +{ + class MruCache + { + const int MaxItems = 42; + + readonly List<string> lastItems = new List<string> (MaxItems); + readonly object mruLock = new object (); + + public void CommitCompletionData (CompletionData item) + { + lock (mruLock) { + var removed = lastItems.Remove (item.DisplayText); + if (!removed && lastItems.Count == MaxItems) + lastItems.RemoveAt (0); + + lastItems.Add (item.DisplayText); + } + } + + /// <summary> + /// Lower is better. 1 == not in list. + /// </summary> + public int GetIndex (CompletionData item) + { + lock (mruLock) { + var index = lastItems.IndexOf (item.DisplayText); + return -index; + } + } + + public void Clear () + { + lock (mruLock) { + lastItems.Clear (); + } + } + } +}
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/MutableCompletionDataList.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/MutableCompletionDataList.cs index 871134a1c8..69488e2d04 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/MutableCompletionDataList.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/MutableCompletionDataList.cs @@ -61,32 +61,24 @@ namespace MonoDevelop.Ide.CodeCompletion public event EventHandler Changing { add { - if (changing == null) - TypeSystemService.ParseOperationStarted += HandleParseOperationStarted; changing += value; } remove { changing -= value; - if (changing == null) - TypeSystemService.ParseOperationStarted -= HandleParseOperationStarted; } } public event EventHandler Changed { add { - if (changed == null) - TypeSystemService.ParseOperationFinished += HandleParseOperationFinished; changed += value; } remove { changed -= value; - if (changed == null) - TypeSystemService.ParseOperationFinished -= HandleParseOperationFinished; } } public bool IsChanging { - get { return TypeSystemService.IsParsing; } + get { return false; } } protected virtual void OnChanging () @@ -117,10 +109,6 @@ namespace MonoDevelop.Ide.CodeCompletion { if (!disposed) { disposed = true; - if (changing != null) - TypeSystemService.ParseOperationStarted -= HandleParseOperationStarted; - if (changed != null) - TypeSystemService.ParseOperationFinished -= HandleParseOperationFinished; } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ParameterDataProvider.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ParameterHintingData.cs index 3d1b0811b9..aa2077c177 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ParameterDataProvider.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ParameterHintingData.cs @@ -25,54 +25,43 @@ // THE SOFTWARE. using System; using ICSharpCode.NRefactory.Completion; +using ICSharpCode.NRefactory6.CSharp.Completion; +using Microsoft.CodeAnalysis; +using System.Collections.Immutable; +using System.Linq; +using System.Collections.Generic; +using System.Threading; +using MonoDevelop.Ide.TypeSystem; +using MonoDevelop.Projects; +using MonoDevelop.Ide.Editor; namespace MonoDevelop.Ide.CodeCompletion { - public abstract class ParameterDataProvider : IParameterDataProvider + public abstract class ParameterHintingData { - public ParameterDataProvider (int startOffset) - { - this.startOffset = startOffset; - } - - public virtual TooltipInformation CreateTooltipInformation (int overload, int currentParameter, bool smartWrap) - { - return new TooltipInformation (); - } - - #region IParameterDataProvider implementation - - string IParameterDataProvider.GetHeading (int overload, string[] parameterDescription, int currentParameter) - { - throw new NotImplementedException (); + public ISymbol Symbol { + get; + private set; } - string IParameterDataProvider.GetDescription (int overload, int currentParameter) + protected ParameterHintingData (ISymbol symbol) { - throw new NotImplementedException (); + Symbol = symbol; } - string IParameterDataProvider.GetParameterDescription (int overload, int paramIndex) - { - throw new NotImplementedException (); + public abstract int ParameterCount { + get; } - public abstract int GetParameterCount (int overload); - public abstract bool AllowParameterList (int overload); - public abstract string GetParameterName (int overload, int paramIndex); - - public abstract int Count { + public abstract bool IsParameterListAllowed { get; } - readonly int startOffset; - public int StartOffset { - get { - return startOffset; - } - } + public abstract string GetParameterName (int parameter); - #endregion + public virtual TooltipInformation CreateTooltipInformation (TextEditor editor, DocumentContext ctx, int currentParameter, bool smartWrap) + { + return new TooltipInformation (); + } } } - diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ParameterHintingResult.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ParameterHintingResult.cs new file mode 100644 index 0000000000..dba4aedf0c --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ParameterHintingResult.cs @@ -0,0 +1,88 @@ +// +// ParameterHintingResult.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc. (http://xamarin.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.Collections.Generic; + +namespace MonoDevelop.Ide.CodeCompletion +{ + public class ParameterHintingResult : IReadOnlyList<ParameterHintingData> + { + public static readonly ParameterHintingResult Empty = new ParameterHintingResult (new List<ParameterHintingData> (), -1); + + protected readonly List<ParameterHintingData> data; + /// <summary> + /// Gets the start offset of the parameter expression node. + /// </summary> + public int StartOffset { + get; + private set; + } + + protected ParameterHintingResult (int startOffset) + { + this.data = new List<ParameterHintingData> (); + this.StartOffset = startOffset; + } + + public ParameterHintingResult (List<ParameterHintingData> data, int startOffset) + { + this.data = data; + this.StartOffset = startOffset; + } + + #region IEnumerable implementation + public IEnumerator<ParameterHintingData> GetEnumerator () + { + return data.GetEnumerator (); + } + #endregion + + #region IEnumerable implementation + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator () + { + return data.GetEnumerator (); + } + #endregion + + #region IReadOnlyList implementation + public ParameterHintingData this [int index] { + get { + return data [index]; + } + } + #endregion + + #region IReadOnlyCollection implementation + public int Count { + get { + return data.Count; + } + } + #endregion + } + +} + diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ParameterInformationWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ParameterInformationWindow.cs index 14c2042e07..40278f4734 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ParameterInformationWindow.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ParameterInformationWindow.cs @@ -25,16 +25,15 @@ // // - using System; -using System.Text; using MonoDevelop.Core; using Gtk; using MonoDevelop.Components; -using ICSharpCode.NRefactory.Completion; using MonoDevelop.Ide.Gui.Content; -using System.Collections.Generic; using MonoDevelop.Ide.Fonts; +using MonoDevelop.Ide.Editor; +using MonoDevelop.Ide.Editor.Highlighting; +using MonoDevelop.Ide.Editor.Extension; namespace MonoDevelop.Ide.CodeCompletion { @@ -74,7 +73,7 @@ namespace MonoDevelop.Ide.CodeCompletion this.AllowGrow = false; this.CanFocus = false; this.CanDefault = false; - Mono.TextEditor.PopupWindow.WindowTransparencyDecorator.Attach (this); + WindowTransparencyDecorator.Attach (this); headlabel = new MonoDevelop.Components.FixedWidthWrapLabel (); headlabel.Indent = -20; @@ -96,7 +95,7 @@ namespace MonoDevelop.Ide.CodeCompletion vb2.Spacing = 4; vb2.PackStart (hb, true, true, 0); ContentBox.Add (vb2); - var scheme = Mono.TextEditor.Highlighting.SyntaxModeService.GetColorStyle (IdeApp.Preferences.ColorScheme); + var scheme = SyntaxModeService.GetColorStyle (IdeApp.Preferences.ColorScheme); Theme.SetSchemeColors (scheme); foreColor = scheme.PlainText.Foreground; @@ -107,22 +106,24 @@ namespace MonoDevelop.Ide.CodeCompletion } int lastParam = -2; - public void ShowParameterInfo (ParameterDataProvider provider, int overload, int _currentParam, int maxSize) + TooltipInformation currentTooltipInformation; + + public void ShowParameterInfo (ParameterHintingResult provider, int overload, int _currentParam, int maxSize) { if (provider == null) throw new ArgumentNullException ("provider"); - int numParams = System.Math.Max (0, provider.GetParameterCount (overload)); + int numParams = System.Math.Max (0, provider[overload].ParameterCount); var currentParam = System.Math.Min (_currentParam, numParams - 1); if (numParams > 0 && currentParam < 0) currentParam = 0; - if (lastParam == currentParam) { + if (lastParam == currentParam && (currentTooltipInformation != null)) { return; } lastParam = currentParam; ClearDescriptions (); - var o = provider.CreateTooltipInformation (overload, currentParam, false); - + var parameterHintingData = (ParameterHintingData)provider [overload]; + currentTooltipInformation = parameterHintingData.CreateTooltipInformation (ext.Editor, ext.DocumentContext, currentParam, false); Theme.NumPages = provider.Count; Theme.CurrentPage = overload; if (provider.Count > 1) { @@ -130,17 +131,17 @@ namespace MonoDevelop.Ide.CodeCompletion Theme.PagerVertical = true; } - headlabel.Markup = o.SignatureMarkup; + headlabel.Markup = currentTooltipInformation.SignatureMarkup; headlabel.Visible = true; if (Theme.DrawPager) headlabel.WidthRequest = headlabel.RealWidth + 70; - foreach (var cat in o.Categories) { + foreach (var cat in currentTooltipInformation.Categories) { descriptionBox.PackStart (CreateCategory (cat.Item1, cat.Item2), true, true, 4); } - if (!string.IsNullOrEmpty (o.SummaryMarkup)) { - descriptionBox.PackStart (CreateCategory (GettextCatalog.GetString ("Summary"), o.SummaryMarkup), true, true, 4); + if (!string.IsNullOrEmpty (currentTooltipInformation.SummaryMarkup)) { + descriptionBox.PackStart (CreateCategory (GettextCatalog.GetString ("Summary"), currentTooltipInformation.SummaryMarkup), true, true, 4); } descriptionBox.ShowAll (); QueueResize (); @@ -185,6 +186,7 @@ namespace MonoDevelop.Ide.CodeCompletion public void ChangeOverload () { lastParam = -2; + currentTooltipInformation = null; } public void HideParameterInfo () diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ParameterInformationWindowManager.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ParameterInformationWindowManager.cs index 64c53b4f5f..f3de5195a4 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ParameterInformationWindowManager.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ParameterInformationWindowManager.cs @@ -31,8 +31,8 @@ using System.Collections; using System.Collections.Generic; using Gtk; using Gdk; -using ICSharpCode.NRefactory.Completion; using MonoDevelop.Ide.Gui.Content; +using MonoDevelop.Ide.Editor.Extension; namespace MonoDevelop.Ide.CodeCompletion { @@ -47,7 +47,8 @@ namespace MonoDevelop.Ide.CodeCompletion static ParameterInformationWindowManager () { - IdeApp.Workbench.RootWindow.Destroyed += (sender, e) => DestroyWindow (); + if (IdeApp.Workbench != null) + IdeApp.Workbench.RootWindow.Destroyed += (sender, e) => DestroyWindow (); } static void DestroyWindow () @@ -60,14 +61,14 @@ namespace MonoDevelop.Ide.CodeCompletion // Called when a key is pressed in the editor. // Returns false if the key press has to continue normal processing. - public static bool ProcessKeyEvent (CompletionTextEditorExtension ext, ICompletionWidget widget, Gdk.Key key, Gdk.ModifierType modifier) + internal static bool ProcessKeyEvent (CompletionTextEditorExtension ext, ICompletionWidget widget, KeyDescriptor descriptor) { if (methods.Count == 0) return false; MethodData cmd = methods [methods.Count - 1]; - - if (key == Gdk.Key.Down) { + + if (descriptor.SpecialKey == SpecialKey.Down) { if (cmd.MethodProvider.Count <= 1) return false; if (cmd.CurrentOverload < cmd.MethodProvider.Count - 1) @@ -77,7 +78,7 @@ namespace MonoDevelop.Ide.CodeCompletion window.ChangeOverload (); UpdateWindow (ext, widget); return true; - } else if (key == Gdk.Key.Up) { + } else if (descriptor.SpecialKey == SpecialKey.Up) { if (cmd.MethodProvider.Count <= 1) return false; if (cmd.CurrentOverload > 0) @@ -88,18 +89,18 @@ namespace MonoDevelop.Ide.CodeCompletion UpdateWindow (ext, widget); return true; } - else if (key == Gdk.Key.Escape) { + else if (descriptor.SpecialKey == SpecialKey.Escape) { HideWindow (ext, widget); return true; } return false; } - public static void PostProcessKeyEvent (CompletionTextEditorExtension ext, ICompletionWidget widget, Gdk.Key key, Gdk.ModifierType modifier) + internal static void PostProcessKeyEvent (CompletionTextEditorExtension ext, ICompletionWidget widget, KeyDescriptor descriptor) { } - public static void UpdateCursorPosition (CompletionTextEditorExtension ext, ICompletionWidget widget) + internal static void UpdateCursorPosition (CompletionTextEditorExtension ext, ICompletionWidget widget) { // Called after the key has been processed by the editor if (methods.Count == 0) @@ -124,12 +125,12 @@ namespace MonoDevelop.Ide.CodeCompletion UpdateWindow (ext, widget); } - public static void RepositionWindow (CompletionTextEditorExtension ext, ICompletionWidget widget) + internal static void RepositionWindow (CompletionTextEditorExtension ext, ICompletionWidget widget) { UpdateWindow (ext, widget); } - public static void ShowWindow (CompletionTextEditorExtension ext, ICompletionWidget widget, CodeCompletionContext ctx, ParameterDataProvider provider) + internal static void ShowWindow (CompletionTextEditorExtension ext, ICompletionWidget widget, CodeCompletionContext ctx, ParameterHintingResult provider) { if (provider.Count == 0) return; @@ -147,7 +148,7 @@ namespace MonoDevelop.Ide.CodeCompletion UpdateWindow (ext, widget); } - public static void HideWindow (CompletionTextEditorExtension ext, ICompletionWidget widget) + internal static void HideWindow (CompletionTextEditorExtension ext, ICompletionWidget widget) { methods.Clear (); if (window != null) @@ -162,7 +163,7 @@ namespace MonoDevelop.Ide.CodeCompletion return methods [methods.Count - 1].CurrentOverload; } - public static IParameterDataProvider GetCurrentProvider () + public static ParameterHintingResult GetCurrentProvider () { if (methods.Count == 0) return null; @@ -284,7 +285,7 @@ namespace MonoDevelop.Ide.CodeCompletion class MethodData { - public ParameterDataProvider MethodProvider; + public ParameterHintingResult MethodProvider; public CodeCompletionContext CompletionContext; int currentOverload; public int CurrentOverload { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/TooltipInformationWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/TooltipInformationWindow.cs index d9847fb2b9..528bb4a685 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/TooltipInformationWindow.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/TooltipInformationWindow.cs @@ -30,7 +30,8 @@ using System.Collections.Generic; using MonoDevelop.Core; using MonoDevelop.Ide.Fonts; using System.Linq; -using Mono.TextEditor.PopupWindow; +using MonoDevelop.Ide.Editor; +using MonoDevelop.Ide.Editor.Highlighting; namespace MonoDevelop.Ide.CodeCompletion { @@ -225,7 +226,7 @@ namespace MonoDevelop.Ide.CodeCompletion internal void SetDefaultScheme () { - var scheme = Mono.TextEditor.Highlighting.SyntaxModeService.GetColorStyle (IdeApp.Preferences.ColorScheme); + var scheme = SyntaxModeService.GetColorStyle (IdeApp.Preferences.ColorScheme); Theme.SetSchemeColors (scheme); foreColor = scheme.PlainText.Foreground; headLabel.ModifyFg (StateType.Normal, foreColor.ToGdkColor ()); |