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); } }
// 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(); }
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()); }
// 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()); }
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); } }