Esempio n. 1
0
        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);
        }
Esempio n. 2
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);
        }
        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;
        }