-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Code Files in TypeScript (#3321)
* Adds codefiles in typescript * Update src/Kiota.Builder/CodeDOM/CodeFile.cs Co-authored-by: Vincent Biret <[email protected]> --------- Co-authored-by: Vincent Biret <[email protected]>
- Loading branch information
Showing
15 changed files
with
365 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/Kiota.Builder/Writers/TypeScript/CodeFileDeclarationWriter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Linq; | ||
using Kiota.Builder.CodeDOM; | ||
|
||
namespace Kiota.Builder.Writers.TypeScript; | ||
|
||
public class CodeFileDeclarationWriter : BaseElementWriter<CodeFileDeclaration, TypeScriptConventionService> | ||
{ | ||
private readonly CodeUsingWriter _codeUsingWriter; | ||
public CodeFileDeclarationWriter(TypeScriptConventionService conventionService, string clientNamespaceName) : base(conventionService) | ||
{ | ||
_codeUsingWriter = new(clientNamespaceName); | ||
} | ||
|
||
public override void WriteCodeElement(CodeFileDeclaration codeElement, LanguageWriter writer) | ||
{ | ||
ArgumentNullException.ThrowIfNull(codeElement); | ||
ArgumentNullException.ThrowIfNull(writer); | ||
|
||
if (codeElement.Parent is CodeFile cf && cf.Parent is CodeNamespace ns) | ||
{ | ||
var usings = cf.GetChildElements().SelectMany(static x => | ||
{ | ||
return x switch | ||
{ | ||
CodeFunction f => f.StartBlock.Usings, | ||
CodeInterface ci => ci.Usings, | ||
CodeClass cc => cc.Usings, | ||
_ => Enumerable.Empty<CodeUsing>() | ||
}; | ||
} | ||
); | ||
_codeUsingWriter.WriteCodeElement(usings, ns, writer); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.