private void StartAddRootDir() { foreach (var fileInfo in WorkspaceFiles()) { if (ModulePath.IsPythonSourceFile(fileInfo.FullName)) { _symbolIndex.Parse(fileInfo.FullName); } } }
private void CreateIndices(IEnumerable <IFileSystemInfo> files, ISymbolIndex symbolIndex, CancellationToken cancellationToken) { foreach (var fileInfo in files) { cancellationToken.ThrowIfCancellationRequested(); if (ModulePath.IsPythonSourceFile(fileInfo.FullName)) { symbolIndex.Parse(fileInfo.FullName); } } }
private static string GetCoveragePath(IEnumerable<TestCase> tests) { string bestFile = null, bestClass = null, bestMethod = null; // Try and generate a friendly name for the coverage report. We use // the filename, class, and method. We include each one if we're // running from a single filename/class/method. When we have multiple // we drop the identifying names. If we have multiple files we // go to the top level directory... If all else fails we do "pycov". foreach (var test in tests) { string testFile, testClass, testMethod; TestReader.ParseFullyQualifiedTestName( test.FullyQualifiedName, out testFile, out testClass, out testMethod ); bestFile = UpdateBestFile(bestFile, test.CodeFilePath); if (bestFile != test.CodeFilePath) { // Different files, don't include class/methods even // if they happen to be the same. bestClass = bestMethod = ""; } bestClass = UpdateBest(bestClass, testClass); bestMethod = UpdateBest(bestMethod, testMethod); } string filename = ""; if (!String.IsNullOrWhiteSpace(bestFile)) { if (ModulePath.IsPythonSourceFile(bestFile)) { filename = ModulePath.FromFullPath(bestFile).ModuleName; } else { filename = Path.GetFileName(bestFile); } } else { filename = "pycov"; } if (!String.IsNullOrWhiteSpace(bestClass)) { filename += "_" + bestClass; } if (!String.IsNullOrWhiteSpace(bestMethod)) { filename += "_" + bestMethod; } filename += "_" + DateTime.Now.ToString("s").Replace(':', '_'); return Path.Combine(Path.GetTempPath(), filename); }
private async Task LoadFromDirectoryAsync(Server s, string rootDir) { foreach (var dir in PathUtils.EnumerateDirectories(rootDir)) { await LoadFromDirectoryAsync(s, dir); } foreach (var file in PathUtils.EnumerateFiles(rootDir)) { if (ModulePath.IsPythonSourceFile(file)) { await s.LoadFileAsync(new Uri(file)); } } }
public Task IndexWorkspace(CancellationToken ct = default) { var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(ct, _disposeToken.CancellationToken); var linkedCt = linkedCts.Token; return(Task.Run(() => { foreach (var fileInfo in WorkspaceFiles()) { linkedCt.ThrowIfCancellationRequested(); if (ModulePath.IsPythonSourceFile(fileInfo.FullName)) { _symbolIndex.Parse(fileInfo.FullName); } } }, linkedCt).ContinueWith(_ => linkedCts.Dispose())); }
private async Task LoadFromDirectoryAsync(string rootDir, PatternMatchingResult matchResult) { foreach (var file in matchResult.Files) { if (_sessionTokenSource.IsCancellationRequested) { break; } var path = Path.Combine(rootDir, PathUtils.NormalizePath(file.Path)); if (!ModulePath.IsPythonSourceFile(path)) { if (ModulePath.IsPythonFile(path, true, true, true)) { // TODO: Deal with scrapable files (if we need to do anything?) } continue; } await _server.LoadFileAsync(new Uri(path)); } }
// Gets the MODULE_INFO that describes this module. // This is how the debugger obtains most of the information about the module. int IDebugModule2.GetInfo(enum_MODULE_INFO_FIELDS dwFields, MODULE_INFO[] infoArray) { MODULE_INFO info = new MODULE_INFO(); if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_NAME) != 0) { info.m_bstrName = DebuggedModule.Name; Debug.Assert(info.m_bstrName != null); info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME; } if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_URL) != 0) { info.m_bstrUrl = DebuggedModule.Filename; Debug.Assert(info.m_bstrUrl != null); info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URL; } if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_LOADORDER) != 0) { info.m_dwLoadOrder = (uint)this.DebuggedModule.ModuleId; info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_LOADORDER; } if ((dwFields & enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION) != 0) { if (ModulePath.IsPythonSourceFile(DebuggedModule.Filename)) { info.m_bstrUrlSymbolLocation = DebuggedModule.Filename; } else { info.m_bstrUrlSymbolLocation = string.Empty; } info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION; } infoArray[0] = info; return(VSConstants.S_OK); }