コード例 #1
0
 public SearcherResult(DateTime startTimeStamp, INode resultNode, string path, SearchOptions searchOptions)
 {
     this.StartTimestamp = startTimeStamp;
     this.ResultNode = resultNode;
     this.Path = path;
     this.SearchOptions = searchOptions;
 }
コード例 #2
0
 public SearcherResult(DateTime startTimeStamp, INode resultNode, string path, SearchOptions searchOptions)
 {
     StartTimestamp = startTimeStamp;
     ResultNode = resultNode;
     Path = path;
     SearchOptions = searchOptions;
 }
コード例 #3
0
 // 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);
 }
コード例 #4
0
 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;
 }
コード例 #5
0
 public SearchOptions(SearchOptions searchOptions)
     : this(searchOptions.SearchField, searchOptions.SearchText, searchOptions.SearchRegex)
 {
 }
コード例 #6
0
 public TokenPosition LocateSubtoken(string filePath, SearchOptions searchOptions)
 {
     return LocateSubtoken(filePath, searchOptions, false, null);
 }
コード例 #7
0
 public TokenPosition LocateNextToken(string filePath, SearchOptions searchOptions, EditorInfo editorInfo)
 {
     return LocateSubtoken(filePath, searchOptions, true, editorInfo);
 }
コード例 #8
0
 public IList<SearchResult> Search(SearchOptions searchOptions)
 {
     Query query = this.customQueryParser.Parse(searchOptions);
     return this.RunQuery(query);
     
 }
コード例 #9
0
 public BackgroundSearcherParams(DocumentHierarchySearcher documentHierarchySearcher, SearchOptions searchOptions, string path)
 {
     this.DocumentHierarchySearcher = documentHierarchySearcher;
     this.SearchOptions = new SearchOptions(searchOptions);
     this.Path = path;
 }
コード例 #10
0
 public SearchOptions(SearchOptions searchOptions) : this(searchOptions.SearchField, searchOptions.SearchText)
 {
 }
コード例 #11
0
        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;
            }
        }