Exemple #1
0
        private async Task DoInitializeAsync(InitializeParams @params)
        {
            _analyzer = await CreateAnalyzer(@params.initializationOptions.interpreter);

            _clientCaps = @params.capabilities;
            _settings.SetCompletionTimeout(_clientCaps?.python?.completionsTimeout);
            _traceLogging = _clientCaps?.python?.traceLogging ?? false;
            _analyzer.EnableDiagnostics = _clientCaps?.python?.liveLinting ?? false;

            _reloadModulesQueueItem = new ReloadModulesQueueItem(_analyzer);

            if (@params.initializationOptions.displayOptions != null)
            {
                DisplayOptions = @params.initializationOptions.displayOptions;
            }
            _displayTextBuilder = DocumentationBuilder.Create(DisplayOptions);

            if (string.IsNullOrEmpty(_analyzer.InterpreterFactory?.Configuration?.InterpreterPath))
            {
                LogMessage(MessageType.Log, "Initializing for generic interpreter");
            }
            else
            {
                LogMessage(MessageType.Log, $"Initializing for {_analyzer.InterpreterFactory.Configuration.InterpreterPath}");
            }

            if (@params.rootUri != null)
            {
                _rootDir = @params.rootUri.ToAbsolutePath();
            }
            else if (!string.IsNullOrEmpty(@params.rootPath))
            {
                _rootDir = PathUtils.NormalizePath(@params.rootPath);
            }

            SetSearchPaths(@params.initializationOptions.searchPaths);
            SetTypeStubSearchPaths(@params.initializationOptions.typeStubSearchPaths);

            if (_rootDir != null && !(_clientCaps?.python?.manualFileLoad ?? false))
            {
                LogMessage(MessageType.Log, $"Loading files from {_rootDir}");
                _loadingFromDirectory = LoadFromDirectoryAsync(_rootDir);
            }
        }
Exemple #2
0
        private async Task DoInitializeAsync(InitializeParams @params, CancellationToken token)
        {
            ThrowIfDisposed();
            Analyzer = await _queue.ExecuteInQueueAsync(ct => CreateAnalyzer(@params.initializationOptions.interpreter, token), AnalysisPriority.High);

            ThrowIfDisposed();
            _clientCaps      = @params.capabilities;
            _traceLogging    = @params.initializationOptions.traceLogging;
            _analysisUpdates = @params.initializationOptions.analysisUpdates;

            Analyzer.EnableDiagnostics = _clientCaps?.python?.liveLinting ?? false;
            _reloadModulesQueueItem    = new ReloadModulesQueueItem(Analyzer);

            if (@params.initializationOptions.displayOptions != null)
            {
                DisplayOptions = @params.initializationOptions.displayOptions;
            }
            _displayTextBuilder = DocumentationBuilder.Create(DisplayOptions);

            if (string.IsNullOrEmpty(Analyzer.InterpreterFactory?.Configuration?.InterpreterPath))
            {
                LogMessage(MessageType._General, "Initializing for generic interpreter");
            }
            else
            {
                LogMessage(MessageType._General, $"Initializing for {Analyzer.InterpreterFactory.Configuration.InterpreterPath}");
            }

            if (@params.rootUri != null)
            {
                _rootDir = @params.rootUri.ToAbsolutePath();
            }
            else if (!string.IsNullOrEmpty(@params.rootPath))
            {
                _rootDir = PathUtils.NormalizePath(@params.rootPath);
            }

            SetSearchPaths(@params.initializationOptions.searchPaths);
            SetTypeStubSearchPaths(@params.initializationOptions.typeStubSearchPaths);

            Analyzer.Interpreter.ModuleNamesChanged += Interpreter_ModuleNamesChanged;
        }