Skip to content

Fix java output folder structure#49

Merged
vshcryabets merged 2 commits intomainfrom
fix/java-file-packages
Feb 22, 2026
Merged

Fix java output folder structure#49
vshcryabets merged 2 commits intomainfrom
fix/java-file-packages

Conversation

@vshcryabets
Copy link
Owner

No description provided.

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 pull request fixes the Java output folder structure by introducing a new getFilePath() abstract method to the Writter base class and updating all language-specific implementations. The changes enable proper handling of working directory and package directory separation for Java and Kotlin file generation, while maintaining backward compatibility for C++, Rust, and Swift.

Changes:

  • Added abstract getFilePath() method to Writter base class to standardize file path construction across all language writers
  • Updated Java and Kotlin file generators to use structured FileMetaInformation with separate WorkingDirectory and PackageDirectory child elements
  • Refactored all writer implementations (Java, Kotlin, C++, Rust, Swift) to use the new getFilePath() method instead of inline path construction

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cgen-lib/src/main/kotlin/generators/obj/Writter.kt Adds abstract getFilePath() method and minor initialization refactoring
cgen-lib/src/main/kotlin/generators/java/JavaWritter.kt Implements getFilePath() with proper directory structure handling for Java files
cgen-lib/src/main/kotlin/generators/java/JavaFileGenerator.kt Updates FileMetaInformation and NamespaceDeclaration structure to support new format
cgen-lib/src/main/kotlin/generators/kotlin/KotlinWriter.kt Extracts getFilePath() from writeFile() to follow new pattern
cgen-lib/src/main/kotlin/generators/cpp/CppWritter.kt Implements getFilePath() and alphabetizes imports
cgen-lib/src/main/kotlin/generators/rust/RustWritter.kt Implements simple getFilePath() returning name + ".rs"
cgen-lib/src/main/kotlin/generators/swift/SwiftWritter.kt Implements simple getFilePath() returning name + ".swift"
cgen-lib/src/test/java/generators/java/JavaFileGeneratorTest.kt Adds new test verifying correct FileMetaInformation structure creation
cgen-lib/src/test/java/ce/writers/JavaWritterTest.kt Adds tests for getFilePath() method with valid and invalid inputs

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

val workingDirectory = fileMetaInformation.findOrNull(WorkingDirectory::class.java)?.name ?:
throw IllegalStateException("No working directory found in fileData ${fileData.name}")
val packageDirectory = fileMetaInformation.findOrNull(PackageDirectory::class.java)?.name ?:
throw IllegalStateException("No working directory found in fileData ${fileData.name}")
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

The error message is inconsistent. When the PackageDirectory is missing, the error message says "No working directory found" instead of "No package directory found". This will make debugging more difficult for users.

Suggested change
throw IllegalStateException("No working directory found in fileData ${fileData.name}")
throw IllegalStateException("No package directory found in fileData ${fileData.name}")

Copilot uses AI. Check for mistakes.
val packageDirectory = fileMetaInformation.findOrNull(PackageDirectory::class.java)?.name ?:
throw IllegalStateException("No working directory found in fileData ${fileData.name}")
val outputFile = File(workingDirectory + File.separator +
throw IllegalStateException("No working directory found in fileData ${fileData.name}")
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

The error message is inconsistent. When the PackageDirectory is missing, the error message says "No working directory found" instead of "No package directory found". This will make debugging more difficult for users.

Suggested change
throw IllegalStateException("No working directory found in fileData ${fileData.name}")
throw IllegalStateException("No package directory found in fileData ${fileData.name}")

Copilot uses AI. Check for mistakes.
@vshcryabets vshcryabets merged commit fefde40 into main Feb 22, 2026
2 checks passed
@vshcryabets vshcryabets deleted the fix/java-file-packages branch February 22, 2026 18:08
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.

2 participants