|
| 1 | +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. |
| 2 | + |
| 3 | +namespace FSharp.Compiler.LanguageServer |
| 4 | + |
| 5 | +// Interfaces as defined at https://microsoft.github.io/language-server-protocol/specification. The properties on these |
| 6 | +// types are camlCased to match the underlying JSON properties to avoid attributes on every field: |
| 7 | +// [<JsonProperty("camlCased")>] |
| 8 | + |
| 9 | +/// Represents a zero-based line and column of a text document. |
| 10 | +type Position = |
| 11 | + { line: int |
| 12 | + character: int } |
| 13 | + |
| 14 | +type Range = |
| 15 | + { start: Position |
| 16 | + ``end``: Position } |
| 17 | + |
| 18 | +type DocumentUri = string |
| 19 | + |
| 20 | +type Location = |
| 21 | + { uri: DocumentUri |
| 22 | + range: Range } |
| 23 | + |
| 24 | +type DiagnosticRelatedInformation = |
| 25 | + { location: Location |
| 26 | + message: string } |
| 27 | + |
| 28 | +type Diagnostic = |
| 29 | + { range: Range |
| 30 | + severity: int |
| 31 | + code: string |
| 32 | + source: string // "F#" |
| 33 | + message: string |
| 34 | + relatedInformation: DiagnosticRelatedInformation[] } |
| 35 | + static member Error = 1 |
| 36 | + static member Warning = 2 |
| 37 | + static member Information = 3 |
| 38 | + static member Hint = 4 |
| 39 | + |
| 40 | +type PublishDiagnosticsParams = |
| 41 | + { uri: DocumentUri |
| 42 | + diagnostics: Diagnostic[] } |
| 43 | + |
| 44 | +type InitializeParams = string // TODO: |
| 45 | + |
| 46 | +// Note, this type has many more optional values that can be expanded as support is added. |
| 47 | +type ServerCapabilities = |
| 48 | + { hoverProvider: bool } |
| 49 | + static member DefaultCapabilities() = |
| 50 | + { ServerCapabilities.hoverProvider = true } |
| 51 | + |
| 52 | +type InitializeResult = |
| 53 | + { capabilities: ServerCapabilities } |
| 54 | + |
| 55 | +type MarkupKind = |
| 56 | + | PlainText |
| 57 | + | Markdown |
| 58 | + |
| 59 | +type MarkupContent = |
| 60 | + { kind: MarkupKind |
| 61 | + value: string } |
| 62 | + |
| 63 | +type Hover = |
| 64 | + { contents: MarkupContent |
| 65 | + range: Range option } |
| 66 | + |
| 67 | +type TextDocumentIdentifier = |
| 68 | + { uri: DocumentUri } |
| 69 | + |
| 70 | +type TextDocumentPositionParams = |
| 71 | + { textDocument: TextDocumentIdentifier |
| 72 | + position: Position } |
0 commit comments