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); }
public StaticMethodBehavior([NotNull] MethodsInfo info) : base(info) { var instances = info.AllDeclaredElements; if (instances == null) { return; } foreach (var instance in instances) { var method = instance.Element as IMethod; if (method == null) { continue; } myMethods.Add(new DeclaredElementInstance <IMethod>(method, instance.Substitution)); } }