Skip to content

Conversation

@Vladislav0Art
Copy link
Collaborator

@Vladislav0Art Vladislav0Art commented Dec 8, 2025

Description

  1. Add TransformationExecutor.kt‎ that executes the given transformation and file context, and its intellij-based implementation IntelliJTransformationExecutor.kt‎.
  2. Assign built-in transformations in headless starter (not in trasnformations registry) to make the latter side-affect-free.
  3. Add AddCommentTransformation.kt‎ that adds a comment mentioned in its config into the provided file.
  4. Introduce IntelliJAwareTransformation.kt‎ that acts as a bridge between IntelliJ Platform and our transformations.
  5. Introduce HeadlessLogger.kt‎ that logs in both idea.log and stdout/stderr.
  6. Add musc utilitary functions to work with VFS and PSI files.
  7. Now, TransformationService.kt‎ can apply the transformations.
  8. Add a :java module (right now, no-op; see description of this commit d762958).

Closes: JBRes-6959

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

Qodana Community for JVM

6 new problems were found

Inspection name Severity Problems
Unstable API Usage 🔶 Warning 5
Unused symbol 🔶 Warning 1

💡 Qodana analysis was run in the pull request mode: only the changed files were checked

View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/[email protected]
        with:
          upload-result: true
Contact Qodana team

Contact us at [email protected]

@Vladislav0Art Vladislav0Art force-pushed the vartiukhov/feature/add-comment-transformation branch from 8a44bff to b69dda8 Compare December 15, 2025 15:01
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.
@Vladislav0Art Vladislav0Art changed the title Vartiukhov/feature/add comment transformation JBRes-6959: Introduce Add-Comment Transformation Dec 15, 2025
Copy link
Collaborator Author

@Vladislav0Art Vladislav0Art left a comment

Choose a reason for hiding this comment

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

TODO(@Vladislav0Art):

  1. [+] go through the implementation one more time.
  2. [+] fix left TODOs.

@Vladislav0Art Vladislav0Art marked this pull request as ready for review December 15, 2025 16:14
Copy link

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 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 TransformationExecutor abstraction and IntelliJTransformationExecutor implementation for applying transformations using IntelliJ PSI
  • Implementation of AddCommentTransformation as an example transformation that adds comments to Java/Kotlin files
  • Addition of HeadlessLogger wrapper 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 :java module (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.

@@ -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"
Copy link
Collaborator

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 :)

Copy link
Collaborator Author

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:

  1. Remove codecocoon.yml from being tracked by git by replacing it with codecocoon.example.yml (or similar).
  2. An actual codecocoon.yml will be local to every developer.

Created an issue for this: JBRes-7332

@Vladislav0Art Vladislav0Art merged commit dc06183 into main Dec 17, 2025
1 check passed
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.

3 participants