private AutoCompleteResponse MakeAutoCompleteResponse(AutoCompleteRequest request, ISymbol symbol, string completionText, bool preselect, bool isSuggestionMode, bool includeOptionalParams = true)
        {
            var displayNameGenerator = new SnippetGenerator();

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

            var response = new AutoCompleteResponse();

            response.CompletionText = completionText;

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

            response.IsSuggestionMode = isSuggestionMode;

            if (request.WantDocumentationForEveryCompletionResult)
            {
                response.Description = DocumentationConverter.ConvertDocumentation(symbol.GetDocumentationCommentXml(), _formattingOptions.NewLine);
            }

            if (request.WantReturnType)
            {
                response.ReturnType = ReturnTypeFormatter.GetReturnType(symbol);
            }

            if (request.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);
            }

            response.Preselect = preselect;

            return(response);
        }
示例#2
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);
        }