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); }
/// <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)); }
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; } }
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); }
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);
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()
public FSharpGlobalOptions(IGlobalOptionService globalOptions, VisualStudioWorkspace workspace) { _globalOptions = globalOptions; _workspace = workspace; }
public EtwLogger(IGlobalOptionService optionService) { _loggingChecker = new Lazy <Func <FunctionId, bool> >(() => Logger.GetLoggingChecker(optionService)); }
public DocumentHighlightsHandler(IHighlightingService highlightingService, IGlobalOptionService globalOptions) { _highlightingService = highlightingService; _globalOptions = globalOptions; }
public static AutoFormattingOptions GetAutoFormattingOptions(this IGlobalOptionService globalOptions, string language) => new(
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; }
public GoToDefinitionHandler(IMetadataAsSourceFileService metadataAsSourceFileService, IGlobalOptionService globalOptions) : base(metadataAsSourceFileService, globalOptions) { }
public OptionServiceFactory(IGlobalOptionService globalOptionService) { _globalOptionService = globalOptionService; }
public static SymbolDescriptionOptions GetSymbolDescriptionOptions(this IGlobalOptionService globalOptions, string language) => new(
// 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);
public static DocumentationCommentOptions GetDocumentationCommentOptions(this IGlobalOptionService globalOptions, DocumentOptionSet documentOptions) => new(
public CSharpInlineParameterNameHintsService(IGlobalOptionService globalOptions) : base(globalOptions) { }
public static MetadataAsSourceOptions GetMetadataAsSourceOptions(this IGlobalOptionService globalOptions, HostLanguageServices languageServices) => new(
public OptionServiceFactory(IGlobalOptionService globalOptionService) =>
public TraceLogger(IGlobalOptionService optionService) : this(Logger.GetLoggingChecker(optionService)) { }
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);
public InlineHintsKeyProcessorProvider(IGlobalOptionService globalOptionService) { _globalOptionService = globalOptionService; }
public static IdeCodeStyleOptions.CommonOptions GetCommonCodeStyleOptions(this IGlobalOptionService globalOptions, string language) => new()
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; } }
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); }
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; } }