-
Notifications
You must be signed in to change notification settings - Fork 156
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
Add param completion command #30
Conversation
Some intergration tests currently fail, will investigate.
@@ -366,7 +370,7 @@ module internal Main = | |||
new RangeConverter() :> JsonConverter | |||
|] | |||
|
|||
let prAsJson o = printAgent.WriteLine (JsonConvert.SerializeObject(o, jsonConverters)) | |||
let prAsJson o = printAgent.WriteLine (JsonConvert.SerializeObject(o, Formatting.Indented, jsonConverters)) |
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 prints indented, instead of trying to indent later in integration tests. Hope this is ok?
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'm afraid not really. The JSON parsers that interpret what is printed by FSAC assume that each message is exactly one line.
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've reverted this.
@@ -607,6 +611,21 @@ module internal Main = | |||
|
|||
main state | |||
|
|||
|
|||
| Methods -> | |||
let meth = tyRes.GetMethods(line, col, lineStr) |
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 think at this point we should first scan back using this code. An editor should be able to give the current cursor position with some parameters already filled in.
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 wonder on this point, though, with multiple parameters how we could communicate to the editor which parameter we are on.
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.
Maybe something to consider when deciding on a json format. Which parameter of which overload.
I think the test should have some overloads and multiple parameters. Perhaps something like:
And maybe using something from the standard library like |
I agree, I don't think the structure with tuples and ADTs has serialized well at all. We should see how it looks in a more complicated case and come up with a record and list structure that can be consumed cleanly. |
Please do send a PR if you'd like to help out! |
I'd appreciate a test that fails because the startOffset code is not there. |
Test with overloaded methods and request in call
@rneatherway I've incorporated the startPos code from fsharpbinding, and the tests pass. |
Thanks, I will have a think about it tomorrow. I definitely think we should define a simple type hierarchy to return the results in. |
Given {
"Kind": "method",
"Data": {
"Item1": "NewObjectType",
"Item2": [
{
"Description": {
"Case": "FSharpToolTipText",
"Fields": [
[
{
"Case": "Group",
"Fields": [
[
{
"Item1": "new : unit -> FileTwo.NewObjectType",
"Item2": {
"Case": "None"
}
}
]
]
}
]
]
},
"TypeText": ": FileTwo.NewObjectType",
"Parameters": [],
"IsStaticArguments": false
}
]
}
} type OverloadParameter =
{
ParameterName : string
Name : string
CanonicalTypeTextForSorting : string
Display : string
Description : string
}
type Overload =
{
Tip : string
TypeText : string
Parameters : OverloadParameter list
IsStaticArguments : bool
}
type MethodResponse =
{
Name : string
Overloads : Overload list
} There are some assumptions here: Description always returns |
There may be more to do, but now it looks pretty usable.
@rneatherway There's a deliberate serialization in place. It may need improvements, but it looks pretty ok to me. I didn't add XmlDoc resolution, I consider that a separate issue. There are now two places where that should be done. |
If your assumption is just on the tooltip text, then it seems reasonable to assume that passing it to |
p.parse "Program.fs" | ||
Threading.Thread.Sleep(6000) | ||
p.methods "Program.fs" 4 36 | ||
p.methods "Program.fs" 4 37 |
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 one is failing, but I think it shouldn't. Using 1-indexed columns this is a request at $
in let testval = FileTwo.NewObjectType($)
, so I think we should return results here. The previous one is actually on the open bracket, which it would be nice if it succeeded, but I think slightly less important than this one.
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.
Indeed, I'd go so far as to say the first one shouldn't succeed. :)
Looking good, but I'd like to sort out this off-by-1 issue. They can be really annoying to debug at the level of the editor. The other thing is, I wonder if we could add a field to |
Great feedback, thanks. I'll try and make some time to address your concerns. We should definitely bail at some arbitrary cutoff, 3 lines or so. :) |
I've addressed all concerns except this one:
Do you have a suggestion for how this might look? |
Great, thanks! I will have time to review and merge this tomorrow. At a quick glance it all looks good to me. Regarding the richer tooltip output, I don't think that is important for this change. I was just thinking of offering the option for this and the normal tooltips of returning structured data rather than a preformatted string. |
If you find any bugs with the source from the F# addin please PR back upstream, there are quite a few edge cases that probably are not covered. |
Add param completion command
This is a starting point for #29.
I'm not sure I'm happy with the serialized format, see added
output.json
.