private ImmutableArray <EnvDTE.CodeElement> EnumerateOverloads() { var symbol = (IMethodSymbol)ParentElement.LookupSymbol(); // Only methods and constructors can be overloaded. However, all functions // can successfully return a collection of overloaded functions; if not // really overloaded, the collection contains just the original function. if (symbol.MethodKind is not MethodKind.Ordinary and not MethodKind.Constructor) { return(ImmutableArray.Create((EnvDTE.CodeElement)Parent)); } var overloadsBuilder = ArrayBuilder <EnvDTE.CodeElement> .GetInstance(); foreach (var method in symbol.ContainingType.GetMembers(symbol.Name)) { if (method.Kind != SymbolKind.Method) { continue; } var element = ExternalCodeFunction.Create(this.State, _projectId, (IMethodSymbol)method); if (element != null) { overloadsBuilder.Add((EnvDTE.CodeElement)element); } } return(overloadsBuilder.ToImmutableAndFree()); }
private ExternalOverloadsCollection( CodeModelState state, ExternalCodeFunction parent, ProjectId projectId) : base(state, parent) { _projectId = projectId; }
internal static EnvDTE.CodeElements Create( CodeModelState state, ExternalCodeFunction parent, ProjectId projectId) { var collection = new ExternalOverloadsCollection(state, parent, projectId); return (EnvDTE.CodeElements)ComAggregate.CreateAggregatedObject(collection); }
private ExternalOverloadsCollection( CodeModelState state, ExternalCodeFunction parent, ProjectId projectId) : base(state, parent) { _projectId = projectId; }
internal static EnvDTE.CodeElements Create( CodeModelState state, ExternalCodeFunction parent, ProjectId projectId) { var collection = new ExternalOverloadsCollection(state, parent, projectId); return((EnvDTE.CodeElements)ComAggregate.CreateAggregatedObject(collection)); }