Exemple #1
0
        private AutoCompleteItem MakeAutoCompleteResponse(WantsType wants, ISymbol symbol, string completionText, bool includeOptionalParams = true)
        {
            var displayNameGenerator = new SnippetGenerator();

            displayNameGenerator.IncludeMarkers            = false;
            displayNameGenerator.IncludeOptionalParameters = includeOptionalParams;

            var response = new AutoCompleteItem();

            response.CompletionText = completionText;

            // TODO: Do something more intelligent here
            response.DisplayText = displayNameGenerator.Generate(symbol);

            if ((wants & WantsType.WantDocumentationForEveryCompletionResult) == WantsType.WantDocumentationForEveryCompletionResult)
            {
                response.Description = DocumentationConverter.ConvertDocumentation(symbol.GetDocumentationCommentXml(), "\n" /*_formattingOptions.NewLine*/);
            }

            if ((wants & WantsType.WantReturnType) == WantsType.WantReturnType)
            {
                response.ReturnType = ReturnTypeFormatter.GetReturnType(symbol);
            }

            if ((wants & WantsType.WantKind) == WantsType.WantKind)
            {
                response.Kind = symbol.GetKind();
            }

            // if (request.WantSnippet)
            // {
            //     var snippetGenerator = new SnippetGenerator();
            //     snippetGenerator.IncludeMarkers = true;
            //     snippetGenerator.IncludeOptionalParameters = includeOptionalParams;
            //     response.Snippet = snippetGenerator.Generate(symbol);
            // }

            // if (request.WantMethodHeader)
            // {
            //     response.MethodHeader = displayNameGenerator.Generate(symbol);
            // }

            return(response);
        }
        private static SignatureHelpItem BuildSignature(IMethodSymbol symbol)
        {
            var signature = new SignatureHelpItem();

            signature.Documentation           = symbol.GetDocumentationCommentXml();
            signature.Name                    = symbol.MethodKind == MethodKind.Constructor ? symbol.ContainingType.Name : symbol.Name;
            signature.Label                   = symbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat);
            signature.StructuredDocumentation = DocumentationConverter.GetStructuredDocumentation(symbol);

            signature.Parameters = symbol.Parameters.Select(parameter =>
            {
                return(new SignatureHelpParameter()
                {
                    Name = parameter.Name,
                    Label = parameter.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat),
                    Documentation = signature.StructuredDocumentation.GetParameterText(parameter.Name)
                });
            });

            return(signature);
        }