public override IEnumerable<SymbolDisplayPart> GetAnonymousTypeParts( INamedTypeSymbol anonymousType, SemanticModel semanticModel, int position, ISymbolDisplayService displayService) { var members = new List<SymbolDisplayPart>(); members.Add(Keyword(SyntaxFacts.GetText(SyntaxKind.NewKeyword))); members.AddRange(Space()); members.Add(Punctuation(SyntaxFacts.GetText(SyntaxKind.OpenBraceToken))); members.AddRange(Space()); bool first = true; foreach (var property in anonymousType.GetValidAnonymousTypeProperties()) { if (!first) { members.Add(Punctuation(SyntaxFacts.GetText(SyntaxKind.CommaToken))); members.AddRange(Space()); } first = false; members.AddRange(displayService.ToMinimalDisplayParts(semanticModel, position, property.Type).Select(p => p.MassageErrorTypeNames("?"))); members.AddRange(Space()); members.Add(new SymbolDisplayPart(SymbolDisplayPartKind.PropertyName, property, property.Name)); } members.AddRange(Space()); members.Add(Punctuation(SyntaxFacts.GetText(SyntaxKind.CloseBraceToken))); return members; }
private IEnumerable<SignatureHelpItem> GetDelegateTypeConstructors( ObjectCreationExpressionSyntax objectCreationExpression, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, INamedTypeSymbol delegateType, INamedTypeSymbol containingType, CancellationToken cancellationToken) { var invokeMethod = delegateType.DelegateInvokeMethod; if (invokeMethod == null) { return null; } var position = objectCreationExpression.SpanStart; var item = CreateItem( invokeMethod, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService, isVariadic: false, documentationFactory: null, prefixParts: GetDelegateTypePreambleParts(invokeMethod, semanticModel, position), separatorParts: GetSeparatorParts(), suffixParts: GetDelegateTypePostambleParts(invokeMethod), parameters: GetDelegateTypeParameters(invokeMethod, semanticModel, position, cancellationToken)); return SpecializedCollections.SingletonEnumerable(item); }
private IList <SignatureHelpItem> GetDelegateTypeConstructors( ObjectCreationExpressionSyntax objectCreationExpression, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, INamedTypeSymbol delegateType, INamedTypeSymbol containingType, CancellationToken cancellationToken) { var invokeMethod = delegateType.DelegateInvokeMethod; if (invokeMethod == null) { return(null); } var position = objectCreationExpression.SpanStart; var item = CreateItem( invokeMethod, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService, isVariadic: false, documentationFactory: null, prefixParts: GetDelegateTypePreambleParts(invokeMethod, semanticModel, position), separatorParts: GetSeparatorParts(), suffixParts: GetDelegateTypePostambleParts(invokeMethod), parameters: GetDelegateTypeParameters(invokeMethod, semanticModel, position, cancellationToken)); return(SpecializedCollections.SingletonList(item)); }
private IEnumerable<SignatureHelpItem> GetDelegateInvokeItems( InvocationExpressionSyntax invocationExpression, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, ISymbol within, INamedTypeSymbol delegateType, CancellationToken cancellationToken) { var invokeMethod = delegateType.DelegateInvokeMethod; if (invokeMethod == null) { return null; } // Events can only be invoked directly from the class they were declared in. var expressionSymbol = semanticModel.GetSymbolInfo(invocationExpression.Expression, cancellationToken).GetAnySymbol(); if (expressionSymbol.IsKind(SymbolKind.Event) && !expressionSymbol.ContainingType.OriginalDefinition.Equals(within.OriginalDefinition)) { return null; } var position = invocationExpression.SpanStart; var item = CreateItem( invokeMethod, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService, isVariadic: invokeMethod.IsParams(), documentation: SpecializedCollections.EmptyEnumerable<SymbolDisplayPart>(), prefixParts: GetDelegateInvokePreambleParts(invokeMethod, semanticModel, position), separatorParts: GetSeparatorParts(), suffixParts: GetDelegateInvokePostambleParts(), parameters: GetDelegateInvokeParameters(invokeMethod, semanticModel, position, documentationCommentFormattingService, cancellationToken)); return SpecializedCollections.SingletonEnumerable(item); }
private IEnumerable <CodeAction> CreateActions( CodeFixContext context, Document document, Diagnostic diagnostic, SyntaxNode node, SemanticModel semanticModel, IEnumerable <INamespaceOrTypeSymbol> proposedContainers, ISymbolDisplayService displayService) { foreach (var container in proposedContainers) { var containerName = displayService.ToMinimalDisplayString(semanticModel, node.SpanStart, container); var name = GetNodeName(document, node); // Actual member name might differ by case. string memberName; if (this.IgnoreCase) { var member = container.GetMembers(name).FirstOrDefault(); memberName = member != null ? member.Name : name; } else { memberName = name; } var codeAction = new MyCodeAction( $"{containerName}.{memberName}", c => ProcessNode(document, node, containerName, c)); yield return(codeAction); } }
private SignatureHelpItem Convert( IMethodSymbol constructor, ISymbol within, AttributeSyntax attribute, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormatter, CancellationToken cancellationToken) { var position = attribute.SpanStart; var namedParameters = constructor.ContainingType.GetAttributeNamedParameters(semanticModel.Compilation, within) .OrderBy(s => s.Name) .ToList(); var isVariadic = constructor.Parameters.Length > 0 && constructor.Parameters.Last().IsParams&& namedParameters.Count == 0; var item = CreateItem( constructor, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService, isVariadic, constructor.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormatter), GetPreambleParts(constructor, semanticModel, position), GetSeparatorParts(), GetPostambleParts(constructor), GetParameters(constructor, semanticModel, position, namedParameters, documentationCommentFormatter, cancellationToken)); return(item); }
#pragma warning disable CA1822 // Mark members as static - see obsolete comment above. protected SignatureHelpItem CreateItem( #pragma warning restore CA1822 // Mark members as static ISymbol orderSymbol, SemanticModel semanticModel, int position, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, bool isVariadic, Func <CancellationToken, IEnumerable <TaggedText> > documentationFactory, IList <SymbolDisplayPart> prefixParts, IList <SymbolDisplayPart> separatorParts, IList <SymbolDisplayPart> suffixParts, IList <SignatureHelpSymbolParameter> parameters, IList <SymbolDisplayPart>?descriptionParts = null ) { return(CreateItem( orderSymbol, semanticModel, position, anonymousTypeDisplayService, isVariadic, documentationFactory, prefixParts, separatorParts, suffixParts, parameters, descriptionParts )); }
public static ImmutableArray <TSymbol> Sort <TSymbol>( ImmutableArray <TSymbol> symbols, ISymbolDisplayService symbolDisplayService, SemanticModel semanticModel, int position) where TSymbol : ISymbol => Shared.Extensions.ISymbolExtensions2.Sort(symbols, symbolDisplayService, semanticModel, position);
public static ImmutableArray <TSymbol> Sort <TSymbol>( this ImmutableArray <TSymbol> symbols, ISymbolDisplayService symbolDisplayService, SemanticModel semanticModel, int position) where TSymbol : ISymbol { return(Sort(symbols, semanticModel, position)); }
private IEnumerable <SignatureHelpItem> GetMethodGroupItems( InvocationExpressionSyntax invocationExpression, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, ISymbol within, IEnumerable <IMethodSymbol> methodGroup, CancellationToken cancellationToken) { ITypeSymbol throughType = null; if (invocationExpression.Expression is MemberAccessExpressionSyntax) { var throughExpression = ((MemberAccessExpressionSyntax)invocationExpression.Expression).Expression; var throughSymbol = semanticModel.GetSymbolInfo(throughExpression, cancellationToken).GetAnySymbol(); // if it is via a base expression "base.", we know the "throughType" is the base class but // we need to be able to tell between "base.M()" and "new Base().M()". // currently, Access check methods do not differentiate between them. // so handle "base." primary-expression here by nulling out "throughType" if (!(throughExpression is BaseExpressionSyntax)) { throughType = semanticModel.GetTypeInfo(throughExpression, cancellationToken).Type; } var includeInstance = !throughExpression.IsKind(SyntaxKind.IdentifierName) || semanticModel.LookupSymbols(throughExpression.SpanStart, name: throughSymbol.Name).Any(s => !(s is INamedTypeSymbol)) || (!(throughSymbol is INamespaceOrTypeSymbol) && semanticModel.LookupSymbols(throughExpression.SpanStart, container: throughSymbol.ContainingType).Any(s => !(s is INamedTypeSymbol))); var includeStatic = throughSymbol is INamedTypeSymbol || (throughExpression.IsKind(SyntaxKind.IdentifierName) && semanticModel.LookupNamespacesAndTypes(throughExpression.SpanStart, name: throughSymbol.Name).Any(t => t.GetSymbolType() == throughType)); Contract.ThrowIfFalse(includeInstance || includeStatic); methodGroup = methodGroup.Where(m => (m.IsStatic && includeStatic) || (!m.IsStatic && includeInstance)); } else if (invocationExpression.Expression is SimpleNameSyntax && invocationExpression.IsInStaticContext()) { methodGroup = methodGroup.Where(m => m.IsStatic); } var accessibleMethods = methodGroup.Where(m => m.IsAccessibleWithin(within, throughTypeOpt: throughType)).ToList(); if (accessibleMethods.Count == 0) { return(null); } var methodSet = accessibleMethods.ToSet(); accessibleMethods = accessibleMethods.Where(m => !IsHiddenByOtherMethod(m, methodSet)).ToList(); return(accessibleMethods.Select(m => ConvertMethodGroupMethod(m, invocationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService, cancellationToken))); }
private static string[] GetParameterTypeNames( ISymbol symbol, ISymbolDisplayService symbolDisplayService, SemanticModel semanticModel, int position) { return(GetMethodOrIndexerOrEventParameters(symbol) .Select(p => symbolDisplayService.ToMinimalDisplayString(semanticModel, position, p.Type)) .ToArray()); }
public SymbolDescriptionBuilder( ISymbolDisplayService displayService, SemanticModel semanticModel, int position, Workspace workspace, IAnonymousTypeDisplayService anonymousTypeDisplayService, CancellationToken cancellationToken) : base(displayService, semanticModel, position, workspace, anonymousTypeDisplayService, cancellationToken) { }
private IEnumerable<SignatureHelpItem> GetMethodGroupItems( InvocationExpressionSyntax invocationExpression, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, ISymbol within, IEnumerable<IMethodSymbol> methodGroup, CancellationToken cancellationToken) { ITypeSymbol throughType = null; if (invocationExpression.Expression is MemberAccessExpressionSyntax) { var throughExpression = ((MemberAccessExpressionSyntax)invocationExpression.Expression).Expression; var throughSymbol = semanticModel.GetSymbolInfo(throughExpression, cancellationToken).GetAnySymbol(); // if it is via a base expression "base.", we know the "throughType" is the base class but // we need to be able to tell between "base.M()" and "new Base().M()". // currently, Access check methods do not differentiate between them. // so handle "base." primary-expression here by nulling out "throughType" if (!(throughExpression is BaseExpressionSyntax)) { throughType = semanticModel.GetTypeInfo(throughExpression, cancellationToken).Type; } var includeInstance = !throughExpression.IsKind(SyntaxKind.IdentifierName) || semanticModel.LookupSymbols(throughExpression.SpanStart, name: throughSymbol.Name).Any(s => !(s is INamedTypeSymbol)) || (!(throughSymbol is INamespaceOrTypeSymbol) && semanticModel.LookupSymbols(throughExpression.SpanStart, container: throughSymbol.ContainingType).Any(s => !(s is INamedTypeSymbol))); var includeStatic = throughSymbol is INamedTypeSymbol || (throughExpression.IsKind(SyntaxKind.IdentifierName) && semanticModel.LookupNamespacesAndTypes(throughExpression.SpanStart, name: throughSymbol.Name).Any(t => t.GetSymbolType() == throughType)); Contract.ThrowIfFalse(includeInstance || includeStatic); methodGroup = methodGroup.Where(m => (m.IsStatic && includeStatic) || (!m.IsStatic && includeInstance)); } else if (invocationExpression.Expression is SimpleNameSyntax && invocationExpression.IsInStaticContext()) { methodGroup = methodGroup.Where(m => m.IsStatic); } var accessibleMethods = methodGroup.Where(m => m.IsAccessibleWithin(within, throughTypeOpt: throughType)).ToList(); if (accessibleMethods.Count == 0) { return null; } var methodSet = accessibleMethods.ToSet(); accessibleMethods = accessibleMethods.Where(m => !IsHiddenByOtherMethod(m, methodSet)).ToList(); return accessibleMethods.Select(m => ConvertMethodGroupMethod(m, invocationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService, cancellationToken)); }
public static IList <TSymbol> Sort <TSymbol>( this IEnumerable <TSymbol> symbols, ISymbolDisplayService symbolDisplayService, SemanticModel semanticModel, int position) where TSymbol : ISymbol { var symbolToParameterTypeNames = new ConcurrentDictionary <TSymbol, string[]>(); Func <TSymbol, string[]> getParameterTypeNames = s => GetParameterTypeNames(s, symbolDisplayService, semanticModel, position); return(symbols.OrderBy((s1, s2) => Compare(s1, s2, symbolToParameterTypeNames, getParameterTypeNames)).ToList()); }
public AnonymousTypeDisplayInfo GetNormalAnonymousTypeDisplayInfo( ISymbol orderSymbol, IEnumerable <INamedTypeSymbol> directNormalAnonymousTypeReferences, SemanticModel semanticModel, int position, ISymbolDisplayService displayService) { if (!directNormalAnonymousTypeReferences.Any()) { return(new AnonymousTypeDisplayInfo( SpecializedCollections.EmptyDictionary <INamedTypeSymbol, string>(), SpecializedCollections.EmptyList <SymbolDisplayPart>())); } var transitiveNormalAnonymousTypeReferences = GetTransitiveNormalAnonymousTypeReferences(directNormalAnonymousTypeReferences.ToSet()); transitiveNormalAnonymousTypeReferences = OrderAnonymousTypes(transitiveNormalAnonymousTypeReferences, orderSymbol); IList <SymbolDisplayPart> anonymousTypeParts = new List <SymbolDisplayPart>(); anonymousTypeParts.Add(PlainText(FeaturesResources.Anonymous_Types_colon)); anonymousTypeParts.AddRange(LineBreak()); for (int i = 0; i < transitiveNormalAnonymousTypeReferences.Count; i++) { if (i != 0) { anonymousTypeParts.AddRange(LineBreak()); } var anonymousType = transitiveNormalAnonymousTypeReferences[i]; anonymousTypeParts.AddRange(Space(count: 4)); anonymousTypeParts.Add(Part(SymbolDisplayPartKind.ClassName, anonymousType, anonymousType.Name)); anonymousTypeParts.AddRange(Space()); anonymousTypeParts.Add(PlainText(FeaturesResources.is_)); anonymousTypeParts.AddRange(Space()); anonymousTypeParts.AddRange(GetAnonymousTypeParts(anonymousType, semanticModel, position, displayService)); } // Now, inline any delegate anonymous types we've got. anonymousTypeParts = this.InlineDelegateAnonymousTypes(anonymousTypeParts, semanticModel, position, displayService); // Finally, assign a name to all the anonymous types. var anonymousTypeToName = GenerateAnonymousTypeNames(transitiveNormalAnonymousTypeReferences); anonymousTypeParts = AnonymousTypeDisplayInfo.ReplaceAnonymousTypes(anonymousTypeParts, anonymousTypeToName); return(new AnonymousTypeDisplayInfo(anonymousTypeToName, anonymousTypeParts)); }
protected AbstractSymbolDescriptionBuilder( ISymbolDisplayService displayService, SemanticModel semanticModel, int position, Workspace workspace, IAnonymousTypeDisplayService anonymousTypeDisplayService, CancellationToken cancellationToken) { _displayService = displayService; _anonymousTypeDisplayService = anonymousTypeDisplayService; this.Workspace = workspace; this.CancellationToken = cancellationToken; _semanticModel = semanticModel; _position = position; }
private SignatureHelpSymbolParameter InlineDelegateAnonymousTypes( SignatureHelpSymbolParameter parameter, SemanticModel semanticModel, int position, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService) { return(new SignatureHelpSymbolParameter( parameter.Name, parameter.IsOptional, parameter.DocumentationFactory, anonymousTypeDisplayService.InlineDelegateAnonymousTypes(parameter.DisplayParts, semanticModel, position, symbolDisplayService), anonymousTypeDisplayService.InlineDelegateAnonymousTypes(parameter.PrefixDisplayParts, semanticModel, position, symbolDisplayService), anonymousTypeDisplayService.InlineDelegateAnonymousTypes(parameter.SuffixDisplayParts, semanticModel, position, symbolDisplayService), anonymousTypeDisplayService.InlineDelegateAnonymousTypes(parameter.SelectedDisplayParts, semanticModel, position, symbolDisplayService))); }
public AnonymousTypeDisplayInfo GetNormalAnonymousTypeDisplayInfo( ISymbol orderSymbol, IEnumerable<INamedTypeSymbol> directNormalAnonymousTypeReferences, SemanticModel semanticModel, int position, ISymbolDisplayService displayService) { if (!directNormalAnonymousTypeReferences.Any()) { return new AnonymousTypeDisplayInfo( SpecializedCollections.EmptyDictionary<INamedTypeSymbol, string>(), SpecializedCollections.EmptyList<SymbolDisplayPart>()); } var transitiveNormalAnonymousTypeReferences = GetTransitiveNormalAnonymousTypeReferences(directNormalAnonymousTypeReferences.ToSet()); transitiveNormalAnonymousTypeReferences = OrderAnonymousTypes(transitiveNormalAnonymousTypeReferences, orderSymbol); IList<SymbolDisplayPart> anonymousTypeParts = new List<SymbolDisplayPart>(); anonymousTypeParts.Add(PlainText(FeaturesResources.AnonymousTypes)); anonymousTypeParts.AddRange(LineBreak()); for (int i = 0; i < transitiveNormalAnonymousTypeReferences.Count; i++) { if (i != 0) { anonymousTypeParts.AddRange(LineBreak()); } var anonymousType = transitiveNormalAnonymousTypeReferences[i]; anonymousTypeParts.AddRange(Space(count: 4)); anonymousTypeParts.Add(Part(SymbolDisplayPartKind.ClassName, anonymousType, anonymousType.Name)); anonymousTypeParts.AddRange(Space()); anonymousTypeParts.Add(PlainText(FeaturesResources.Is)); anonymousTypeParts.AddRange(Space()); anonymousTypeParts.AddRange(GetAnonymousTypeParts(anonymousType, semanticModel, position, displayService)); } // Now, inline any delegate anonymous types we've got. anonymousTypeParts = this.InlineDelegateAnonymousTypes(anonymousTypeParts, semanticModel, position, displayService); // Finally, assign a name to all the anonymous types. var anonymousTypeToName = GenerateAnonymousTypeNames(transitiveNormalAnonymousTypeReferences); anonymousTypeParts = AnonymousTypeDisplayInfo.ReplaceAnonymousTypes(anonymousTypeParts, anonymousTypeToName); return new AnonymousTypeDisplayInfo(anonymousTypeToName, anonymousTypeParts); }
private CompletionItem CreateItem( ISymbol symbol, ISymbolDisplayService symbolDisplayService, SemanticModel semanticModel, SyntaxToken startToken, DeclarationModifiers modifiers) { var position = startToken.SpanStart; var displayString = symbolDisplayService.ToMinimalDisplayString(semanticModel, position, symbol, _overrideNameFormat); return(MemberInsertionCompletionItem.Create( displayString, modifiers, _startLineNumber, symbol, startToken, position, rules: _provider.GetRules())); }
private (IList <SignatureHelpItem>, int?) GetMethodGroupItemsAndSelection( InvocationExpressionSyntax invocationExpression, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, ISymbol within, IEnumerable <IMethodSymbol> methodGroup, SymbolInfo currentSymbol, CancellationToken cancellationToken) { ITypeSymbol throughType = null; if (invocationExpression.Expression is MemberAccessExpressionSyntax) { var throughExpression = ((MemberAccessExpressionSyntax)invocationExpression.Expression).Expression; var throughSymbol = semanticModel.GetSymbolInfo(throughExpression, cancellationToken).GetAnySymbol(); // if it is via a base expression "base.", we know the "throughType" is the base class but // we need to be able to tell between "base.M()" and "new Base().M()". // currently, Access check methods do not differentiate between them. // so handle "base." primary-expression here by nulling out "throughType" if (!(throughExpression is BaseExpressionSyntax)) { throughType = semanticModel.GetTypeInfo(throughExpression, cancellationToken).Type; } var includeInstance = !throughExpression.IsKind(SyntaxKind.IdentifierName) || semanticModel.LookupSymbols(throughExpression.SpanStart, name: throughSymbol.Name).Any(s => !(s is INamedTypeSymbol)) || (!(throughSymbol is INamespaceOrTypeSymbol) && semanticModel.LookupSymbols(throughExpression.SpanStart, container: throughSymbol.ContainingType).Any(s => !(s is INamedTypeSymbol))); var includeStatic = throughSymbol is INamedTypeSymbol || (throughExpression.IsKind(SyntaxKind.IdentifierName) && semanticModel.LookupNamespacesAndTypes(throughExpression.SpanStart, name: throughSymbol.Name).Any(t => Equals(t.GetSymbolType(), throughType))); Contract.ThrowIfFalse(includeInstance || includeStatic); methodGroup = methodGroup.Where(m => (m.IsStatic && includeStatic) || (!m.IsStatic && includeInstance)); } else if (invocationExpression.Expression is SimpleNameSyntax && invocationExpression.IsInStaticContext()) { // We always need to include local functions regardless of whether they are static. methodGroup = methodGroup.Where(m => m.IsStatic || m is IMethodSymbol { MethodKind: MethodKind.LocalFunction });
private MemberInsertionCompletionItem CreateItem( ISymbol symbol, TextSpan textChangeSpan, ISymbolDisplayService symbolDisplayService, SemanticModel semanticModel, SyntaxToken startToken, DeclarationModifiers modifiers) { var position = startToken.SpanStart; var displayString = symbolDisplayService.ToMinimalDisplayString(semanticModel, position, symbol, _overrideNameFormat); return(new MemberInsertionCompletionItem(_provider, displayString, textChangeSpan, CommonCompletionUtilities.CreateDescriptionFactory(_document.Project.Solution.Workspace, semanticModel, position, symbol), symbol.GetGlyph(), modifiers, _startLineNumber, symbol.GetSymbolKey(), startToken)); }
private IList<SignatureHelpItem> GetNormalTypeConstructors( Document document, ObjectCreationExpressionSyntax objectCreationExpression, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, INamedTypeSymbol normalType, ISymbol within, CancellationToken cancellationToken) { var accessibleConstructors = normalType.InstanceConstructors .Where(c => c.IsAccessibleWithin(within)) .Where(s => s.IsEditorBrowsable(document.ShouldHideAdvancedMembers(), semanticModel.Compilation)) .Sort(symbolDisplayService, semanticModel, objectCreationExpression.SpanStart); return accessibleConstructors.Select(c => ConvertNormalTypeConstructor(c, objectCreationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService, cancellationToken)).ToList(); }
public static IList<SymbolDisplayPart> InlineDelegateAnonymousTypes( this IAnonymousTypeDisplayService service, IList<SymbolDisplayPart> parts, SemanticModel semanticModel, int position, ISymbolDisplayService displayService) { IList<SymbolDisplayPart> result = parts; while (true) { var delegateAnonymousType = result.Select(p => p.Symbol).OfType<INamedTypeSymbol>().FirstOrDefault(s => s.IsAnonymousDelegateType()); if (delegateAnonymousType == null) { break; } result = result == parts ? new List<SymbolDisplayPart>(parts) : result; ReplaceAnonymousType(result, delegateAnonymousType, service.GetAnonymousTypeParts(delegateAnonymousType, semanticModel, position, displayService)); } return result; }
private IList <SignatureHelpItem> GetNormalTypeConstructors( Document document, ObjectCreationExpressionSyntax objectCreationExpression, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, INamedTypeSymbol normalType, ISymbol within, CancellationToken cancellationToken) { var accessibleConstructors = normalType.InstanceConstructors .Where(c => c.IsAccessibleWithin(within)) .Where(s => s.IsEditorBrowsable(document.ShouldHideAdvancedMembers(), semanticModel.Compilation)) .Sort(symbolDisplayService, semanticModel, objectCreationExpression.SpanStart); return(accessibleConstructors.Select(c => ConvertNormalTypeConstructor(c, objectCreationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService, cancellationToken)).ToList()); }
private SignatureHelpItem Convert( ISymbol symbol, SyntaxToken lessThanToken, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, CancellationToken cancellationToken) { var position = lessThanToken.SpanStart; SignatureHelpItem item; if (symbol is INamedTypeSymbol) { var namedType = (INamedTypeSymbol)symbol; item = CreateItem( symbol, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService, false, symbol.GetDocumentationParts(semanticModel, position, documentationCommentFormattingService, cancellationToken), GetPreambleParts(namedType, semanticModel, position), GetSeparatorParts(), GetPostambleParts(namedType), namedType.TypeParameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService, cancellationToken))); } else { var method = (IMethodSymbol)symbol; item = CreateItem( symbol, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService, false, symbol.GetDocumentationParts(semanticModel, position, documentationCommentFormattingService, cancellationToken).Concat(GetAwaitableUsage(method, semanticModel, position)), GetPreambleParts(method, semanticModel, position), GetSeparatorParts(), GetPostambleParts(method, semanticModel, position), method.TypeParameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService, cancellationToken))); } return(item); }
protected SignatureHelpItem CreateItem( ISymbol orderSymbol, SemanticModel semanticModel, int position, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, bool isVariadic, Func <CancellationToken, IEnumerable <SymbolDisplayPart> > documentationFactory, IEnumerable <SymbolDisplayPart> prefixParts, IEnumerable <SymbolDisplayPart> separatorParts, IEnumerable <SymbolDisplayPart> suffixParts, IEnumerable <SignatureHelpParameter> parameters, IEnumerable <SymbolDisplayPart> descriptionParts = null) { var item = new SymbolKeySignatureHelpItem( orderSymbol, isVariadic, documentationFactory, prefixParts, separatorParts, suffixParts, parameters, descriptionParts); return(FixAnonymousTypeParts(orderSymbol, item, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService)); }
protected SignatureHelpItem CreateItem( ISymbol orderSymbol, SemanticModel semanticModel, int position, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, bool isVariadic, Func<CancellationToken, IEnumerable<SymbolDisplayPart>> documentationFactory, IEnumerable<SymbolDisplayPart> prefixParts, IEnumerable<SymbolDisplayPart> separatorParts, IEnumerable<SymbolDisplayPart> suffixParts, IEnumerable<SignatureHelpParameter> parameters, IEnumerable<SymbolDisplayPart> descriptionParts = null) { var item = new SymbolKeySignatureHelpItem( orderSymbol, isVariadic, documentationFactory, prefixParts, separatorParts, suffixParts, parameters, descriptionParts); return FixAnonymousTypeParts(orderSymbol, item, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService); }
private SignatureHelpItem Convert( IPropertySymbol indexer, SyntaxToken openToken, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, CancellationToken cancellationToken) { var position = openToken.SpanStart; var item = CreateItem(indexer, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService, indexer.IsParams(), indexer.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormattingService), GetPreambleParts(indexer, position, semanticModel), GetSeparatorParts(), GetPostambleParts(indexer), indexer.Parameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService, cancellationToken)).ToList()); return(item); }
private SignatureHelpItem ConvertNormalTypeConstructor( IMethodSymbol constructor, ObjectCreationExpressionSyntax objectCreationExpression, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, CancellationToken cancellationToken) { var position = objectCreationExpression.SpanStart; var item = CreateItem( constructor, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService, constructor.IsParams(), constructor.GetDocumentationParts(semanticModel, position, documentationCommentFormattingService, cancellationToken), GetNormalTypePreambleParts(constructor, semanticModel, position), GetSeparatorParts(), GetNormalTypePostambleParts(constructor), constructor.Parameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService, cancellationToken))); return item; }
private SignatureHelpItem ConvertMethodGroupMethod( IMethodSymbol method, InvocationExpressionSyntax invocationExpression, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, CancellationToken cancellationToken) { var position = invocationExpression.SpanStart; var item = CreateItem( method, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService, method.IsParams(), c => method.OriginalDefinition.GetDocumentationParts(semanticModel, position, documentationCommentFormattingService, c).Concat(GetAwaitableUsage(method, semanticModel, position)), GetMethodGroupPreambleParts(method, semanticModel, position), GetSeparatorParts(), GetMethodGroupPostambleParts(method), method.Parameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService, cancellationToken))); return(item); }
private SignatureHelpItem ConvertNormalTypeConstructor( IMethodSymbol constructor, ObjectCreationExpressionSyntax objectCreationExpression, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, CancellationToken cancellationToken) { var position = objectCreationExpression.SpanStart; var item = CreateItem( constructor, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService, constructor.IsParams(), constructor.GetDocumentationParts(semanticModel, position, documentationCommentFormattingService, cancellationToken), GetNormalTypePreambleParts(constructor, semanticModel, position), GetSeparatorParts(), GetNormalTypePostambleParts(constructor), constructor.Parameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService, cancellationToken))); return(item); }
private (IList <SignatureHelpItem> items, int?selectedItem) GetNormalTypeConstructors( Document document, ObjectCreationExpressionSyntax objectCreationExpression, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, INamedTypeSymbol normalType, ISymbol within, CancellationToken cancellationToken) { var accessibleConstructors = normalType.InstanceConstructors .WhereAsArray(c => c.IsAccessibleWithin(within)) .WhereAsArray(s => s.IsEditorBrowsable(document.ShouldHideAdvancedMembers(), semanticModel.Compilation)) .Sort(symbolDisplayService, semanticModel, objectCreationExpression.SpanStart); var symbolInfo = semanticModel.GetSymbolInfo(objectCreationExpression, cancellationToken); var selectedItem = TryGetSelectedIndex(accessibleConstructors, symbolInfo); var items = accessibleConstructors.SelectAsArray(c => ConvertNormalTypeConstructor(c, objectCreationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService, cancellationToken)); return(items, selectedItem); }
private SignatureHelpItem FixAnonymousTypeParts( ISymbol orderSymbol, SignatureHelpItem item, SemanticModel semanticModel, int position, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService) { var currentItem = new SymbolKeySignatureHelpItem( orderSymbol, item.IsVariadic, item.DocumentationFactory, anonymousTypeDisplayService.InlineDelegateAnonymousTypes(item.PrefixDisplayParts, semanticModel, position, symbolDisplayService), anonymousTypeDisplayService.InlineDelegateAnonymousTypes(item.SeparatorDisplayParts, semanticModel, position, symbolDisplayService), anonymousTypeDisplayService.InlineDelegateAnonymousTypes(item.SuffixDisplayParts, semanticModel, position, symbolDisplayService), item.Parameters.Select(p => InlineDelegateAnonymousTypes(p, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService)), item.DescriptionParts); var directAnonymousTypeReferences = from part in currentItem.GetAllParts() where part.Symbol.IsNormalAnonymousType() select(INamedTypeSymbol) part.Symbol; var info = anonymousTypeDisplayService.GetNormalAnonymousTypeDisplayInfo( orderSymbol, directAnonymousTypeReferences, semanticModel, position, symbolDisplayService); if (info.AnonymousTypesParts.Count > 0) { var anonymousTypeParts = new List <SymbolDisplayPart> { new SymbolDisplayPart(SymbolDisplayPartKind.Space, null, "\r\n\r\n") }; anonymousTypeParts.AddRange(info.AnonymousTypesParts); currentItem = new SymbolKeySignatureHelpItem( orderSymbol, currentItem.IsVariadic, currentItem.DocumentationFactory, info.ReplaceAnonymousTypes(currentItem.PrefixDisplayParts), info.ReplaceAnonymousTypes(currentItem.SeparatorDisplayParts), info.ReplaceAnonymousTypes(currentItem.SuffixDisplayParts), currentItem.Parameters.Select(p => ReplaceAnonymousTypes(p, info)), anonymousTypeParts); } return(currentItem); }
private SignatureHelpItem FixAnonymousTypeParts( ISymbol orderSymbol, SignatureHelpItem item, SemanticModel semanticModel, int position, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService) { var currentItem = new SymbolKeySignatureHelpItem( orderSymbol, item.IsVariadic, item.DocumenationFactory, anonymousTypeDisplayService.InlineDelegateAnonymousTypes(item.PrefixDisplayParts, semanticModel, position, symbolDisplayService), anonymousTypeDisplayService.InlineDelegateAnonymousTypes(item.SeparatorDisplayParts, semanticModel, position, symbolDisplayService), anonymousTypeDisplayService.InlineDelegateAnonymousTypes(item.SuffixDisplayParts, semanticModel, position, symbolDisplayService), item.Parameters.Select(p => InlineDelegateAnonymousTypes(p, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService)), item.DescriptionParts); var directAnonymousTypeReferences = from part in currentItem.GetAllParts() where part.Symbol.IsNormalAnonymousType() select (INamedTypeSymbol)part.Symbol; var info = anonymousTypeDisplayService.GetNormalAnonymousTypeDisplayInfo( orderSymbol, directAnonymousTypeReferences, semanticModel, position, symbolDisplayService); if (info.AnonymousTypesParts.Count > 0) { var anonymousTypeParts = new List<SymbolDisplayPart> { new SymbolDisplayPart(SymbolDisplayPartKind.Space, null, "\r\n\r\n") }; anonymousTypeParts.AddRange(info.AnonymousTypesParts); currentItem = new SymbolKeySignatureHelpItem( orderSymbol, currentItem.IsVariadic, currentItem.DocumenationFactory, info.ReplaceAnonymousTypes(currentItem.PrefixDisplayParts), info.ReplaceAnonymousTypes(currentItem.SeparatorDisplayParts), info.ReplaceAnonymousTypes(currentItem.SuffixDisplayParts), currentItem.Parameters.Select(p => ReplaceAnonymousTypes(p, info)), anonymousTypeParts); } return currentItem; }
private CompletionItem CreateItem( ISymbol symbol, TextSpan textChangeSpan, ISymbolDisplayService symbolDisplayService, SemanticModel semanticModel, SyntaxToken startToken, DeclarationModifiers modifiers) { var position = startToken.SpanStart; var displayString = symbolDisplayService.ToMinimalDisplayString(semanticModel, position, symbol, _overrideNameFormat); return MemberInsertionCompletionItem.Create( displayString, textChangeSpan, symbol.GetGlyph(), modifiers, _startLineNumber, symbol, startToken, position, rules: _provider.GetRules()); }
public override IEnumerable <SymbolDisplayPart> GetAnonymousTypeParts( INamedTypeSymbol anonymousType, SemanticModel semanticModel, int position, ISymbolDisplayService displayService) { var members = new List <SymbolDisplayPart>(); members.Add(Keyword(SyntaxFacts.GetText(SyntaxKind.NewKeyword))); members.AddRange(Space()); members.Add(Punctuation(SyntaxFacts.GetText(SyntaxKind.OpenBraceToken))); members.AddRange(Space()); bool first = true; foreach (var property in anonymousType.GetValidAnonymousTypeProperties()) { if (!first) { members.Add(Punctuation(SyntaxFacts.GetText(SyntaxKind.CommaToken))); members.AddRange(Space()); } first = false; members.AddRange(displayService.ToMinimalDisplayParts(semanticModel, position, property.Type).Select(p => p.MassageErrorTypeNames("?"))); members.AddRange(Space()); members.Add(new SymbolDisplayPart(SymbolDisplayPartKind.PropertyName, property, property.Name)); } members.AddRange(Space()); members.Add(Punctuation(SyntaxFacts.GetText(SyntaxKind.CloseBraceToken))); return(members); }
private SignatureHelpItem Convert( ISymbol symbol, SyntaxToken lessThanToken, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, CancellationToken cancellationToken) { var position = lessThanToken.SpanStart; SignatureHelpItem item; if (symbol is INamedTypeSymbol) { var namedType = (INamedTypeSymbol)symbol; item = CreateItem( symbol, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService, false, symbol.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormattingService), GetPreambleParts(namedType, semanticModel, position), GetSeparatorParts(), GetPostambleParts(namedType), namedType.TypeParameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService, cancellationToken)).ToList()); } else { var method = (IMethodSymbol)symbol; item = CreateItem( symbol, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService, false, c => symbol.GetDocumentationParts(semanticModel, position, documentationCommentFormattingService, c).Concat(GetAwaitableUsage(method, semanticModel, position)), GetPreambleParts(method, semanticModel, position), GetSeparatorParts(), GetPostambleParts(method, semanticModel, position), method.TypeParameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService, cancellationToken)).ToList()); } return item; }
public abstract IEnumerable <SymbolDisplayPart> GetAnonymousTypeParts( INamedTypeSymbol anonymousType, SemanticModel semanticModel, int position, ISymbolDisplayService displayService);
private IList <SignatureHelpItem> GetDelegateInvokeItems( InvocationExpressionSyntax invocationExpression, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, ISymbol within, INamedTypeSymbol delegateType, CancellationToken cancellationToken) { var invokeMethod = delegateType.DelegateInvokeMethod; if (invokeMethod == null) { return(null); } // Events can only be invoked directly from the class they were declared in. var expressionSymbol = semanticModel.GetSymbolInfo(invocationExpression.Expression, cancellationToken).GetAnySymbol(); if (expressionSymbol.IsKind(SymbolKind.Event) && !expressionSymbol.ContainingType.OriginalDefinition.Equals(within.OriginalDefinition)) { return(null); } var position = invocationExpression.SpanStart; var item = CreateItem( invokeMethod, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService, isVariadic: invokeMethod.IsParams(), documentationFactory: null, prefixParts: GetDelegateInvokePreambleParts(invokeMethod, semanticModel, position), separatorParts: GetSeparatorParts(), suffixParts: GetDelegateInvokePostambleParts(), parameters: GetDelegateInvokeParameters(invokeMethod, semanticModel, position, documentationCommentFormattingService, cancellationToken)); return(SpecializedCollections.SingletonList(item)); }
public abstract IEnumerable<SymbolDisplayPart> GetAnonymousTypeParts( INamedTypeSymbol anonymousType, SemanticModel semanticModel, int position, ISymbolDisplayService displayService);
protected SignatureHelpItem CreateItem( ISymbol orderSymbol, SemanticModel semanticModel, int position, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, bool isVariadic, Func <CancellationToken, IEnumerable <TaggedText> > documentationFactory, IList <SymbolDisplayPart> prefixParts, IList <SymbolDisplayPart> separatorParts, IList <SymbolDisplayPart> suffixParts, IList <SignatureHelpSymbolParameter> parameters, IList <SymbolDisplayPart> descriptionParts = null) { prefixParts = anonymousTypeDisplayService.InlineDelegateAnonymousTypes(prefixParts, semanticModel, position, symbolDisplayService); separatorParts = anonymousTypeDisplayService.InlineDelegateAnonymousTypes(separatorParts, semanticModel, position, symbolDisplayService); suffixParts = anonymousTypeDisplayService.InlineDelegateAnonymousTypes(suffixParts, semanticModel, position, symbolDisplayService); parameters = parameters.Select(p => InlineDelegateAnonymousTypes(p, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService)).ToList(); descriptionParts = descriptionParts == null ? SpecializedCollections.EmptyList <SymbolDisplayPart>() : descriptionParts; var allParts = prefixParts.Concat(separatorParts) .Concat(suffixParts) .Concat(parameters.SelectMany(p => p.GetAllParts())) .Concat(descriptionParts); var directAnonymousTypeReferences = from part in allParts where part.Symbol.IsNormalAnonymousType() select(INamedTypeSymbol) part.Symbol; var info = anonymousTypeDisplayService.GetNormalAnonymousTypeDisplayInfo( orderSymbol, directAnonymousTypeReferences, semanticModel, position, symbolDisplayService); if (info.AnonymousTypesParts.Count > 0) { var anonymousTypeParts = new List <SymbolDisplayPart> { new SymbolDisplayPart(SymbolDisplayPartKind.Space, null, "\r\n\r\n") }; anonymousTypeParts.AddRange(info.AnonymousTypesParts); return(new SymbolKeySignatureHelpItem( orderSymbol, isVariadic, documentationFactory, info.ReplaceAnonymousTypes(prefixParts).ToTaggedText(), info.ReplaceAnonymousTypes(separatorParts).ToTaggedText(), info.ReplaceAnonymousTypes(suffixParts).ToTaggedText(), parameters.Select(p => ReplaceAnonymousTypes(p, info)).Select(p => (SignatureHelpParameter)p), anonymousTypeParts.ToTaggedText())); } return(new SymbolKeySignatureHelpItem( orderSymbol, isVariadic, documentationFactory, prefixParts.ToTaggedText(), separatorParts.ToTaggedText(), suffixParts.ToTaggedText(), parameters.Select(p => (SignatureHelpParameter)p), descriptionParts.ToTaggedText())); }
private SignatureHelpItem Convert( IMethodSymbol constructor, ISymbol within, AttributeSyntax attribute, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormatter, CancellationToken cancellationToken) { var position = attribute.SpanStart; var namedParameters = constructor.ContainingType.GetAttributeNamedParameters(semanticModel.Compilation, within) .OrderBy(s => s.Name) .ToList(); var isVariadic = constructor.Parameters.Length > 0 && constructor.Parameters.Last().IsParams && namedParameters.Count == 0; var item = CreateItem( constructor, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService, isVariadic, constructor.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormatter), GetPreambleParts(constructor, semanticModel, position), GetSeparatorParts(), GetPostambleParts(constructor), GetParameters(constructor, semanticModel, position, namedParameters, documentationCommentFormatter, cancellationToken)); return item; }
private MemberInsertionCompletionItem CreateItem( ISymbol symbol, TextSpan textChangeSpan, ISymbolDisplayService symbolDisplayService, SemanticModel semanticModel, SyntaxToken startToken, DeclarationModifiers modifiers) { var position = startToken.SpanStart; var displayString = symbolDisplayService.ToMinimalDisplayString(semanticModel, position, symbol, _overrideNameFormat); return new MemberInsertionCompletionItem(_provider, displayString, textChangeSpan, CommonCompletionUtilities.CreateDescriptionFactory(_document.Project.Solution.Workspace, semanticModel, position, symbol), symbol.GetGlyph(), modifiers, _startLineNumber, symbol.GetSymbolKey(), startToken); }
private IEnumerable<CodeAction> CreateActions( CodeFixContext context, Document document, Diagnostic diagnostic, SyntaxNode node, SemanticModel semanticModel, IEnumerable<INamespaceOrTypeSymbol> proposedContainers, ISymbolDisplayService displayService) { foreach (var container in proposedContainers) { var containerName = displayService.ToMinimalDisplayString(semanticModel, node.SpanStart, container); var name = GetNodeName(document, node); // Actual member name might differ by case. string memberName; if (this.IgnoreCase) { var member = container.GetMembers(name).FirstOrDefault(); memberName = member != null ? member.Name : name; } else { memberName = name; } var codeAction = new MyCodeAction( $"{containerName}.{memberName}", c => ProcessNode(document, node, containerName, c)); yield return codeAction; } }
private SignatureHelpItem Convert( IPropertySymbol indexer, SyntaxToken openToken, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, CancellationToken cancellationToken) { var position = openToken.SpanStart; var item = CreateItem(indexer, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService, indexer.IsParams(), indexer.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormattingService), GetPreambleParts(indexer, position, semanticModel), GetSeparatorParts(), GetPostambleParts(indexer), indexer.Parameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService, cancellationToken))); return item; }
private SignatureHelpParameter InlineDelegateAnonymousTypes( SignatureHelpParameter parameter, SemanticModel semanticModel, int position, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService) { return new SignatureHelpParameter( parameter.Name, parameter.IsOptional, parameter.DocumentationFactory, anonymousTypeDisplayService.InlineDelegateAnonymousTypes(parameter.DisplayParts, semanticModel, position, symbolDisplayService), anonymousTypeDisplayService.InlineDelegateAnonymousTypes(parameter.PrefixDisplayParts, semanticModel, position, symbolDisplayService), anonymousTypeDisplayService.InlineDelegateAnonymousTypes(parameter.SuffixDisplayParts, semanticModel, position, symbolDisplayService), anonymousTypeDisplayService.InlineDelegateAnonymousTypes(parameter.SelectedDisplayParts, semanticModel, position, symbolDisplayService)); }
public static IList <SymbolDisplayPart> InlineDelegateAnonymousTypes( this IAnonymousTypeDisplayService service, IList <SymbolDisplayPart> parts, SemanticModel semanticModel, int position, ISymbolDisplayService displayService) { var result = parts; while (true) { var delegateAnonymousType = result.Select(p => p.Symbol).OfType <INamedTypeSymbol>().FirstOrDefault(s => s.IsAnonymousDelegateType()); if (delegateAnonymousType == null) { break; } result = result == parts ? new List <SymbolDisplayPart>(parts) : result; ReplaceAnonymousType(result, delegateAnonymousType, service.GetAnonymousTypeParts(delegateAnonymousType, semanticModel, position, displayService)); } return(result); }
private SignatureHelpItem ConvertMethodGroupMethod( IMethodSymbol method, InvocationExpressionSyntax invocationExpression, SemanticModel semanticModel, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, CancellationToken cancellationToken) { var position = invocationExpression.SpanStart; var item = CreateItem( method, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService, method.IsParams(), c => method.OriginalDefinition.GetDocumentationParts(semanticModel, position, documentationCommentFormattingService, c).Concat(GetAwaitableUsage(method, semanticModel, position)), GetMethodGroupPreambleParts(method, semanticModel, position), GetSeparatorParts(), GetMethodGroupPostambleParts(method), method.Parameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService, cancellationToken))); return item; }
protected SignatureHelpItem CreateItem( ISymbol orderSymbol, SemanticModel semanticModel, int position, ISymbolDisplayService symbolDisplayService, IAnonymousTypeDisplayService anonymousTypeDisplayService, bool isVariadic, Func<CancellationToken, IEnumerable<TaggedText>> documentationFactory, IList<SymbolDisplayPart> prefixParts, IList<SymbolDisplayPart> separatorParts, IList<SymbolDisplayPart> suffixParts, IList<SignatureHelpSymbolParameter> parameters, IList<SymbolDisplayPart> descriptionParts = null) { prefixParts = anonymousTypeDisplayService.InlineDelegateAnonymousTypes(prefixParts, semanticModel, position, symbolDisplayService); separatorParts = anonymousTypeDisplayService.InlineDelegateAnonymousTypes(separatorParts, semanticModel, position, symbolDisplayService); suffixParts = anonymousTypeDisplayService.InlineDelegateAnonymousTypes(suffixParts, semanticModel, position, symbolDisplayService); parameters = parameters.Select(p => InlineDelegateAnonymousTypes(p, semanticModel, position, symbolDisplayService, anonymousTypeDisplayService)).ToList(); descriptionParts = descriptionParts == null ? SpecializedCollections.EmptyList<SymbolDisplayPart>() : descriptionParts; var allParts = prefixParts.Concat(separatorParts) .Concat(suffixParts) .Concat(parameters.SelectMany(p => p.GetAllParts())) .Concat(descriptionParts); var directAnonymousTypeReferences = from part in allParts where part.Symbol.IsNormalAnonymousType() select (INamedTypeSymbol)part.Symbol; var info = anonymousTypeDisplayService.GetNormalAnonymousTypeDisplayInfo( orderSymbol, directAnonymousTypeReferences, semanticModel, position, symbolDisplayService); if (info.AnonymousTypesParts.Count > 0) { var anonymousTypeParts = new List<SymbolDisplayPart> { new SymbolDisplayPart(SymbolDisplayPartKind.Space, null, "\r\n\r\n") }; anonymousTypeParts.AddRange(info.AnonymousTypesParts); return new SymbolKeySignatureHelpItem( orderSymbol, isVariadic, documentationFactory, info.ReplaceAnonymousTypes(prefixParts).ToTaggedText(), info.ReplaceAnonymousTypes(separatorParts).ToTaggedText(), info.ReplaceAnonymousTypes(suffixParts).ToTaggedText(), parameters.Select(p => ReplaceAnonymousTypes(p, info)).Select(p => (SignatureHelpParameter)p), anonymousTypeParts.ToTaggedText()); } return new SymbolKeySignatureHelpItem( orderSymbol, isVariadic, documentationFactory, prefixParts.ToTaggedText(), separatorParts.ToTaggedText(), suffixParts.ToTaggedText(), parameters.Select(p => (SignatureHelpParameter)p), descriptionParts.ToTaggedText()); }