private void CreateEntries(DirectoryEntry searchResults) {
      if (!_enabled)
        return;

      using (new TimeElapsedLogger("Creating document tracking entries for search results")) {
        _searchResults.Clear();
        foreach (DirectoryEntry projectRoot in searchResults.Entries) {
          var rootPath = new FullPath(projectRoot.Name);
          foreach (FileEntry fileEntry in projectRoot.Entries) {
            var path = rootPath.Combine(new RelativePath(fileEntry.Name));
            var spans = fileEntry.Data as FilePositionsData;
            if (spans != null) {
              _searchResults[path] = spans;

              // If the document is open, create the tracking spans now.
              var document = _textDocumentTable.GetOpenDocument(path);
              if (document != null) {
                var entry = new DocumentChangeTrackingEntry(spans);
                _trackingEntries[path] = entry;
                entry.CreateTrackingSpans(document.TextBuffer);
              }
            }
          }
        }
      }
    }
 public DirectoryEntryViewModel(
     ICodeSearchController controller,
     TreeViewItemViewModel parentViewModel,
     DirectoryEntry directoryEntry)
     : base(controller, parentViewModel, directoryEntry.Entries.Count > 0)
 {
     _directoryEntry = directoryEntry;
       _children = new Lazy<IList<TreeViewItemViewModel>>(CreateChildren);
 }
Пример #3
0
 public DirectoryEntryViewModel(
     ISourceExplorerViewModelHost host,
     TreeViewItemViewModel parentViewModel,
     DirectoryEntry directoryEntry)
     : base(host, parentViewModel, directoryEntry.Entries.Count > 0)
 {
     _directoryEntry = directoryEntry;
       _children = new Lazy<IList<TreeViewItemViewModel>>(CreateChildren);
 }
    public void Enable(DirectoryEntry searchResults) {
      _trackingEntries.Clear();

      _enabled = true;
      _searchResults.Clear();

      // Delay to avoid processing results too often.
      _uiRequestProcessor.Post(new DelayedOperation {
        Id = _requestId,
        Delay = TimeSpan.FromSeconds(1.0),
        Action = () => CreateEntries(searchResults)
      });
    }
Пример #5
0
 public void SetFileNamesSearchResult(DirectoryEntry fileResults, string description, bool expandAll)
 {
     _fileNamesResultRootNodes =
     new List<TreeViewItemViewModel> {
       new TextItemViewModel(_sourceExplorerViewModelHost.StandarImageSourceFactory, null, description)
     }.Concat(
       fileResults
     .Entries
     .Select(x => FileSystemEntryViewModel.Create(_sourceExplorerViewModelHost, null, x)))
       .ToList();
       ExpandNodes(_fileNamesResultRootNodes, expandAll);
       SwitchToFileNamesSearchResult();
 }
Пример #6
0
 public SearchFilePathsResponse() {
   // To avoid getting "null" property if empty collection deserialized using protobuf.
   SearchResult = new DirectoryEntry();
 }
Пример #7
0
 private static string ExtractFileText(DirectoryEntry chromiumEntry, FileSystemEntry fileSystemEntry, FilePositionSpan filePositionSpan) {
   var path = PathHelpers.CombinePaths(chromiumEntry.Name, fileSystemEntry.Name);
   if (!File.Exists(path))
     return string.Format("File not found: {0}", path);
   var text = File.ReadAllText(path);
   var offset = filePositionSpan.Position;
   var length = Math.Min(80, filePositionSpan.Length);
   if (offset < 0)
     return "<Invalid offset>";
   if (length < 0)
     return "<Invalid length>";
   if (offset + length > text.Length)
     return "<Invalid span>";
   var extract = text.Substring(offset, length);
   return extract;
 }
Пример #8
0
 private void ProcessDirectory(DirectoryItem parent, string parentPath, DirectoryEntry entry)
 {
     DirectoryCount++;
     DirectoryItem newParent;
     string newPath;
     if (parent == null) {
       RootDirectory = new TreeStats.DirectoryItem();
       newParent = RootDirectory;
       newPath = parentPath;
     } else {
       var newDir = new DirectoryItem {
     Name = entry.Name
       };
       parent.Children.Add(newDir);
       newParent = newDir;
       newPath = Path.Combine(parentPath, entry.Name);
     }
     foreach (var x in entry.Entries) {
       ProcessTree(newParent, newPath, x);
     }
 }