private void GenerateModule(TypescriptModule module, Func <ModuleElement, bool> elementFilter = null) { Formatter.Write("module "); Formatter.Write(module.Name); Formatter.Write(" {"); Formatter.WriteLine(); Formatter.PushIndent(); GenerateModuleContent(module, elementFilter); Formatter.PopIndent(); Formatter.WriteEndOfLine(); Formatter.Write("}"); Formatter.WriteLine(); }
public void GenerateModuleContent(TypescriptModule module, Func <ModuleElement, bool> elementFilter) { DefaultNameResolver.ThisModule = module; var members = module.Members.AsEnumerable(); if (elementFilter != null) { members = members.Where(elementFilter); } var ordered = OrderByInheritance(members); Formatter.WriteSeparated("\n", ordered, Generate); }
public void Generate(TypescriptModule m) { GenerateModule(m); }
public void GenerateNonAmbient(TypescriptModule module) { GenerateModule(module, e => !CanGenerateInAmbientModule(e)); }
public void GenerateAmbient(TypescriptModule module) { Formatter.Write("declare "); GenerateModule(module, CanGenerateInAmbientModule); }
public DeclarationModuleElement(TypescriptModule innerModule) { InnerModule = innerModule; }
public static void AddModule(TypescriptModule m, string alias = null) { Modules[alias ?? m.Name] = m; }
private static bool ContainsItem <T>(TypescriptModule m, T item) where T : class { return(m.Members.OfType <DeclarationModuleElement>().Any(d => d.Declaration == item || d.EnumDeclaration == item)); }