public static List <string> GetFullNamespace(Node node) { List <string> currentNamespace = new List <string>(); ANamespaceDecl n = GetAncestor <ANamespaceDecl>(node); while (n != null) { currentNamespace.Add(n.GetName().Text); n = GetAncestor <ANamespaceDecl>(n.Parent()); } currentNamespace.Reverse(); return(currentNamespace); }
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 override void CaseANamedType(ANamedType node) { AAName name = (AAName)node.GetName(); if (name.GetIdentifier().Count > 2) { return; } if (name.GetIdentifier().Count == 2 && ((TIdentifier)name.GetIdentifier()[0]).Text != "Dialogs") { return; } if (name.GetIdentifier().Count == 1) { bool foundDialogs = false; AASourceFile file = Util.GetAncestor <AASourceFile>(node); foreach (AUsingDecl usingDecl in file.GetUsings()) { if (usingDecl.GetNamespace().Count == 1) { TIdentifier identifer = (TIdentifier)usingDecl.GetNamespace()[0]; if (identifer.Text == "Dialogs") { foundDialogs = true; break; } } } if (!foundDialogs) { ANamespaceDecl ns = Util.GetAncestor <ANamespaceDecl>(node); if (!Util.HasAncestor <ANamespaceDecl>(ns.Parent()) && ns.GetName().Text == "Dialogs") { foundDialogs = true; } } if (!foundDialogs) { return; } } if (((TIdentifier)name.GetIdentifier()[name.GetIdentifier().Count - 1]).Text == oldName) { types.Add((TIdentifier)name.GetIdentifier()[name.GetIdentifier().Count - 1]); } }