ionide / FsAutoComplete

F# language server using Language Server Protocol
Other
389 stars 151 forks source link

Refactoring: Extract Interface from Type member declaration (refactoring) #1227

Open jkone27 opened 5 months ago

jkone27 commented 5 months ago

Details

would be great to be able to easilly extract an abstact type (interface) from a type with a public member, and have it implement (interface with) that interface,

with just 1 context action.

Reason


// LIGHT BULB HERE ---> extract all public members to interface, also useful..
type TripFaqMapper( ... ) =

        // LIGHT BULB HERE! --> here suggestion lights up, as this is a public member, possibly can be extracted to interface
        member this.MapGroupTagAsync
            (
                id: int64,
                groupCode: string,
                tag: string,
                appId: string,
                locale,
                currency,
                cancellationToken: CancellationToken
            ) : TravixFaqResponse Task =

            task {...} // implementation

// generates this, like in C# extract interface..

type TripFaqMapper( ... ) =

    interface ITripFaqMapper with

        member this.MapGroupTagAsync
            (
                id: int64,
                groupCode: string,
                tag: string,
                appId: string,
                locale,
                currency,
                cancellationToken: CancellationToken
            ) : TravixFaqResponse Task =

            task {...} // implementation

type ITripFaqMapper =
    abstract member MapGroupTagAsync:
        id: int64 *
        groupCode: string *
        tag: string *
        appId: string *
        locale: Locale *
        currency: Currency *
        cancellationToken: CancellationToken ->
            TravixFaqResponse Task

Checklist