Beispiel #1
0
 public void AddClientContext(IPythonLanguageClientContext context, bool fireSettingsChanged = false)
 {
     _clientContexts.Add(context);
     context.InterpreterChanged += OnSettingsChanged;
     if (fireSettingsChanged)
     {
         SendDidChangeConfiguration(context).DoNotWait();
     }
 }
Beispiel #2
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 #3
0
 public void AddClientContext(IPythonLanguageClientContext context)
 {
     _clientContexts.Add(context);
     context.InterpreterChanged += OnSettingsChanged;
     context.SearchPathsChanged += OnSettingsChanged;
 }