public SearcherResult(DateTime startTimeStamp, INode resultNode, string path, SearchOptions searchOptions) { this.StartTimestamp = startTimeStamp; this.ResultNode = resultNode; this.Path = path; this.SearchOptions = searchOptions; }
public SearcherResult(DateTime startTimeStamp, INode resultNode, string path, SearchOptions searchOptions) { StartTimestamp = startTimeStamp; ResultNode = resultNode; Path = path; SearchOptions = searchOptions; }
// note: can be invoked by multiple threads simultaneously public INode GetDocumentHierarchyViewNodeProjection(DocumentHierarchy documentHierarchy, string path, SearchOptions searchOptions, BackgroundWorker worker) { if (documentHierarchy == null) { return null; } var node = path == null ? documentHierarchy.RootNode : documentHierarchy.GetNode(path); if (node == null || String.IsNullOrWhiteSpace(searchOptions.SearchText)) { return node; } IList<INode> filteredNodes = documentHierarchy .SearchNodesFullText(searchOptions) .Where(result => result.Path.StartsWith(node.Path)) // TODO: filter it earlier for performance .Select(result => result.Node) .ToList(); this.ReportProgress(worker); return this.FillNewFilteredDocumentHierarchyRecursively(filteredNodes, node, null, worker); }
private TokenPosition LocateSubtoken(string filePath, SearchOptions searchOptions, bool fullTokensOnly, EditorInfo editorInfo) { int startLine = 1; int startColumnInFirstLine = 0; if (editorInfo != null) { startLine = editorInfo.CurrentLineNum; startColumnInFirstLine = editorInfo.CurrentColumn; } string searchText = searchOptions.SearchText; if (!searchOptions.SearchRegex) { searchText = searchText.Replace("\"", string.Empty); } int queryLen = searchText.Length; var bestSubtokenPosition = new TokenPosition(-1, 0, 0); Regex regex = searchOptions.SearchRegex ? new Regex(searchText, RegexOptions.Compiled | RegexOptions.IgnoreCase) : null; bool firstLine = true; foreach (LineInfo lineInfo in fileReader.ReadFileAsEnumerableWithWrap(filePath, startLine)) { int columnsToIgnore = (firstLine ? startColumnInFirstLine : 0); firstLine = false; TokenPosition tokenPos = GetLongestSubtoken(lineInfo.LineNumber, lineInfo.LineText, searchText, regex, columnsToIgnore); if (tokenPos.MatchLength > bestSubtokenPosition.MatchLength) { bestSubtokenPosition = tokenPos; if (tokenPos.MatchLength == queryLen) { break; } } } if (!searchOptions.SearchRegex && fullTokensOnly && bestSubtokenPosition.MatchLength != queryLen) { return new TokenPosition(-1, 0, 0); } return bestSubtokenPosition; }
public SearchOptions(SearchOptions searchOptions) : this(searchOptions.SearchField, searchOptions.SearchText, searchOptions.SearchRegex) { }
public TokenPosition LocateSubtoken(string filePath, SearchOptions searchOptions) { return LocateSubtoken(filePath, searchOptions, false, null); }
public TokenPosition LocateNextToken(string filePath, SearchOptions searchOptions, EditorInfo editorInfo) { return LocateSubtoken(filePath, searchOptions, true, editorInfo); }
public IList<SearchResult> Search(SearchOptions searchOptions) { Query query = this.customQueryParser.Parse(searchOptions); return this.RunQuery(query); }
public BackgroundSearcherParams(DocumentHierarchySearcher documentHierarchySearcher, SearchOptions searchOptions, string path) { this.DocumentHierarchySearcher = documentHierarchySearcher; this.SearchOptions = new SearchOptions(searchOptions); this.Path = path; }
public SearchOptions(SearchOptions searchOptions) : this(searchOptions.SearchField, searchOptions.SearchText) { }
public void OpenItem(TreeViewEntryItemModel item, SearchOptions searchOptions) { if (this.IseIntegrator == null) { throw new InvalidOperationException("IseIntegrator has not ben set yet."); } if (item == null) { return; } if (item.Node.NodeType == NodeType.File) { bool wasOpen = (this.IseIntegrator.SelectedFilePath == item.Node.Path); if (!wasOpen) { this.IseIntegrator.GoToFile(item.Node.Path); } else { this.IseIntegrator.SetFocusOnCurrentTab(); } if (searchOptions.SearchText != null && searchOptions.SearchText.Length > 2) { EditorInfo editorInfo = (wasOpen ? this.IseIntegrator.GetCurrentLineWithColumnIndex() : null); TokenPosition tokenPos = this.TokenLocator.LocateNextToken(item.Node.Path, searchOptions, editorInfo); if (tokenPos.MatchLength > 2) { this.IseIntegrator.SelectText(tokenPos.Line, tokenPos.Column, tokenPos.MatchLength); } else if (string.IsNullOrEmpty(this.IseIntegrator.SelectedText)) { tokenPos = this.TokenLocator.LocateSubtoken(item.Node.Path, searchOptions); if (tokenPos.MatchLength > 2) { this.IseIntegrator.SelectText(tokenPos.Line, tokenPos.Column, tokenPos.MatchLength); } } } } else if (item.Node.NodeType == NodeType.Function) { var node = ((PowershellItemNode)item.Node); this.IseIntegrator.GoToFile(node.FilePath); this.IseIntegrator.SelectText(node.PowershellItem.StartLine, node.PowershellItem.StartColumn, node.Name.Length); } else if (item.Node.NodeType == NodeType.Directory) { item.IsExpanded = !item.IsExpanded; } }