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;
		}		
Ejemplo n.º 2
0
        public void TestBug447985()
        {
            IParameterDataProvider provider = CreateProvider(
                @"
namespace System {
	public class Exception
	{
		public Exception () {}
	}
}

class MyException : System.Exception
{
	public MyException (int test)
	{}
}

class AClass
{
	public void Test ()
	{
		$throw new MyException($
	}

}");

            Assert.IsNotNull(provider, "provider was not created.");
            Assert.AreEqual(1, provider.Count);
            Assert.AreEqual(1, provider.GetParameterCount(0), "Parameter 'test' should exist");
        }
        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();
        }
Ejemplo n.º 4
0
        public override int GuessBestMethodOverload(IParameterDataProvider provider, int currentOverload)
        {
            var engine = new CSharpParameterCompletionEngine(
                TextEditorData.Document,
                typeSystemSegmentTree,
                this,
                Document.GetProjectContext(),
                CSharpUnresolvedFile.GetTypeResolveContext(Document.Compilation, document.Editor.Caret.Location) as CSharpTypeResolveContext
                );
            List <string> list;
            int           cparam = engine.GetCurrentParameterIndex(provider.StartOffset, document.Editor.Caret.Offset, out list);

            if (cparam > provider.GetParameterCount(currentOverload) && !provider.AllowParameterList(currentOverload) || !HasAllUsedParameters(provider, list, 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)
                    {
                        if (HasAllUsedParameters(provider, list, n))
                        {
                            bestOverload   = n;
                            bestParamCount = pc;
                        }
                    }
                }
                if (bestOverload == -1)
                {
                    for (int n = 0; n < provider.Count; n++)
                    {
                        if (provider.AllowParameterList(n) && HasAllUsedParameters(provider, list, n))
                        {
                            bestOverload = n;
                            break;
                        }
                    }
                }
                return(bestOverload);
            }
            return(-1);
        }
Ejemplo n.º 5
0
        public void TestBug432658()
        {
            IParameterDataProvider provider = CreateProvider(
                @"static class Extensions
{
	public static void Ext1 (this int start)
	{
	}
	public static void Ext2 (this int end)
	{
		$Ext1($
	}
}");

            Assert.IsNotNull(provider, "provider was not created.");
            Assert.AreEqual(1, provider.Count, "There should be one overload");
            Assert.AreEqual(1, provider.GetParameterCount(0), "Parameter 'start' should exist");
        }
Ejemplo n.º 6
0
        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 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 ();
		}
        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;
        }