public FileTreeNode(string key) { Key = key; _nodes = new(); _volume = new CodeVolume(); }
public void Add(string[] path, CodeVolume volume) { if (path.Length > 0) { var key = path[0]; path = path.Where((val, i) => i != 0).ToArray(); if (!_nodes.ContainsKey(key)) { _nodes.Add(key, new FileTreeNode(key)); } _nodes[key].Add(path, volume); } else { _volume = volume; } }
private void Process(List <Project> projects, Dispatcher dispatcher) { var extentions = Languages.Get().SelectMany(x => x.Extensions).ToHashSet(); var ignoredFiles = InspectorConfig.IgnoredFilesList; void ProcessUpdate(InspectorStage stage, InspectState state) { dispatcher.Invoke(() => OnUpdate?.Invoke(stage, state)); } // var allFiles = new List <string>(); int i = 0, j = 0; foreach (var project in projects) { ProcessUpdate(InspectorStage.ProgressPrimary, new InspectState { Used = ++i, All = projects.Count }); // var files = _fileProvider .GetFilesData(project, extentions, ignoredFiles, (files, dirs, cur) => { ProcessUpdate(InspectorStage.ProgressSecondary, new InspectState { Used = Math.Min(files, dirs), All = Math.Max(files, dirs) }); }); project.Info.Clear(); // var projectVolume = new CodeVolume(); if (!files.Any()) { project.Info.Error("This project has no files to analyse"); } j = 0; foreach (var file in files) { if (j % 10 == 0) { ProcessUpdate(InspectorStage.ProgressSecondary, new InspectState { Used = j, All = files.Count() }); } j++; // if (!allFiles.Contains(file)) { allFiles.Add(file); if (allFiles.Count % 10 == 0) { ProcessUpdate(InspectorStage.FetchingFiles, new InspectState { All = allFiles.Count }); } } else { project.Info.Error($"File '{file}' already has added"); } } j = 0; foreach (var file in files) { if (j % 10 == 0) { ProcessUpdate(InspectorStage.ProgressSecondary, new InspectState { Used = j, All = files.Count() }); ProcessUpdate(InspectorStage.FetchingLines, new InspectState { All = projectVolume.Lines }); } j++; if (File.Exists(file)) { // Geting data var data = ""; try { data = File.ReadAllText(file); // var newLastEdit = File.GetLastWriteTime(file); if (project.LastRevision < newLastEdit) { project.LastRevision = newLastEdit; } } catch (Exception ex) { project.Info.Error($"File '{file}' thrown {ex.GetType().Name}"); } // Calculating lines var localPath = file.StartsWith(project.Location) ? file[project.Location.Length..] : file;
public void Add(string path, CodeVolume volume) { Add(path.Split(new char[] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries), volume); }