Skip to content

Commit f282341

Browse files
committed
PR feedback: Folder FromFile/FromFolder
1 parent 798b699 commit f282341

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/FSharpLint.Client/LSPFSharpLintService.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ let private getFolderFor filePath (): Result<Folder, FSharpLintServiceError> =
150150
let handleFile filePath =
151151
if not (isPathAbsolute filePath) then
152152
Error FSharpLintServiceError.FilePathIsNotAbsolute
153-
else match Folder.From filePath with
153+
else match Folder.FromFile filePath with
154154
| None -> Error FSharpLintServiceError.FileDoesNotExist
155155
| Some folder -> Ok folder
156156

src/FSharpLint.Client/LSPFSharpLintServiceTypes.fs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,21 @@ type FSharpLintVersion = FSharpLintVersion of string
2727
type FSharpLintExecutableFile = FSharpLintExecutableFile of File
2828
type Folder = private Folder of string
2929
with
30-
static member From (filePath: string) =
30+
static member FromFile (filePath: string) =
3131
if File.Exists(filePath) then
32-
// Path.GetFullPath to resolve path like /foo/bar/../baz
33-
let folder = ((filePath |> Path.GetFullPath |> FileInfo).Directory)
32+
let folder = (FileInfo filePath).Directory
3433
if folder.Exists then
3534
folder.FullName |> Folder |> Some
3635
else
3736
None
3837
else
3938
None
39+
static member FromFolder (folderPath: string) =
40+
if Directory.Exists(folderPath) then
41+
let folder = DirectoryInfo folderPath
42+
folder.FullName |> Folder |> Some
43+
else
44+
None
4045
static member Unwrap(Folder f) = f
4146

4247
[<RequireQualifiedAccess>]

src/FSharpLint.Client/LSPFSharpLintServiceTypes.fsi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ type FSharpLintExecutableFile = FSharpLintExecutableFile of File
1919

2020
type Folder = private Folder of string
2121
with
22-
static member From: string -> Folder option
22+
static member FromFile: string -> Folder option
23+
static member FromFolder: string -> Folder option
2324
static member Unwrap: Folder -> string
2425

2526
[<RequireQualifiedAccess>]

0 commit comments

Comments
 (0)