-
Notifications
You must be signed in to change notification settings - Fork 346
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
improvement:don't show types for match case for showInferredType #5284
Conversation
@@ -488,7 +488,8 @@ final class SyntheticsDecorationProvider( | |||
case param: m.Term.Param => | |||
if (param.decltpe.isEmpty) List(param.name.pos.toSemanticdb) else Nil | |||
case cs: m.Case => | |||
explorePatterns(List(cs.pat)) ++ visit(cs.body) | |||
// if the case is too long then it'll be too messy | |||
visit(cs.body) // explorePatterns(List(cs.pat)) ++ visit(cs.body) |
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 don't agree about removing this, since it might be useful to know the type in case.
We might be over eager in case of inferred type for methods, we could for sure separate it under another flag (or rethink the settings here to be more useful).
Any other opininos?
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.
It could also be nice to provide more options like showInferredType = minimal| full | etc...
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.
+1 for more granularity
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.
Totally forgot about your PR, sorry about that! I think that's a smart idea with switching the setting. This might require some tinkering on Vs Code sie, but can be done later on without na issue.
I would however add a test case for this option in SyntheticDecorationsLspSuite, just repeat the 54-89 lines with the setting switched.
metals/src/main/scala/scala/meta/internal/decorations/SyntheticsDecorationProvider.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/decorations/SyntheticsDecorationProvider.scala
Show resolved
Hide resolved
…csDecorationProvider.scala Co-authored-by: Tomasz Godzik <[email protected]>
@tgodzik I just added a test in SyntheticDecorationsLspSuite |
Thanks! We seem to have a lot tests failing in the PR, but it's not clear to me why. I will try and rerun and if that doesn't help I will take a look next week. |
Ok cool, seems that the tests were flaky. I will try and get this merged after the next release. I am stoping merging anything but fixes until the release next week. |
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.
LGTM
One thing we should do is to change the options to enum on the VS Code setting and change the toggle command to go though the options instead of false/true.
previously, showInferredType will show types even for long cases like below:
![image](https://private-user-images.githubusercontent.com/6041353/241582924-836f06a7-9d11-49c6-9043-b7845bec6b21.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxMjYzMzAsIm5iZiI6MTczOTEyNjAzMCwicGF0aCI6Ii82MDQxMzUzLzI0MTU4MjkyNC04MzZmMDZhNy05ZDExLTQ5YzYtOTA0My1iNzg0NWJlYzZiMjEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwOSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDlUMTgzMzUwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MGMxYWVkODgxOTkzMjdmM2VlMzYzZWNmMjZkZDRiODY3NWUyNTFhMjc3OWVhMWY0YzFjZGVlNGQ1ZDM4ZTI4MCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.hRyh-CINRT388Sy_blOc-4hVA0bMUM3QKChmuA3qg84)
if we don't show cases the effect is like below(this PR):
![image](https://private-user-images.githubusercontent.com/6041353/241583271-21cf9e5a-6a02-41e5-864d-5f612478a2cb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxMjYzMzAsIm5iZiI6MTczOTEyNjAzMCwicGF0aCI6Ii82MDQxMzUzLzI0MTU4MzI3MS0yMWNmOWU1YS02YTAyLTQxZTUtODY0ZC01ZjYxMjQ3OGEyY2IucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwOSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDlUMTgzMzUwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9M2M5NjI3YjNiMmVjZjhjODgxZTI0NGJjZDdhZmY0MTI3YzI5NTM5ZTVhODA3ZGNkZDQ5ZWFiMDc3M2FkYTU5MyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.-WfWrNtCwY0_jQQLIWUorZDXVzzC5WDnCYgthDt2Zp4)
In my opinion, showing too much information like everything in match case isn't very helpful, but showing types elsewhere is quite nice. although we can toggle showInferredType, it's a bit tedious to do so and I end up not using this functionality.
feel free to suggest edits (maybe only enable showInferredType when case contains one field?)