Exemplo n.º 1
0
 private MemberDeclarationSyntax WrapInNamespace(XSharpTreeTransformationCore trans, MemberDeclarationSyntax member,
                                                 XP.Namespace_Context xns, string defaultNamespace)
 {
     if (xns != null || !String.IsNullOrEmpty(defaultNamespace))
     {
         var    members = _pool.Allocate <MemberDeclarationSyntax>();
         string nsName;
         if (xns != null)
         {
             nsName = GetNsFullName(xns);
         }
         else
         {
             nsName = defaultNamespace;
         }
         members.Add(member);
         member = _syntaxFactory.NamespaceDeclaration(SyntaxFactory.MakeToken(SyntaxKind.NamespaceKeyword),
                                                      name: trans.GenerateQualifiedName(nsName),
                                                      openBraceToken: SyntaxFactory.MakeToken(SyntaxKind.OpenBraceToken),
                                                      externs: null,
                                                      usings: null,
                                                      members: members,
                                                      closeBraceToken: SyntaxFactory.MakeToken(SyntaxKind.CloseBraceToken),
                                                      semicolonToken: SyntaxFactory.MakeToken(SyntaxKind.SemicolonToken));
         _pool.Free(members);
     }
     return(member);
 }
        public override void ExitNamespace_([NotNull] XP.Namespace_Context context)
        {
            // we do not call base.ExitNamespace
            bindXPPClasses();
            _classes = _classstack.Pop();
            var entities = new List <XSharpParserRuleContext>();

            // do not add the methods. These should be linked to a class
            entities.AddRange(context._Entities.Where(e => !(e.GetChild(0) is XP.XppmethodContext)));
            _exitNamespace(context, context.Name.GetText(), entities);
        }
Exemplo n.º 3
0
        private string GetNsFullName(XP.Namespace_Context ns)
        {
            string name = ns.Name.GetText();

            while (ns.Parent is XP.Namespace_Context)
            {
                ns   = ns.Parent as XP.Namespace_Context;
                name = ns.Name.GetText() + "." + name;
            }
            return(name);
        }
 public override void EnterNamespace_([NotNull] XP.Namespace_Context context)
 {
     base.EnterNamespace_(context);
     _classstack.Push(_classes);
     _classes = new List <XppClassInfo>();
 }