Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ProtocolReader #7

Merged
merged 8 commits into from
Nov 5, 2021
Merged

Add ProtocolReader #7

merged 8 commits into from
Nov 5, 2021

Conversation

sidepelican
Copy link
Collaborator

概要

protocolの読み取りに対応します。
これにより、protocolをベースに実質的な関数型やクラス型を読み取ってコード生成し、TypeScriptに関数型を提供することが狙いです。
型としての関数型やタプルには既存実装と同様に対応していません。
associatedtype に対しても型名を読み取るだけです。実用上必要なタイミングがあれば型制約の部分の読み取りも実装します。

レビューしてほしいところ

  • 読み取り実装が正しそうか
  • テストが十分か
  • 新しく定義した型 FunctionRequirement PropertyRequirement まわりの命名や保持するプロパティに違和感がないか

その他

またasyncなどの新しいキーワードを扱う都合上、Xcode12ではビルドできなくなります。
(おそらくSwiftSyntaxの asyncOrReasyncKeyword が存在しないのでエラーになる)
実用上問題ないかと思っているためXcode12への後方互換は気にしていない実装になっています。

Copy link
Owner

@omochi omochi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

おお、大きな機能追加ありがとうございます。

パーサ実装は良さそうです。
テストコードはこれで十分だと思います。
対応しきれていないパターンは必要になった時に足せば良いでしょう。

@@ -5,6 +5,20 @@ import PackageDescription
var dependencies: [Package.Dependency] = []
var targetDependencies: [Target.Dependency] = []

#if swift(>=5.5)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swift5.5/Xcode13.0環境では BinarySwiftSyntax を使わずに SwiftSyntax を使う状態になった?
これだと、未来のXcode14や、場合によってはXcode13.1でも動かなくなるので、
(指定してるSwiftSyntaxライブラリのバージョンと、ビルド環境が揃っていなければならない)
BinarySwiftSyntax も更新して、
SwiftSytanx-Xcode13.0 ターゲットを提供するようにしたいですね。

このパッチのマージ後にいつかやるでいいですが。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そのとおりだと思います。BinarySwiftSyntaxの作り方がよくわかっていなくてここは一旦サボりました

import Foundation

public struct FunctionRequirement {
public struct InputParameter {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FunctionにおいてParameterというと仮引数の事なので、「Input」というprefixは冗長なので消したいです。

Sources/SwiftTypeReader/Entity/FunctionRequirement.swift Outdated Show resolved Hide resolved
sidepelican and others added 2 commits November 5, 2021 19:43
@omochi omochi merged commit c641ae8 into main Nov 5, 2021
@omochi omochi deleted the protocol_scan branch November 5, 2021 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants