public string GetReferencedName(DeclarationBase type) { string result; if (_cache.TryGetValue(type, out result)) { return(result); } var m = FindModule(type); if (m != null) { result = m.Item1; if (!String.IsNullOrEmpty(result)) { result = result + "."; } result = result + type.Name; } else { result = GetFailedName(type.Name); } _cache[type] = result; return(result); }
public override void VisitGenericParameters(DeclarationBase decl) { if (decl.IsGeneric) { Formatter.Write("<"); base.VisitGenericParameters(decl); Formatter.Write(">"); } }
public static IEnumerable <TypescriptTypeReference> GetExtends(this DeclarationBase decl) { if (decl is InterfaceType) { return(((InterfaceType)decl).ExtendsTypes); } else if (decl is ClassType) { return((new[] { ((ClassType)decl).Extends }).Where(x => x != null)); } else { throw new NotImplementedException("Cannot get extends from " + decl); } }
public void Generate(DeclarationBase decl) { if (decl is ClassType) { Generate((ClassType)decl); } else if (decl is InterfaceType) { Generate((InterfaceType)decl); } else { throw new ArgumentOutOfRangeException(); } }
public DeclarationModuleElement(DeclarationBase decl) { Declaration = decl; }
private void GenerateReference(DeclarationBase type) { Formatter.Write(NameResolver.GetReferencedName(type)); }