@@ -2,6 +2,7 @@ module FSharpLanguageServer.Program
2
2
3
3
open LSP.Log
4
4
open FSharp.Compiler
5
+ open FSharp.Compiler .Text
5
6
open FSharp.Compiler .SourceCodeServices
6
7
open System
7
8
open System.Diagnostics
@@ -137,7 +138,12 @@ let private testFunctions(parse: FSharpParseFileResults): (string list * Ast.Syn
137
138
| _ -> false
138
139
let isTestFunction ( binding : Ast.SynBinding ): bool =
139
140
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
141
147
let name ( binding : Ast.SynBinding ): string list =
142
148
match binding with
143
149
| Ast.Binding(_, _, _, _, _, _, _, Ast.SynPat.LongIdent( Ast.LongIdentWithDots( ids, _), _, _, _, _, _), _, _, _, _) ->
@@ -222,7 +228,7 @@ type Server(client: ILanguageClient) =
222
228
| None ->
223
229
try
224
230
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)
226
232
return Ok( parse)
227
233
with e ->
228
234
return Error( e.Message)
@@ -245,7 +251,7 @@ type Server(client: ILanguageClient) =
245
251
| Ok( projectOptions), Some( sourceText, sourceVersion) ->
246
252
let recompile = async {
247
253
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)
249
255
dprintfn " Checked %s in %d ms" file.Name timeCheck.ElapsedMilliseconds
250
256
match force with
251
257
| parseResult, FSharpCheckFileAnswer.Aborted -> return Error( asDiagnostics parseResult.Errors)
@@ -484,7 +490,7 @@ type Server(client: ILanguageClient) =
484
490
// Check file
485
491
let sourceVersion = docs.GetVersion( sourceFile) |> Option.defaultValue 0
486
492
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)
488
494
dprintfn " Checked %s in %d ms" sourceFile.Name timeCheck.ElapsedMilliseconds
489
495
match maybeCheck with
490
496
| FSharpCheckFileAnswer.Aborted -> dprintfn " Aborted checking %s " sourceFile.Name
@@ -744,11 +750,11 @@ type Server(client: ILanguageClient) =
744
750
dprintfn " ...scan %s " sourceFile.Name
745
751
match maybeMatchesQuery( p.query, sourceFile) with
746
752
| None -> ()
747
- | Some sourceText ->
753
+ | Some( sourceText) ->
748
754
try
749
755
dprintfn " ...parse %s " sourceFile.Name
750
756
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)
752
758
for declaration, container in findDeclarations( parse) do
753
759
if matchesQuery( p.query, declaration.Name) then
754
760
all.Add( asSymbolInformation( declaration, container))
@@ -763,7 +769,7 @@ type Server(client: ILanguageClient) =
763
769
match projects.FindProjectOptions( file), getOrRead( file) with
764
770
| Ok( projectOptions), Some( sourceText) ->
765
771
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)
767
773
if file.Name.EndsWith( " .fs" ) then
768
774
let fns = testFunctions( parse)
769
775
let fsproj = FileInfo( projectOptions.ProjectFileName)
@@ -795,7 +801,7 @@ type Server(client: ILanguageClient) =
795
801
match projects.FindProjectOptions( file), getOrRead( file) with
796
802
| Ok( projectOptions), Some( sourceText) ->
797
803
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)
799
805
match findSignatureImplementation( parse, name) with
800
806
| [ range] ->
801
807
return resolveGoToImplementation( p, file, range)
0 commit comments