Ejemplo n.º 1
0
        public LanguageSettingsPersister(
            [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider,
            IGlobalOptionService optionService)
            : base(assertIsForeground: true)
        {
            _textManager = (IVsTextManager4)serviceProvider.GetService(typeof(SVsTextManager));
            _optionService = optionService;

            // TODO: make this configurable
            _languageMap = BidirectionalMap<string, Tuple<Guid>>.Empty.Add(LanguageNames.CSharp, Tuple.Create(Guids.CSharpLanguageServiceId))
                                                               .Add(LanguageNames.VisualBasic, Tuple.Create(Guids.VisualBasicLanguageServiceId))
                                                               .Add("TypeScript", Tuple.Create(new Guid("4a0dddb5-7a95-4fbf-97cc-616d07737a77")))
                                                               .Add("F#", Tuple.Create(new Guid("BC6DD5A5-D4D6-4dab-A00D-A51242DBAF1B")))
                                                               .Add("Xaml", Tuple.Create(new Guid("CD53C9A1-6BC2-412B-BE36-CC715ED8DD41")));

            foreach (var languageGuid in _languageMap.Values)
            {
                var languagePreferences = new LANGPREFERENCES3[1];
                languagePreferences[0].guidLang = languageGuid.Item1;

                // The function can potentially fail if that language service isn't installed
                if (ErrorHandler.Succeeded(_textManager.GetUserPreferences4(pViewPrefs: null, pLangPrefs: languagePreferences, pColorPrefs: null)))
                {
                    RefreshLanguageSettings(languagePreferences);
                }
            }

            _textManagerEvents2Sink = ComEventSink.Advise<IVsTextManagerEvents4>(_textManager, this);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// let one such as ETA to set logger for the service layer
        /// </summary>
        internal static void SetLogger(IGlobalOptionService optionsService, string loggerName)
        {
            if (loggerName == null)
            {
                ResetLogger();
            }

            Logger.SetLogger(GetLogger(optionsService, loggerName));
        }
Ejemplo n.º 3
0
        protected override AbstractOptionPageControl CreateOptionPage(IServiceProvider serviceProvider)
        {
            if (_optionService == null)
            {
                var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));

                _optionService = componentModel.GetService<IGlobalOptionService>();
            }

            return new InternalOptionsControl(nameof(LoggerOptions), serviceProvider);
        }
        public RoamingVisualStudioProfileOptionPersister(IGlobalOptionService globalOptionService, [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider)
            : base(assertIsForeground: true) // The GetService call requires being on the UI thread or else it will marshal and risk deadlock
        {
            Contract.ThrowIfNull(globalOptionService);

            this._settingManager = (ISettingsManager)serviceProvider.GetService(typeof(SVsSettingsPersistenceManager));
            _globalOptionService = globalOptionService;

            // While the settings persistence service should be available in all SKUs it is possible an ISO shell author has undefined the
            // contributing package. In that case persistence of settings won't work (we don't bother with a backup solution for persistence
            // as the scenario seems exceedingly unlikely), but we shouldn't crash the IDE.
            if (this._settingManager != null)
            {
                ISettingsSubset settingsSubset = this._settingManager.GetSubset("*");
                settingsSubset.SettingChangedAsync += OnSettingChangedAsync;
            }
        }
Ejemplo n.º 5
0
        public LanguageSettingsPersister(
            [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider,
            IGlobalOptionService optionService)
            : base(assertIsForeground: true)
        {
            _textManager = (IVsTextManager4)serviceProvider.GetService(typeof(SVsTextManager));
            _optionService = optionService;

            // TODO: make this configurable
            _languageMap = BidirectionalMap<string, Guid>.Empty.Add(LanguageNames.CSharp, Guids.CSharpLanguageServiceId)
                                                               .Add(LanguageNames.VisualBasic, Guids.VisualBasicLanguageServiceId)
                                                               .Add("TypeScript", new Guid("4a0dddb5-7a95-4fbf-97cc-616d07737a77"));

            foreach (var languageGuid in _languageMap.Values)
            {
                var languagePreferences = new LANGPREFERENCES3[1];
                languagePreferences[0].guidLang = languageGuid;
                Marshal.ThrowExceptionForHR(_textManager.GetUserPreferences4(pViewPrefs: null, pLangPrefs: languagePreferences, pColorPrefs: null));

                RefreshLanguageSettings(languagePreferences);
            }

            _textManagerEvents2Sink = ComEventSink.Advise<IVsTextManagerEvents4>(_textManager, this);
        }
Ejemplo n.º 6
0
 public EtwLogger(IGlobalOptionService optionService)
 {
     _loggingChecker = new Lazy<Func<FunctionId, bool>>(() => Logger.GetLoggingChecker(optionService));
 }
 public static ValueTask <DocumentFormattingOptions> GetDocumentFormattingOptionsAsync(this Document document, IGlobalOptionService globalOptions, CancellationToken cancellationToken)
 => document.GetDocumentFormattingOptionsAsync(globalOptions.GetDocumentFormattingOptions(document.Project.Language), cancellationToken);
Ejemplo n.º 8
0
 public RazorGlobalOptions(IGlobalOptionService globalOptions)
 {
     _globalOptions = globalOptions;
 }
 public CSharpInlineTypeHintsService(IGlobalOptionService globalOptions)
     : base(globalOptions)
 {
 }
 public ExtractInterfaceCommandHandler(IThreadingContext threadingContext, IGlobalOptionService globalOptions)
     : base(threadingContext, globalOptions)
 {
 }
 public static CompletionOptions GetCompletionOptions(this IGlobalOptionService options, string language)
 => new()
Ejemplo n.º 12
0
 public FSharpGlobalOptions(IGlobalOptionService globalOptions, VisualStudioWorkspace workspace)
 {
     _globalOptions = globalOptions;
     _workspace     = workspace;
 }
Ejemplo n.º 13
0
 public EtwLogger(IGlobalOptionService optionService)
 {
     _loggingChecker = new Lazy <Func <FunctionId, bool> >(() => Logger.GetLoggingChecker(optionService));
 }
Ejemplo n.º 14
0
 public DocumentHighlightsHandler(IHighlightingService highlightingService, IGlobalOptionService globalOptions)
 {
     _highlightingService = highlightingService;
     _globalOptions       = globalOptions;
 }
Ejemplo n.º 15
0
 public static AutoFormattingOptions GetAutoFormattingOptions(this IGlobalOptionService globalOptions, string language)
 => new(
Ejemplo n.º 16
0
 public AbstractInlineParameterNameHintsService(IGlobalOptionService globalOptions)
 {
     _globalOptions = globalOptions;
 }
 public VisualStudioSyntaxTreeConfigurationService(IGlobalOptionService globalOptions)
 {
     _globalOptions = globalOptions;
 }
#pragma warning disable IDE0060 // Unused parameters to match common pattern
    public static DocumentFormattingOptions GetDocumentFormattingOptions(this IGlobalOptionService globalOptions, string language)
    => new(
 public GlobalOptionChangedEventSource(IGlobalOptionService globalOptions, IOption globalOption)
 {
     _globalOptions = globalOptions;
     _globalOption  = globalOption;
 }
 public CachingCodeActionsOptionsProvider(IGlobalOptionService globalOptions)
 {
     _globalOptions = globalOptions;
 }
 protected AbstractEditorInlineRenameService(IEnumerable <IRefactorNotifyService> refactorNotifyServices, IGlobalOptionService globalOptions)
 {
     _refactorNotifyServices = refactorNotifyServices;
     _globalOptions          = globalOptions;
 }
Ejemplo n.º 22
0
 public GoToDefinitionHandler(IMetadataAsSourceFileService metadataAsSourceFileService, IGlobalOptionService globalOptions)
     : base(metadataAsSourceFileService, globalOptions)
 {
 }
Ejemplo n.º 23
0
 public OptionServiceFactory(IGlobalOptionService globalOptionService)
 {
     _globalOptionService = globalOptionService;
 }
 public static SymbolDescriptionOptions GetSymbolDescriptionOptions(this IGlobalOptionService globalOptions, string language)
 => new(
Ejemplo n.º 25
0
            // Local functions
            static BackgroundAnalysisScope?GetBackgroundAnalysisScope(Solution solution, IGlobalOptionService globalOptions)
            {
                var csharpAnalysisScope      = globalOptions.GetOption(SolutionCrawlerOptionsStorage.BackgroundAnalysisScopeOption, LanguageNames.CSharp);
                var visualBasicAnalysisScope = globalOptions.GetOption(SolutionCrawlerOptionsStorage.BackgroundAnalysisScopeOption, LanguageNames.VisualBasic);

                var containsCSharpProject      = solution.Projects.Any(static project => project.Language == LanguageNames.CSharp);
Ejemplo n.º 26
0
 public static DocumentationCommentOptions GetDocumentationCommentOptions(this IGlobalOptionService globalOptions, DocumentOptionSet documentOptions)
 => new(
Ejemplo n.º 27
0
 public CSharpInlineParameterNameHintsService(IGlobalOptionService globalOptions)
     : base(globalOptions)
 {
 }
 public static MetadataAsSourceOptions GetMetadataAsSourceOptions(this IGlobalOptionService globalOptions, HostLanguageServices languageServices)
 => new(
Ejemplo n.º 29
0
 public OptionServiceFactory(IGlobalOptionService globalOptionService) =>
Ejemplo n.º 30
0
 public TraceLogger(IGlobalOptionService optionService)
     : this(Logger.GetLoggingChecker(optionService))
 {
 }
Ejemplo n.º 31
0
 public WorkspacePullDiagnosticHandler(IDiagnosticAnalyzerService analyzerService, EditAndContinueDiagnosticUpdateSource editAndContinueDiagnosticUpdateSource, IGlobalOptionService globalOptions)
     : base(analyzerService, editAndContinueDiagnosticUpdateSource, globalOptions)
 {
 }
 public static IdeCodeStyleOptions GetCodeStyleOptions(this IGlobalOptionService globalOptions, HostLanguageServices languageServices)
 => languageServices.GetRequiredService <ICodeStyleOptionsStorage>().GetOptions(globalOptions);
Ejemplo n.º 33
0
 public InlineHintsKeyProcessorProvider(IGlobalOptionService globalOptionService)
 {
     _globalOptionService = globalOptionService;
 }
 public static IdeCodeStyleOptions.CommonOptions GetCommonCodeStyleOptions(this IGlobalOptionService globalOptions, string language)
 => new()
Ejemplo n.º 35
0
 private static ILogger GetLogger(IGlobalOptionService optionsService, string loggerName)
 {
     switch (loggerName)
     {
         case "EtwLogger":
             return new EtwLogger(optionsService);
         case "TraceLogger":
             return new TraceLogger(Logger.GetLoggingChecker(optionsService));
         default:
             return EmptyLogger.Instance;
     }
 }
Ejemplo n.º 36
0
 static void ResetPerLanguageOption2 <T>(IGlobalOptionService globalOptions, PerLanguageOption2 <T> option)
 {
     globalOptions.SetGlobalOption(new OptionKey(option, LanguageNames.CSharp), option.DefaultValue);
     globalOptions.SetGlobalOption(new OptionKey(option, LanguageNames.VisualBasic), option.DefaultValue);
 }
Ejemplo n.º 37
0
 static void ResetOption2 <T>(IGlobalOptionService globalOptions, Option2 <T> option)
 {
     globalOptions.SetGlobalOption(new OptionKey(option, language: null), option.DefaultValue);
 }
        public RoamingVisualStudioProfileOptionPersister(IThreadingContext threadingContext, IGlobalOptionService globalOptionService, [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider)
            : base(threadingContext, assertIsForeground: true) // The GetService call requires being on the UI thread or else it will marshal and risk deadlock
        {
            Contract.ThrowIfNull(globalOptionService);

            _settingManager      = (ISettingsManager)serviceProvider.GetService(typeof(SVsSettingsPersistenceManager));
            _globalOptionService = globalOptionService;

            // While the settings persistence service should be available in all SKUs it is possible an ISO shell author has undefined the
            // contributing package. In that case persistence of settings won't work (we don't bother with a backup solution for persistence
            // as the scenario seems exceedingly unlikely), but we shouldn't crash the IDE.
            if (_settingManager != null)
            {
                var settingsSubset = _settingManager.GetSubset("*");
                settingsSubset.SettingChangedAsync += OnSettingChangedAsync;
            }
        }