Skip to content

Feat/#12 WispRegistry 코드 생성 기능 구현#13

Merged
jm991014 merged 10 commits into
mainfrom
feat/#12-WispRegistry
Nov 23, 2025
Merged

Feat/#12 WispRegistry 코드 생성 기능 구현#13
jm991014 merged 10 commits into
mainfrom
feat/#12-WispRegistry

Conversation

@jm991014

@jm991014 jm991014 commented Nov 20, 2025

Copy link
Copy Markdown
Collaborator

Summary

수집된 모든 RouteFactory 정보를 관리하는 WispRegistry 싱글톤 객체 생성 로직을 구현하고, 빌드 타임에 중복된 경로를 감지하는 검증 로직을 추가했습니다.

Related Issue

Closes #12

ScreenShot(Option)

스크린샷 2025-11-20 오후 3 38 19

Details

이번 PR은 개별 RouteFactory들을 하나로 묶어 런타임에 제공하는 Registry 시스템을 구축합니다.

  1. WispRegistryGenerator 구현

    • kotlinpoet을 사용하여 WispRegistry 코드를 생성합니다.
    • pathRouteFactory를 매핑하는 Map을 생성하여 런타임에서 O(1) 조회가 가능하도록 했습니다.
  2. WispProcessor 로직 통합

    • process 단계에서 수집된 모든 RouteInfo를 모아 마지막에 레지스트리를 생성하도록 흐름을 개선했습니다.
    • 레지스트리는 프로젝트 내 모든 라우트 파일에 의존하므로 Dependencies(aggregating = true)를 설정하여 증분 빌드 시 올바르게 갱신되도록 했습니다.
  3. 중복 검사 구현

    • 서로 다른 클래스가 동일한 @Wisp("path")를 가질 경우, logger를 통해 해당 심볼 위치에 에러를 표시하도록 추가했습니다.
  4. 테스트 코드 추가

    • WispRegistryGeneratorTest: 생성된 코드가 예상된 Map 구조를 갖는지 문자열 검증
  5. WispClassName 추가

    • WispRegistryGeneratorRouteFactoryGenerator에서 공통적으로 사용되는 ClassName을 추출하여 관리하도록 수정했습니다.
      • 이 외에 더 추가할 클래스가 있는지 피드백 주시면 감사하겠습니다!

@jm991014 jm991014 requested a review from angryPodo November 20, 2025 06:45
@jm991014 jm991014 self-assigned this Nov 20, 2025
@jm991014 jm991014 added the FEAT✨ Add a new feature or change the behavior/policy of an existing feature. label Nov 20, 2025

@angryPodo angryPodo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

정말 고생많으셨습니다🙇🏻‍♂️ 코드가 점점 읽기 편해지는게 보여서 저도 많이 배우고 가요!
사소한 제안들 남겼습니다, 한번 확인해주세요💪🏻

Comment on lines +31 to +34
val factoriesProperty = PropertySpec.builder("factories", mapType)
.addModifiers(KModifier.INTERNAL)
.initializer(initializerBlock.build())
.build()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

생성 로직 잘 구현해주셨네요! 고생하셨습니다🥲
여기서 한가지 제안은 WispRegistry 내부에 registry라는 이름의 private 맵을 만들고 이 맵을 사용하는 createRoute같은 public 함수를 만드는건 어떨까요?

위의 제안은 향후에 외부에서 registry맵에 직접 접근하는 것을 막아서 더 안정적인 구조를 만들 수 있을 것 같습니다👍🏻

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

좋은 아이디어 같습니다👍 레지스트리 객체를 생성하는 것에만 집중하다 보니 캡슐화와 유지보수 측면을 놓쳤던 것 같습니다. 말씀하신 대로 registryprivate으로 숨기고 접근 메서드를 제공하는 구조가 훨씬 안정적이겠네요. 바로 반영하겠습니다!

Comment on lines +67 to +69
private fun validateDuplicatePaths(
routesWithSymbols: List<Pair<RouteInfo, KSClassDeclaration>>
): Boolean {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

이 부분도 구조적인 측면에서 제안이 있어요😊
이 검증 함수를 WispValidator클래스로 옮기는 건 어떻게 생각하시나요?
저는 WispProcessor는 심볼을 찾고 생성기를 호출하는 흐름을 담당하고 Wispvalidator는 모든 종류의 유효성 검사를 책임지는 구조가 될것 같아요🤔

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

좋은 제안입니다! 😊 작성할 때 기존에 있던 validateSerializable 때문에 검증 로직을 어디에 두는 게 맞을지 저도 살짝 고민했었거든요. ㅎㅎ 제안해주신 대로 WispValidator 객체에서 유효성 검사를 할 수 있도록 리팩토링 진행하겠습니다!

val factoryObject = TypeSpec.objectBuilder(routeInfo.factoryClassName)
.addModifiers(KModifier.INTERNAL)
.addSuperinterface(routeFactoryInterface)
.addSuperinterface(ROUTE_FACTORY)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

이거 아주 좋네요👍🏻
WispError관련 ClassName도 옮겨도 좋다고 생각해요!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

바로 수정하겠습니다!

@jm991014 jm991014 merged commit 628123c into main Nov 23, 2025
2 checks passed
@jm991014 jm991014 deleted the feat/#12-WispRegistry branch November 23, 2025 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FEAT✨ Add a new feature or change the behavior/policy of an existing feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KSP 프로세서의 WispRegistry 코드 생성 기능 구현

2 participants