/// <summary> /// Applies a SearchCriteria to the index. /// </summary> /// <param name="crit">The SearchCriteria to apply.</param> /// <returns>A ResultsTable that contains the result of applying the criteria.</returns> public ResultsTable GenerateResultsTable(SearchCriteria crit) { Debug.Assert(crit != null); CodeElementWrapperArrayIndexTable idxTable; // If using all criteria, perform a copy. if (crit.ElementFilter == CodeElementType.All) { idxTable = (CodeElementWrapperArrayIndexTable)indexTable.Clone(); } else { idxTable = new CodeElementWrapperArrayIndexTable(codeElementArray); for (int i = 0; i < codeElementArray.Count; i++) { if (codeElementArray[i].ElementType == crit.ElementFilter) { idxTable.Add(i); } } idxTable.Sort(new SortCriteria(SortCriteria.SortType.ALPHA)); } var ret = new ResultsTable(idxTable); return(ret); }
/// <summary> /// Applies a SearchCriteria to the index. /// </summary> /// <param name="crit">The SearchCriteria to apply.</param> /// <returns>A ResultsTable that contains the result of applying the criteria.</returns> public ResultsTable GenerateResultsTable(SearchCriteria crit) { Debug.Assert(crit != null); CodeElementWrapperArrayIndexTable idxTable; // If using all criteria, perform a copy. if (crit.ElementFilter == CodeElementType.All) { idxTable = (CodeElementWrapperArrayIndexTable) indexTable.Clone(); } else { idxTable = new CodeElementWrapperArrayIndexTable(codeElementArray); for (int i = 0; i < codeElementArray.Count; i++) { if (codeElementArray[i].ElementType == crit.ElementFilter) { idxTable.Add(i); } } idxTable.Sort(new SortCriteria(SortCriteria.SortType.ALPHA)); } var ret = new ResultsTable(idxTable); return (ret); }
/// <summary> /// Decrements the transaction counter. /// </summary> /// <remarks> /// The counter determines if nested operations are running, /// and when it reaches zero, the filter is rebuilt to reflect the operations. /// </remarks> private void EndTransaction() { if (transactionCounter == 0) { Debug.Assert(false, "Invalid call to EndTransaction"); return; } transactionCounter--; if (transactionCounter == 0) { // Recompute current results. codeElementWrapperIndexTable = new CodeElementWrapperIndexTable(codeElementWrapperArray); currentResults = codeElementWrapperIndexTable.GenerateResultsTable(searchCriteria); FilterText = currentFilterText; } }
/// <summary> /// Completes loading the source outline. /// </summary> internal void FinishLoading() { codeElementWrapperIndexTable = new CodeElementWrapperIndexTable(codeElementWrapperArray); currentResults = codeElementWrapperIndexTable.GenerateResultsTable(searchCriteria); if ((control.filterStringTextBox.Text != "<Filter>") && (control.filterStringTextBox.Text != "")) { control.filterStringTextBox.Text = "<Filter>"; if (viewType == ViewType.TreeView) { TreeView.ExpandAll(); } } else { switch (viewType) { case ViewType.FlatView: LoadFlatView(); break; case ViewType.TreeView: TreeView.ExpandAll(); break; } } State = OutlineFileManagerState.WaitToStartOver; }
/// <summary> /// Clears the filters and displays the hierarchical TreeView. /// </summary> public void ResetFilters() { searchCriteria = new SearchCriteria(CodeElementType.All); if (currentDocument != null) { currentFilterText = ""; currentResults = codeElementWrapperIndexTable.GenerateResultsTable(searchCriteria); ViewType = ViewType.TreeView; control.Reset(); } }
/// <summary> /// Resets the state of the TreeView and the filters. /// </summary> public void Reset() { transactionCounter = 0; codeElementWrapperArray = new CodeElementWrapperArray(); codeElementWrapperIndexTable = new CodeElementWrapperIndexTable(codeElementWrapperArray); mapElementIDToTreeViewCodeElementWrapper = null; mapElementIDToFilterViewCodeElementWrapper = null; currentResults = null; ResetFilters(); }
/// <summary> /// Occurs when a new code element is added to the text window, /// and adds the new element to the appropriate place in the outline. /// </summary> /// <param name="newElement">The new code element.</param> public void OnCodeModelElementAdd(CodeElement newElement) { if ((newElement == null) || !CodeModelHelpers.IsInterestingKind(newElement.Kind)) { return; } try { int line = newElement.StartPoint.Line; } catch { // An exception can be thrown here when an element is being edited, so ignore it. return; } // Update the tree. if (newElement.Kind == vsCMElement.vsCMElementParameter) { FindBestMatchCodeElementToRefreshFrom(newElement); return; } // Get the start point from the wrapper object and not from the CodeElement directly. var temp = new CodeElementWrapper(newElement); TextPoint tp = temp.StartPoint; CodeElementWrapper cew = GetClosestCodeElementInTreeView(TreeView, tp); if (cew == null) { // Nothing found, this must be the first element drawn. ReadCodeModelElementsRecursive(newElement, TreeView.Nodes, false); } else { var newNode = new CodeElementWrapper(newElement); // Note that the add could result from a paste, and the editor only informs // regarding the outer element that was added if the language is C# or VB; // the C++ language raises an event for each element. AddNodeToInternalStructures(newNode); ReadCodeModelChildrenElementsRecursive(newNode, false); newNode.ExpandAll(); int index = 0; // Insert this element in the correct place. foreach (CodeElementWrapper n in cew.Nodes) { if (n.Location > newNode.Location) { // Insert prior to n. cew.Nodes.Insert(index, newNode); newNode = null; break; } index++; } // If it was not inserted, append it. if (newNode != null) { cew.Nodes.Add(newNode); } } // Update the filter view. codeElementWrapperIndexTable = new CodeElementWrapperIndexTable(codeElementWrapperArray); currentResults = codeElementWrapperIndexTable.GenerateResultsTable(searchCriteria); FilterText = currentFilterText; }