Skip to content

Commit

Permalink
Use Uri instead of FileName for several fsharp/ requests (#949)
Browse files Browse the repository at this point in the history
* Use Uri instead of filename for `fsharp/FileParsed`

* Fix: Off-by-One column in `fsharp/documentation`

In Ionide: used for Info Panel

* Fix: Off-by-One column in `fsharp/f1Help`

* Change `FSharpPipelineHintRequest` to use Uri

Change `HighlightingRequest`, `FSharpLiterateRequest` to use Uri too
* But neither of these two is actually used

Note: This commit results in changed API:
* Prev: `{ FileName: string }`
* Now: `{ TextDocument: TextDocumentIdentifier }`
-> Clients must be adjusted

* Format Code
  • Loading branch information
Booksbaum committed May 29, 2022
1 parent 5883bce commit 754dd2d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/FsAutoComplete.Core/AbstractClassStubGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ let private walkTypeDefn (SynTypeDefn (info, repr, members, implicitCtor, range,




(
// filter out implicit/explicit constructors and inherit statements, as all members _must_ come after these
function
Expand Down
4 changes: 2 additions & 2 deletions src/FsAutoComplete.Core/ParseAndCheckResults.fs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ type ParseAndCheckResults
Ok(Some(tip, signature, footer, typeDoc))

member __.TryGetFormattedDocumentation (pos: Position) (lineStr: LineStr) =
match Lexer.findLongIdents (pos.Column - 1, lineStr) with
match Lexer.findLongIdents (pos.Column, lineStr) with
| None -> Error "Cannot find ident"
| Some (col, identIsland) ->
let identIsland = Array.toList identIsland
Expand Down Expand Up @@ -546,7 +546,7 @@ type ParseAndCheckResults
| _ -> ResultOrString.Error "Not a member, function or value"

member __.TryGetF1Help (pos: Position) (lineStr: LineStr) =
match Lexer.findLongIdents (pos.Column - 1, lineStr) with
match Lexer.findLongIdents (pos.Column, lineStr) with
| None -> ResultOrString.Error "No ident at this location"
| Some (colu, identIsland) ->

Expand Down
22 changes: 9 additions & 13 deletions src/FsAutoComplete/FsAutoComplete.Lsp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,9 @@ type FSharpLspServer(backgroundServiceEnabled: bool, state: State, lspClient: FS
try
match n with
| NotificationEvent.FileParsed fn ->
({ Content = UMX.untag fn }: PlainNotification)
let uri = Path.LocalPathToUri fn

({ Content = UMX.untag uri }: PlainNotification)
|> lspClient.NotifyFileParsed
|> Async.Start
| NotificationEvent.Workspace ws ->
Expand Down Expand Up @@ -705,9 +707,10 @@ type FSharpLspServer(backgroundServiceEnabled: bool, state: State, lspClient: FS
///Helper function for handling file requests using **recent** type check results
member x.fileHandler<'a>
(f: string<LocalPath> -> ParseAndCheckResults -> NamedText -> AsyncLspResult<'a>)
(file: string<LocalPath>)
(arg: TextDocumentIdentifier)
: AsyncLspResult<'a> =
async {
let file = arg.GetFilePath() |> Utils.normalizePath

// logger.info (Log.setMessage "PositionHandler - Position request: {file} at {pos}" >> Log.addContextDestructured "file" file >> Log.addContextDestructured "pos" pos)
match commands.TryGetFileCheckerOptionsWithLines(file) with
Expand Down Expand Up @@ -2656,7 +2659,7 @@ type FSharpLspServer(backgroundServiceEnabled: bool, state: State, lspClient: FS
// member __.FSharpLiterate (p: FSharpLiterateRequest) = async {
// logger.info (Log.setMessage "FSharpLiterate Request: {parms}" >> Log.addContextDestructured "parms" p )

// let fn = p.FileName |> Utils.normalizePath
// let fn = p.TextDocument.GetFilePath() |> Utils.normalizePath
// let! res = commands.FSharpLiterate fn
// let res =
// match res with
Expand All @@ -2680,15 +2683,10 @@ type FSharpLspServer(backgroundServiceEnabled: bool, state: State, lspClient: FS
>> Log.addContextDestructured "parms" p
)

let fn =
p.TextDocument.GetFilePath()
|> Utils.normalizePath

let fcsRange = protocolRangeToRange (UMX.untag fn) p.Range

fn
p.TextDocument
|> x.fileHandler (fun fn tyRes lines ->
async {
let fcsRange = protocolRangeToRange (UMX.untag fn) p.Range
let! hints = commands.InlayHints(lines, tyRes, fcsRange)

let lspHints =
Expand All @@ -2708,9 +2706,7 @@ type FSharpLspServer(backgroundServiceEnabled: bool, state: State, lspClient: FS
>> Log.addContextDestructured "parms" p
)

let fn = p.FileName |> Utils.normalizePath

fn
p.TextDocument
|> x.fileHandler (fun fn tyRes lines ->
match commands.PipelineHints tyRes with
| CoreResponse.InfoRes msg
Expand Down
9 changes: 6 additions & 3 deletions src/FsAutoComplete/LspHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,8 @@ type DocumentationForSymbolReuqest = { XmlSig: string; Assembly: string }

// type FakeTargetsRequest = { FileName : string; FakeContext : FakeSupport.FakeContext; }

type HighlightingRequest = { FileName: string }
type HighlightingRequest =
{ TextDocument: TextDocumentIdentifier }

type LineLensConfig = { Enabled: string; Prefix: string }

Expand All @@ -618,9 +619,11 @@ type DotnetFile2Request =
FileVirtualPath: string
NewFile: string }

type FSharpLiterateRequest = { FileName: string }
type FSharpLiterateRequest =
{ TextDocument: TextDocumentIdentifier }

type FSharpPipelineHintRequest = { FileName: string }
type FSharpPipelineHintRequest =
{ TextDocument: TextDocumentIdentifier }

type CodeLensConfigDto =
{ Signature: {| Enabled: bool option |} option
Expand Down

0 comments on commit 754dd2d

Please sign in to comment.