@@ -10,12 +10,13 @@ open System.Threading
10
10
open Internal.Utilities .Collections
11
11
open Internal.Utilities .Library
12
12
open Internal.Utilities .Library .Extras
13
+
13
14
open FSharp.Compiler
14
15
open FSharp.Compiler .AbstractIL
15
16
open FSharp.Compiler .AbstractIL .IL
16
17
open FSharp.Compiler .AbstractIL .ILBinaryReader
17
18
open FSharp.Compiler .CodeAnalysis
18
- open FSharp.Compiler .CheckExpressions
19
+ open FSharp.Compiler .CheckBasics
19
20
open FSharp.Compiler .CheckDeclarations
20
21
open FSharp.Compiler .CompilerConfig
21
22
open FSharp.Compiler .CompilerDiagnostics
@@ -24,8 +25,8 @@ open FSharp.Compiler.CompilerImports
24
25
open FSharp.Compiler .CompilerOptions
25
26
open FSharp.Compiler .DependencyManager
26
27
open FSharp.Compiler .Diagnostics
28
+ open FSharp.Compiler .DiagnosticsLogger
27
29
open FSharp.Compiler .Driver
28
- open FSharp.Compiler .ErrorLogger
29
30
open FSharp.Compiler .NameResolution
30
31
open FSharp.Compiler .ParseAndCheckInputs
31
32
open FSharp.Compiler .ScriptClosure
@@ -44,7 +45,7 @@ open FSharp.Compiler.BuildGraph
44
45
// InteractiveChecker
45
46
//-------------------------------------------------------------------------
46
47
47
- type internal TcResult = TcEnv * TopAttribs * TypedImplFile option * ModuleOrNamespaceType
48
+ type internal TcResult = TcEnv * TopAttribs * CheckedImplFile option * ModuleOrNamespaceType
48
49
type internal TcErrors = FSharpDiagnostic[]
49
50
50
51
type internal CompilerState = {
@@ -109,19 +110,18 @@ module internal ParseAndCheck =
109
110
let initializeCompilerState projectOptions reset = async {
110
111
let tcConfig =
111
112
let tcConfigB =
112
- TcConfigBuilder.CreateNew( SimulatedMSBuildReferenceResolver.getResolver(),
113
- includewin32manifest= false ,
114
- framework= false ,
115
- portablePDB= false ,
116
- defaultFSharpBinariesDir= FSharpCheckerResultsSettings.defaultFSharpBinariesDir,
117
- reduceMemoryUsage= ReduceMemoryFlag.Yes,
118
- implicitIncludeDir= Path.GetDirectoryName( projectOptions.ProjectFileName),
119
- isInteractive= false ,
120
- isInvalidationSupported= true ,
121
- defaultCopyFSharpCore= CopyFSharpCoreFlag.No,
122
- tryGetMetadataSnapshot=( fun _ -> None),
123
- sdkDirOverride= None,
124
- rangeForErrors= range0)
113
+ TcConfigBuilder.CreateNew(
114
+ SimulatedMSBuildReferenceResolver.getResolver(),
115
+ defaultFSharpBinariesDir = FSharpCheckerResultsSettings.defaultFSharpBinariesDir,
116
+ reduceMemoryUsage = ReduceMemoryFlag.Yes,
117
+ implicitIncludeDir = Path.GetDirectoryName( projectOptions.ProjectFileName),
118
+ isInteractive = false ,
119
+ isInvalidationSupported = true ,
120
+ defaultCopyFSharpCore = CopyFSharpCoreFlag.No,
121
+ tryGetMetadataSnapshot = ( fun _ -> None),
122
+ sdkDirOverride = None,
123
+ rangeForErrors = range0
124
+ )
125
125
let sourceFiles = projectOptions.SourceFiles |> Array.toList
126
126
let argv = projectOptions.OtherOptions |> Array.toList
127
127
let _sourceFiles = ApplyCommandLineArgs( tcConfigB, sourceFiles, argv)
@@ -140,10 +140,9 @@ module internal ParseAndCheck =
140
140
ccu.Deref.InvalidateEvent.Add( fun _ -> reset())
141
141
)
142
142
143
- let niceNameGen = NiceNameGenerator()
144
143
let assemblyName = projectOptions.ProjectFileName |> Path.GetFileNameWithoutExtension
145
144
let tcInitial , openDecls0 = GetInitialTcEnv ( assemblyName, rangeStartup, tcConfig, tcImports, tcGlobals)
146
- let tcInitialState = GetInitialTcState ( rangeStartup, assemblyName, tcConfig, tcGlobals, tcImports, niceNameGen , tcInitial, openDecls0)
145
+ let tcInitialState = GetInitialTcState ( rangeStartup, assemblyName, tcConfig, tcGlobals, tcImports, tcInitial, openDecls0)
147
146
148
147
// parse cache, keyed on file name and source hash
149
148
let parseCache = ConcurrentDictionary< string * int, FSharpParseFileResults>( HashIdentity.Structural)
@@ -162,14 +161,14 @@ module internal ParseAndCheck =
162
161
}
163
162
164
163
let MakeProjectResults ( projectFileName : string , parseResults : FSharpParseFileResults [], tcState : TcState , errors : FSharpDiagnostic [],
165
- topAttrsOpt : TopAttribs option , tcImplFilesOpt : TypedImplFile list option ,
166
- compilerState ) =
164
+ topAttrsOpt : TopAttribs option , tcImplFilesOpt : CheckedImplFile list option , compilerState ) =
167
165
let assemblyRef = mkSimpleAssemblyRef " stdin"
168
166
let access = tcState.TcEnvFromImpls.AccessRights
169
167
let symbolUses = Choice2Of2 TcSymbolUses.Empty
170
168
let dependencyFiles = parseResults |> Seq.map ( fun x -> x.DependencyFiles) |> Array.concat
169
+ let getAssemblyData () = None
171
170
let details = ( compilerState.tcGlobals, compilerState.tcImports, tcState.Ccu, tcState.CcuSig, symbolUses, topAttrsOpt,
172
- assemblyRef, access, tcImplFilesOpt, dependencyFiles, compilerState.projectOptions)
171
+ getAssemblyData , assemblyRef, access, tcImplFilesOpt, dependencyFiles, compilerState.projectOptions)
173
172
let keepAssemblyContents = true
174
173
FSharpCheckProjectResults ( projectFileName, Some compilerState.tcConfig, keepAssemblyContents, errors, Some details)
175
174
@@ -199,20 +198,21 @@ module internal ParseAndCheck =
199
198
200
199
let TypeCheckOneInputEntry ( parseResults : FSharpParseFileResults , tcSink : TcResultsSink , tcState : TcState , moduleNamesDict : ModuleNamesDict , compilerState ) =
201
200
let input = parseResults.ParseTree
202
- let capturingErrorLogger = CompilationErrorLogger( " TypeCheckFile" , compilerState.tcConfig.errorSeverityOptions)
203
- let errorLogger = GetErrorLoggerFilteringByScopedPragmas( false , GetScopedPragmasForInput( input), capturingErrorLogger)
204
- use _errorScope = new CompilationGlobalsScope ( errorLogger, BuildPhase.TypeCheck)
201
+ let diagnosticsOptions = compilerState.tcConfig.diagnosticsOptions
202
+ let capturingLogger = CompilationDiagnosticLogger( " TypeCheckFile" , diagnosticsOptions)
203
+ let diagnosticsLogger = GetDiagnosticsLoggerFilteringByScopedPragmas( false , input.ScopedPragmas, diagnosticsOptions, capturingLogger)
204
+ use _scope = new CompilationGlobalsScope ( diagnosticsLogger, BuildPhase.TypeCheck)
205
205
206
- let checkForErrors () = parseResults.ParseHadErrors || errorLogger .ErrorCount > 0
206
+ let checkForErrors () = parseResults.ParseHadErrors || diagnosticsLogger .ErrorCount > 0
207
207
let prefixPathOpt = None
208
208
209
209
let input , moduleNamesDict = input |> DeduplicateParsedInputModuleName moduleNamesDict
210
210
let tcResult , tcState =
211
- TypeCheckOneInput ( checkForErrors, compilerState.tcConfig, compilerState.tcImports, compilerState.tcGlobals, prefixPathOpt, tcSink, tcState, input, false )
212
- |> Cancellable.runWithoutCancellation
211
+ CheckOneInput ( checkForErrors, compilerState.tcConfig, compilerState.tcImports, compilerState.tcGlobals, prefixPathOpt, tcSink, tcState, input, false )
212
+ |> Cancellable.runWithoutCancellation
213
213
214
214
let fileName = parseResults.FileName
215
- let tcErrors = DiagnosticHelpers.CreateDiagnostics ( compilerState.tcConfig.errorSeverityOptions , false , fileName, ( capturingErrorLogger .GetDiagnostics()), suggestNamesForErrors)
215
+ let tcErrors = DiagnosticHelpers.CreateDiagnostics ( diagnosticsOptions , false , fileName, ( capturingLogger .GetDiagnostics()), suggestNamesForErrors)
216
216
( tcResult, tcErrors), ( tcState, moduleNamesDict)
217
217
218
218
let CheckFile ( projectFileName : string , parseResults : FSharpParseFileResults , tcState : TcState , moduleNamesDict : ModuleNamesDict , compilerState ) =
@@ -239,7 +239,7 @@ module internal ParseAndCheck =
239
239
let checkCacheKey = parseRes.FileName
240
240
241
241
let typeCheckOneInput _fileName =
242
- TypeCheckOneInputEntry ( parseRes, TcResultsSink.NoSink, tcState, moduleNamesDict, compilerState)
242
+ TypeCheckOneInputEntry ( parseRes, TcResultsSink.NoSink, tcState, moduleNamesDict, compilerState)
243
243
244
244
let ( result , errors ), ( tcState , moduleNamesDict ) = compilerState.checkCache.GetOrAdd( checkCacheKey, typeCheckOneInput)
245
245
@@ -257,9 +257,9 @@ module internal ParseAndCheck =
257
257
258
258
let tcResults , tcErrors = Array.unzip results
259
259
let ( tcEnvAtEndOfLastFile , topAttrs , implFiles , _ccuSigsForFiles ), tcState =
260
- TypeCheckMultipleInputsFinish ( tcResults |> Array.toList, tcState)
260
+ CheckMultipleInputsFinish ( tcResults |> Array.toList, tcState)
261
261
262
- let tcState , declaredImpls , ccuContents = TypeCheckClosedInputSetFinish ( implFiles, tcState)
262
+ let tcState , declaredImpls , ccuContents = CheckClosedInputSetFinish ( implFiles, tcState)
263
263
tcState.Ccu.Deref.Contents <- ccuContents
264
264
tcState, topAttrs, declaredImpls, tcEnvAtEndOfLastFile, moduleNamesDict, tcErrors
265
265
@@ -304,11 +304,11 @@ type InteractiveChecker internal (compilerStateCache) =
304
304
TypeCheckClosedInputSet ( parseResults, compilerState.tcInitialState, compilerState, None)
305
305
306
306
let ctok = CompilationThreadToken()
307
- let errors , errorLogger , _loggerProvider = CompileHelpers.mkCompilationErrorHandlers ()
307
+ let errors , diagnosticsLogger , _loggerProvider = CompileHelpers.mkCompilationDiagnosticsHandlers ()
308
308
let exitCode =
309
- CompileHelpers.tryCompile errorLogger ( fun exiter ->
310
- compileOfTypedAst ( ctok, compilerState.tcGlobals, compilerState.tcImports, tcState.Ccu,
311
- tcImplFiles, topAttrs, compilerState.tcConfig, outFile, errorLogger , exiter))
309
+ CompileHelpers.tryCompile diagnosticsLogger ( fun exiter ->
310
+ CompileFromTypedAst ( ctok, compilerState.tcGlobals, compilerState.tcImports, tcState.Ccu,
311
+ tcImplFiles, topAttrs, compilerState.tcConfig, outFile, diagnosticsLogger , exiter))
312
312
313
313
return errors.ToArray(), exitCode
314
314
}
@@ -340,7 +340,7 @@ type InteractiveChecker internal (compilerStateCache) =
340
340
fileNames |> Array.map parseFile
341
341
342
342
// type check files
343
- let ( tcState , topAttrs , tcImplFiles , _tcEnvAtEnd , _moduleNamesDict , tcErrors ) = // measureTime <| fun _ ->
343
+ let ( tcState , topAttrs , tcImplFiles , _tcEnvAtEnd , _moduleNamesDict , tcErrors ) =
344
344
TypeCheckClosedInputSet ( parseResults, compilerState.tcInitialState, compilerState, subscriber)
345
345
346
346
// make project results
0 commit comments