Exemplo n.º 1
0
        private static string GetParenthesesPreferenceEditorConfigString(CodeStyleOption <ParenthesesPreference> option)
        {
            Debug.Assert(s_parenthesesPreferenceMap.ContainsValue(option.Value));
            var value = s_parenthesesPreferenceMap.GetKeyOrDefault(option.Value) ?? s_parenthesesPreferenceMap.GetKeyOrDefault(ParenthesesPreference.AlwaysForClarity);

            return(option.Notification == null ? value : $"{value}:{option.Notification.ToEditorConfigString()}");
        }
Exemplo n.º 2
0
        private static string GetAccessibilityModifiersRequiredEditorConfigString(CodeStyleOption <AccessibilityModifiersRequired> option)
        {
            // If they provide 'never', they don't need a notification level.
            if (option.Notification == null)
            {
                Debug.Assert(s_accessibilityModifiersRequiredMap.ContainsValue(AccessibilityModifiersRequired.Never));
                return(s_accessibilityModifiersRequiredMap.GetKeyOrDefault(AccessibilityModifiersRequired.Never));
            }

            Debug.Assert(s_accessibilityModifiersRequiredMap.ContainsValue(option.Value));
            return($"{s_accessibilityModifiersRequiredMap.GetKeyOrDefault(option.Value)}:{option.Notification.ToEditorConfigString()}");
        }
Exemplo n.º 3
0
        private static string GetUnusedExpressionAssignmentPreferenceEditorConfigString(CodeStyleOption <UnusedValuePreference> option, UnusedValuePreference defaultPreference)
        {
            Debug.Assert(s_unusedExpressionAssignmentPreferenceMap.ContainsValue(option.Value));
            var value = s_unusedExpressionAssignmentPreferenceMap.GetKeyOrDefault(option.Value) ?? s_unusedExpressionAssignmentPreferenceMap.GetKeyOrDefault(defaultPreference);

            return(option.Notification == null ? value : $"{value}:{option.Notification.ToEditorConfigString()}");
        }
Exemplo n.º 4
0
        private string GetAnalyzerId(BidirectionalMap <string, DiagnosticAnalyzer> analyzerMap, DiagnosticAnalyzer analyzer)
        {
            var analyzerId = analyzerMap.GetKeyOrDefault(analyzer);

            Contract.ThrowIfNull(analyzerId);

            return(analyzerId);
        }
        private async Task HandleHoverRequest(
            TextDocumentPositionParams textDocumentPositionParams,
            RequestContext <Hover> requestContext)
        {
            var document = GetDocument(textDocumentPositionParams.TextDocument);
            var position = ConvertPosition(document, textDocumentPositionParams.Position);

            var providerCoordinatorFactory = GetGlobalService <IQuickInfoProviderCoordinatorFactory>();
            var providerCoordinator        = providerCoordinatorFactory.CreateCoordinator(document);

            var(item, _) = await providerCoordinator.GetItemAsync(document, position, CancellationToken.None);

            var   symbolInfo  = new List <MarkedString>();
            Range?symbolRange = null;

            if (item != null)
            {
                switch (item.Content)
                {
                case QuickInfoDisplayContent c:
                    symbolInfo.Add(new MarkedString
                    {
                        Language = VsCodeLanguageToLanguageNameMap.GetKeyOrDefault(document.Language),
                        Value    = c.MainDescription.GetFullText()
                    });

                    if (!c.Documentation.IsEmpty)
                    {
                        symbolInfo.Add(new MarkedString
                        {
                            Value = c.Documentation.GetFullText()
                        });
                    }

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                symbolRange = ConvertTextSpanToRange(document.SourceText, item.TextSpan);
            }

            await requestContext.SendResult(
                new Hover
            {
                Contents = symbolInfo.ToArray(),
                Range    = symbolRange
            });
        }
Exemplo n.º 6
0
        private string GetAnalyzerId(BidirectionalMap<string, DiagnosticAnalyzer> analyzerMap, DiagnosticAnalyzer analyzer)
        {
            var analyzerId = analyzerMap.GetKeyOrDefault(analyzer);
            Contract.ThrowIfNull(analyzerId);

            return analyzerId;
        }