Example #1
0
 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();
 }
Example #2
0
        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);
        }
Example #3
0
 public void Generate(TypescriptModule m)
 {
     GenerateModule(m);
 }
Example #4
0
 public void GenerateNonAmbient(TypescriptModule module)
 {
     GenerateModule(module, e => !CanGenerateInAmbientModule(e));
 }
Example #5
0
 public void GenerateAmbient(TypescriptModule module)
 {
     Formatter.Write("declare ");
     GenerateModule(module, CanGenerateInAmbientModule);
 }
Example #6
0
 public DeclarationModuleElement(TypescriptModule innerModule)
 {
     InnerModule = innerModule;
 }
Example #7
0
 public static void AddModule(TypescriptModule m, string alias = null)
 {
     Modules[alias ?? m.Name] = m;
 }
Example #8
0
 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));
 }