-
-
Notifications
You must be signed in to change notification settings - Fork 389
semantic tokens: add infix operator #4030
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
fb5317b
add infix operator
soulomoon 6908653
add test
soulomoon 39b8d8a
mark all infix operator to have operator semantic type
soulomoon 4b0108c
Merge branch 'master' into add-infix-semantic
soulomoon 30ced05
Merge branch 'master' into add-infix-semantic
soulomoon fc63b58
Merge branch 'master' into add-infix-semantic
soulomoon 213896a
update scheme
soulomoon c174dc2
Merge branch 'master' into add-infix-semantic
soulomoon 155d6cd
fix test
soulomoon 5dfdbb4
fix more test
soulomoon 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
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
6 changes: 3 additions & 3 deletions
6
plugins/hls-semantic-tokens-plugin/test/testdata/TInstanceClassMethodBind.expected
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
4:6-9 TTypeConstructor "Foo" | ||
4:12-15 TDataConstructor "Foo" | ||
4:16-19 TTypeConstructor "Int" | ||
5:10-12 TClass "Eq" | ||
5:13-16 TTypeConstructor "Foo" | ||
6:6-8 TClassMethod "==" | ||
5:10-14 TClass "Show" | ||
5:15-18 TTypeConstructor "Foo" | ||
6:5-9 TClassMethod "show" | ||
6:12-21 TVariable "undefined" |
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
2 changes: 1 addition & 1 deletion
2
plugins/hls-semantic-tokens-plugin/test/testdata/TInstanceClassMethodUse.expected
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
4:1-3 TFunction "go" | ||
4:10-12 TClassMethod "==" | ||
4:8-12 TClassMethod "show" |
2 changes: 1 addition & 1 deletion
2
plugins/hls-semantic-tokens-plugin/test/testdata/TInstanceClassMethodUse.hs
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module TInstanceClassMethodUse where | ||
|
||
|
||
go = (==) | ||
go = show | ||
|
33 changes: 33 additions & 0 deletions
33
plugins/hls-semantic-tokens-plugin/test/testdata/TOperator.expected
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,33 @@ | ||
4:1-3 TFunction "go" | ||
4:4-5 TFunction "f" | ||
4:6-7 TVariable "x" | ||
4:10-11 TFunction "f" | ||
4:12-13 TOperator "$" | ||
4:14-15 TVariable "x" | ||
6:2-6 TOperator "$$$$" | ||
7:1-2 TVariable "x" | ||
7:7-11 TOperator "$$$$" | ||
8:6-7 TTypeVariable "a" | ||
8:8-11 TOperator ":+:" | ||
8:12-13 TTypeVariable "b" | ||
8:16-19 TDataConstructor "Add" | ||
8:20-21 TTypeVariable "a" | ||
8:22-23 TTypeVariable "b" | ||
9:7-10 TOperator ":-:" | ||
9:12-13 TTypeVariable "a" | ||
9:14-15 TTypeVariable "b" | ||
9:19-20 TTypeVariable "a" | ||
9:22-23 TTypeVariable "b" | ||
11:1-4 TFunction "add" | ||
11:8-11 TTypeConstructor "Int" | ||
11:12-15 TOperator ":+:" | ||
11:16-19 TTypeConstructor "Int" | ||
11:23-26 TTypeConstructor "Int" | ||
11:27-30 TOperator ":-:" | ||
11:31-34 TTypeConstructor "Int" | ||
13:1-4 TFunction "add" | ||
13:6-9 TDataConstructor "Add" | ||
13:10-11 TVariable "x" | ||
13:12-13 TVariable "y" | ||
13:18-19 TVariable "x" | ||
13:21-22 TVariable "y" |
13 changes: 13 additions & 0 deletions
13
plugins/hls-semantic-tokens-plugin/test/testdata/TOperator.hs
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,13 @@ | ||
module TOperator where | ||
|
||
-- imported operator | ||
go f x = f $ x | ||
-- operator defined in local module | ||
($$$$) = b | ||
x = 1 $$$$ 2 | ||
data a :+: b = Add a b | ||
type (:-:) a b = (a, b) | ||
-- type take precedence over operator | ||
add :: Int :+: Int -> Int :-: Int | ||
-- class method take precedence over operator | ||
add (Add x y) = (x, y) |
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
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
Oops, something went wrong.
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.
I actually think people might prefer to see type operators highlighted differently? In "normal" Haskell syntax highlighting they are!
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've been thinking about this, may be it's better for us to mark all the infix thing as operator.
Since infix does change the semantic of normal function application ordering, visually showing this would be more preferable.
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 feel reasonably sure that we want "operator" to take precedence over "type". I'm still unsure about "operator" vs "class method"
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.
me neither, maybe we can make a pool or something to collect people's opinion on this.
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.
To be clear, I think it's fine for you to just make a decision for now, we can adjust based on feedback or add configuration.
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.
Yep, lets stick to the simplest way for now. Make the infix on top of all.
We can sort things out in configuration PR that switching to the
[HsSemanticTokenType]
.