Skip to content

Conversation

@auduchinok
Copy link
Member

@auduchinok auduchinok commented Nov 8, 2017

We don't use Accessibility field in FSharpDeclarationListItem and want to pass other symbol info instead.
I added two optional parameters to GetDeclarationListInfo:

  • getAdditionalInfo: function to replace getAccessibility which takes FSharpSymbol and FSharpDisplayContext and allows passing arbitrary symbol info.
  • shortTypeNames: use short type names in the display context

Copy link
Contributor

@KevinRansom KevinRansom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

Thank you

Kevin

let getAdditionalInfo item =
try getAdditionalInfo(FSharpSymbol.Create(g, thisCcu, tcImports, item), displayContext)
with _ ->
Trace.TraceInformation(sprintf "FCS: could not get additional info for %A" item)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be useful for diagnostics to trace the exception here.

@dsyme
Copy link
Contributor

dsyme commented Nov 8, 2017

@auduchinok The use of generics like this is odd for FCS and I'd like to explore alternatives ways of getting the same result.

e.g. why not just include the FSharpDisplayContext and FSharpSymbol in each returned FSharpDeclarationListItem and let the caller augment the information post-hoc?

@auduchinok
Copy link
Member Author

@dsyme I like this idea. Initially I've tried to make this an in-place replacement for Accessibility field and ended up with this design.

@dsyme
Copy link
Contributor

dsyme commented Nov 8, 2017

@dsyme I like this idea.

:) You mean you like the PR as is, or with the suggestion above? Thx :)

@auduchinok
Copy link
Member Author

The suggestion. :)

@dsyme
Copy link
Contributor

dsyme commented Nov 8, 2017

:) thx

@auduchinok
Copy link
Member Author

auduchinok commented Nov 8, 2017

@dsyme Do you know if there was a particular reason FSharpDeclarationListInfo was written as a class? I'd like to rewrite it as a discriminated union (and keep the Create method there) as there are three situations (Empty, Error and (let's say) Info) that need completely different sets of fields.

@dsyme
Copy link
Contributor

dsyme commented Nov 8, 2017

@dsyme Do you know if there was a particular reason FSharpDeclarationListInfo was written as a class? I'd like to rewrite it as a discriminated union (and keep the Create method there) as there are three situations (Empty, Error and (let's say) Info) that need completely different sets of fields.

I think it just grew up that way. If you feel as a consumer that you would have have avoided an error or need to evolve the three cases separately then yes, please do send the PR

That said I'm not totally sure it's worth churning the API at this point. There will be consumers in various tooling like FSharp.Formatting and Ionide. But send the PR and we can discuss

(In general using unions and records in evolving APIs is not always encouraged. There's a tradeoff here - unions and records are great accurate programming devices since they cause rigidity - and thus force accuracy on consumers as types evolve. In contrast, classes cause less rigidity - since you can just add new properties - but likewise new information can creep in that the consumer ignores. )

@KevinRansom
Copy link
Contributor

@dsyme this looks ready to go to me. Are you satisfied?

@auduchinok
Copy link
Member Author

@KevinRansom I'd like to change it the way we discussed it before it goes in.

Copy link
Contributor

@dsyme dsyme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

marking as changes requested as discussed

@KevinRansom
Copy link
Contributor

@auduchinok, do you think you will be able to get to the requested changes?

Thanks

Kevin

@auduchinok
Copy link
Member Author

@KevinRansom Yes, I was going to work on it next week.

@KevinRansom
Copy link
Contributor

Yay ... a Christmas present then :-)

@auduchinok
Copy link
Member Author

auduchinok commented Dec 20, 2017

That said I'm not totally sure it's worth churning the API at this point. There will be consumers in various tooling like FSharp.Formatting and Ionide. But send the PR and we can discuss

@dsyme I think we can simplify APIs a lot in the way it was stated in this Vasily's comment. Looking at the comment reactions I suppose most extensive API users would be happy with such changes, so may we assume that people will be OK with adopting changed APIs then?
I'd be happy to propose such a PR if it's OK to change these core public APIs. I'd like to simplify signatures and improve the wording a bit (e.g. to change GetDeclarationListInfo to GetCompletionItems or GetF1Keword to GetHelpKeyword).
/cc @nosami @Krzysztof-Cieslak

Speaking of this PR I'd like to continue working on completion features on top of simplified APIs if the change is welcomed.

@nosami
Copy link
Contributor

nosami commented Dec 20, 2017

@auduchinok VS for Mac doesn't use GetDeclarationListInfo. It uses GetDeclarationListSymbols instead (for now at least).

See fsharp/fsharp-compiler-docs#841 for the API change I wanted to make. I think it's important that the two APIs share the same features.

@auduchinok
Copy link
Member Author

@nosami Yeah, I've checked if there're real uses of GetDeclarationListSymbols and GetMethodsAsSymbols and found VS for Mac to be the only tool using them. We've moved to the non-symbol ones (at least for now) as there's ready-to-use results including the text to insert, namespace to open, etc, and getting the symbol will probably be added to the info.

@nosami
Copy link
Contributor

nosami commented Dec 20, 2017

@auduchinok: If the symbol was added to the completion info, then I think I would stop using GetDeclarationListSymbols :)

@cartermp
Copy link
Contributor

+1 on changing the API names as you suggested @auduchinok

@Krzysztof-Cieslak
Copy link
Contributor

+1 from me, on both API changed in the PR, and changing the names of the functions across the API. If we were looking into any breaking changes we could seriously review all the API and change it even more - for example, I'm not a big fan of passing idents to most functions, I kinda feel it could be hidden from the consumer (especially that we have now QuickParse module already in place)

@auduchinok
Copy link
Member Author

@Krzysztof-Cieslak I've already removed idents passing in public APIs (in a branch) and do it in implementations.

@forki
Copy link
Contributor

forki commented Jan 28, 2018

Ping

Copy link
Contributor

@dsyme dsyme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@auduchinok I'm ok with these changes but they need to be merged with master

@KevinRansom
Copy link
Contributor

@auduchinok, the PR has approval, if you resolve the merge issues it can be merged.

Thanks

Kevin

@KevinRansom
Copy link
Contributor

These look like good changes to have in the product.

Please reactivate when you get some time to devote to this.

Thank you

Kevin

@KevinRansom KevinRansom closed this Oct 2, 2018
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.

7 participants