Beispiel #1
0
        private async Task SendDidChangeConfiguration(IPythonLanguageClientContext context)
        {
            if (context is PythonLanguageClientContextProject)
            {
                // Project interactions are main thread only.
                await JoinableTaskContext.Factory.SwitchToMainThreadAsync();
            }

            Debug.Assert(context != null);
            Debug.Assert(_analysisOptions != null);

            var extraPaths = UserSettings.GetStringSetting(
                PythonConstants.ExtraPathsSetting, null, Site, PythonWorkspaceContextProvider.Workspace, out _)?.Split(';')
                             ?? _analysisOptions.ExtraPaths;

            var stubPath = UserSettings.GetStringSetting(
                PythonConstants.StubPathSetting, null, Site, PythonWorkspaceContextProvider.Workspace, out _)
                           ?? _analysisOptions.StubPath;

            var typeCheckingMode = UserSettings.GetStringSetting(
                PythonConstants.TypeCheckingModeSetting, null, Site, PythonWorkspaceContextProvider.Workspace, out _)
                                   ?? _analysisOptions.TypeCheckingMode;

            var ver3 = new Version(3, 0);

            if (context.InterpreterConfiguration.Version < ver3)
            {
                MessageBox.ShowWarningMessage(Site, Strings.WarningPython2NotSupported);
            }

            var settings = new LanguageServerSettings {
                python = new LanguageServerSettings.PythonSettings {
                    pythonPath = context.InterpreterConfiguration.InterpreterPath,
                    venvPath   = string.Empty,
                    analysis   = new LanguageServerSettings.PythonSettings.PythonAnalysisSettings {
                        logLevel               = _analysisOptions.LogLevel,
                        autoSearchPaths        = _analysisOptions.AutoSearchPaths,
                        diagnosticMode         = _analysisOptions.DiagnosticMode,
                        extraPaths             = extraPaths,
                        stubPath               = stubPath,
                        typeshedPaths          = _analysisOptions.TypeshedPaths,
                        typeCheckingMode       = typeCheckingMode,
                        useLibraryCodeForTypes = true,
                        completeFunctionParens = _advancedEditorOptions.CompleteFunctionParens,
                        autoImportCompletions  = _advancedEditorOptions.AutoImportCompletions
                    }
                }
            };

            var config = new LSP.DidChangeConfigurationParams()
            {
                Settings = settings
            };

            await InvokeDidChangeConfigurationAsync(config);
        }
Beispiel #2
0
 public Task InvokeDidChangeConfigurationAsync(LSP.DidChangeConfigurationParams request)
 => _rpc == null ? Task.CompletedTask : _rpc.NotifyWithParameterObjectAsync("workspace/didChangeConfiguration", request);