Skip to content

Commit 272cfb0

Browse files
committed
Latest FCS
1 parent e67fbea commit 272cfb0

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

src/FSharpLanguageServer/FSharpLanguageServer.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="FSharp.Compiler.Service" Version="27.0.1" />
21+
<PackageReference Include="FSharp.Compiler.Service" Version="34.1.1" />
2222
<PackageReference Include="HtmlAgilityPack" Version="1.8.4" />
2323
</ItemGroup>
2424

src/FSharpLanguageServer/Program.fs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module FSharpLanguageServer.Program
22

33
open LSP.Log
44
open FSharp.Compiler
5+
open FSharp.Compiler.Text
56
open FSharp.Compiler.SourceCodeServices
67
open System
78
open System.Diagnostics
@@ -137,7 +138,12 @@ let private testFunctions(parse: FSharpParseFileResults): (string list * Ast.Syn
137138
| _ -> false
138139
let isTestFunction(binding: Ast.SynBinding): bool =
139140
let attrs = match binding with Ast.Binding(_, _, _, _, attrs, _, _, _, _, _, _, _) -> attrs
140-
List.exists isTestAttribute attrs
141+
let mutable found = false
142+
for list in attrs do
143+
for a in list.Attributes do
144+
if isTestAttribute(a) then
145+
found <- true
146+
found
141147
let name(binding: Ast.SynBinding): string list =
142148
match binding with
143149
| Ast.Binding(_, _, _, _, _, _, _, Ast.SynPat.LongIdent(Ast.LongIdentWithDots(ids, _), _, _, _, _, _), _, _, _, _) ->
@@ -222,7 +228,7 @@ type Server(client: ILanguageClient) =
222228
| None ->
223229
try
224230
let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions(projectOptions)
225-
let! parse = checker.ParseFile(file.FullName, sourceText, parsingOptions)
231+
let! parse = checker.ParseFile(file.FullName, SourceText.ofString(sourceText), parsingOptions)
226232
return Ok(parse)
227233
with e ->
228234
return Error(e.Message)
@@ -245,7 +251,7 @@ type Server(client: ILanguageClient) =
245251
| Ok(projectOptions), Some(sourceText, sourceVersion) ->
246252
let recompile = async {
247253
let timeCheck = Stopwatch.StartNew()
248-
let! force = checker.ParseAndCheckFileInProject(file.FullName, sourceVersion, sourceText, projectOptions)
254+
let! force = checker.ParseAndCheckFileInProject(file.FullName, sourceVersion, SourceText.ofString(sourceText), projectOptions)
249255
dprintfn "Checked %s in %dms" file.Name timeCheck.ElapsedMilliseconds
250256
match force with
251257
| parseResult, FSharpCheckFileAnswer.Aborted -> return Error(asDiagnostics parseResult.Errors)
@@ -484,7 +490,7 @@ type Server(client: ILanguageClient) =
484490
// Check file
485491
let sourceVersion = docs.GetVersion(sourceFile) |> Option.defaultValue 0
486492
let timeCheck = Stopwatch.StartNew()
487-
let! _, maybeCheck = checker.ParseAndCheckFileInProject(sourceFile.FullName, sourceVersion, sourceText, projectOptions)
493+
let! _, maybeCheck = checker.ParseAndCheckFileInProject(sourceFile.FullName, sourceVersion, SourceText.ofString(sourceText), projectOptions)
488494
dprintfn "Checked %s in %dms" sourceFile.Name timeCheck.ElapsedMilliseconds
489495
match maybeCheck with
490496
| FSharpCheckFileAnswer.Aborted -> dprintfn "Aborted checking %s" sourceFile.Name
@@ -744,11 +750,11 @@ type Server(client: ILanguageClient) =
744750
dprintfn "...scan %s" sourceFile.Name
745751
match maybeMatchesQuery(p.query, sourceFile) with
746752
| None -> ()
747-
| Some sourceText ->
753+
| Some(sourceText) ->
748754
try
749755
dprintfn "...parse %s" sourceFile.Name
750756
let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions(projectOptions)
751-
let! parse = checker.ParseFile(sourceFile.FullName, sourceText, parsingOptions)
757+
let! parse = checker.ParseFile(sourceFile.FullName, SourceText.ofString(sourceText), parsingOptions)
752758
for declaration, container in findDeclarations(parse) do
753759
if matchesQuery(p.query, declaration.Name) then
754760
all.Add(asSymbolInformation(declaration, container))
@@ -763,7 +769,7 @@ type Server(client: ILanguageClient) =
763769
match projects.FindProjectOptions(file), getOrRead(file) with
764770
| Ok(projectOptions), Some(sourceText) ->
765771
let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions(projectOptions)
766-
let! parse = checker.ParseFile(file.FullName, sourceText, parsingOptions)
772+
let! parse = checker.ParseFile(file.FullName, SourceText.ofString(sourceText), parsingOptions)
767773
if file.Name.EndsWith(".fs") then
768774
let fns = testFunctions(parse)
769775
let fsproj = FileInfo(projectOptions.ProjectFileName)
@@ -795,7 +801,7 @@ type Server(client: ILanguageClient) =
795801
match projects.FindProjectOptions(file), getOrRead(file) with
796802
| Ok(projectOptions), Some(sourceText) ->
797803
let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions(projectOptions)
798-
let! parse = checker.ParseFile(file.FullName, sourceText, parsingOptions)
804+
let! parse = checker.ParseFile(file.FullName, SourceText.ofString(sourceText), parsingOptions)
799805
match findSignatureImplementation(parse, name) with
800806
| [range] ->
801807
return resolveGoToImplementation(p, file, range)

src/FSharpLanguageServer/ProjectManager.fs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ open FSharp.Data
1111
open FSharp.Data.JsonExtensions
1212
open LSP.Types
1313
open FSharp.Compiler.SourceCodeServices
14+
open FSharp.Compiler.Text
1415
open ProjectCracker
1516

1617
type private ResolvedProject = {
@@ -238,8 +239,8 @@ type ProjectManager(checker: FSharpChecker) =
238239
/// Analyze a script file
239240
let analyzeFsx(fsx: FileInfo) =
240241
dprintfn "Creating project options for script %s" fsx.Name
241-
let source = File.ReadAllText(fsx.FullName)
242-
let inferred, errors = checker.GetProjectOptionsFromScript(fsx.FullName, source, fsx.LastWriteTime, assumeDotNetFramework=false) |> Async.RunSynchronously
242+
let source = SourceText.ofString(File.ReadAllText(fsx.FullName))
243+
let inferred, errors = checker.GetProjectOptionsFromScript(fsx.FullName, source, loadedTimeStamp=fsx.LastWriteTime, assumeDotNetFramework=false) |> Async.RunSynchronously
243244
let combinedOtherOptions = [|
244245
for p in dotNetFramework do
245246
yield "-r:" + p.FullName

tests/FSharpLanguageServer.Tests/ServerTests.fs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ open FSharpLanguageServer.Program
55
open System
66
open System.IO
77
open FSharp.Compiler.SourceCodeServices
8+
open FSharp.Compiler.Text
89
open NUnit.Framework
910
open LSP.Types
1011
open LSP
@@ -18,9 +19,9 @@ let setup() =
1819
[<Test>]
1920
let ``check errors in some text``() =
2021
let file = "MyScript.fsx"
21-
let input = """
22+
let input = SourceText.ofString("""
2223
let foo() = "foo!""
23-
"""
24+
""")
2425
let checker = FSharpChecker.Create()
2526
let projOptions, projOptionsErrors = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously
2627
let parsingOptions, parsingOptionsErrors = checker.GetParsingOptionsFromProjectOptions(projOptions)

0 commit comments

Comments
 (0)