-
Notifications
You must be signed in to change notification settings - Fork 32
Conversation
src/scry/hover_provider.cr
Outdated
context.each do |key, value| | ||
contents << "| #{key} | #{value} |" | ||
escaped_value = "`#{value.gsub("|", "∣")}`" |
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.
is that a special unicode pipe? if yes, can you add a comment saying that (and maybe the unicode code (in hexa) too)
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.
Done!
src/scry/hover_provider.cr
Outdated
end | ||
|
||
private def vertical_align(contexts) | ||
contents = [] of String |
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.
Use an IO::Memory
instead?
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.
Done!
src/scry/hover_provider.cr
Outdated
private def vertical_align(contexts) | ||
contents = [] of String | ||
contexts.each_with_index do |context, i| | ||
contents << "**Context #{i + 1}**\n" |
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.
If there is only one context we should hide the Context 1/2/...
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.
Done!
src/scry/hover_provider.cr
Outdated
titles_lines = ["| :--- |"] of String | ||
contents_hash = {} of String => Array(String) | ||
contexts.each_with_index do |context, i| | ||
titles << " Type #{i + 1} |" |
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.
ditto
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.
Done!
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.
more comments ;)
src/scry/hover_provider.cr
Outdated
contexts.each_with_index do |context, i| | ||
contents << "**Context #{i + 1}**\n" if contexts.size > 1 | ||
contents << "```crystal\n" | ||
max_size = context.keys.max_by(&.size).size |
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.
can be calculated outside the each_with_index
loop
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.
Done!
src/scry/hover_provider.cr
Outdated
contents << "```crystal\n" | ||
max_size = context.keys.max_by(&.size).size | ||
context.each do |key, value| | ||
key_aligned = "#{key}".ljust(max_size) |
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.
key
is already a String, no?
So: key.ljust(max_size)
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.
Done!
src/scry/hover_provider.cr
Outdated
contents << "**Context #{i + 1}**\n" if contexts.size > 1 | ||
contents << "```crystal\n" | ||
max_size = context.keys.max_by(&.size).size | ||
context.each do |key, value| |
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.
key
=> var_name
value
=> var_type
(or juste type
?)
wdyt?
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.
Done!
src/scry/hover_provider.cr
Outdated
# | arg1 | `String` | `String` | | ||
# | arg2 | `Int32 ∣ Nil` | `Bool` | | ||
private def horizontal_align(contexts) | ||
contents = [] of String |
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.
You could build this one with an IO::Memory
too, by generating the output line by line (first the header, then the lines, then the types)
I think it would lead to cleaner/readable code
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.
Done!
#95 is already merged 🎉 , waiting for more reviews... |
src/scry/protocol/hover.cr
Outdated
JSON.mapping({ | ||
contents: MarkupContent, | ||
range: Range?, | ||
}, true) |
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.
Use named arg static: true
here, 'cause by just reading true
I have no idea what it refers to for a json mapping, I think it's better with the named arg
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.
Also, why only this mapping have this static check?
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.
Done!
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.
static: true
is not needed here anymore, I'm already fixing that on lsp shard
Lets remove it for now 👍
@faustinoaq More of an overall comment, I noticed a lot of the code between |
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.
Looks good to me, and if specs passing im 👍
Fixes #103 🎉
Depends on #95Merged! 🎉This uses
crystal tool context
to get context information