public override void CaseANamespaceDecl(ANamespaceDecl node)
 {
     string lastNamespace = currentNamespace;
     currentNamespace += node.GetName().Text + "_";
     base.CaseANamespaceDecl(node);
     currentNamespace = lastNamespace;
     while (node.GetDecl().Count > 0)
     {
         PDecl decl = (PDecl) node.GetDecl()[0];
         node.RemoveChild(decl);
         if (node.Parent() is ANamespaceDecl)
         {
             ANamespaceDecl parent = (ANamespaceDecl) node.Parent();
             parent.GetDecl().Insert(parent.GetDecl().IndexOf(node), decl);
         }
         else
         {
             AASourceFile parent = (AASourceFile)node.Parent();
             parent.GetDecl().Insert(parent.GetDecl().IndexOf(node), decl);
         }
     }
     node.Parent().RemoveChild(node);
 }
        public NamespaceDescription(ANamespaceDecl ns)
        {
            decl = ns;
            LineFrom = decl.GetToken().Line;
            if (decl.GetEndToken() == null)
                LineTo = int.MaxValue;
            else
                LineTo = decl.GetEndToken().Line;
            SourceFileContents.Parser parser = new SourceFileContents.Parser(ns);

            //if (Structs.Count != parser.Structs.Count && Form1.Form.CurrentOpenFile != null && Form1.Form.CurrentOpenFile.OpenFile != null)
              //  Form1.Form.CurrentOpenFile.OpenFile.Editor.Restyle();

            Methods = parser.Methods;
            foreach (MethodDescription method in Methods)
            {
                method.ParentFile = this;
            }
            Fields = parser.Fields;
            foreach (VariableDescription field in Fields)
            {
                field.ParentFile = this;
            }
            Structs = parser.Structs;
            foreach (StructDescription structDescription in Structs)
            {
                foreach (MethodDescription method in structDescription.Methods)
                {
                    method.ParentFile = this;
                }
                foreach (VariableDescription field in structDescription.Fields)
                {
                    field.ParentFile = this;
                }
                structDescription.ParentFile = this;
            }
            Enrichments = parser.Enrichments;
            foreach (EnrichmentDescription structDescription in Enrichments)
            {
                structDescription.ParentFile = this;
                foreach (MethodDescription method in structDescription.Methods)
                {
                    method.ParentFile = this;
                }
                foreach (VariableDescription field in structDescription.Fields)
                {
                    field.ParentFile = this;
                }
            }
            Typedefs = parser.Typedefs;
            foreach (TypedefDescription typedef in Typedefs)
            {
                typedef.ParentFile = this;
            }
            Usings = parser.Usings;
            Namespaces = parser.Namespaces;
            foreach (NamespaceDescription namespaceDescription in Namespaces)
            {
                namespaceDescription.Parent = this;
            }
            Position = TextPoint.FromCompilerCoords(ns.GetName());
        }
示例#3
0
 internal Decl_Cast(ANamespaceDecl obj)
 {
     this.obj = obj;
 }
 public virtual void CaseANamespaceDecl(ANamespaceDecl node)
 {
     DefaultCase(node);
 }
 public virtual void OutANamespaceDecl(ANamespaceDecl node)
 {
     DefaultOut(node);
 }
 public virtual void InANamespaceDecl(ANamespaceDecl node)
 {
     DefaultIn(node);
 }
 public override void CaseANamespaceDecl(ANamespaceDecl node)
 {
     InANamespaceDecl(node);
     if (node.GetEndToken() != null)
     {
         node.GetEndToken().Apply(this);
     }
     {
         Object[] temp = new Object[node.GetDecl().Count];
         node.GetDecl().CopyTo(temp, 0);
         for (int i = temp.Length - 1; i >= 0; i--)
         {
             ((PDecl)temp[i]).Apply(this);
         }
     }
     if (node.GetName() != null)
     {
         node.GetName().Apply(this);
     }
     if (node.GetToken() != null)
     {
         node.GetToken().Apply(this);
     }
     OutANamespaceDecl(node);
 }
示例#8
0
        public override void CaseATempNamespaceDecl(ATempNamespaceDecl node)
        {
            ANamespaceDecl visitMe = null;
            Node parent = node.Parent();
            IList declList;
            if (parent is ANamespaceDecl)
                declList = ((ANamespaceDecl) parent).GetDecl();
            else
                declList = ((AASourceFile)parent).GetDecl();
            parent.RemoveChild(node);

            List<TIdentifier> identifiers = new List<TIdentifier>();
            foreach (TIdentifier identifier in node.GetName())
            {
                identifiers.Add(identifier);
            }

            foreach (TIdentifier identifier in identifiers)
            {
                TRBrace endToken = null;
                if (node.GetEndToken() != null)
                    endToken = new TRBrace("}", node.GetEndToken().Line, node.GetEndToken().Pos);
                ANamespaceDecl ns = new ANamespaceDecl(new TNamespace("namespace", node.GetToken().Line, node.GetToken().Pos), identifier, new ArrayList(), endToken);
                if (visitMe == null)
                    visitMe = ns;
                declList.Add(ns);
                declList = ns.GetDecl();
            }
            while (node.GetDecl().Count > 0)
            {
                declList.Add(node.GetDecl()[0]);
            }
            visitMe.Apply(this);
        }
 public override void CaseANamespaceDecl(ANamespaceDecl node)
 {
     if (isFirst)
     {
         base.CaseANamespaceDecl(node);
         return;
     }
     NamespaceDescription ns = new NamespaceDescription(node);
     Namespaces.Add(ns);
 }