internal void AddNode(LibraryNode node) { lock (children) { children.Add(node); } updateCount += 1; }
internal void RemoveNode(LibraryNode node) { lock (this) { root = new LibraryNode(root); root.RemoveNode(node); } }
private void CreateModuleTree(LibraryNode root, LibraryNode current, ScopeNode scope, string namePrefix, ModuleId moduleId) { if ((null == root) || (null == scope) || (null == scope.NestedScopes)) { return; } foreach (ScopeNode subItem in scope.NestedScopes) { PythonLibraryNode newNode = new PythonLibraryNode(subItem, namePrefix, moduleId.Hierarchy, moduleId.ItemID, provider); string newNamePrefix = namePrefix; // The classes are always added to the root node, the functions to the // current node. if ((newNode.NodeType & LibraryNode.LibraryNodeType.Members) != LibraryNode.LibraryNodeType.None) { current.AddNode(newNode); } else if ((newNode.NodeType & LibraryNode.LibraryNodeType.Classes) != LibraryNode.LibraryNodeType.None) { // Classes are always added to the root. root.AddNode(newNode); newNamePrefix = newNode.Name + "."; } // Now use recursion to get the other types. CreateModuleTree(root, newNode, subItem, newNamePrefix, moduleId); } }
internal void RemoveNode(LibraryNode node) { lock (children) { children.Remove(node); } updateCount += 1; }
internal void AddNode(LibraryNode node) { lock (this) { root = new LibraryNode(root); root.AddNode(node); } }
public LibraryNode(LibraryNode node) { this.capabilities = node.capabilities; this.contextMenuID = node.contextMenuID; this.displayData = node.displayData; this.name = node.name; 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.updateCount = node.updateCount; }
public LibraryNode(LibraryNode node) { this.capabilities = node.capabilities; this.contextMenuID = node.contextMenuID; this.displayData = node.displayData; this.name = node.name; 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.updateCount = node.updateCount; }
private void OnDeleteFile(object sender, HierarchyEventArgs args) { IVsHierarchy hierarchy = sender as IVsHierarchy; if (null == hierarchy) { return; } ModuleId id = new ModuleId(hierarchy, args.ItemID); LibraryNode node = null; lock (files) { if (files.TryGetValue(id, out node)) { files.Remove(id); } } if (null != node) { library.RemoveNode(node); } }
protected 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); }
/// <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; } ScopeNode scope = null; if (null == task.Text) { if (System.IO.File.Exists(task.FileName)) { scope = ScopeWalker.GetScopesFromFile(task.FileName); } } else { scope = ScopeWalker.GetScopesFromText(task.Text); } LibraryNode module = new LibraryNode( System.IO.Path.GetFileName(task.FileName), LibraryNode.LibraryNodeType.PhysicalContainer); CreateModuleTree(module, module, scope, "", task.ModuleID); if (null != task.ModuleID) { LibraryNode previousItem = null; lock (files) { if (files.TryGetValue(task.ModuleID, out previousItem)) { files.Remove(task.ModuleID); } } library.RemoveNode(previousItem); } library.AddNode(module); if (null != task.ModuleID) { lock (files) { files.Add(task.ModuleID, module); } } } }
public Library(Guid libraryGuid) { this.guid = libraryGuid; root = new LibraryNode("", LibraryNode.LibraryNodeType.Package); }
/// <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; } ScopeNode scope = null; if (null == task.Text) { if (System.IO.File.Exists(task.FileName)) { scope = ScopeWalker.GetScopesFromFile(task.FileName); } } else { scope = ScopeWalker.GetScopesFromText(task.Text); } LibraryNode module = new LibraryNode( System.IO.Path.GetFileName(task.FileName), LibraryNode.LibraryNodeType.PhysicalContainer); CreateModuleTree(module, module, scope, "", task.ModuleID); if (null != task.ModuleID) { LibraryNode previousItem = null; lock (files) { if (files.TryGetValue(task.ModuleID, out previousItem)) { files.Remove(task.ModuleID); } } library.RemoveNode(previousItem); } library.AddNode(module); if (null != task.ModuleID) { lock(files) { files.Add(task.ModuleID, module); } } } }