public int GetList2(uint ListType, uint flags, VSOBSEARCHCRITERIA2[] pobSrch, out IVsSimpleObjectList2 ppIVsSimpleObjectList2) { ppIVsSimpleObjectList2 = null; if (pobSrch != null) { if (ListType != (uint)_LIB_LISTFLAGS.LLF_USESEARCHFILTER) { return(VSConstants.E_NOTIMPL); } VSOBSEARCHCRITERIA2 sp = pobSrch[0]; LibraryNode results = new LibraryNode("results", LibraryNode.LibraryNodeType.PhysicalContainer); // partial key matching foreach (LibraryNode node in root.Children) { SearchNodePartialKey(sp.szName, "", node, ref results); } ppIVsSimpleObjectList2 = results as IVsSimpleObjectList2; } else { ppIVsSimpleObjectList2 = root as IVsSimpleObjectList2; } return(VSConstants.S_OK); }
internal void Add(LibraryNode fileNode) { if (filenodes.ContainsKey(fileNode.Path)) { filenodes.Remove(fileNode.Path); } filenodes.Add(fileNode.Path, fileNode); List <LibraryNode> fileList = new List <LibraryNode>(); lock (this) { foreach (LibraryNode ch in fileNode.Children) { MergeNodeTree(fileList, root, ch); } } string path = fileNode.Path; if (files.ContainsKey(path)) { files.Remove(path); } files.Add(path, fileList); }
public Library(Guid libraryGuid) { this.guid = libraryGuid; root = new LibraryNode("", LibraryNode.LibraryNodeType.Package); filenodes = new Dictionary <string, LibraryNode>(); files = new Dictionary <string, List <LibraryNode> >(); }
public LibraryNode(LibraryNode node) { this.capabilities = node.capabilities; this.contextMenuID = node.contextMenuID; this.displayData = node.displayData; this.name = node.name; this.uniquename = node.uniquename; this.tooltip = node.tooltip; this.type = node.type; this.children = new List <LibraryNode>(); foreach (LibraryNode child in node.children) { children.Add(child); } this.clipboardFormats = new List <VSOBJCLIPFORMAT>(); foreach (VSOBJCLIPFORMAT format in node.clipboardFormats) { clipboardFormats.Add(format); } this.filteredView = new Dictionary <LibraryNodeType, LibraryNode>(); this.ownerHierarchy = node.ownerHierarchy; this.fileId = node.fileId; this.sourceSpan = node.sourceSpan; this.CanGoToSource = node.CanGoToSource; this.updateCount = node.updateCount; }
private void MergeNodeTree(List <LibraryNode> lst, LibraryNode hNode, LibraryNode fileNode) { // compare each level of hNode and fileNode // combine the children of nodes that have same name LibraryNode hn = FindNode(hNode, fileNode.Name); if (hn == null) { hn = fileNode.ShallowClone(); hNode.AddNode(hn); } uint refs = hn.AddRef(); lst.Add(hn); int chcnt = fileNode.Children.Count; if (chcnt != 0) { for (int i = 0; i < chcnt; i++) { LibraryNode ch = fileNode.GetChild(i); MergeNodeTree(lst, hn, ch); } } }
public LibraryNode(string name, LibraryNodeType type, LibraryNodeCapabilities capabilities, CommandID contextMenuID, ModuleId moduleId) { this.capabilities = capabilities; this.contextMenuID = contextMenuID; this.name = name; this.uniquename = name; this.tooltip = name; this.type = type; parent = null; children = new List <LibraryNode>(); clipboardFormats = new List <VSOBJCLIPFORMAT>(); filteredView = new Dictionary <LibraryNodeType, LibraryNode>(); if (moduleId != null) { this.ownerHierarchy = moduleId.Hierarchy; this.fileId = moduleId.ItemID; ownerHierarchy.GetCanonicalName(fileId, out this.path); } sourceSpan = new TextSpan(); if (type == LibraryNodeType.Package) { this.CanGoToSource = false; } else { this.CanGoToSource = true; } if (type == LibraryNodeType.Members) { displayData.Image = (ushort)OMGlyphType.Members; displayData.SelectedImage = displayData.Image; } }
internal void RemoveNode(LibraryNode node) { lock (children) { children.Remove(node); filteredView.Clear(); } updateCount += 1; }
internal void AddNode(LibraryNode node) { lock (children) { node.Parent = this; children.Add(node); filteredView.Clear(); } updateCount += 1; }
private LibraryNode FindNode(LibraryNode hNode, string targetname) { for (int i = 0; i < hNode.Children.Count; i++) { LibraryNode ch = hNode.GetChild(i); if (ch.Name == targetname) { return(ch); } } return(null); }
public LibraryNode ShallowClone() { LibraryNode node = new LibraryNode(Name); node.uniquename = this.uniquename; node.ownerHierarchy = this.ownerHierarchy; node.fileId = this.fileId; node.sourceSpan = this.sourceSpan; node.CanGoToSource = this.CanGoToSource; node.updateCount = this.updateCount; node.type = this.type; node.displayData = this.displayData; return(node); }
private void UpdateClassView(LibraryNode fileNode) { lock (library) { List <LibraryNode> retlist; library.Files.TryGetValue(fileNode.Path, out retlist); library.Add(fileNode); if (retlist != null) { library.Release(retlist); } library.Refresh(); } }
/// <summary> /// Main function of the parsing thread. /// This function waits on the queue of the parsing requests and build the parsing tree for /// a specific file. The resulting tree is built using LibraryNode objects so that it can /// be used inside the class view or object browser. /// </summary> private void ParseThread() { const int waitTimeout = 500; // Define the array of events this function is interest in. WaitHandle[] eventsToWait = new WaitHandle[] { requestPresent, shutDownStarted }; // Execute the tasks. while (true) { // Wait for a task or a shutdown request. int waitResult = WaitHandle.WaitAny(eventsToWait, waitTimeout, false); if (1 == waitResult) { // The shutdown of this component is started, so exit the thread. return; } LibraryTask task = null; lock (requests) { if (0 != requests.Count) { task = requests.Dequeue(); } if (0 == requests.Count) { requestPresent.Reset(); } } if (null == task) { continue; } // parse the file to search for classes and functions LibraryNode fileNode = parser.Parse(task); if (null != task.ModuleID) { UpdateClassView(fileNode); //SQLanguageService ls = (SQLanguageService)provider.GetService(typeof(SQLanguageService)); //ls.SynchronizeDropdowns(); } } }
private void SearchNodePartialKey(string searchstr, string parentstr, LibraryNode source, ref LibraryNode results) { // recursively search node if (string.Compare(parentstr, "") != 0) { parentstr += "."; } foreach (LibraryNode child in source.Children) { SearchNodePartialKey(searchstr, parentstr + source.Name, child, ref results); } if (source.Name.IndexOf(searchstr, StringComparison.OrdinalIgnoreCase) >= 0) { // modify node name for search presentation only LibraryNode placeholder = new LibraryNode(source); placeholder.Name = parentstr + placeholder.Name; results.AddNode(placeholder); } }
public IVsSimpleObjectList2 FilterView(LibraryNodeType filterType) { LibraryNode filtered = null; if (filteredView.TryGetValue(filterType, out filtered)) { return(filtered as IVsSimpleObjectList2); } filtered = this.Clone(); for (int i = 0; i < filtered.children.Count;) { if (0 == (filtered.children[i].type & filterType)) { filtered.children.RemoveAt(i); } else { i += 1; } } filteredView.Add(filterType, filtered); return(filtered as IVsSimpleObjectList2); }