提交 06a4af3e 编写于 作者: C Cyrus Najmabadi

Revert sighelp

上级 31801795
......@@ -55,7 +55,8 @@ protected static SymbolDisplayPart NewLine()
IParameterSymbol parameter,
SemanticModel semanticModel,
int position,
IDocumentationCommentFormattingService formatter)
IDocumentationCommentFormattingService formatter,
CancellationToken cancellationToken)
{
return new SignatureHelpSymbolParameter(
parameter.Name,
......
......@@ -19,7 +19,8 @@ internal abstract class AbstractOrdinaryMethodSignatureHelpProvider : AbstractCS
Document document,
IMethodSymbol method,
int position,
SemanticModel semanticModel)
SemanticModel semanticModel,
CancellationToken cancellationToken)
{
return ConvertMethodGroupMethod(document, method, position, semanticModel, descriptionParts: null);
}
......@@ -43,7 +44,7 @@ internal abstract class AbstractOrdinaryMethodSignatureHelpProvider : AbstractCS
GetMethodGroupPreambleParts(method, semanticModel, position),
GetSeparatorParts(),
GetMethodGroupPostambleParts(),
method.Parameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService)).ToList(),
method.Parameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService, CancellationToken.None)).ToList(),
descriptionParts: descriptionParts);
}
......
......@@ -159,7 +159,7 @@ public override SignatureHelpState GetCurrentArgumentState(SyntaxNode root, int
var result = new List<SignatureHelpSymbolParameter>();
foreach (var parameter in constructor.Parameters)
{
result.Add(Convert(parameter, semanticModel, position, documentationCommentFormatter));
result.Add(Convert(parameter, semanticModel, position, documentationCommentFormatter, cancellationToken));
}
for (var i = 0; i < namedParameters.Count; i++)
......
......@@ -111,7 +111,7 @@ protected override async Task<SignatureHelpItems> GetItemsWorkerAsync(Document d
var selectedItem = TryGetSelectedIndex(accessibleConstructors, symbolInfo);
return CreateSignatureHelpItems(accessibleConstructors.SelectAsArray(c =>
Convert(c, constructorInitializer.ArgumentList.OpenParenToken, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService)).ToList(),
Convert(c, constructorInitializer.ArgumentList.OpenParenToken, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService, cancellationToken)).ToList(),
textSpan, GetCurrentArgumentState(root, position, syntaxFacts, textSpan, cancellationToken), selectedItem);
}
......@@ -132,7 +132,8 @@ public override SignatureHelpState GetCurrentArgumentState(SyntaxNode root, int
SemanticModel semanticModel,
ISymbolDisplayService symbolDisplayService,
IAnonymousTypeDisplayService anonymousTypeDisplayService,
IDocumentationCommentFormattingService documentationCommentFormattingService)
IDocumentationCommentFormattingService documentationCommentFormattingService,
CancellationToken cancellationToken)
{
var position = openToken.SpanStart;
var item = CreateItem(
......@@ -142,8 +143,8 @@ public override SignatureHelpState GetCurrentArgumentState(SyntaxNode root, int
constructor.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormattingService),
GetPreambleParts(constructor, semanticModel, position),
GetSeparatorParts(),
GetPostambleParts(),
constructor.Parameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService)).ToList());
GetPostambleParts(constructor),
constructor.Parameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService, cancellationToken)).ToList());
return item;
}
......@@ -160,7 +161,10 @@ public override SignatureHelpState GetCurrentArgumentState(SyntaxNode root, int
return result;
}
private IList<SymbolDisplayPart> GetPostambleParts()
=> SpecializedCollections.SingletonList(Punctuation(SyntaxKind.CloseParenToken));
private IList<SymbolDisplayPart> GetPostambleParts(IMethodSymbol method)
{
return SpecializedCollections.SingletonList(
Punctuation(SyntaxKind.CloseParenToken));
}
}
}
......@@ -110,7 +110,7 @@ protected override async Task<SignatureHelpItems> GetItemsWorkerAsync(Document d
var syntaxFacts = document.GetLanguageService<ISyntaxFactsService>();
return CreateSignatureHelpItems(accessibleIndexers.Select(p =>
Convert(p, openBrace, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService)).ToList(),
Convert(p, openBrace, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService, cancellationToken)).ToList(),
textSpan, GetCurrentArgumentState(root, position, syntaxFacts, textSpan, cancellationToken), selectedItem: null);
}
......@@ -118,9 +118,14 @@ private TextSpan GetTextSpan(ExpressionSyntax expression, SyntaxToken openBracke
{
if (openBracket.Parent is BracketedArgumentListSyntax)
{
return expression.Parent is ConditionalAccessExpressionSyntax conditional
? TextSpan.FromBounds(conditional.Span.Start, openBracket.FullSpan.End)
: CompleteElementAccessExpression.GetTextSpan(openBracket);
if (expression.Parent is ConditionalAccessExpressionSyntax conditional)
{
return TextSpan.FromBounds(conditional.Span.Start, openBracket.FullSpan.End);
}
else
{
return CompleteElementAccessExpression.GetTextSpan(expression, openBracket);
}
}
else if (openBracket.Parent is ArrayRankSpecifierSyntax)
{
......@@ -155,6 +160,7 @@ public override SignatureHelpState GetCurrentArgumentState(SyntaxNode root, int
if (expression.Parent is ConditionalAccessExpressionSyntax)
{
// The typed code looks like: <expression>?[
var conditional = (ConditionalAccessExpressionSyntax)expression.Parent;
var elementBinding = SyntaxFactory.ElementBindingExpression(newBracketedArgumentList);
var conditionalAccessExpression = SyntaxFactory.ConditionalAccessExpression(expression, elementBinding);
offset = expression.SpanStart - conditionalAccessExpression.SpanStart;
......@@ -225,7 +231,8 @@ public override SignatureHelpState GetCurrentArgumentState(SyntaxNode root, int
SemanticModel semanticModel,
ISymbolDisplayService symbolDisplayService,
IAnonymousTypeDisplayService anonymousTypeDisplayService,
IDocumentationCommentFormattingService documentationCommentFormattingService)
IDocumentationCommentFormattingService documentationCommentFormattingService,
CancellationToken cancellationToken)
{
var position = openToken.SpanStart;
var item = CreateItem(indexer, semanticModel, position,
......@@ -234,8 +241,8 @@ public override SignatureHelpState GetCurrentArgumentState(SyntaxNode root, int
indexer.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormattingService),
GetPreambleParts(indexer, position, semanticModel),
GetSeparatorParts(),
GetPostambleParts(),
indexer.Parameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService)).ToList());
GetPostambleParts(indexer),
indexer.Parameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService, cancellationToken)).ToList());
return item;
}
......@@ -274,8 +281,11 @@ public override SignatureHelpState GetCurrentArgumentState(SyntaxNode root, int
return result;
}
private IList<SymbolDisplayPart> GetPostambleParts()
=> SpecializedCollections.SingletonList(Punctuation(SyntaxKind.CloseBracketToken));
private IList<SymbolDisplayPart> GetPostambleParts(IPropertySymbol indexer)
{
return SpecializedCollections.SingletonList(
Punctuation(SyntaxKind.CloseBracketToken));
}
private static class CompleteElementAccessExpression
{
......@@ -294,7 +304,7 @@ internal static bool IsArgumentListToken(ElementAccessExpressionSyntax expressio
token != expression.ArgumentList.CloseBracketToken;
}
internal static TextSpan GetTextSpan(SyntaxToken openBracket)
internal static TextSpan GetTextSpan(SyntaxNode expression, SyntaxToken openBracket)
{
Contract.ThrowIfFalse(openBracket.Parent is BracketedArgumentListSyntax &&
(openBracket.Parent.Parent is ElementAccessExpressionSyntax || openBracket.Parent.Parent is ElementBindingExpressionSyntax));
......
......@@ -186,7 +186,7 @@ protected virtual TextSpan GetTextSpan(SyntaxToken genericIdentifier, SyntaxToke
symbol.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormattingService),
GetPreambleParts(namedType, semanticModel, position),
GetSeparatorParts(),
GetPostambleParts(),
GetPostambleParts(namedType),
namedType.TypeParameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService, cancellationToken)).ToList());
}
else
......@@ -222,13 +222,14 @@ protected virtual TextSpan GetTextSpan(SyntaxToken genericIdentifier, SyntaxToke
isOptional: false,
documentationFactory: parameter.GetDocumentationPartsFactory(semanticModel, position, formatter),
displayParts: parameter.ToMinimalDisplayParts(semanticModel, position, s_minimallyQualifiedFormat),
selectedDisplayParts: GetSelectedDisplayParts(parameter, semanticModel, position));
selectedDisplayParts: GetSelectedDisplayParts(parameter, semanticModel, position, cancellationToken));
}
private IList<SymbolDisplayPart> GetSelectedDisplayParts(
ITypeParameterSymbol typeParam,
SemanticModel semanticModel,
int position)
int position,
CancellationToken cancellationToken)
{
var parts = new List<SymbolDisplayPart>();
......
......@@ -22,7 +22,10 @@ internal partial class GenericNameSignatureHelpProvider
return result;
}
private IList<SymbolDisplayPart> GetPostambleParts()
=> SpecializedCollections.SingletonList(Punctuation(SyntaxKind.GreaterThanToken));
private IList<SymbolDisplayPart> GetPostambleParts(INamedTypeSymbol namedType)
{
return SpecializedCollections.SingletonList(
Punctuation(SyntaxKind.GreaterThanToken));
}
}
}
......@@ -61,7 +61,7 @@ protected override async Task<SignatureHelpItems> GetItemsWorkerAsync(Document d
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
return CreateCollectionInitializerSignatureHelpItems(addMethods.Select(s =>
ConvertMethodGroupMethod(document, s, initializerExpression.OpenBraceToken.SpanStart, semanticModel)).ToList(),
ConvertMethodGroupMethod(document, s, initializerExpression.OpenBraceToken.SpanStart, semanticModel, cancellationToken)).ToList(),
textSpan, GetCurrentArgumentState(root, position, syntaxFacts, textSpan, cancellationToken));
}
......
......@@ -26,7 +26,7 @@ internal partial class InvocationExpressionSignatureHelpProviderBase
CancellationToken cancellationToken)
{
return Task.FromResult(
(accessibleMethods.SelectAsArray(m => ConvertMethodGroupMethod(document, m, invocationExpression.SpanStart, semanticModel)),
(accessibleMethods.SelectAsArray(m => ConvertMethodGroupMethod(document, m, invocationExpression.SpanStart, semanticModel, cancellationToken)),
TryGetSelectedIndex(accessibleMethods, currentSymbol)));
}
......
......@@ -81,7 +81,7 @@ protected override async Task<SignatureHelpItems> GetItemsWorkerAsync(Document d
var syntaxFacts = document.GetLanguageService<ISyntaxFactsService>();
var (items, selectedItem) = type.TypeKind == TypeKind.Delegate
? GetDelegateTypeConstructors(objectCreationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, type, cancellationToken)
? GetDelegateTypeConstructors(objectCreationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, type, within, cancellationToken)
: GetNormalTypeConstructors(document, objectCreationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService, type, within, cancellationToken);
return CreateSignatureHelpItems(items, textSpan,
......
......@@ -19,6 +19,7 @@ internal partial class ObjectCreationExpressionSignatureHelpProvider
ISymbolDisplayService symbolDisplayService,
IAnonymousTypeDisplayService anonymousTypeDisplayService,
INamedTypeSymbol delegateType,
INamedTypeSymbol containingType,
CancellationToken cancellationToken)
{
var invokeMethod = delegateType.DelegateInvokeMethod;
......@@ -35,8 +36,8 @@ internal partial class ObjectCreationExpressionSignatureHelpProvider
documentationFactory: null,
prefixParts: GetDelegateTypePreambleParts(invokeMethod, semanticModel, position),
separatorParts: GetSeparatorParts(),
suffixParts: GetDelegateTypePostambleParts(),
parameters: GetDelegateTypeParameters(invokeMethod, semanticModel, position));
suffixParts: GetDelegateTypePostambleParts(invokeMethod),
parameters: GetDelegateTypeParameters(invokeMethod, semanticModel, position, cancellationToken));
return (SpecializedCollections.SingletonList(item), 0);
}
......@@ -51,7 +52,7 @@ private IList<SymbolDisplayPart> GetDelegateTypePreambleParts(IMethodSymbol invo
return result;
}
private IList<SignatureHelpSymbolParameter> GetDelegateTypeParameters(IMethodSymbol invokeMethod, SemanticModel semanticModel, int position)
private IList<SignatureHelpSymbolParameter> GetDelegateTypeParameters(IMethodSymbol invokeMethod, SemanticModel semanticModel, int position, CancellationToken cancellationToken)
{
const string TargetName = "target";
......@@ -85,7 +86,10 @@ private IList<SignatureHelpSymbolParameter> GetDelegateTypeParameters(IMethodSym
displayParts: parts));
}
private IList<SymbolDisplayPart> GetDelegateTypePostambleParts()
=> SpecializedCollections.SingletonList(Punctuation(SyntaxKind.CloseParenToken));
private IList<SymbolDisplayPart> GetDelegateTypePostambleParts(IMethodSymbol invokeMethod)
{
return SpecializedCollections.SingletonList(
Punctuation(SyntaxKind.CloseParenToken));
}
}
}
......@@ -37,7 +37,7 @@ internal partial class ObjectCreationExpressionSignatureHelpProvider
var selectedItem = TryGetSelectedIndex(accessibleConstructors, symbolInfo);
var items = accessibleConstructors.SelectAsArray(c =>
ConvertNormalTypeConstructor(c, objectCreationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService));
ConvertNormalTypeConstructor(c, objectCreationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService, cancellationToken));
return (items, selectedItem);
}
......@@ -48,7 +48,8 @@ internal partial class ObjectCreationExpressionSignatureHelpProvider
SemanticModel semanticModel,
ISymbolDisplayService symbolDisplayService,
IAnonymousTypeDisplayService anonymousTypeDisplayService,
IDocumentationCommentFormattingService documentationCommentFormattingService)
IDocumentationCommentFormattingService documentationCommentFormattingService,
CancellationToken cancellationToken)
{
var position = objectCreationExpression.SpanStart;
var item = CreateItem(
......@@ -58,8 +59,8 @@ internal partial class ObjectCreationExpressionSignatureHelpProvider
constructor.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormattingService),
GetNormalTypePreambleParts(constructor, semanticModel, position),
GetSeparatorParts(),
GetNormalTypePostambleParts(),
constructor.Parameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService)).ToList());
GetNormalTypePostambleParts(constructor),
constructor.Parameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService, cancellationToken)).ToList());
return item;
}
......@@ -77,7 +78,10 @@ internal partial class ObjectCreationExpressionSignatureHelpProvider
return result;
}
private IList<SymbolDisplayPart> GetNormalTypePostambleParts()
=> SpecializedCollections.SingletonList(Punctuation(SyntaxKind.CloseParenToken));
private IList<SymbolDisplayPart> GetNormalTypePostambleParts(IMethodSymbol method)
{
return SpecializedCollections.SingletonList(
Punctuation(SyntaxKind.CloseParenToken));
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册