Skip to content
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

Merged
merged 3 commits into from May 7, 2024
Merged

Remove PsiFile.absolutePath #7254

merged 3 commits into from May 7, 2024

Conversation

3flex
Copy link
Member

@3flex 3flex commented May 3, 2024

This is now fully handled by the IntelliJ components in the embeddable compiler.

Copy link

codecov bot commented May 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.74%. Comparing base (0951519) to head (292a526).

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.
📢 Have feedback on the report? Share it here.

@@ -26,6 +27,9 @@ fun PsiFile.fileNameWithoutSuffix(multiplatformTargetSuffixes: List<String> = em

fun PsiFile.absolutePath(): Path = Path(virtualFile.path)
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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.
@3flex 3flex merged commit 5b83dc3 into detekt:main May 7, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants