示例#1
0
        private ILookupItem CreateLookoutItem(
            CSharpCodeCompletionContext context,
            string name,
            IList <DeclaredElementInstance <IMethod> > methods,
            bool skipGenericArguments,
            bool includeFollowingExpression = true,
            bool setFunctionParameters      = true)
        {
            var basicContext = context.BasicContext;
            var editorBrowsableProcessing = basicContext.EditorBrowsableProcessing;

            if (editorBrowsableProcessing != EditorBrowsableProcessingType.All)
            {
                methods = methods.Where(x => CodeInsightUtil.IsBrowsable(x.Element,
                                                                         showNever: false,
                                                                         showAdvanced: editorBrowsableProcessing == EditorBrowsableProcessingType.Advanced)).ToList();
            }
            if (methods.IsEmpty())
            {
                return(null);
            }
            var elements    = methods.Select(_ => new Pair <IDeclaredElement, ISubstitution>(_.Element, _.Substitution));
            var methodsInfo = new MethodsInfo(name, elements, CSharpLanguage.Instance, basicContext.LookupItemsOwner, context);

            methodsInfo.Ranges = context.CompletionRanges;
            methodsInfo.SkipGenericArguments = skipGenericArguments;
            methodsInfo.PutData(CompletionKeys.IsMethodsKey, new object());

            if (methods.All(x => x.Element.IsExtensionMethod))
            {
                methodsInfo.PutKey(CompletionKeys.IsExtensionMethodsKey);
            }

            var lookupItem = LookupItemFactory.CreateLookupItem(methodsInfo).WithPresentation(_gGetMethodsPresentation)
                             .WithBehavior(_ => new NukeTasksBehaviour(_.Info)).WithMatcher(_getMethodsMatcher);
            var qualifiableReference = CSharpLookupItemFactory.GetQualifiableReference(context);
            var qualifier            = qualifiableReference != null?qualifiableReference.GetQualifier() : null;

            var qualifierStaticness = qualifier == null ? new Staticness?() : AccessUtil.GetQualifierStaticness(qualifier);

            if (setFunctionParameters)
            {
                var functions = methodsInfo.AllDeclaredElements.Select(x => x.Element).OfType <IMethod>();
                CSharpLookupItemFactory.Instance.SetFunctionParameters(context,
                                                                       functions,
                                                                       lookupItem,
                                                                       methodsInfo);
            }

            methodsInfo.Placement.OrderString = name;
            return(lookupItem);
        }
示例#2
0
        private static DeclaredElementPresentation <DeclaredElementInfo> GetOrCreatePresentation(
            DeclaredElementInfo info,
            DeclaredElementPresenterStyle style,
            string typeParameterString = null)
        {
            var preferredDeclaredElement = info.PreferredDeclaredElement;

            if (preferredDeclaredElement != null && preferredDeclaredElement.Element is ICompiledElement &&
                preferredDeclaredElement.Element.Type() == null)
            {
                return(CSharpLookupItemFactory.GetPresentationCache(preferredDeclaredElement.Element.GetSolution())
                       .GetPresentation(info, (ICompiledElement)preferredDeclaredElement.Element, style, typeParameterString));
            }
            return(new DeclaredElementPresentation <DeclaredElementInfo>(info, style, typeParameterString, LogoThemedIcons.NukeLogo.Id));
        }