-
-
Notifications
You must be signed in to change notification settings - Fork 830
Add hover info for custom types #4458
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
Open
unknown
wants to merge
5
commits into
gleam-lang:main
Choose a base branch
from
ossd-s25:ls-custom-type-hover
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bee9fd6
Display hover info for custom types
unknown ced70b6
Add tests for custom type hover info
unknown 1b4a077
Fix hover info for record arguments without labels
unknown 90a2c45
Fix hover info for labels in record constructors
unknown 0c6acae
Fix contents to match function expression
unknown File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
..._server/tests/snapshots/gleam_core__language_server__tests__hover__hover_custom_type.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
source: compiler-core/src/language_server/tests/hover.rs | ||
expression: "\n/// Exciting documentation\n/// Maybe even multiple lines\ntype Wibble {\n /// Some more exciting documentation\n Wibble(String)\n /// The most exciting documentation\n Wobble(arg: Int)\n}\n" | ||
--- | ||
/// Exciting documentation | ||
/// Maybe even multiple lines | ||
type Wibble { | ||
▔▔▔▔▔↑▔▔▔▔▔▔▔ | ||
/// Some more exciting documentation | ||
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ | ||
Wibble(String) | ||
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ | ||
/// The most exciting documentation | ||
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ | ||
Wobble(arg: Int) | ||
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ | ||
} | ||
▔ | ||
|
||
|
||
----- Hover content ----- | ||
Scalar( | ||
String( | ||
"```gleam\nWibble\n```\n Exciting documentation\n Maybe even multiple lines", | ||
), | ||
) |
21 changes: 21 additions & 0 deletions
21
...shots/gleam_core__language_server__tests__hover__hover_for_label_in_type_constructor.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
source: compiler-core/src/language_server/tests/hover.rs | ||
expression: "\n/// Exciting documentation\n/// Maybe even multiple lines\ntype Wibble {\n /// Some more exciting documentation\n Wibble(arg: String)\n /// The most exciting documentation\n Wobble(Int)\n}\n" | ||
--- | ||
/// Exciting documentation | ||
/// Maybe even multiple lines | ||
type Wibble { | ||
/// Some more exciting documentation | ||
Wibble(arg: String) | ||
↑▔▔▔▔▔▔▔▔▔▔ | ||
/// The most exciting documentation | ||
Wobble(Int) | ||
} | ||
|
||
|
||
----- Hover content ----- | ||
Scalar( | ||
String( | ||
"```gleam\nString\n```", | ||
), | ||
) |
21 changes: 21 additions & 0 deletions
21
...er/tests/snapshots/gleam_core__language_server__tests__hover__hover_type_constructor.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
source: compiler-core/src/language_server/tests/hover.rs | ||
expression: "\n/// Exciting documentation\n/// Maybe even multiple lines\ntype Wibble {\n /// Some more exciting documentation\n Wibble(arg: String)\n /// The most exciting documentation\n Wobble(Int)\n}\n" | ||
--- | ||
/// Exciting documentation | ||
/// Maybe even multiple lines | ||
type Wibble { | ||
/// Some more exciting documentation | ||
Wibble(arg: String) | ||
↑▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ | ||
/// The most exciting documentation | ||
Wobble(Int) | ||
} | ||
|
||
|
||
----- Hover content ----- | ||
Scalar( | ||
String( | ||
"```gleam\nWibble(arg: String)\n```\n Some more exciting documentation", | ||
), | ||
) |
21 changes: 21 additions & 0 deletions
21
...apshots/gleam_core__language_server__tests__hover__hover_type_constructor_with_label.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
source: compiler-core/src/language_server/tests/hover.rs | ||
expression: "\n/// Exciting documentation\n/// Maybe even multiple lines\ntype Wibble {\n /// Some more exciting documentation\n Wibble(arg: String)\n /// The most exciting documentation\n Wobble(Int)\n}\n" | ||
--- | ||
/// Exciting documentation | ||
/// Maybe even multiple lines | ||
type Wibble { | ||
/// Some more exciting documentation | ||
Wibble(arg: String) | ||
/// The most exciting documentation | ||
Wobble(Int) | ||
↑▔▔▔▔▔▔▔▔▔▔ | ||
} | ||
|
||
|
||
----- Hover content ----- | ||
Scalar( | ||
String( | ||
"```gleam\nWobble(Int)\n```\n The most exciting documentation", | ||
), | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is different from the format we use for variants!
Can we reuse the existing code to ensure they are the same?
Uh oh!
There was an error while loading. Please reload this page.
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.
Yeah I made a note of that here: #4451 (comment)
It's been a while since I worked on this, but if I remember correctly, the reason it differs is because
RecordConstructor
doesn't store any information about the custom type its a member of (aka the return type of the constructor). Should I add a string inRecordConstructor
with the name of the custom type?Not sure if there are other approaches, but adding a string wouldn't allow for code reuse. The return type would have to be a
Type
.