Skip to content
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

Merged
merged 12 commits into from
Jun 28, 2015
Merged

Add param completion command #30

merged 12 commits into from
Jun 28, 2015

Conversation

rojepp
Copy link
Contributor

@rojepp rojepp commented Jun 22, 2015

This is a starting point for #29.

I'm not sure I'm happy with the serialized format, see added output.json.

@@ -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))
Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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)
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@rneatherway
Copy link
Contributor

I think the test should have some overloads and multiple parameters. Perhaps something like:

type NewObjectType() =

  member x.Terrific (y : int) (z : char) : int =  y
  member x.Terrific (y : int) (z : System.DateTime) : int =  y
  member x.Terrific (y : Set<'a>) (z : int) : Set<'a> =  y

And maybe using something from the standard library like System.DateTime.Parse. I could send a PR to this PR if that'll help?

@rneatherway
Copy link
Contributor

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.

@rojepp
Copy link
Contributor Author

rojepp commented Jun 23, 2015

Please do send a PR if you'd like to help out!

@rojepp
Copy link
Contributor Author

rojepp commented Jun 23, 2015

I'd appreciate a test that fails because the startOffset code is not there.

@rojepp
Copy link
Contributor Author

rojepp commented Jun 25, 2015

@rneatherway I've incorporated the startPos code from fsharpbinding, and the tests pass.
What are your thoughts on the output format?

@rneatherway
Copy link
Contributor

Thanks, I will have a think about it tomorrow. I definitely think we should define a simple type hierarchy to return the results in.

@rojepp
Copy link
Contributor Author

rojepp commented Jun 25, 2015

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 FSharpToolTipText DU case, Fields always returns DU case Group. I have no idea if these assumptions hold. :) This is as flat as I could get it without losing any information. I don't presume to know exact uses of this, so I'd rather not leave anything out.

There may be more to do, but now it looks pretty usable.
@rojepp
Copy link
Contributor Author

rojepp commented Jun 25, 2015

@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.

@rneatherway
Copy link
Contributor

If your assumption is just on the tooltip text, then it seems reasonable to assume that passing it to TipFormatter.formatTip should account for the different cases there. It's interesting, I suppose if we do want to allow editors to produce a richer tooltip output then we will want to stop called that function and return the fully structured information somehow.

p.parse "Program.fs"
Threading.Thread.Sleep(6000)
p.methods "Program.fs" 4 36
p.methods "Program.fs" 4 37
Copy link
Contributor

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.

Copy link
Contributor Author

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. :)

@rneatherway
Copy link
Contributor

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 MethodResponse called Parameter: int, which indicates what parameter we are on. This would be helpful for an editor and would require extending the scanning-back loop to track the number of commas seen at the current depth.

@rojepp
Copy link
Contributor Author

rojepp commented Jun 26, 2015

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. :)

@rojepp
Copy link
Contributor Author

rojepp commented Jun 27, 2015

I've addressed all concerns except this one:

I suppose if we do want to allow editors to produce a richer tooltip output then we will want to stop called that function and return the fully structured information somehow.

Do you have a suggestion for how this might look?

@rneatherway
Copy link
Contributor

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.

@7sharp9
Copy link
Contributor

7sharp9 commented Jun 27, 2015

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.

rneatherway added a commit that referenced this pull request Jun 28, 2015
Add param completion command
@rneatherway rneatherway merged commit bfd4c7d into ionide:master Jun 28, 2015
@rojepp rojepp deleted the methods branch June 28, 2015 21:34
rneatherway pushed a commit that referenced this pull request Dec 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants