Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected static SignatureHelpParameter Convert(
return new SignatureHelpParameter(
parameter.Name,
parameter.IsOptional,
parameter.GetDocumentationParts(semanticModel, position, formatter, cancellationToken),
parameter.GetDocumentationPartsFactory(semanticModel, position, formatter),
parameter.ToMinimalDisplayParts(semanticModel, position));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private SignatureHelpItem Convert(
constructor, semanticModel, position,
symbolDisplayService, anonymousTypeDisplayService,
isVariadic,
constructor.GetDocumentationParts(semanticModel, position, documentationCommentFormatter, cancellationToken),
constructor.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormatter),
GetPreambleParts(constructor, semanticModel, position),
GetSeparatorParts(),
GetPostambleParts(constructor),
Expand All @@ -158,6 +158,8 @@ private IEnumerable<SignatureHelpParameter> GetParameters(

for (int i = 0; i < namedParameters.Count; i++)
{
cancellationToken.ThrowIfCancellationRequested();

var namedParameter = namedParameters[i];

var type = namedParameter is IFieldSymbol ? ((IFieldSymbol)namedParameter).Type : ((IPropertySymbol)namedParameter).Type;
Expand All @@ -175,7 +177,7 @@ private IEnumerable<SignatureHelpParameter> GetParameters(
yield return new SignatureHelpParameter(
namedParameter.Name,
isOptional: true,
documentation: namedParameter.GetDocumentationParts(semanticModel, position, documentationCommentFormatter, cancellationToken),
documentationFactory: namedParameter.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormatter),
displayParts: displayParts,
prefixDisplayParts: GetParameterPrefixDisplayParts(i));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private SignatureHelpItem Convert(
constructor, semanticModel, position,
symbolDisplayService, anonymousTypeDisplayService,
constructor.IsParams(),
constructor.GetDocumentationParts(semanticModel, position, documentationCommentFormattingService, cancellationToken),
constructor.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormattingService),
GetPreambleParts(constructor, semanticModel, position),
GetSeparatorParts(),
GetPostambleParts(constructor),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private SignatureHelpItem Convert(
var item = CreateItem(indexer, semanticModel, position,
symbolDisplayService, anonymousTypeDisplayService,
indexer.IsParams(),
indexer.GetDocumentationParts(semanticModel, position, documentationCommentFormattingService, cancellationToken),
indexer.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormattingService),
GetPreambleParts(indexer, position, semanticModel),
GetSeparatorParts(),
GetPostambleParts(indexer),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private SignatureHelpItem Convert(
symbol, semanticModel, position,
symbolDisplayService, anonymousTypeDisplayService,
false,
symbol.GetDocumentationParts(semanticModel, position, documentationCommentFormattingService, cancellationToken),
symbol.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormattingService),
GetPreambleParts(namedType, semanticModel, position),
GetSeparatorParts(),
GetPostambleParts(namedType),
Expand All @@ -196,7 +196,7 @@ private SignatureHelpItem Convert(
symbol, semanticModel, position,
symbolDisplayService, anonymousTypeDisplayService,
false,
symbol.GetDocumentationParts(semanticModel, position, documentationCommentFormattingService, cancellationToken).Concat(GetAwaitableUsage(method, semanticModel, position)),
c => symbol.GetDocumentationParts(semanticModel, position, documentationCommentFormattingService, c).Concat(GetAwaitableUsage(method, semanticModel, position)),
GetPreambleParts(method, semanticModel, position),
GetSeparatorParts(),
GetPostambleParts(method, semanticModel, position),
Expand All @@ -220,7 +220,7 @@ private SignatureHelpParameter Convert(
return new SignatureHelpParameter(
parameter.Name,
isOptional: false,
documentation: parameter.GetDocumentationParts(semanticModel, position, formatter, cancellationToken),
documentationFactory: parameter.GetDocumentationPartsFactory(semanticModel, position, formatter),
displayParts: parameter.ToMinimalDisplayParts(semanticModel, position, s_minimallyQualifiedFormat),
selectedDisplayParts: GetSelectedDisplayParts(parameter, semanticModel, position, cancellationToken));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private IEnumerable<SignatureHelpItem> GetDelegateInvokeItems(
invokeMethod, semanticModel, position,
symbolDisplayService, anonymousTypeDisplayService,
isVariadic: invokeMethod.IsParams(),
documentation: SpecializedCollections.EmptyEnumerable<SymbolDisplayPart>(),
documentationFactory: null,
prefixParts: GetDelegateInvokePreambleParts(invokeMethod, semanticModel, position),
separatorParts: GetSeparatorParts(),
suffixParts: GetDelegateInvokePostambleParts(),
Expand All @@ -62,10 +62,11 @@ private IEnumerable<SignatureHelpParameter> GetDelegateInvokeParameters(
{
foreach (var parameter in invokeMethod.Parameters)
{
cancellationToken.ThrowIfCancellationRequested();
yield return new SignatureHelpParameter(
parameter.Name,
parameter.IsOptional,
parameter.GetDocumentationParts(semanticModel, position, formattingService, cancellationToken),
parameter.GetDocumentationPartsFactory(semanticModel, position, formattingService),
parameter.ToMinimalDisplayParts(semanticModel, position));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private SignatureHelpItem ConvertMethodGroupMethod(
method, semanticModel, position,
symbolDisplayService, anonymousTypeDisplayService,
method.IsParams(),
method.OriginalDefinition.GetDocumentationParts(semanticModel, position, documentationCommentFormattingService, cancellationToken).Concat(GetAwaitableUsage(method, semanticModel, position)),
c => method.OriginalDefinition.GetDocumentationParts(semanticModel, position, documentationCommentFormattingService, c).Concat(GetAwaitableUsage(method, semanticModel, position)),
GetMethodGroupPreambleParts(method, semanticModel, position),
GetSeparatorParts(),
GetMethodGroupPostambleParts(method),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private IEnumerable<SignatureHelpItem> GetDelegateTypeConstructors(
invokeMethod, semanticModel, position,
symbolDisplayService, anonymousTypeDispalyService,
isVariadic: false,
documentation: SpecializedCollections.EmptyEnumerable<SymbolDisplayPart>(),
documentationFactory: null,
prefixParts: GetDelegateTypePreambleParts(invokeMethod, semanticModel, position),
separatorParts: GetSeparatorParts(),
suffixParts: GetDelegateTypePostambleParts(invokeMethod),
Expand Down Expand Up @@ -80,7 +80,7 @@ private IEnumerable<SignatureHelpParameter> GetDelegateTypeParameters(IMethodSym
yield return new SignatureHelpParameter(
TargetName,
isOptional: false,
documentation: SpecializedCollections.EmptyEnumerable<SymbolDisplayPart>(),
documentationFactory: null,
displayParts: parts);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private SignatureHelpItem ConvertNormalTypeConstructor(
constructor, semanticModel, position,
symbolDisplayService, anonymousTypeDisplayService,
constructor.IsParams(),
constructor.GetDocumentationParts(semanticModel, position, documentationCommentFormattingService, cancellationToken),
constructor.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormattingService),
GetNormalTypePreambleParts(constructor, semanticModel, position),
GetSeparatorParts(),
GetNormalTypePostambleParts(constructor),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis;
using Roslyn.Utilities;

Expand All @@ -16,25 +18,26 @@ internal class SignatureHelpItem
/// selected parameter index strictly goes past the number of defined parameters for this
/// item.
/// </summary>
public bool IsVariadic { get; private set; }
public bool IsVariadic { get; }

public IList<SymbolDisplayPart> PrefixDisplayParts { get; private set; }
public IList<SymbolDisplayPart> SuffixDisplayParts { get; private set; }
public ImmutableArray<SymbolDisplayPart> PrefixDisplayParts { get; }
public ImmutableArray<SymbolDisplayPart> SuffixDisplayParts { get; }

// TODO(cyrusn): This probably won't be sufficient for VB query signature help. It has
// TODO: This probably won't be sufficient for VB query signature help. It has
// arbitrary separators between parameters.
public IList<SymbolDisplayPart> SeparatorDisplayParts { get; private set; }
public ImmutableArray<SymbolDisplayPart> SeparatorDisplayParts { get; }

public IList<SignatureHelpParameter> Parameters { get; private set; }
public ImmutableArray<SignatureHelpParameter> Parameters { get; }

public IList<SymbolDisplayPart> DescriptionParts { get; internal set; }
public ImmutableArray<SymbolDisplayPart> DescriptionParts { get; internal set; }

// TODO(cyrusn): This may be unnecessary. How would a user ever see this.
public IList<SymbolDisplayPart> Documentation { get; set; }
public Func<CancellationToken, IEnumerable<SymbolDisplayPart>> DocumenationFactory { get; }

private static readonly Func<CancellationToken, IEnumerable<SymbolDisplayPart>> s_emptyDocumentationFactory = _ => SpecializedCollections.EmptyEnumerable<SymbolDisplayPart>();

public SignatureHelpItem(
bool isVariadic,
IEnumerable<SymbolDisplayPart> documentation,
Func<CancellationToken, IEnumerable<SymbolDisplayPart>> documentationFactory,
IEnumerable<SymbolDisplayPart> prefixParts,
IEnumerable<SymbolDisplayPart> separatorParts,
IEnumerable<SymbolDisplayPart> suffixParts,
Expand All @@ -47,7 +50,7 @@ public SignatureHelpItem(
}

this.IsVariadic = isVariadic;
this.Documentation = documentation.ToImmutableArrayOrEmpty();
this.DocumenationFactory = documentationFactory ?? s_emptyDocumentationFactory;
this.PrefixDisplayParts = prefixParts.ToImmutableArrayOrEmpty();
this.SeparatorDisplayParts = separatorParts.ToImmutableArrayOrEmpty();
this.SuffixDisplayParts = suffixParts.ToImmutableArrayOrEmpty();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.Editor
Expand All @@ -13,54 +14,56 @@ internal class SignatureHelpParameter
/// <summary>
/// The name of this parameter.
/// </summary>
public string Name { get; private set; }
public string Name { get; }

/// <summary>
/// Documentation for this parameter. This should normally be presented to the user when
/// this parameter is selected.
/// </summary>
public IList<SymbolDisplayPart> Documentation { get; private set; }
public Func<CancellationToken, IEnumerable<SymbolDisplayPart>> DocumentationFactory { get; }

/// <summary>
/// Display parts to show before the normal display parts for the parameter.
/// </summary>
public IList<SymbolDisplayPart> PrefixDisplayParts { get; private set; }
public IList<SymbolDisplayPart> PrefixDisplayParts { get; }

/// <summary>
/// Display parts to show after the normal display parts for the parameter.
/// </summary>
public IList<SymbolDisplayPart> SuffixDisplayParts { get; private set; }
public IList<SymbolDisplayPart> SuffixDisplayParts { get; }

/// <summary>
/// Display parts for this parameter. This should normally be presented to the user as part
/// of the entire signature display.
/// </summary>
public IList<SymbolDisplayPart> DisplayParts { get; private set; }
public IList<SymbolDisplayPart> DisplayParts { get; }

/// <summary>
/// True if this parameter is optional or not. Optional parameters may be presented in a
/// different manner to users.
/// </summary>
public bool IsOptional { get; private set; }
public bool IsOptional { get; }

/// <summary>
/// Display parts for this parameter that should be presented to the user when this
/// parameter is selected.
/// </summary>
public IList<SymbolDisplayPart> SelectedDisplayParts { get; private set; }
public IList<SymbolDisplayPart> SelectedDisplayParts { get; }

private static readonly Func<CancellationToken, IEnumerable<SymbolDisplayPart>> s_emptyDocumentationFactory = _ => SpecializedCollections.EmptyEnumerable<SymbolDisplayPart>();

public SignatureHelpParameter(
string name,
bool isOptional,
IEnumerable<SymbolDisplayPart> documentation,
Func<CancellationToken, IEnumerable<SymbolDisplayPart>> documentationFactory,
IEnumerable<SymbolDisplayPart> displayParts,
IEnumerable<SymbolDisplayPart> prefixDisplayParts = null,
IEnumerable<SymbolDisplayPart> suffixDisplayParts = null,
IEnumerable<SymbolDisplayPart> selectedDisplayParts = null)
{
this.Name = name ?? string.Empty;
this.IsOptional = isOptional;
this.Documentation = documentation.ToImmutableArrayOrEmpty();
this.DocumentationFactory = documentationFactory ?? s_emptyDocumentationFactory;
this.DisplayParts = displayParts.ToImmutableArrayOrEmpty();
this.PrefixDisplayParts = prefixDisplayParts.ToImmutableArrayOrEmpty();
this.SuffixDisplayParts = suffixDisplayParts.ToImmutableArrayOrEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,25 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.SignatureHelp
{
internal abstract partial class AbstractSignatureHelpProvider
{
internal class SymbolKeySignatureHelpItem : SignatureHelpItem, IEquatable<SymbolKeySignatureHelpItem>
{
public SymbolKey SymbolKey { get; private set; }
public SymbolKey SymbolKey { get; }

public SymbolKeySignatureHelpItem(
ISymbol symbol,
bool isVariadic,
IEnumerable<SymbolDisplayPart> documentation,
Func<CancellationToken, IEnumerable<SymbolDisplayPart>> documentationFactory,
IEnumerable<SymbolDisplayPart> prefixParts,
IEnumerable<SymbolDisplayPart> separatorParts,
IEnumerable<SymbolDisplayPart> suffixParts,
IEnumerable<SignatureHelpParameter> parameters,
IEnumerable<SymbolDisplayPart> descriptionParts) : base(isVariadic, documentation, prefixParts, separatorParts, suffixParts, parameters, descriptionParts)
IEnumerable<SymbolDisplayPart> descriptionParts) : base(isVariadic, documentationFactory, prefixParts, separatorParts, suffixParts, parameters, descriptionParts)
{
this.SymbolKey = symbol == null ? null : symbol.GetSymbolKey();
}
Expand Down
Loading