fix: guard file type override for virtual files#6
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR improves the robustness of the QiqFileTypeOverrider by adding guard clauses to validate file types before processing and introduces comprehensive unit tests to verify the overrider's behavior.
Key changes:
- Added type and validity checks in
getOverriddenFileTypeto ensure only supported local virtual files are processed - Moved directory check earlier in the method for better performance
- Added comprehensive unit tests covering both supported and unsupported file scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
QiqFileTypeOverrider.kt |
Added guard clauses for file type validation and moved directory check for optimization |
QiqFileTypeOverriderTest.kt |
Added new test class with comprehensive coverage for file type override scenarios |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…peOverriderTest.kt Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…e-issue # Conflicts: # src/main/kotlin/io/github/jingu/idea_qiq_plugin/lang/QiqFileTypeOverrider.kt
This pull request improves the robustness of the
QiqFileTypeOverriderlogic and adds comprehensive unit tests to ensure correct file type overriding behavior. The main changes include stricter checks for file validity and type, and the introduction of tests covering both supported and unsupported file scenarios.File type override logic improvements
QiqFileTypeOverrider.getOverriddenFileTypeto ensure the file is aVirtualFileWithId, is not a directory, is valid, and is in the local file system before attempting to override its file type. This prevents unnecessary processing and potential errors for unsupported file types.VirtualFileWithIdto support the new type check in the overrider logic.Testing enhancements
QiqFileTypeOverriderTestthat verifies the overrider does not overrideLightVirtualFileinstances and correctly overrides local virtual files, including setting marker flags to prevent repeated re-evaluation.