New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove PsiFile.absolutePath #7254
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7254 +/- ##
============================================
- Coverage 84.74% 84.74% -0.01%
Complexity 3996 3996
============================================
Files 577 577
Lines 12126 12124 -2
Branches 2483 2482 -1
============================================
- Hits 10276 10274 -2
Misses 624 624
Partials 1226 1226 ☔ View full report in Codecov by Sentry. |
@@ -26,6 +27,9 @@ fun PsiFile.fileNameWithoutSuffix(multiplatformTargetSuffixes: List<String> = em | |||
|
|||
fun PsiFile.absolutePath(): Path = Path(virtualFile.path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could even remove this one, right? I guess that there should be really few usages of this one. And, even if they are, it should be safe to cast them to KtFile
. To keep the api as small as possible. This way we don't even need the comment :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My idea for keeping it is that 3rd party rule authors will have an easier time finding the right function to call - requiring a cast makes them less discoverable, particularly when using something like KtElement/PsiElement.containingFile which returns PsiFile.
One improvement would be to change this line to
fun PsiFile.absolutePath(): Path = (this as KtFile).absolutePath()
So that way it always queries the cached path. That would provide some additional value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with make it easier to find. Then maybe we can always cast it and just remove the new extension function. This is not really important, anyway.
KtFile.virtualFilePath is cached so should be a tiny bit more performant when called repeatedly for the same file.
This is now fully handled by the IntelliJ components in the embeddable compiler.