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 static string[] GetParameterTypeNames(
     ISymbol symbol,
     ISymbolDisplayService symbolDisplayService,
     SemanticModel semanticModel,
     int position)
 {
     return(GetMethodOrIndexerOrEventParameters(symbol)
            .Select(p => symbolDisplayService.ToMinimalDisplayString(semanticModel, position, p.Type))
            .ToArray());
 }
            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()));
            }
Exemple #4
0
            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 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());
            }
        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 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);
            }