Пример #1
0
 public void Add(IEmitable statement)
 {
     if (statement is IPyStatement && !PyCodeBlock.HasAny(statement as IPyStatement))
     {
         return;
     }
     if (statement is PyNamespaceStatement)
     {
         var tmp  = statement as PyNamespaceStatement;
         var item = GetItemForNamespace(Container, tmp.Name);
         item.Items.AddRange(tmp.Code.Statements);
     }
     else if (statement is PyClassDefinition)
     {
         var tmp = statement as PyClassDefinition;
         if (tmp.IsEmpty)
         {
             return;
         }
         var item = GetItemForNamespace(Container, tmp.Name.Namespace);
         item.Items.Add(statement);
     }
     else
     {
         var item = GetItemForNamespace(Container, PyNamespace.Root);
         item.Items.Add(statement);
     }
 }
Пример #2
0
        // Private Methods 

        private static string GetCode(IEmitable method)
        {
            var emiter = new PhpSourceCodeEmiter();
            var writer = new PhpSourceCodeWriter();
            writer.Clear();
            method.Emit(emiter, writer, new PhpEmitStyle());
            return writer.GetCode(true).Trim();
        }
Пример #3
0
        private static void WriteCode(IEmitable emitable, string expected)
        {
            var writer = new PySourceCodeWriter();

            emitable.Emit(new PySourceCodeEmiter(), writer, new PyEmitStyle());
            var code = writer.GetCode();

            Assert.Equal(expected.Trim(), code.Trim());
        }
Пример #4
0
        // Private Methods 

        private static string GetCode(IEmitable method)
        {
            var emiter = new PhpSourceCodeEmiter();
            var writer = new PhpSourceCodeWriter();

            writer.Clear();
            method.Emit(emiter, writer, new PhpEmitStyle());
            return(writer.GetCode(true).Trim());
        }
Пример #5
0
 public void Add(IEmitable statement)
 {
     if (statement is IPhpStatement && !PhpCodeBlock.HasAny(statement as IPhpStatement))
         return;
     if (statement is PhpNamespaceStatement)
     {
         var tmp = statement as PhpNamespaceStatement;
         var item = GetItemForNamespace(container, tmp.Name);
         item.Items.AddRange(tmp.Code.Statements);
     }
     else if (statement is PhpClassDefinition)
     {
         var tmp = statement as PhpClassDefinition;
         if (tmp.IsEmpty)
             return;
         var item = GetItemForNamespace(container, tmp.Name.Namespace);
         item.Items.Add(statement);
     }
     else
     {
         var item = GetItemForNamespace(container, PhpNamespace.Root);
         item.Items.Add(statement);
     }
 }