Skip to content

Commit

Permalink
Add signature files for FSharpLspClient, Parser and UnionPatternMatch…
Browse files Browse the repository at this point in the history
…CaseGenerator. (#1213)
  • Loading branch information
nojaf authored Dec 7, 2023
1 parent cc4f61b commit e1498aa
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/FsAutoComplete.Core/FsAutoComplete.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<Compile Include="State.fs" />
<Compile Include="CodeGeneration.fsi" />
<Compile Include="CodeGeneration.fs" />
<Compile Include="UnionPatternMatchCaseGenerator.fsi" />
<Compile Include="UnionPatternMatchCaseGenerator.fs" />
<Compile Include="RecordStubGenerator.fs" />
<Compile Include="AbstractClassStubGenerator.fs" />
Expand Down
36 changes: 36 additions & 0 deletions src/FsAutoComplete.Core/UnionPatternMatchCaseGenerator.fsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/// Original code from VisualFSharpPowerTools project: https://github.com/fsprojects/VisualFSharpPowerTools/blob/master/src/FSharp.Editing/CodeGeneration/UnionPatternMatchCaseGenerator.fs
module FsAutoComplete.UnionPatternMatchCaseGenerator

open FSharp.Compiler.Syntax
open FSharp.Compiler.Text
open FSharp.Compiler.Symbols

[<NoEquality; NoComparison>]
type PatternMatchExpr =
{
/// Range of 'match x with' or 'function'
MatchWithOrFunctionRange: Range
/// The whole pattern match expression
Expr: SynExpr
Clauses: SynMatchClause list
}

[<NoComparison>]
type UnionMatchCasesInsertionParams =
{ InsertionPos: Position
IndentColumn: int }

val shouldGenerateUnionPatternMatchCases: patMatchExpr: PatternMatchExpr -> entity: FSharpEntity -> bool

val tryFindUnionDefinitionFromPos:
codeGenService: ICodeGenerationService ->
pos: Position ->
document: Document ->
Async<(PatternMatchExpr * FSharpEntity * UnionMatchCasesInsertionParams) option>

val formatMatchExpr:
insertionParams: UnionMatchCasesInsertionParams ->
caseDefaultValue: string ->
patMatchExpr: PatternMatchExpr ->
entity: FSharpEntity ->
string
2 changes: 2 additions & 0 deletions src/FsAutoComplete/FsAutoComplete.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
<Compile Include="CodeFixes/*.fsi" />
<Compile Include="CodeFixes/*.fs" />
<Compile Include="LspServers/IFSharpLspServer.fs" />
<Compile Include="LspServers/FSharpLspClient.fsi" />
<Compile Include="LspServers/FSharpLspClient.fs" />
<Compile Include="LspServers/Common.fs" />
<Compile Include="LspServers/AdaptiveServerState.fsi" />
<Compile Include="LspServers/AdaptiveServerState.fs" />
<Compile Include="LspServers/AdaptiveFSharpLspServer.fsi" />
<Compile Include="LspServers/AdaptiveFSharpLspServer.fs" />
<Compile Include="Parser.fsi" />
<Compile Include="Parser.fs" />
<Compile Include="Program.fs" />
<None Include="FsAutoComplete.fsproj.paket.references" />
Expand Down
50 changes: 50 additions & 0 deletions src/FsAutoComplete/LspServers/FSharpLspClient.fsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
namespace FsAutoComplete.Lsp

open Ionide.LanguageServerProtocol
open Ionide.LanguageServerProtocol.Server
open Ionide.LanguageServerProtocol.Types
open FsAutoComplete.LspHelpers
open System
open IcedTasks

type FSharpLspClient =
new: sendServerNotification: ClientNotificationSender * sendServerRequest: ClientRequestSender -> FSharpLspClient
inherit LspClient
member ClientCapabilities: ClientCapabilities option with get, set
override WindowShowMessage: ShowMessageParams -> Async<unit>
override WindowShowMessageRequest: ShowMessageRequestParams -> AsyncLspResult<MessageActionItem option>
override WindowLogMessage: LogMessageParams -> Async<unit>
override TelemetryEvent: Newtonsoft.Json.Linq.JToken -> Async<unit>
override ClientRegisterCapability: RegistrationParams -> AsyncLspResult<unit>
override ClientUnregisterCapability: UnregistrationParams -> AsyncLspResult<unit>
override WorkspaceWorkspaceFolders: unit -> AsyncLspResult<WorkspaceFolder array option>
override WorkspaceConfiguration: ConfigurationParams -> AsyncLspResult<Newtonsoft.Json.Linq.JToken array>
override WorkspaceApplyEdit: ApplyWorkspaceEditParams -> AsyncLspResult<ApplyWorkspaceEditResponse>
override WorkspaceSemanticTokensRefresh: unit -> Async<unit>
override TextDocumentPublishDiagnostics: PublishDiagnosticsParams -> Async<unit>
///Custom notification for workspace/solution/project loading events
member NotifyWorkspace: p: PlainNotification -> Async<unit>
///Custom notification for initial workspace peek
member NotifyWorkspacePeek: p: PlainNotification -> Async<unit>
member NotifyCancelledRequest: p: PlainNotification -> Async<unit>
member NotifyFileParsed: p: PlainNotification -> Async<unit>
member NotifyDocumentAnalyzed: p: DocumentAnalyzedNotification -> Async<unit>
member NotifyTestDetected: p: TestDetectedNotification -> Async<unit>
member CodeLensRefresh: unit -> Async<unit>
override WorkDoneProgressCreate: ProgressToken -> AsyncLspResult<unit>
override Progress: ProgressToken * 'Progress -> Async<unit>

type ServerProgressReport =
new: lspClient: FSharpLspClient * ?token: ProgressToken -> ServerProgressReport
member Token: ProgressToken
member Begin: title: string * ?cancellable: bool * ?message: string * ?percentage: uint -> CancellableTask<unit>
member Report: ?cancellable: bool * ?message: string * ?percentage: uint -> CancellableTask<unit>
member End: ?message: string -> CancellableTask<unit>
interface IAsyncDisposable
interface IDisposable

/// <summary>listener for the the events generated from the fsc ActivitySource</summary>
type ProgressListener =
new: lspClient: FSharpLspClient * traceNamespace: string array -> ProgressListener
interface IDisposable
interface IAsyncDisposable
14 changes: 4 additions & 10 deletions src/FsAutoComplete/Parser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,18 @@ module Parser =
Start: FSharp.Compiler.Text.pos
End: FSharp.Compiler.Text.pos }

let private setArity arity (o: #Option) =
let setArity arity (o: #Option) =
o.Arity <- arity
o

/// set option to expect no arguments (e.g a flag-style argument: `--verbose`)
let inline private zero x = setArity ArgumentArity.Zero x
let inline zero x = setArity ArgumentArity.Zero x
/// set option to expect one argument (e.g a single value: `--foo bar)
let inline private one x = setArity ArgumentArity.ExactlyOne x
let inline one x = setArity ArgumentArity.ExactlyOne x

/// set option to expect multiple arguments
/// (e.g a list of values: `--foo bar baz` or `--foo bar --foo baz` depending on the style)
let inline private many x = setArity ArgumentArity.OneOrMore x

/// set option to allow multiple arguments per use of the option flag
/// (e.g. `--foo bar baz` is equivalent to `--foo bar --foo baz`)
let inline private multipleArgs (x: #Option) =
x.AllowMultipleArgumentsPerToken <- true
x
let inline many x = setArity ArgumentArity.OneOrMore x

let verboseOption =
Option<bool>([| "--verbose"; "-v"; "--debug" |], "Enable verbose logging. This is equivalent to --log-level debug.")
Expand Down
6 changes: 6 additions & 0 deletions src/FsAutoComplete/Parser.fsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace FsAutoComplete

open System.CommandLine.Parsing

module Parser =
val parser: Parser

0 comments on commit e1498aa

Please sign in to comment.