-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Named Arguments #625
Merged
+228
−23
Merged
Named Arguments #625
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
8ac5b1d
Initial commit for semantic tokenizer.
gdotdesign 60f1bb5
Simplify semantic tokenizer a bit.
gdotdesign 0e865c6
Working language server implementation.
gdotdesign 1c14a5a
Cleanup semantic tokenizer class.
gdotdesign ca01ad6
Save keywords automatically instead of manually.
gdotdesign 6926d57
Use an array derived from the actual token types.
gdotdesign 29fb79b
Implement suggestions from code review.
gdotdesign 6b25fc8
Update src/ls/semantic_tokens.cr
gdotdesign 0eea575
Implement HTML highlighting.
gdotdesign 1cd96da
Implement highlight directive.
gdotdesign 529117d
Avoid unnecessary interations.
gdotdesign 79c3f11
Implement suggestions from code review.
gdotdesign 6faec26
Use the ast from the workspace semantic tokens.
gdotdesign 37db9b6
Implementation of localization language structures.
gdotdesign 6e51ae0
Update operation.cr
gdotdesign 673b361
Merge branch 'master' into locales
gdotdesign 92833ca
Update test.
gdotdesign 5e9eef7
Merge branch 'master' into locales
gdotdesign 44ab595
Revert change to the operation formatting.
gdotdesign a8ecd78
Update Locale.md
gdotdesign cb99c78
Implement labelled calls.
gdotdesign dd254f8
Don't reorder arguments in the formatter.
gdotdesign 630c080
Minor fixes.
gdotdesign d28c7a3
Merge branch 'master' into locales
gdotdesign 095ab66
Merge branch 'locales' into labelled-calls
gdotdesign d171155
Merge branch 'master' into locales
gdotdesign 88bd4cc
Merge branch 'locales' into labelled-calls
gdotdesign 36c9d98
Apply suggestions from code review
gdotdesign a2a0c04
Update src/compilers/call.cr
gdotdesign 687550d
Finish renaming an error from code review.
gdotdesign 99a1bac
Merge branch 'master' into labelled-calls
gdotdesign 99acd9f
Merge branch 'master' into labelled-calls
gdotdesign 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 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 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 @@ | ||
component Main { | ||
fun test (argument1 : String, argument2: Number) : Html { | ||
<div/> | ||
} | ||
|
||
fun render : Html { | ||
test(argument2: 0, argument1: "") | ||
} | ||
} | ||
-------------------------------------------------------------------------------- | ||
class A extends _C { | ||
a(b, c) { | ||
return _h("div", {}); | ||
} | ||
|
||
render() { | ||
return this.a(``, 0); | ||
} | ||
}; | ||
|
||
A.displayName = "Main"; |
This file contains 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,39 @@ | ||
component Main { | ||
fun test (argument1 : String, argument2: Number) : Html { | ||
<div/> | ||
} | ||
|
||
fun render : Html { | ||
test(argument2: 0, argument1: "") | ||
} | ||
} | ||
---------------------------------------------------------CallWithMixedArguments | ||
component Main { | ||
fun test (argument1 : String, argument2: Number) : Html { | ||
<div/> | ||
} | ||
|
||
fun render : Html { | ||
test(0, argument1: "") | ||
} | ||
} | ||
---------------------------------------------------------CallWithMixedArguments | ||
component Main { | ||
fun test (argument1 : String, argument2: Number) : Html { | ||
<div/> | ||
} | ||
|
||
fun render : Html { | ||
test(argument2: 0, "") | ||
} | ||
} | ||
-----------------------------------------------------------CallNotFoundArgument | ||
component Main { | ||
fun test (argument1 : String, argument2: Number) : Html { | ||
<div/> | ||
} | ||
|
||
fun render : Html { | ||
test(argument3: 0, argument1: "") | ||
} | ||
} |
This file contains 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 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,14 @@ | ||
module Mint | ||
class Ast | ||
class CallExpression < Node | ||
getter name, expression | ||
|
||
def initialize(@expression : Expression, | ||
@name : Variable?, | ||
@input : Data, | ||
@from : Int32, | ||
@to : Int32) | ||
end | ||
end | ||
end | ||
end |
This file contains 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 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 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 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 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,7 @@ | ||
module Mint | ||
class Compiler | ||
def _compile(node : Ast::CallExpression) | ||
compile node.expression | ||
end | ||
end | ||
end |
This file contains 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,14 @@ | ||
module Mint | ||
class Formatter | ||
def format(node : Ast::CallExpression) | ||
expression = | ||
format node.expression | ||
|
||
if name = node.name | ||
"#{name.value}: #{expression}" | ||
else | ||
expression | ||
end | ||
end | ||
end | ||
end |
This file contains 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 @@ | ||
message CallNotFoundArgument do | ||
title "Type Error" | ||
|
||
block do | ||
text "I was looking for the argument:" | ||
bold name | ||
text "but it's not there." | ||
end | ||
|
||
type_with_text function_type, "The type of the function is:" | ||
|
||
snippet node, "The call is here:" | ||
end |
This file contains 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,9 @@ | ||
message CallWithMixedArguments do | ||
title "Type Error" | ||
|
||
block do | ||
text "A call cannot have named and unamed arguments at the same time." | ||
end | ||
|
||
snippet node, "It is here:" | ||
end |
This file contains 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 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,27 @@ | ||
module Mint | ||
class Parser | ||
def call_expression : Ast::CallExpression? | ||
start do |start_position| | ||
name = | ||
start do | ||
next unless key = variable | ||
whitespace | ||
|
||
next unless char! ':' | ||
whitespace | ||
|
||
key | ||
end | ||
|
||
return unless expression = self.expression | ||
|
||
Ast::CallExpression.new( | ||
expression: expression, | ||
from: start_position, | ||
to: position, | ||
input: data, | ||
name: name) | ||
end | ||
end | ||
end | ||
end |
This file contains 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 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 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 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 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 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 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'd refactor this into
Record#to_pretty(named_arguments: true)
.