ADFA-4692: Fix unknown project language - #1650
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
📝 Walkthrough
WalkthroughThe change adds Java and Kotlin project-language detection, improves Kotlin version parsing, includes language in project details, persists it in recent projects, and displays it in the project information sheet. Other edits reformat existing code. ChangesProject language detection and details
Recent-project language storage
Project information display
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant MainActivity
participant readProjectLanguage
participant RecentProjectDao
participant ProjectInfoBottomSheet
MainActivity->>readProjectLanguage: detect project language
readProjectLanguage-->>MainActivity: return language
MainActivity->>RecentProjectDao: store project language
ProjectInfoBottomSheet->>RecentProjectDao: load recent project
ProjectInfoBottomSheet-->>ProjectInfoBottomSheet: select language fallback
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 7
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/src/main/java/com/itsaky/androidide/ui/ProjectInfoBottomSheet.kt`:
- Around line 85-87: Remove the decorative separator comment blocks from the
relevant sections of ProjectInfoBottomSheet, including the GENERAL section and
the sections at the other referenced locations. Keep the surrounding method
implementations unchanged, as their names already provide sufficient context.
- Around line 138-146: Update the language filtering in the languageToDisplay
selection to reject both the localized unknown string and the canonical
"Unknown" sentinel for pLang and details.language. Preserve the existing
fallback order, allowing the localized unknown value to be used only as the
final fallback so it is displayed correctly for the current locale.
In `@app/src/main/java/com/itsaky/androidide/viewmodel/MainViewModel.kt`:
- Around line 117-130: Update saveProjectToRecents in
app/src/main/java/com/itsaky/androidide/viewmodel/MainViewModel.kt:117-130 to
rethrow CancellationException and catch only expected
DAO/filesystem/security/web-server failures. Apply the same
cancellation-preserving, narrowly typed handling to the coroutine site in
app/src/main/java/com/itsaky/androidide/viewmodel/RecentProjectsViewModel.kt:272-320
and app/src/main/java/com/itsaky/androidide/activities/MainActivity.kt:458-477.
In vacuumDatabase, ensure runCatching failures are logged and propagated through
the required database error state instead of discarded.
In `@common/src/main/java/com/itsaky/androidide/utils/GetProjectBuildVersions.kt`:
- Around line 109-130: Add KDoc to the public `readProjectLanguage` function
documenting that it checks `app/src/main` and `src/main`, gives Kotlin files
precedence over Java, and returns `"Unknown"` when no supported language is
detected or neither source root exists.
In
`@common/src/test/java/com/itsaky/androidide/utils/GetProjectBuildVersionsTest.kt`:
- Around line 15-48: Extend the readProjectLanguage tests with one case
containing a .kts source file and assert Kotlin, plus another case with an empty
or unsupported source tree and assert Unknown. Keep the existing Java and .kt
coverage unchanged and use the same temporary-project setup and assertions.
- Around line 3-12: Configure the common test setup with the JUnit Jupiter
dependency and useJUnitPlatform(). In GetProjectBuildVersionsTest, replace the
JUnit 4 Test and Rule/TemporaryFolder APIs with org.junit.jupiter.api.Test and
`@TempDir`, updating temporary-directory usage to match Jupiter.
In `@templates-api/src/main/java/com/itsaky/androidide/templates/template.kt`:
- Around line 235-237: Run ktlint and Spotless on the complete changed
template.kt file, not only the displayed lines. Ensure the Template constructor
parameters use tab indentation and the requireNotNull call near its definition
is formatted according to project style, then apply the resulting file-wide
formatting required by the Spotless ratchet.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6dba55e8-dd66-44bf-90ff-5b113d7aaacc
📒 Files selected for processing (10)
app/src/main/java/com/itsaky/androidide/activities/MainActivity.ktapp/src/main/java/com/itsaky/androidide/roomData/recentproject/RecentProjectDao.ktapp/src/main/java/com/itsaky/androidide/ui/ProjectInfoBottomSheet.ktapp/src/main/java/com/itsaky/androidide/viewmodel/MainViewModel.ktapp/src/main/java/com/itsaky/androidide/viewmodel/RecentProjectsViewModel.ktcommon/src/main/java/com/itsaky/androidide/templates/Language.ktcommon/src/main/java/com/itsaky/androidide/utils/GetProjectBuildVersions.ktcommon/src/main/java/com/itsaky/androidide/utils/GetProjectDetails.ktcommon/src/test/java/com/itsaky/androidide/utils/GetProjectBuildVersionsTest.kttemplates-api/src/main/java/com/itsaky/androidide/templates/template.kt
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@common/src/test/java/com/itsaky/androidide/utils/GetProjectBuildVersionsTest.kt`:
- Around line 89-98: Add a separate test for readProjectLanguage that creates an
otherwise empty project without app/src/main or src/main, then assert it returns
"Unknown". Keep the existing empty-source-tree test unchanged and target the
early missing-source-directory branch directly.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 97011d14-7c4b-43a0-9dc5-f3b903b072c1
📒 Files selected for processing (6)
app/src/main/java/com/itsaky/androidide/ui/ProjectInfoBottomSheet.ktapp/src/main/java/com/itsaky/androidide/viewmodel/MainViewModel.ktapp/src/main/java/com/itsaky/androidide/viewmodel/RecentProjectsViewModel.ktcommon/src/main/java/com/itsaky/androidide/templates/Language.ktcommon/src/main/java/com/itsaky/androidide/utils/GetProjectBuildVersions.ktcommon/src/test/java/com/itsaky/androidide/utils/GetProjectBuildVersionsTest.kt
🚧 Files skipped from review as they are similar to previous changes (4)
- common/src/main/java/com/itsaky/androidide/utils/GetProjectBuildVersions.kt
- app/src/main/java/com/itsaky/androidide/viewmodel/RecentProjectsViewModel.kt
- app/src/main/java/com/itsaky/androidide/ui/ProjectInfoBottomSheet.kt
- app/src/main/java/com/itsaky/androidide/viewmodel/MainViewModel.kt
The project
languagefield, one of the recent project details being persisted was previously being saved in the Room database. As a result, the detail is lost when the app data is cleared or when the app is re-installed.The project language is now dynamically detected from Filesystem.