Example #1
0
        public CompletionAnalysis(
            IModuleAnalysis analysis,
            PythonAst tree,
            SourceLocation position,
            GetMemberOptions opts,
            ServerSettings.PythonCompletionOptions completionSettings,
            DocumentationBuilder textBuilder,
            ILogger log,
            Func <TextReader> openDocument
            )
        {
            Analysis      = analysis ?? throw new ArgumentNullException(nameof(analysis));
            Tree          = tree ?? throw new ArgumentNullException(nameof(tree));
            Position      = position;
            Index         = Tree.LocationToIndex(Position);
            Options       = opts;
            _pathResolver = analysis.ProjectState.CurrentPathResolver;
            _textBuilder  = textBuilder;
            _log          = log;
            _openDocument = openDocument;
            _addBrackets  = completionSettings.addBrackets;

            var finder = new ExpressionFinder(Tree, new GetExpressionOptions {
                Names              = true,
                Members            = true,
                NamedArgumentNames = true,
                ImportNames        = true,
                ImportAsNames      = true,
                Literals           = true,
                Errors             = true
            });

            finder.Get(Index, Index, out var node, out _statement, out _scope);

            var index = Index;
            var col   = Position.Column;

            while (CanBackUp(Tree, node, _statement, _scope, col))
            {
                col   -= 1;
                index -= 1;
                finder.Get(index, index, out node, out _statement, out _scope);
            }

            Node = node ?? (_statement as ExpressionStatement)?.Expression;
        }
Example #2
0
        public static Task SendDidChangeConfiguration(this Server server, ServerSettings.PythonCompletionOptions pythonCompletionOptions, int failAfter = 30000)
        {
            var currentSettings = server.Settings;
            var settings        = new LanguageServerSettings();

            settings.completion.showAdvancedMembers = pythonCompletionOptions.showAdvancedMembers;
            settings.completion.addBrackets         = pythonCompletionOptions.addBrackets;

            settings.analysis.openFilesOnly = currentSettings.analysis.openFilesOnly;
            if (currentSettings is LanguageServerSettings languageServerSettings)
            {
                settings.diagnosticPublishDelay     = languageServerSettings.diagnosticPublishDelay;
                settings.symbolsHierarchyDepthLimit = languageServerSettings.symbolsHierarchyDepthLimit;
            }

            var errors      = currentSettings.analysis.errors;
            var warnings    = currentSettings.analysis.warnings;
            var information = currentSettings.analysis.information;
            var disabled    = currentSettings.analysis.disabled;

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

            return(server.SendDidChangeConfiguration(settings, failAfter));
        }
Example #3
0
 public CompletionSource(IDocumentationSource docSource, ServerSettings.PythonCompletionOptions completionSettings, IServiceContainer services)
 {
     _itemSource = new CompletionItemSource(docSource, completionSettings);
     _services   = services;
 }
 public CompletionSource(IDocumentationSource docSource, ServerSettings.PythonCompletionOptions completionSettings)
 {
     _itemSource = new CompletionItemSource(docSource, completionSettings);
 }
 public CompletionItemSource(IDocumentationSource docSource, ServerSettings.PythonCompletionOptions options)
 {
     _docSource = docSource;
     Options    = options;
 }