Conversation
There was a problem hiding this comment.
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 toWritterbase class to standardize file path construction across all language writers - Updated Java and Kotlin file generators to use structured
FileMetaInformationwith separateWorkingDirectoryandPackageDirectorychild 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}") |
There was a problem hiding this comment.
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.
| throw IllegalStateException("No working directory found in fileData ${fileData.name}") | |
| throw IllegalStateException("No package directory found in fileData ${fileData.name}") |
| 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}") |
There was a problem hiding this comment.
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.
| throw IllegalStateException("No working directory found in fileData ${fileData.name}") | |
| throw IllegalStateException("No package directory found in fileData ${fileData.name}") |
No description provided.