Skip to content

Conversation

@twisti-dev
Copy link
Contributor

Motivation

  • Avoid emitting incomplete or duplicate hook metadata when @DependsOnClass references are unresolved so generated surf-hooks.json does not contain entries missing class dependencies.

Description

  • In surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/.../HookSymbolProcessor.kt track unresolved class dependencies with a hasUnresolvedClassDependency flag and short-circuit mapNotNull to return@mapNotNull null when any DependsOnClass reference is unresolved or its closestClassDeclaration() is missing, preventing partial PluginHookMeta.Hook entries.

Testing

  • No automated tests were run for this change.

Codex Task

Copilot AI review requested due to automatic review settings January 24, 2026 22:25
@twisti-dev twisti-dev merged commit c29cbc4 into feat/hook-api Jan 24, 2026
10 checks passed
@twisti-dev twisti-dev deleted the codex/github-mention-feat-hook-api branch January 24, 2026 22:26
@github-actions
Copy link

⚠️ API/ABI changes detected!

This PR contains changes that modified the public API. To update the reference ABI dumps:

./gradlew updateLegacyAbi
git add **/api/**
git commit -m "Update ABI reference"
git push

After updating, the CI will pass. Make sure the changes are backward compatible.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an issue where hook metadata could be incomplete when @DependsOnClass annotation references are unresolved during symbol processing. The change ensures that hooks with unresolved class dependencies are properly deferred for later processing rather than being partially emitted to the generated surf-hooks.json file.

Changes:

  • Added a hasUnresolvedClassDependency flag to track when any @DependsOnClass annotation has an unresolved reference
  • Added early return logic after processing all class dependencies to skip hooks with unresolved dependencies
  • Ensured unresolved hooks are added to the deferred list for reprocessing in subsequent rounds

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 57 to 64
deferred += hookClass
hasUnresolvedClassDependency = true
return@mapNotNull null
}

val closestClass = clazzValue.declaration.closestClassDeclaration()
if (closestClass == null) {
deferred += hookClass
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

If a hook class has multiple @DependsOnClass annotations with unresolved dependencies, hookClass will be added to the deferred list multiple times (lines 57 and 64). This could lead to duplicate entries in the deferred list and potentially reprocessing the same hook multiple times in subsequent rounds.

Consider adding the hook to deferred only once, either by checking if it's already in the list before adding, or by deferring the addition until after all annotations are processed (e.g., moving it to lines 71-73 where the flag is checked).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants