public Gtk.Requisition ShowParameterInfo (IParameterDataProvider provider, int overload, int currentParam) { if (provider == null) throw new ArgumentNullException ("provider"); int numParams = System.Math.Max (0, provider.GetParameterCount (overload)); string[] paramText = new string[numParams]; for (int i = 0; i < numParams; i++) { string txt = provider.GetParameterMarkup (overload, i); if (i == currentParam) txt = "<u><span foreground='darkblue'>" + txt + "</span></u>"; paramText [i] = txt; } string text = provider.GetMethodMarkup (overload, paramText, currentParam); desc.Markup = text; if (provider.OverloadCount > 1) { count.Show (); goPrev.Show (); goNext.Show (); count.Text = GettextCatalog.GetString ("{0} of {1}", overload+1, provider.OverloadCount); } else { count.Hide (); goPrev.Hide (); goNext.Hide (); } Gtk.Requisition req = mainBox.SizeRequest (); Resize (req.Width, req.Height); return req; }
public void TestBug434705B() { IParameterDataProvider provider = CreateProvider( @" class Test<T> { public Test (T t) { } } class TestClass { void TestMethod () { $Test<int> l = new Test<int> ($ } }"); Assert.IsNotNull(provider, "provider was not created."); Assert.AreEqual(1, provider.OverloadCount); }
public void TestBug434705() { IParameterDataProvider provider = CreateProvider( @"class Test { public Test (int a) { } } class AClass { Test A() { $return new Test ($ } }"); Assert.IsNotNull(provider, "provider was not created."); Assert.AreEqual(1, provider.OverloadCount); }
public virtual void RunParameterCompletionCommand() { if (Document.Editor.SelectionMode == Mono.TextEditor.SelectionMode.Block) { return; } IParameterDataProvider 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); } }
static bool HasAllUsedParameters(IParameterDataProvider provider, List <string> list, int n) { int pc = provider.GetParameterCount(n); foreach (var usedParam in list) { bool found = false; for (int m = 0; m < pc; m++) { if (usedParam == provider.GetParameterName(n, m)) { found = true; break; } } if (!found) { return(false); } } return(true); }
public Gtk.Requisition ShowParameterInfo(IParameterDataProvider provider, int overload, int currentParam) { if (provider == null) { throw new ArgumentNullException("provider"); } int numParams = System.Math.Max(0, provider.GetParameterCount(overload)); string[] paramText = new string[numParams]; for (int i = 0; i < numParams; i++) { string txt = provider.GetParameterMarkup(overload, i); if (i == currentParam) { txt = "<u><span foreground='darkblue'>" + txt + "</span></u>"; } paramText [i] = txt; } string text = provider.GetMethodMarkup(overload, paramText, currentParam); desc.Markup = text; if (provider.OverloadCount > 1) { count.Show(); goPrev.Show(); goNext.Show(); count.Text = GettextCatalog.GetString("{0} of {1}", overload + 1, provider.OverloadCount); } else { count.Hide(); goPrev.Hide(); goNext.Hide(); } Gtk.Requisition req = mainBox.SizeRequest(); Resize(req.Width, req.Height); return(req); }
public void TestSecondMethodTypeParameter() { IParameterDataProvider provider = CreateProvider( @"using System; namespace Test { class A { void TestMethod<T, S>() { } void Method () { $TestMethod<string,$ } } }"); Assert.IsNotNull(provider, "provider was not created."); Assert.AreEqual(1, provider.Count); }
public void TestBug3645() { IParameterDataProvider provider = CreateProvider( @"class Main { public static void FooBar (string str) { } public void FooBar (int i) { } public static void Main (string[] args) { $FooBar ($ } }"); Assert.IsNotNull(provider, "provider was not created."); Assert.AreEqual(1, provider.Count); }
public void TestBug9301() { IParameterDataProvider provider = CreateProvider( @"using System; public class A { public virtual int this [int i, string s] { get { return 1; } } } public class B : A { public new bool this [int i, string s2] { get { return true; } } } public class Test { public static int Main () { B p = new B (); $p[$ return 0; } } "); Assert.AreEqual(1, provider.Count); }
public static void ShowWindow (ICompletionWidget widget, CodeCompletionContext ctx, IParameterDataProvider provider) { if (provider.OverloadCount == 0) return; // There can be several method parameter lists open at the same time, so // they have to be queued. The last one of queue is the one being shown // in the information window. MethodData md = new MethodData (); md.MethodProvider = provider; md.CurrentOverload = 0; md.CompletionContext = ctx; methods.Add (md); UpdateWindow (widget); }
// 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; return(false); } autoHideCompletionWindow = false; } if (ParameterInformationWindowManager.IsWindowVisible) { if (ParameterInformationWindowManager.ProcessKeyEvent(this, CompletionWidget, key, modifier)) { return(false); } autoHideCompletionWindow = 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 && currentCompletionContext == null) { 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; IParameterDataProvider paramProvider = HandleParameterCompletion(ctx, keyChar); if (paramProvider != null) { ParameterInformationWindowManager.ShowWindow(this, CompletionWidget, ctx, paramProvider); } } autoHideCompletionWindow = true; return(res); }
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; }
/// <summary> /// Construct a CombiningStrategyAttribute incorporating an /// ICombiningStrategy and an IParamterDataProvider. /// </summary> /// <param name="strategy">Combining strategy to be used in combining data</param> /// <param name="provider">An IParameterDataProvider to supply data</param> protected CombiningStrategyAttribute(ICombiningStrategy strategy, IParameterDataProvider provider) { _strategy = strategy; _dataProvider = provider; }
// 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; KeyActions ka = KeyActions.None; if (currentCompletionContext != null) { if (CompletionWindowManager.PreProcessKeyEvent(key, keyChar, modifier, out ka)) { CompletionWindowManager.PostProcessKeyEvent(ka, key, keyChar, modifier); autoHideCompletionWindow = true; return(false); } autoHideCompletionWindow = false; } if (ParameterInformationWindowManager.IsWindowVisible) { if (ParameterInformationWindowManager.ProcessKeyEvent(CompletionWidget, key, modifier)) { return(false); } autoHideCompletionWindow = false; } // int oldPos = Editor.CursorPosition; // int oldLen = Editor.TextLength; res = base.KeyPress(key, keyChar, modifier); CompletionWindowManager.PostProcessKeyEvent(ka, 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(CompletionWidget, key, modifier); } if ((modifier & ignoreMods) != 0) { return(res); } /* * if (Document.TextEditorData == null || Document.TextEditorData.IsSomethingSelected && Document.TextEditorData.SelectionMode != Mono.TextEditor.SelectionMode.Block) { * int posChange = Editor.CursorPosition - oldPos; * if (currentCompletionContext != null && (Math.Abs (posChange) > 1 || (Editor.TextLength - oldLen) != posChange)) { * currentCompletionContext = null; * CompletionWindowManager.HideWindow (); * ParameterInformationWindowManager.HideWindow (); * 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 && currentCompletionContext == null) { 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(keyChar, completionList, CompletionWidget, currentCompletionContext, OnCompletionWindowClosed)) { currentCompletionContext = null; } } else { currentCompletionContext = null; } } if (enableParameterInsight && CompletionWidget != null) { CodeCompletionContext ctx = CompletionWidget.CurrentCodeCompletionContext; IParameterDataProvider paramProvider = HandleParameterCompletion(ctx, keyChar); if (paramProvider != null) { ParameterInformationWindowManager.ShowWindow(CompletionWidget, ctx, paramProvider); } } autoHideCompletionWindow = true; return(res); }
public static void ShowWindow(CompletionTextEditorExtension ext, ICompletionWidget widget, CodeCompletionContext ctx, IParameterDataProvider provider) { if (provider.Count == 0) { return; } // There can be several method parameter lists open at the same time, so // they have to be queued. The last one of queue is the one being shown // in the information window. MethodData md = new MethodData(); md.MethodProvider = provider; md.CurrentOverload = 0; md.CompletionContext = ctx; methods.Add(md); UpdateOverload(ext, widget); UpdateWindow(ext, widget); }
/// <summary> /// Construct a CombiningStrategyAttribute incorporating an /// ICombiningStrategy and an IParameterDataProvider. /// </summary> /// <param name="strategy">Combining strategy to be used in combining data</param> /// <param name="provider">An IParameterDataProvider to supply data</param> protected CombiningStrategyAttribute(ICombiningStrategy strategy, IParameterDataProvider provider) { _strategy = strategy; _dataProvider = provider; }
public void ShowParameterInfo (IParameterDataProvider provider, int overload, int _currentParam, int maxSize) { if (provider == null) throw new ArgumentNullException ("provider"); int numParams = System.Math.Max (0, provider.GetParameterCount (overload)); var currentParam = System.Math.Min (_currentParam, numParams - 1); if (numParams > 0 && currentParam < 0) currentParam = 0; if (lastParam == currentParam) { return; } lastParam = currentParam; string[] paramText = new string[numParams]; for (int i = 0; i < numParams; i++) { string txt = provider.GetParameterDescription (overload, i); if (i == currentParam) txt = "<u><span foreground='" + LinkColor + "'>" + txt + "</span></u>"; paramText [i] = txt; } string text = provider.GetHeading (overload, paramText, currentParam); heading.Markup = text; desc.Markup = provider.GetDescription (overload, currentParam); if (provider.Count > 1) { count.Show (); goPrev.Show (); goNext.Show (); count.Text = GettextCatalog.GetString ("{0} of {1}", overload + 1, provider.Count); } else { count.Hide (); goPrev.Hide (); goNext.Hide (); } var req = this.SizeRequest (); if (doBreakParameters.ContainsKey (overload) || req.Width > maxSize) { for (int i = 1; i < numParams; i++) { paramText [i] = Environment.NewLine + "\t" + paramText [i]; } text = provider.GetHeading (overload, paramText, currentParam); heading.Markup = text; doBreakParameters [overload] = true; } QueueResize (); }