Example #1
0
        internal XSharpLibraryProject(XProject prj, IVsHierarchy hierarchy)
            : base(prj.Name, LibraryNodeType.Package)
        {
            this.ownerHierarchy = hierarchy;
            //
            this.displayData.hImageList    = XSharpProjectNode.ImageList.Handle;
            this.displayData.Image         = (ushort)XSharpProjectNode.XSharpProjectImageName.Project;
            this.displayData.SelectedImage = (ushort)XSharpProjectNode.XSharpProjectImageName.Project;
            //
            this.NodeType = LibraryNodeType.Package;
            //
            //prj.ProjectNode
            this._defaultNameSpace = prj.ProjectNode.RootNameSpace;
            if (String.IsNullOrEmpty(this._defaultNameSpace))
            {
                this._defaultNameSpace = "Default Namespace";
            }
            //
            XSharpLibraryNode defaultNS = new XSharpLibraryNode(_defaultNameSpace, LibraryNodeType.Namespaces);

            defaultNS.displayData.Image         = (ushort)IconImageIndex._Namespace;
            defaultNS.displayData.SelectedImage = (ushort)IconImageIndex._Namespace;
            this.AddNode(defaultNS);
            //
        }
Example #2
0
        private void CreateMembersTree(LibraryNode current, XTypeDefinition scope, XSharpModuleId moduleId)
        {
            if (null == scope || XSolution.IsClosing)
            {
                return;
            }


            foreach (XMemberDefinition member in scope.Members)
            {
                XSharpLibraryNode newNode = new XSharpLibraryNode(member, "", moduleId.Hierarchy, moduleId.ItemID);

                // 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);
                    newNode.parent = current;
                    lock (files)
                    {
                        files.Add(moduleId, newNode);
                    }
                }
            }
        }
 internal XSharpLibraryNode(XSharpLibraryNode node) :
     base(node)
 {
     this.filesId = new List <uint>();
     this.Depends(node.filesId);
     this.ownerHierarchy = node.ownerHierarchy;
     this.fileMoniker    = node.fileMoniker;
     this.member         = node.member;
     this.NodeType       = node.NodeType;
 }
Example #4
0
 private void CreateGlobalTree(LibraryNode current, XTypeDefinition scope, XSharpModuleId moduleId)
 {
     if (null == scope || XSolution.IsClosing)
     {
         return;
     }
     foreach (XMemberDefinition member in scope.XMembers)
     {
         XSharpLibraryNode newNode = new XSharpLibraryNode(member, "", moduleId.Hierarchy, moduleId.ItemID);
         // Functions ?
         if ((newNode.NodeType & LibraryNode.LibraryNodeType.Members) != LibraryNode.LibraryNodeType.None)
         {
             current.AddNode(newNode);
             newNode.parent = current;
             lock (files)
             {
                 files.Add(moduleId, newNode);
             }
         }
     }
 }
Example #5
0
        internal LibraryNode SearchHierarchy(IVsHierarchy hierarchy)
        {
            LibraryNode found = null;

            lock (this)
            {
                foreach (LibraryNode nd in root.children)
                {
                    if (nd is XSharpLibraryNode)
                    {
                        XSharpLibraryNode vln = (XSharpLibraryNode)nd;
                        if (hierarchy.Equals(vln.ownerHierarchy))
                        {
                            found = nd;
                            break;
                        }
                    }
                }
            }
            return(found);
        }
Example #6
0
 private void CreateGlobalTree(LibraryNode globalScope, IList <XMemberDefinition> XMembers, XSharpModuleId moduleId)
 {
     if (XSolution.IsClosing)
     {
         return;
     }
     foreach (XMemberDefinition member in XMembers)
     {
         XSharpLibraryNode newNode = new XSharpLibraryNode(member, "", moduleId.Hierarchy, moduleId.ItemID);
         // Functions ?
         if ((newNode.NodeType & LibraryNode.LibraryNodeType.Members) != LibraryNode.LibraryNodeType.None)
         {
             globalScope.AddNode(newNode);
             newNode.parent = globalScope;
             lock (files)
             {
                 files.Add(moduleId, newNode);
             }
         }
     }
 }
Example #7
0
        private void CreateModuleTree(XSharpLibraryProject prjNode, XFile scope, XSharpModuleId moduleId)
        {
            if (null == scope || XSolution.IsClosing)
            {
                return;
            }

            if (!scope.HasCode)
            {
                return;
            }
            // Retrieve all Types
            // !!! WARNING !!! The XFile object (scope) comes from the DataBase
            // We should retrieve TypeList from the DataBase.....
            var namespaces = XSharpModel.XDatabase.GetNamespacesInFile(scope.Id.ToString());

            if (namespaces == null)
            {
                return;
            }
            //
            var elements = XDbResultHelpers.BuildTypesInFile(scope, namespaces);

            // First search for NameSpaces
            foreach (XTypeDefinition xType in elements)
            {
                if (xType.Kind == Kind.Namespace)
                {
                    // Does that NameSpace already exist ?
                    // Search for the corresponding NameSpace
                    XSharpLibraryNode newNode;
                    LibraryNode       nsNode = prjNode.SearchNameSpace(xType.Name);
                    if (nsNode is XSharpLibraryNode)
                    {
                        newNode = (XSharpLibraryNode)nsNode;
                        newNode.Depends(moduleId.ItemID);
                    }
                    else
                    {
                        newNode = new XSharpLibraryNode(xType, "", moduleId.Hierarchy, moduleId.ItemID);

                        // NameSpaces are always added to the root.
                        prjNode.AddNode(newNode);
                        newNode.parent = prjNode;
                    }
                    // Handle Global Scope here
                    // It contains Function/Procedure/etc...
                    if (newNode.Name == "(Global Scope)")
                    {
                        CreateGlobalTree(newNode, xType, moduleId);
                    }
                    lock (files)
                    {
                        files.Add(moduleId, newNode);
                    }
                }
            }

            // Retrieve Classes from the file
            var types = XSharpModel.XDatabase.GetTypesInFile(scope.Id.ToString());

            if (types == null)
            {
                return;
            }
            elements = XDbResultHelpers.BuildFullTypesInFile(scope, types);
            // Now, look for Classes
            foreach (XTypeDefinition xType in elements)
            {
                // Is it a kind of Type ?
                if ((xType.Kind.IsType()))
                {
                    string nSpace = prjNode.DefaultNameSpace;
                    if (!String.IsNullOrEmpty(xType.Namespace))
                    {
                        nSpace = xType.Namespace;
                    }
                    // Search for the corresponding NameSpace
                    LibraryNode nsNode = prjNode.SearchNameSpace(nSpace);
                    if (nsNode == null)
                    {
                        nsNode = prjNode.SearchClass(nSpace);
                    }

                    if (nsNode is XSharpLibraryNode)
                    {
                        XSharpLibraryNode xsNSNode = (XSharpLibraryNode)nsNode;
                        // So the Class node will belong to that NameSpace Node
                        // Now, try to check if such Type already exist
                        XSharpLibraryNode newNode;
                        LibraryNode       newTmpNode;
                        newTmpNode = xsNSNode.SearchClass(xType.Name);
                        if (newTmpNode is XSharpLibraryNode)
                        {
                            newNode = (XSharpLibraryNode)newTmpNode;
                            newNode.Depends(moduleId.ItemID);
                        }
                        else
                        {
                            newNode = new XSharpLibraryNode(xType, "", moduleId.Hierarchy, moduleId.ItemID);
                            nsNode.AddNode(newNode);
                            newNode.parent = nsNode;
                        }
                        //
                        // Insert Members
                        CreateMembersTree(newNode, xType, moduleId);
                        //
                        lock (files)
                        {
                            files.Add(moduleId, newNode);
                        }
                    }
                    else
                    {
                        // Not found !?
                    }
                }
            }
        }
        private void CreateModuleTree(XSharpLibraryProject prjNode, XFile scope, XSharpModuleId moduleId)
        {
            if ((null == scope))
            {
                return;
            }
            if (!scope.HasCode)
            {
                return;
            }
            // Retrieve all Types
            var elements = scope.TypeList;

            if (elements == null)
            {
                return;
            }
            //
            // First search for NameSpaces
            foreach (KeyValuePair <string, XType> pair in elements)
            {
                XType xType = pair.Value;
                if (xType.Kind == Kind.Namespace)
                {
                    // Does that NameSpave already exist ?
                    // Search for the corresponding NameSpace
                    XSharpLibraryNode newNode;
                    LibraryNode       nsNode = prjNode.SearchNameSpace(xType.Name);
                    if (nsNode is XSharpLibraryNode)
                    {
                        newNode = (XSharpLibraryNode)nsNode;
                        newNode.Depends(moduleId.ItemID);
                    }
                    else
                    {
                        newNode = new XSharpLibraryNode(xType, "", moduleId.Hierarchy, moduleId.ItemID);

                        // NameSpaces are always added to the root.
                        prjNode.AddNode(newNode);
                        newNode.parent = prjNode;
                    }
                    // Handle Global Scope here
                    // It contains Function/Procedure/etc...
                    if (newNode.Name == "(Global Scope)")
                    {
                        CreateGlobalTree(newNode, xType, moduleId);
                    }
                    lock (files)
                    {
                        files.Add(moduleId, newNode);
                    }
                }
            }

            // Now, look for Classes
            foreach (KeyValuePair <string, XType> pair in elements)
            {
                XType xType = pair.Value;
                // Is it a kind of Type ?
                if ((xType.Kind.IsType()))
                {
                    string nSpace = prjNode.DefaultNameSpace;
                    if (!String.IsNullOrEmpty(xType.NameSpace))
                    {
                        nSpace = xType.NameSpace;
                    }
                    // Search for the corresponding NameSpace
                    LibraryNode nsNode = prjNode.SearchNameSpace(nSpace);
                    if (nsNode is XSharpLibraryNode)
                    {
                        XSharpLibraryNode xsNSNode = (XSharpLibraryNode)nsNode;
                        // So the Class node will belong to that NameSpace Node
                        // Now, try to check if such Type already exist
                        XSharpLibraryNode newNode;
                        LibraryNode       newTmpNode;
                        newTmpNode = xsNSNode.SearchClass(xType.Name);
                        if (newTmpNode is XSharpLibraryNode)
                        {
                            newNode = (XSharpLibraryNode)newTmpNode;
                            newNode.Depends(moduleId.ItemID);
                        }
                        else
                        {
                            newNode = new XSharpLibraryNode(xType, "", moduleId.Hierarchy, moduleId.ItemID);
                            nsNode.AddNode(newNode);
                            newNode.parent = nsNode;
                        }
                        // Insert Members
                        CreateMembersTree(newNode, xType, moduleId);
                        //
                        lock (files)
                        {
                            files.Add(moduleId, newNode);
                        }
                    }
                    else
                    {
                        // Not found !?
                    }
                }
            }
        }