コード例 #1
0
        private void HandlePathWatchChange(JToken section)
        {
            var watchSearchPaths = GetSetting(section, "watchSearchPaths", true);

            if (!watchSearchPaths)
            {
                // No longer watching.
                _pathsWatcher?.Dispose();
                _searchPaths      = Array.Empty <string>();
                _watchSearchPaths = false;
                return;
            }

            // Now watching.
            if (!_watchSearchPaths || (_watchSearchPaths && _searchPaths.SetEquals(_initParams.initializationOptions.searchPaths)))
            {
                // Were not watching OR were watching but paths have changed. Recreate the watcher.
                _pathsWatcher?.Dispose();
                _pathsWatcher = new PathsWatcher(
                    _initParams.initializationOptions.searchPaths,
                    () => _server.ReloadModulesAsync(CancellationToken.None).DoNotWait(),
                    _server
                    );
            }

            _watchSearchPaths = watchSearchPaths;
            _searchPaths      = _initParams.initializationOptions.searchPaths;
        }
コード例 #2
0
        private void HandlePathWatchChanges(JToken section, CancellationToken cancellationToken)
        {
            var watchSearchPaths = GetSetting(section, "watchSearchPaths", true);

            if (!watchSearchPaths)
            {
                // No longer watching.
                _pathsWatcher?.Dispose();
                _searchPaths      = Array.Empty <string>();
                _watchSearchPaths = false;
                return;
            }

            // Now watching.
            if (!_watchSearchPaths || (_watchSearchPaths && _searchPaths.SetEquals(_initParams.initializationOptions.searchPaths)))
            {
                // Were not watching OR were watching but paths have changed. Recreate the watcher.
                _pathsWatcher?.Dispose();
                _pathsWatcher = new PathsWatcher(
                    _initParams.initializationOptions.searchPaths,
                    () => _server.NotifyPackagesChanged(cancellationToken),
                    _services.GetService <ILogger>()
                    );

                _watchSearchPaths = true;
                _searchPaths      = _initParams.initializationOptions.searchPaths;
            }
        }
コード例 #3
0
        private void ResetPathWatcher()
        {
            var paths = _interpreter.ModuleResolution.InterpreterPaths.ToArray();

            if (_searchPaths == null || !_searchPaths.SequenceEqual(paths))
            {
                _searchPaths = paths;
                _pathsWatcher?.Dispose();
                _pathsWatcher = new PathsWatcher(_searchPaths, NotifyPackagesChanged, _log);
            }
        }
コード例 #4
0
        public async Task DidChangeConfiguration(JToken token, CancellationToken cancellationToken)
        {
            using (await _prioritizer.ConfigurationPriorityAsync(cancellationToken)) {
                var settings = new LanguageServerSettings();

                var rootSection   = token["settings"];
                var pythonSection = rootSection?["python"];
                if (pythonSection == null)
                {
                    return;
                }

                var autoComplete = pythonSection["autoComplete"];
                settings.completion.showAdvancedMembers = GetSetting(autoComplete, "showAdvancedMembers", true);

                var analysis = pythonSection["analysis"];
                settings.analysis.openFilesOnly     = GetSetting(analysis, "openFilesOnly", false);
                settings.diagnosticPublishDelay     = GetSetting(analysis, "diagnosticPublishDelay", 1000);
                settings.symbolsHierarchyDepthLimit = GetSetting(analysis, "symbolsHierarchyDepthLimit", 10);

                _ui.SetLogLevel(GetLogLevel(analysis));

                _idleTimeTracker?.Dispose();
                _idleTimeTracker = new IdleTimeTracker(settings.diagnosticPublishDelay, PublishPendingDiagnostics);

                _pathsWatcher?.Dispose();
                var watchSearchPaths = GetSetting(analysis, "watchSearchPaths", true);
                if (watchSearchPaths)
                {
                    if (!_searchPaths.SetEquals(_initParams.initializationOptions.searchPaths))
                    {
                        _pathsWatcher = new PathsWatcher(
                            _initParams.initializationOptions.searchPaths,
                            () => _server.ReloadModulesAsync(CancellationToken.None).DoNotWait(),
                            _server
                            );
                    }
                }

                var errors      = GetSetting(analysis, "errors", Array.Empty <string>());
                var warnings    = GetSetting(analysis, "warnings", Array.Empty <string>());
                var information = GetSetting(analysis, "information", Array.Empty <string>());
                var disabled    = GetSetting(analysis, "disabled", Array.Empty <string>());
                settings.analysis.SetErrorSeverityOptions(errors, warnings, information, disabled);

                await _server.DidChangeConfiguration(new DidChangeConfigurationParams { settings = settings }, cancellationToken);

                if (!_filesLoaded)
                {
                    await LoadDirectoryFiles();
                }
                _filesLoaded = true;
            }
        }
コード例 #5
0
ファイル: LanguageServer.cs プロジェクト: willv84/PTVS
        public async Task DidChangeConfiguration(JToken token, CancellationToken cancellationToken)
        {
            var settings = new LanguageServerSettings();

            var rootSection   = token["settings"];
            var pythonSection = rootSection?["python"];

            if (pythonSection == null)
            {
                return;
            }

            var autoComplete = pythonSection["autoComplete"];

            settings.completion.showAdvancedMembers = GetSetting(autoComplete, "showAdvancedMembers", true);

            var analysis = pythonSection["analysis"];

            settings.analysis.openFilesOnly = GetSetting(analysis, "openFilesOnly", false);

            _pathsWatcher?.Dispose();
            var watchSearchPaths = GetSetting(analysis, "watchSearchPaths", true);

            if (watchSearchPaths)
            {
                _pathsWatcher = new PathsWatcher(
                    _initParams.initializationOptions.searchPaths,
                    () => _server.ReloadModulesAsync(CancellationToken.None).DoNotWait()
                    );
            }

            var errors      = GetSetting(analysis, "errors", Array.Empty <string>());
            var warnings    = GetSetting(analysis, "warnings", Array.Empty <string>());
            var information = GetSetting(analysis, "information", Array.Empty <string>());
            var disabled    = GetSetting(analysis, "disabled", Array.Empty <string>());

            settings.analysis.SetErrorSeverityOptions(errors, warnings, information, disabled);

            await _server.DidChangeConfiguration(new DidChangeConfigurationParams { settings = settings }, cancellationToken);

            if (!_filesLoaded)
            {
                await LoadDirectoryFiles();

                _filesLoaded = true;
            }
        }
コード例 #6
0
        public void HandleWatchPathsChange(bool watchSearchPaths)
        {
            if (watchSearchPaths == _watchSearchPaths)
            {
                return;
            }

            _watchSearchPaths = watchSearchPaths;

            if (!_watchSearchPaths)
            {
                _searchPaths = null;
                _pathsWatcher?.Dispose();
                _pathsWatcher = null;
                return;
            }

            ResetPathWatcher();
        }