Beispiel #1
0
        private async Task InitializeAsync(CancellationToken cancellationToken)
        {
            await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            _lazyRoslynPackage = await RoslynPackage.GetOrLoadAsync(_threadingContext, _serviceProvider, cancellationToken).ConfigureAwait(true);

            Assumes.Present(_lazyRoslynPackage);

            _optionService.RefreshOption(new OptionKey(SolutionCrawlerOptions.SolutionBackgroundAnalysisScopeOption), _lazyRoslynPackage.AnalysisScope);
            _lazyRoslynPackage.AnalysisScopeChanged += OnAnalysisScopeChanged;
        }
        private System.Threading.Tasks.Task OnSettingChangedAsync(object sender, PropertyChangedEventArgs args)
        {
            List <OptionKey> optionsToRefresh = null;

            lock (_optionsToMonitorForChangesGate)
            {
                if (_optionsToMonitorForChanges.TryGetValue(args.PropertyName, out var optionsToRefreshInsideLock))
                {
                    // Make a copy of the list so we aren't using something that might mutate underneath us.
                    optionsToRefresh = optionsToRefreshInsideLock.ToList();
                }
            }

            if (optionsToRefresh != null)
            {
                // Refresh the actual options outside of our _optionsToMonitorForChangesGate so we avoid any deadlocks by calling back
                // into the global option service under our lock. There isn't some race here where if we were fetching an option for the first time
                // while the setting was changed we might not refresh it. Why? We call RecordObservedValueToWatchForChanges before we fetch the value
                // and since this event is raised after the setting is modified, any new setting would have already been observed in GetFirstOrDefaultValue.
                // And if it wasn't, this event will then refresh it.
                foreach (var optionToRefresh in optionsToRefresh)
                {
                    if (TryFetch(optionToRefresh, out var optionValue))
                    {
                        _globalOptionService.RefreshOption(optionToRefresh, optionValue);
                    }
                }
            }

            return(System.Threading.Tasks.Task.CompletedTask);
        }
        private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName != nameof(ITaskList.CommentTokens))
            {
                return;
            }

            var commentString = GetTaskTokenList(_taskList);

            var optionValue = _globalOptionService.GetOption(TodoCommentOptions.TokenList);

            if (optionValue == commentString)
            {
                return;
            }

            // cache last result
            _lastCommentTokenCache = commentString;

            // let people to know that comment string has changed
            _globalOptionService.RefreshOption(
                TodoCommentOptions.TokenList,
                _lastCommentTokenCache
                );
        }
Beispiel #4
0
        private void RefreshLanguageSettings(LANGPREFERENCES3[] langPrefs, string languageName)
        {
            this.AssertIsForeground();

            foreach (var option in _supportedOptions)
            {
                var keyWithLanguage = new OptionKey(option, languageName);
                var newValue        = GetValueForOption(option, langPrefs[0]);

                _globalOptions.RefreshOption(keyWithLanguage, newValue);
            }
        }
        private void RefreshLanguageSettings(LANGPREFERENCES3[] langPrefs)
        {
            this.AssertIsForeground();
            if (_languageMap.TryGetKey(Tuple.Create(langPrefs[0].guidLang), out var languageName))
            {
                foreach (var option in _supportedOptions)
                {
                    var    keyWithLanguage = new OptionKey(option, languageName);
                    object newValue        = GetValueForOption(option, langPrefs[0]);

                    _optionService.RefreshOption(keyWithLanguage, newValue);
                }
            }
        }
Beispiel #6
0
        public void Refresh(string propertyName, object newValue)
        {
            lock (_optionsToMonitorForChanges) {
                if (!_optionsToMonitorForChanges.TryGetValue(propertyName, out var optionsToRefresh))
                {
                    return;
                }

                foreach (var optionToRefresh in optionsToRefresh)
                {
                    globalOptionService.RefreshOption(optionToRefresh, Deserialize(newValue, optionToRefresh.Option.Type));
                }
            }
        }
Beispiel #7
0
            private void Toggle(bool on)
            {
                // No need to do anything if we're already in the requested state
                var state = _globalOptionService.GetOption(InlineHintsOptions.DisplayAllOverride);

                if (state == on)
                {
                    return;
                }

                // We can only enter the on-state if the user has the chord feature enabled.  We can always enter the
                // off state though.
                on = on && _globalOptionService.GetOption(InlineHintsOptions.DisplayAllHintsWhilePressingAltF1);
                _globalOptionService.RefreshOption(new OptionKey(InlineHintsOptions.DisplayAllOverride), on);
            }
        private System.Threading.Tasks.Task OnSettingChangedAsync(object sender, PropertyChangedEventArgs args)
        {
            lock (_optionsToMonitorForChangesGate)
            {
                if (_optionsToMonitorForChanges.TryGetValue(args.PropertyName, out var optionsToRefresh))
                {
                    foreach (var optionToRefresh in optionsToRefresh)
                    {
                        if (TryFetch(optionToRefresh, out var optionValue))
                        {
                            _globalOptionService.RefreshOption(optionToRefresh, optionValue);
                        }
                    }
                }
            }

            return(SpecializedTasks.EmptyTask);
        }