/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; // Opening declaration writer.WriteLine("{0} {1} {2}{3} {4}", TokenUtility.ToString(this.Visibility), this.ReturnType.Translate(), this.Name.Translate(), SyntaxUtility.ToBracketEnclosedList(this.Arguments.Select(unit => unit.Translate())), Lexems.OpenCurlyBracket); // Statements // The body, we render them as a list of semicolon/newline separated elements writer.WriteLine("{0}", SyntaxUtility.ToNewlineSemicolonSeparatedList( this.statements.Select(unit => unit.Translate()), true)); // Closing declaration writer.WriteLine("{0}", Lexems.CloseCurlyBracket); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; writer.Write(this.unaryPosition == UnaryPosition.Postfix ? "{0}{1}" : "{1}{0}", this.Operand.Translate(), TokenUtility.ToString(this.operatorToken)); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public virtual string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; // Opening declaration writer.WriteLine("{0} {1} {2}{3}", TokenUtility.ToString(this.Visibility), this.ReturnType.Translate(), this.Name.Translate(), SyntaxUtility.ToBracketEnclosedList(this.arguments.Select(unit => unit.Translate()))); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public override string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; // TODO: Use `{0}{1}{2}{1}{3}` when FormatWriter gets fixed to support repetitive placeholders writer.Write("{0}{1}{2}{3}{4}", this.LeftOperand.Translate(), Lexems.Whitespace, TokenUtility.ToString(this.operatorToken), Lexems.Whitespace, this.RightOperand.Translate()); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public virtual string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; // Opening declaration writer.Write("{0} {1} {2} {3}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), TokenUtility.ToString(this.Visibility), this.Name.Translate(), Lexems.Colon, this.type.Translate()); return(writer.ToString()); }
/// <summary> /// Translate the unit into TypeScript. /// </summary> /// <returns></returns> public string Translate() { FormatWriter writer = new FormatWriter() { Formatter = this.Formatter }; // Opening declaration string classVisibility = TokenUtility.ToString(this.Visibility); string baseList = this.BuildClassInheritanceAndInterfaceImplementationList(); if (this.injectedBefore == null) { writer.WriteLine("{0} class {1} {2} {3}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), classVisibility, this.Name.Translate(), baseList, Lexems.OpenCurlyBracket); } else { writer.WriteLine("{0} {1} class {2} {3} {4}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), this.injectedBefore.Translate(), classVisibility, this.Name.Translate(), baseList, Lexems.OpenCurlyBracket); } // Translating members first foreach (ITranslationUnit translationUnit in this.memberDeclarations) { if (translationUnit as NestedElementTranslationUnit != null) { ((NestedElementTranslationUnit)translationUnit).NestingLevel = this.NestingLevel + 1; } writer.WriteLine("{0}{1}", translationUnit.Translate(), Lexems.Semicolon); } // Then constructors foreach (ITranslationUnit translationUnit in this.constructorDeclarations) { if (translationUnit as NestedElementTranslationUnit != null) { ((NestedElementTranslationUnit)translationUnit).NestingLevel = this.NestingLevel + 1; } writer.WriteLine(translationUnit.Translate()); } // Then properties foreach (ITranslationUnit translationUnit in this.propertyDeclarations) { if (translationUnit as NestedElementTranslationUnit != null) { ((NestedElementTranslationUnit)translationUnit).NestingLevel = this.NestingLevel + 1; } writer.WriteLine(translationUnit.Translate()); } // Finally methods foreach (ITranslationUnit translationUnit in this.methodDeclarations) { if (translationUnit as NestedElementTranslationUnit != null) { ((NestedElementTranslationUnit)translationUnit).NestingLevel = this.NestingLevel + 1; } writer.WriteLine(translationUnit.Translate()); } // Closing writer.WriteLine("{0}", text => ClassDeclarationCodePerfect.RefineDeclaration(text), Lexems.CloseCurlyBracket); return(writer.ToString()); }