Ejemplo n.º 1
0
        public async Task HierarchicalDocumentSymbolsAsync()
        {
            var context            = new IndexTestContext(this);
            var pythonTestFilePath = context.FileWithXVarInRootDir();

            var indexManager = context.GetDefaultIndexManager();

            var symbols = await indexManager.HierarchicalDocumentSymbolsAsync(pythonTestFilePath);

            SymbolsShouldBeOnlyX(symbols);
        }
Ejemplo n.º 2
0
        public async Task WorkspaceSymbolsAddsRootDirectory()
        {
            var context = new IndexTestContext(this);

            var pythonTestFilePath = context.FileWithXVarInRootDir();

            var indexManager = context.GetDefaultIndexManager();

            var symbols = await indexManager.WorkspaceSymbolsAsync("", maxSymbolsCount);

            SymbolsShouldBeOnlyX(symbols);
        }
Ejemplo n.º 3
0
        public async Task AddsRootDirectoryAsync()
        {
            var context = new IndexTestContext(this);

            context.FileWithXVarInRootDir();
            context.AddFileToRoot($"{_rootPath}\foo.py", MakeStream("y = 1"));

            var indexManager = context.GetDefaultIndexManager();

            var symbols = await indexManager.WorkspaceSymbolsAsync("", maxSymbolsCount);

            symbols.Should().HaveCount(2);
        }
        public async Task UpdateFilesOnWorkspaceIndexesLatestAsync()
        {
            var context            = new IndexTestContext(this);
            var pythonTestFilePath = context.FileWithXVarInRootDir();

            var indexManager = context.GetDefaultIndexManager();
            await indexManager.IndexWorkspace();

            indexManager.ReIndexFile(pythonTestFilePath, DocumentWithAst("y = 1"));

            var symbols = await indexManager.WorkspaceSymbolsAsync("", maxSymbolsCount);

            symbols.Should().HaveCount(1);
            symbols.First().Kind.Should().BeEquivalentTo(SymbolKind.Variable);
            symbols.First().Name.Should().BeEquivalentTo("y");
        }
        public async Task LatestVersionASTVersionIsIndexed()
        {
            var context            = new IndexTestContext(this);
            var pythonTestFilePath = context.FileWithXVarInRootDir();

            var indexManager = context.GetDefaultIndexManager();

            indexManager.ProcessNewFile(pythonTestFilePath, DocumentWithAst("y = 1"));
            indexManager.ProcessClosedFile(pythonTestFilePath);
            indexManager.ProcessNewFile(pythonTestFilePath, DocumentWithAst("z = 1"));

            var symbols = await indexManager.HierarchicalDocumentSymbolsAsync(pythonTestFilePath);

            symbols.Should().HaveCount(1);
            symbols.First().Kind.Should().BeEquivalentTo(SymbolKind.Variable);
            symbols.First().Name.Should().BeEquivalentTo("z");
        }
        public async Task CloseWorkspaceFilesReUpdatesIndexAsync()
        {
            var context            = new IndexTestContext(this);
            var pythonTestFilePath = context.FileWithXVarInRootDir();

            context.FileSystem.IsPathUnderRoot(_rootPath, pythonTestFilePath).Returns(true);

            var indexManager = context.GetDefaultIndexManager();
            await indexManager.IndexWorkspace();

            indexManager.ProcessNewFile(pythonTestFilePath, DocumentWithAst("r = 1"));
            // It Needs to remake the stream for the file, previous one is closed
            context.FileSystem.FileExists(pythonTestFilePath).Returns(true);
            context.SetFileOpen(pythonTestFilePath, MakeStream("x = 1"));
            context.FileSystem.IsPathUnderRoot(_rootPath, pythonTestFilePath).Returns(true);
            indexManager.ProcessClosedFile(pythonTestFilePath);

            var symbols = await indexManager.WorkspaceSymbolsAsync("", maxSymbolsCount);

            SymbolsShouldBeOnlyX(symbols);
        }