void BuildImport(XmlElement element) { var compUnit = this.CompilationUnit as PythonCompilationUnit; Console.WriteLine("Import({0})", element.GetAttribute("name")); var region = GetDomRegion(element); var domUsing = new DomUsing(region, element.GetAttribute("name")); compUnit.Add(domUsing); }
public override object VisitUsingDeclaration (ICSharpCode.NRefactory.Ast.UsingDeclaration usingDeclaration, object data) { DomUsing domUsing = new DomUsing (); domUsing.Region = ConvertRegion (usingDeclaration.StartLocation, usingDeclaration.EndLocation); domUsing.ValidRegion = ConvertRegion (usingDeclaration.StartLocation, namespaceEndLocationStack.Peek ()); foreach (ICSharpCode.NRefactory.Ast.Using u in usingDeclaration.Usings) { if (u.IsAlias) { domUsing.Add (u.Name, ConvertReturnType (u.Alias)); } else { domUsing.Add (u.Name); } } ((CompilationUnit)result.CompilationUnit).Add (domUsing); return data; }
public override object VisitNamespaceDeclaration (ICSharpCode.NRefactory.Ast.NamespaceDeclaration namespaceDeclaration, object data) { string[] splittedNamespace = namespaceDeclaration.Name.Split ('.'); for (int i = splittedNamespace.Length; i > 0; i--) { DomUsing domUsing = new DomUsing (); domUsing.IsFromNamespace = true; domUsing.Region = ConvertRegion (namespaceDeclaration.StartLocation, namespaceDeclaration.EndLocation); domUsing.ValidRegion = domUsing.Region; domUsing.Add (String.Join (".", splittedNamespace, 0, i)); ((CompilationUnit)result.CompilationUnit).Add (domUsing); } namespaceEndLocationStack.Push (namespaceDeclaration.EndLocation); namespaceStack.Push (namespaceStack.Count == 0 ? namespaceDeclaration.Name : namespaceStack.Peek () + "." + namespaceDeclaration.Name); namespaceDeclaration.AcceptChildren (this, data); namespaceStack.Pop (); namespaceEndLocationStack.Pop (); return null; }
public override void Visit (UsingsBag.AliasUsing u) { DomUsing domUsing = new DomUsing (); domUsing.Region = ConvertRegion (u.UsingLocation, u.SemicolonLocation); domUsing.ValidRegion = ConvertRegion (currentNamespace.Peek ().OpenBrace, currentNamespace.Peek ().CloseBrace); domUsing.Add (u.Identifier.Value, new DomReturnType (ConvertToString (u.Nspace))); Unit.Add (domUsing); }
public override void Visit (UsingsBag.Using u) { if (!string.IsNullOrEmpty (currentNamespaceName)) { DomUsing relativeNamespaceUsing = new DomUsing (); relativeNamespaceUsing.Region = ConvertRegion (u.UsingLocation, u.SemicolonLocation); relativeNamespaceUsing.ValidRegion = ConvertRegion (currentNamespace.Peek ().OpenBrace, currentNamespace.Peek ().CloseBrace); relativeNamespaceUsing.Add (currentNamespaceName + "." + ConvertToString (u.NSpace)); Unit.Add (relativeNamespaceUsing); } DomUsing domUsing = new DomUsing (); domUsing.Region = ConvertRegion (u.UsingLocation, u.SemicolonLocation); domUsing.ValidRegion = ConvertRegion (currentNamespace.Peek ().OpenBrace, currentNamespace.Peek ().CloseBrace); domUsing.Add (ConvertToString (u.NSpace)); Unit.Add (domUsing); }
public override void Visit (UsingsBag.Namespace nspace) { string oldNamespace = currentNamespaceName; currentNamespace.Push (nspace); if (nspace.Name != null) { // no need to push the global namespace string name = ConvertToString (nspace.Name); string[] splittedNamespace = name.Split ('.'); for (int i = splittedNamespace.Length; i > 0; i--) { DomUsing domUsing = new DomUsing (); domUsing.IsFromNamespace = true; domUsing.Region = domUsing.ValidRegion = ConvertRegion (nspace.OpenBrace, nspace.CloseBrace); domUsing.Add (string.Join (".", splittedNamespace, 0, i)); Unit.Add (domUsing); } currentNamespaceName = string.IsNullOrEmpty (currentNamespaceName) ? name : currentNamespaceName + "." + name; } VisitNamespaceUsings (nspace); VisitNamespaceBody (nspace); currentNamespace.Pop (); currentNamespaceName = oldNamespace; }
public override object VisitNamespaceDeclaration (ICSharpCode.NRefactory.Ast.NamespaceDeclaration namespaceDeclaration, object data) { string[] splittedNamespace = namespaceDeclaration.Name.Split ('.'); for (int i = splittedNamespace.Length; i > 0; i--) { DomUsing domUsing = new DomUsing (); domUsing.IsFromNamespace = true; domUsing.Region = ConvertRegion (namespaceDeclaration.StartLocation, namespaceDeclaration.EndLocation); domUsing.ValidRegion = domUsing.Region; domUsing.Add (String.Join (".", splittedNamespace, 0, i)); ((CompilationUnit)result.CompilationUnit).Add (domUsing); } namespaceEndLocationStack.Push (namespaceDeclaration.EndLocation); namespaceStack.Push (namespaceStack.Count == 0 ? namespaceDeclaration.Name : namespaceStack.Peek () + "." + namespaceDeclaration.Name); namespaceDeclaration.AcceptChildren (this, data); namespaceStack.Pop (); namespaceEndLocationStack.Pop (); return null; }
public override object VisitUsingDeclaration (ICSharpCode.NRefactory.Ast.UsingDeclaration usingDeclaration, object data) { DomUsing domUsing = new DomUsing (); domUsing.Region = ConvertRegion (usingDeclaration.StartLocation, usingDeclaration.EndLocation); domUsing.ValidRegion = ConvertRegion (usingDeclaration.StartLocation, namespaceEndLocationStack.Peek ()); foreach (ICSharpCode.NRefactory.Ast.Using u in usingDeclaration.Usings) { if (u.IsAlias) { domUsing.Add (u.Name, ConvertReturnType (u.Alias)); } else { domUsing.Add (u.Name); } } ((CompilationUnit)result.CompilationUnit).Add (domUsing); return data; }
public override void Visit (UsingsBag.Namespace nspace) { string oldNamespace = currentNamespaceName; currentNamespace.Push (nspace); if (nspace.Name != null) { // no need to push the global namespace DomUsing domUsing = new DomUsing (); domUsing.IsFromNamespace = true; domUsing.Region = domUsing.ValidRegion = ConvertRegion (nspace.OpenBrace, nspace.CloseBrace); string name = ConvertToString (nspace.Name); domUsing.Add (name); Unit.Add (domUsing); currentNamespaceName = string.IsNullOrEmpty (currentNamespaceName) ? name : currentNamespaceName + "." + name; } VisitNamespaceUsings (nspace); VisitNamespaceBody (nspace); currentNamespace.Pop (); currentNamespaceName = oldNamespace; }
void BuildImport (XmlElement element) { var compUnit = this.CompilationUnit as PythonCompilationUnit; Console.WriteLine ("Import({0})", element.GetAttribute ("name")); var region = GetDomRegion (element); var domUsing = new DomUsing (region, element.GetAttribute ("name")); compUnit.Add (domUsing); }