-
Notifications
You must be signed in to change notification settings - Fork 0
JBRes-6959: Introduce Add-Comment Transformation #25
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
JBRes-6959: Introduce Add-Comment Transformation #25
Conversation
Qodana Community for JVM6 new problems were found
💡 Qodana analysis was run in the pull request mode: only the changed files were checked View the detailed Qodana reportTo be able to view the detailed Qodana report, you can either:
To get - name: 'Qodana Scan'
uses: JetBrains/[email protected]
with:
upload-result: trueContact Qodana teamContact us at [email protected]
|
Because this parsing can be done in init block of an exact transformation. This makes the API easier since a user doesn't need to explicitly parse the config (it's responsibility of the transformation itself).
Additionally, register `AddCommentTransformation` as an example.
8a44bff to
b69dda8
Compare
Otherwise, the build fails due to missing credentials in `java` module required to install a private Space module. It is so because `java` module used `core` as `implementation` dependency, all `core`'s deps must be resolvable, which isn't the case for `grazie-llm-interaction`. A possible solution is to duplicate private deps setup from `core`'s build.gradle.kts into `java`'s build file. Probably, there's a better one. Right now, merely removing a dependency on `core` in `java` module setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO(@Vladislav0Art):
- [+] go through the implementation one more time.
- [+] fix left TODOs.
There was a problem hiding this 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 introduces the foundational transformation execution infrastructure for the CodeCocoon plugin, enabling the system to apply code transformations to project files. It implements a platform-agnostic transformation executor pattern with an IntelliJ-specific implementation, introduces the first concrete transformation (AddCommentTransformation) as an example, and reorganizes code into a more modular structure.
Key changes include:
- Introduction of
TransformationExecutorabstraction andIntelliJTransformationExecutorimplementation for applying transformations using IntelliJ PSI - Implementation of
AddCommentTransformationas an example transformation that adds comments to Java/Kotlin files - Addition of
HeadlessLoggerwrapper to duplicate log messages to stdout/stderr for better visibility in headless mode - Migration of transformation registration from TransformationRegistry to HeadlessModeStarter to keep the registry side-effect-free
- New utility functions for working with VirtualFiles and PSI files
- Addition of a
:javamodule (currently a placeholder for future Java-specific transformations)
Reviewed changes
Copilot reviewed 18 out of 20 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/services/TransformationService.kt |
Added transformation application pipeline with file filtering and result tracking |
src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/intellij/vfs/VirtualFiles.kt |
New utility functions for finding VirtualFiles by path and FileContext |
src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/intellij/psi/PsiFiles.kt |
New utility functions for retrieving PSI files and documents |
src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/intellij/logging/HeadlessLogger.kt |
New logger wrapper that duplicates messages to stdout/stderr for headless debugging |
src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/intellij/Project.kt |
Package reorganization from components to intellij |
src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/components/transformations/TransformationRegistry.kt |
Removed init block and side effects, simplified to pure registry |
src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/components/transformations/IntelliJAwareTransformation.kt |
New interface for transformations requiring IntelliJ Platform components |
src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/components/transformations/AddCommentTransformation.kt |
Example transformation that adds comments to Java/Kotlin files |
src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/components/executor/IntelliJTransformationExecutor.kt |
IntelliJ-specific executor using PSI and VFS for transformations |
src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/components/VirtualFiles.kt |
Moved to intellij/vfs/VirtualFiles.kt |
src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/appstarter/HeadlessModeStarter.kt |
Added transformation registration and updated logging to use HeadlessLogger |
settings.gradle.kts |
Added :java module |
java/src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/java/JavaTransformation.kt |
Placeholder for future Java-specific transformations |
java/build.gradle.kts |
Build configuration for Java module |
core/src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/transformation/Transformation.kt |
Changed config type from Map<String, Any?> to Map<String, Any> and removed parseConfig() method |
core/src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/transformation/TextBasedTransformation.kt |
New base class for text-based transformations with language filtering |
core/src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/executor/TransformationExecutor.kt |
Platform-agnostic interface for transformation execution |
codecocoon.yml |
Updated configuration to use add-comment-transformation example |
build.gradle.kts |
Added :java module as plugin dependency |
.idea/gradle.xml |
Updated Gradle configuration to include :java module |
Files not reviewed (1)
- .idea/gradle.xml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/appstarter/HeadlessModeStarter.kt
Outdated
Show resolved
Hide resolved
...github/pderakhshanfar/codecocoonplugin/components/executor/IntelliJTransformationExecutor.kt
Show resolved
Hide resolved
...github/pderakhshanfar/codecocoonplugin/components/executor/IntelliJTransformationExecutor.kt
Outdated
Show resolved
Hide resolved
...ithub/pderakhshanfar/codecocoonplugin/components/transformations/AddCommentTransformation.kt
Outdated
Show resolved
Hide resolved
...ithub/pderakhshanfar/codecocoonplugin/components/transformations/AddCommentTransformation.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/services/TransformationService.kt
Show resolved
Hide resolved
src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/services/TransformationService.kt
Outdated
Show resolved
Hide resolved
...ithub/pderakhshanfar/codecocoonplugin/components/transformations/AddCommentTransformation.kt
Outdated
Show resolved
Hide resolved
...ithub/pderakhshanfar/codecocoonplugin/components/transformations/AddCommentTransformation.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/com/github/pderakhshanfar/codecocoonplugin/services/TransformationService.kt
Show resolved
Hide resolved
| @@ -1,5 +1,5 @@ | |||
| # Absolute or project-local path to the root of the project you want to transform | |||
| projectRoot: "/absolute/path/to/your/project" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the sake of avoiding merge conflicts every time we change this, I think we should not commit the path here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we do the following:
- Remove
codecocoon.ymlfrom being tracked by git by replacing it withcodecocoon.example.yml(or similar). - An actual
codecocoon.ymlwill be local to every developer.
Created an issue for this: JBRes-7332
Description
:javamodule (right now, no-op; see description of this commit d762958).Closes: JBRes-6959