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); }
public async Task IgnoresNonPythonFiles() { using (var context = new IndexTestContext(this)) { var nonPythonTestFileInfo = MakeFileInfoProxy($"{_rootPath}/bla.txt"); context.AddFileInfoToRootTestFS(nonPythonTestFileInfo); var indexManager = context.GetDefaultIndexManager(); await indexManager.IndexWorkspace(); context.FileSystem.DidNotReceive().FileExists(nonPythonTestFileInfo.FullName); } }
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); }
public async Task CloseNonWorkspaceFilesRemovesFromIndexAsync() { using (var context = new IndexTestContext(this)) { var pythonTestFileInfo = MakeFileInfoProxy("C:/nonRoot/bla.py"); context.FileSystem.IsPathUnderRoot(_rootPath, pythonTestFileInfo.FullName).Returns(false); var indexManager = context.GetDefaultIndexManager(); indexManager.ProcessNewFile(pythonTestFileInfo.FullName, DocumentWithAst("x = 1")); indexManager.ProcessClosedFile(pythonTestFileInfo.FullName); await SymbolIndexShouldBeEmpty(indexManager); } }
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 CanOpenFiles() { string nonRootPath = "C:/nonRoot"; var context = new IndexTestContext(this); var pythonTestFileInfo = MakeFileInfoProxy($"{nonRootPath}/bla.py"); IDocument doc = DocumentWithAst("x = 1"); IIndexManager indexManager = context.GetDefaultIndexManager(); indexManager.ProcessNewFile(pythonTestFileInfo.FullName, doc); var symbols = await indexManager.WorkspaceSymbolsAsync("", maxSymbolsCount); SymbolsShouldBeOnlyX(symbols); }
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 WorkspaceSymbolsLimited() { var context = new IndexTestContext(this); for (int fileNumber = 0; fileNumber < 10; fileNumber++) { context.AddFileToRoot($"{_rootPath}\bla{fileNumber}.py", MakeStream($"x{fileNumber} = 1")); } var indexManager = context.GetDefaultIndexManager(); const int amountOfSymbols = 3; var symbols = await indexManager.WorkspaceSymbolsAsync("", amountOfSymbols); symbols.Should().HaveCount(amountOfSymbols); }
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 AddFilesToPendingChanges() { var context = new IndexTestContext(this); var f1 = context.AddFileToRoot($"{_rootPath}/fileA.py", MakeStream("")); var f2 = context.AddFileToRoot($"{_rootPath}/fileB.py", MakeStream("")); var indexManager = context.GetDefaultIndexManager(); await indexManager.IndexWorkspace(); indexManager.AddPendingDoc(DocumentWithAst("y = 1", f1)); indexManager.AddPendingDoc(DocumentWithAst("x = 1", f2)); context.SetIdleEvent(Raise.Event()); var symbols = await indexManager.WorkspaceSymbolsAsync("", maxSymbolsCount); symbols.Should().HaveCount(2); }
public async Task ProcessFileIfIndexedAfterCloseIgnoresUpdateAsync() { // If events get to index manager in the order: [open, close, update] // it should not reindex file var context = new IndexTestContext(this); var pythonTestFileInfo = MakeFileInfoProxy("C:/nonRoot/bla.py"); var indexManager = context.GetDefaultIndexManager(); indexManager.ProcessNewFile(pythonTestFileInfo.FullName, DocumentWithAst("x = 1")); indexManager.ProcessClosedFile(pythonTestFileInfo.FullName); context.FileSystem.IsPathUnderRoot(_rootPath, pythonTestFileInfo.FullName).Returns(false); indexManager.ReIndexFile(pythonTestFileInfo.FullName, DocumentWithAst("x = 1")); await SymbolIndexShouldBeEmpty(indexManager); }
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); }