public async Task<ImmutableArray<SymbolDisplayPart>> ToDescriptionPartsAsync(Workspace workspace, SemanticModel semanticModel, int position, ImmutableArray<ISymbol> symbols, SymbolDescriptionGroups groups, CancellationToken cancellationToken)
        {
            if (symbols.Length == 0)
            {
                return ImmutableArray.Create<SymbolDisplayPart>();
            }

            var builder = CreateDescriptionBuilder(workspace, semanticModel, position, cancellationToken);
            return await builder.BuildDescriptionAsync(symbols, groups).ConfigureAwait(false);
        }
            protected void AddToGroup(SymbolDescriptionGroups group, params IEnumerable<SymbolDisplayPart>[] partsArray)
            {
                var partsList = partsArray.Flatten().ToList();
                if (partsList.Count > 0)
                {
                    IList<SymbolDisplayPart> existingParts;
                    if (!_groupMap.TryGetValue(group, out existingParts))
                    {
                        existingParts = new List<SymbolDisplayPart>();
                        _groupMap.Add(group, existingParts);
                    }

                    existingParts.AddRange(partsList);
                }
            }
 protected void AddToGroup(SymbolDescriptionGroups group, params SymbolDisplayPart[] partsArray)
 {
     AddToGroup(group, (IEnumerable<SymbolDisplayPart>)partsArray);
 }
            private static int GetPrecedingNewLineCount(SymbolDescriptionGroups group)
            {
                switch (group)
                {
                    case SymbolDescriptionGroups.MainDescription:
                        // these parts are continuations of whatever text came before them
                        return 0;

                    case SymbolDescriptionGroups.Documentation:
                        return 1;

                    case SymbolDescriptionGroups.AnonymousTypes:
                        return 0;

                    case SymbolDescriptionGroups.Exceptions:
                    case SymbolDescriptionGroups.TypeParameterMap:
                        // Everything else is in a group on its own
                        return 2;

                    default:
                        return Contract.FailWithReturn<int>("unknown part kind");
                }
            }
            private ImmutableArray<SymbolDisplayPart> BuildDescription(SymbolDescriptionGroups groups)
            {
                var finalParts = new List<SymbolDisplayPart>();
                var orderedGroups = _groupMap.Keys.OrderBy((g1, g2) => g1 - g2);

                foreach (var group in orderedGroups)
                {
                    if ((groups & group) == 0)
                    {
                        continue;
                    }

                    if (!finalParts.IsEmpty())
                    {
                        var newLines = GetPrecedingNewLineCount(group);
                        finalParts.AddRange(LineBreak(newLines));
                    }

                    var parts = _groupMap[group];
                    finalParts.AddRange(parts);
                }

                return finalParts.AsImmutable();
            }
            public async Task<ImmutableArray<SymbolDisplayPart>> BuildDescriptionAsync(
                ImmutableArray<ISymbol> symbolGroup, SymbolDescriptionGroups groups)
            {
                Contract.ThrowIfFalse(symbolGroup.Length > 0);

                await AddPartsAsync(symbolGroup).ConfigureAwait(false);

                return this.BuildDescription(groups);
            }
 public Task<string> ToDescriptionStringAsync(Workspace workspace, SemanticModel semanticModel, int position, ISymbol symbol, SymbolDescriptionGroups groups, CancellationToken cancellationToken)
 {
     return ToDescriptionStringAsync(workspace, semanticModel, position, ImmutableArray.Create<ISymbol>(symbol), groups, cancellationToken);
 }
 public async Task<string> ToDescriptionStringAsync(Workspace workspace, SemanticModel semanticModel, int position, ImmutableArray<ISymbol> symbols, SymbolDescriptionGroups groups, CancellationToken cancellationToken)
 {
     var parts = await ToDescriptionPartsAsync(workspace, semanticModel, position, symbols, groups, cancellationToken).ConfigureAwait(false);
     return parts.ToDisplayString();
 }
 public Task <string> ToDescriptionStringAsync(Workspace workspace, SemanticModel semanticModel, int position, ISymbol symbol, SymbolDescriptionGroups groups, CancellationToken cancellationToken)
 {
     return(ToDescriptionStringAsync(workspace, semanticModel, position, ImmutableArray.Create <ISymbol>(symbol), groups, cancellationToken));
 }
Beispiel #10
0
 protected void AddToGroup(SymbolDescriptionGroups group, params SymbolDisplayPart[] partsArray)
 {
     AddToGroup(group, (IEnumerable <SymbolDisplayPart>)partsArray);
 }
Beispiel #11
0
        public async Task <ImmutableArray <SymbolDisplayPart> > ToDescriptionPartsAsync(Workspace workspace, SemanticModel semanticModel, int position, ImmutableArray <ISymbol> symbols, SymbolDescriptionGroups groups, CancellationToken cancellationToken)
        {
            if (symbols.Length == 0)
            {
                return(ImmutableArray.Create <SymbolDisplayPart>());
            }

            var builder = CreateDescriptionBuilder(workspace, semanticModel, position, cancellationToken);

            return(await builder.BuildDescriptionAsync(symbols, groups).ConfigureAwait(false));
        }
Beispiel #12
0
        public async Task <string> ToDescriptionStringAsync(Workspace workspace, SemanticModel semanticModel, int position, ImmutableArray <ISymbol> symbols, SymbolDescriptionGroups groups, CancellationToken cancellationToken)
        {
            var parts = await ToDescriptionPartsAsync(workspace, semanticModel, position, symbols, groups, cancellationToken).ConfigureAwait(false);

            return(parts.ToDisplayString());
        }
Beispiel #13
0
 public Task <string> ToDescriptionStringAsync(SemanticModel semanticModel, int position, ISymbol symbol, SymbolDescriptionOptions options, SymbolDescriptionGroups groups, CancellationToken cancellationToken)
 => ToDescriptionStringAsync(semanticModel, position, ImmutableArray.Create(symbol), options, groups, cancellationToken);