Пример #1
0
        int GetCurrentNamespace(ISymbolDocumentWriter doc)
        {
            if (namespaceStack.Count == 0)
            {
                OpenNamespace("");
            }

            NamespaceInfo ni = (NamespaceInfo)namespaceStack.Peek();

            if (ni.NamespaceID == -1)
            {
                string[] usings = (string[])ni.UsingClauses.ToArray(typeof(string));

                int parentId = 0;
                if (namespaceStack.Count > 1)
                {
                    namespaceStack.Pop();
                    parentId = ((NamespaceInfo)namespaceStack.Peek()).NamespaceID;
                    namespaceStack.Push(ni);
                }

                ni.NamespaceID = msw.DefineNamespace(ni.Name, ((ICompileUnit)doc).Entry, usings, parentId);
            }
            return(ni.NamespaceID);
        }
Пример #2
0
        public void OpenNamespace(string name)
        {
            NamespaceInfo n = new NamespaceInfo();

            n.NamespaceID = -1;
            n.Name        = name;
            namespaceStack.Push(n);
        }
Пример #3
0
        public void UsingNamespace(string fullName)
        {
            if (namespaceStack.Count == 0)
            {
                OpenNamespace("");
            }

            NamespaceInfo ni = (NamespaceInfo)namespaceStack.Peek();

            if (ni.NamespaceID != -1)
            {
                NamespaceInfo old = ni;
                CloseNamespace();
                OpenNamespace(old.Name);
                ni = (NamespaceInfo)namespaceStack.Peek();
                ni.UsingClauses = old.UsingClauses;
            }
            ni.UsingClauses.Add(fullName);
        }