Exemple #1
0
        protected void ShowInsight(SharpDevelopTextAreaControl editor, MethodInsightDataProvider dp, ICollection <ResolveResult> parameters, char charTyped)
        {
            int paramCount = parameters.Count;

            dp.SetupDataProvider(editor.FileName, editor.ActiveTextAreaControl.TextArea);
            List <IMethodOrProperty> methods = dp.Methods;

            if (methods.Count == 0)
            {
                return;
            }
            bool overloadIsSure;

            if (methods.Count == 1)
            {
                overloadIsSure  = true;
                dp.DefaultIndex = 0;
            }
            else
            {
                IReturnType[] argumentTypes = new IReturnType[paramCount + 1];
                int           i             = 0;
                foreach (ResolveResult rr in parameters)
                {
                    if (rr != null)
                    {
                        argumentTypes[i] = rr.ResolvedType;
                    }
                    i++;
                }
                IMethodOrProperty result = Dom.CSharp.OverloadResolution.FindOverload(
                    methods, argumentTypes, true, false, out overloadIsSure);
                dp.DefaultIndex = methods.IndexOf(result);
            }
            editor.ShowInsightWindow(dp);
            if (overloadIsSure)
            {
                IMethodOrProperty method = methods[dp.DefaultIndex];
                if (paramCount < method.Parameters.Count)
                {
                    IParameter param = method.Parameters[paramCount];
                    ProvideContextCompletion(editor, param.ReturnType, charTyped);
                }
            }
        }
        protected void ShowInsight(SharpDevelopTextAreaControl editor, MethodInsightDataProvider dp, ICollection <ResolveResult> parameters, char charTyped)
        {
            int paramCount = parameters.Count;

            dp.SetupDataProvider(editor.FileName, editor.ActiveTextAreaControl.TextArea);
            List <IMethodOrProperty> methods = dp.Methods;

            if (methods.Count == 0)
            {
                return;
            }
            bool overloadIsSure;

            if (methods.Count == 1)
            {
                overloadIsSure  = true;
                dp.DefaultIndex = 0;
            }
            else
            {
                IReturnType[] parameterTypes = new IReturnType[paramCount + 1];
                int           i = 0;
                foreach (ResolveResult rr in parameters)
                {
                    if (rr != null)
                    {
                        parameterTypes[i] = rr.ResolvedType;
                    }
                    i++;
                }
                IReturnType[][] tmp;
                int[]           ranking      = MemberLookupHelper.RankOverloads(methods, parameterTypes, true, out overloadIsSure, out tmp);
                bool            multipleBest = false;
                int             bestRanking  = -1;
                int             best         = 0;
                for (i = 0; i < ranking.Length; i++)
                {
                    if (ranking[i] > bestRanking)
                    {
                        bestRanking  = ranking[i];
                        best         = i;
                        multipleBest = false;
                    }
                    else if (ranking[i] == bestRanking)
                    {
                        multipleBest = true;
                    }
                }
                if (multipleBest)
                {
                    overloadIsSure = false;
                }
                dp.DefaultIndex = best;
            }
            editor.ShowInsightWindow(dp);
            if (overloadIsSure)
            {
                IMethodOrProperty method = methods[dp.DefaultIndex];
                if (paramCount < method.Parameters.Count)
                {
                    IParameter param = method.Parameters[paramCount];
                    ProvideContextCompletion(editor, param.ReturnType, charTyped);
                }
            }
        }
		protected void ShowInsight(SharpDevelopTextAreaControl editor, MethodInsightDataProvider dp, ICollection<ResolveResult> parameters, char charTyped)
		{
			int paramCount = parameters.Count;
			dp.SetupDataProvider(editor.FileName, editor.ActiveTextAreaControl.TextArea);
			List<IMethodOrProperty> methods = dp.Methods;
			if (methods.Count == 0) return;
			bool overloadIsSure;
			if (methods.Count == 1) {
				overloadIsSure = true;
				dp.DefaultIndex = 0;
			} else {
				IReturnType[] argumentTypes = new IReturnType[paramCount + 1];
				int i = 0;
				foreach (ResolveResult rr in parameters) {
					if (rr != null) {
						argumentTypes[i] = rr.ResolvedType;
					}
					i++;
				}
				IMethodOrProperty result = Dom.CSharp.OverloadResolution.FindOverload(
					methods, argumentTypes, true, false, out overloadIsSure);
				dp.DefaultIndex = methods.IndexOf(result);
			}
			editor.ShowInsightWindow(dp);
			if (overloadIsSure) {
				IMethodOrProperty method = methods[dp.DefaultIndex];
				if (paramCount < method.Parameters.Count) {
					IParameter param = method.Parameters[paramCount];
					ProvideContextCompletion(editor, param.ReturnType, charTyped);
				}
			}
		}
		protected void ShowInsight(SharpDevelopTextAreaControl editor, MethodInsightDataProvider dp, ICollection<ResolveResult> parameters, char charTyped)
		{
			int paramCount = parameters.Count;
			dp.SetupDataProvider(editor.FileName, editor.ActiveTextAreaControl.TextArea);
			List<IMethodOrProperty> methods = dp.Methods;
			if (methods.Count == 0) return;
			bool overloadIsSure;
			if (methods.Count == 1) {
				overloadIsSure = true;
				dp.DefaultIndex = 0;
			} else {
				IReturnType[] parameterTypes = new IReturnType[paramCount + 1];
				int i = 0;
				foreach (ResolveResult rr in parameters) {
					if (rr != null) {
						parameterTypes[i] = rr.ResolvedType;
					}
					i++;
				}
				IReturnType[][] tmp;
				int[] ranking = MemberLookupHelper.RankOverloads(methods, parameterTypes, true, out overloadIsSure, out tmp);
				bool multipleBest = false;
				int bestRanking = -1;
				int best = 0;
				for (i = 0; i < ranking.Length; i++) {
					if (ranking[i] > bestRanking) {
						bestRanking = ranking[i];
						best = i;
						multipleBest = false;
					} else if (ranking[i] == bestRanking) {
						multipleBest = true;
					}
				}
				if (multipleBest) overloadIsSure = false;
				dp.DefaultIndex = best;
			}
			editor.ShowInsightWindow(dp);
			if (overloadIsSure) {
				IMethodOrProperty method = methods[dp.DefaultIndex];
				if (paramCount < method.Parameters.Count) {
					IParameter param = method.Parameters[paramCount];
					ProvideContextCompletion(editor, param.ReturnType, charTyped);
				}
			}
		}