@@ -80,11 +80,11 @@ let PrependPathToSpec x (SynModuleOrNamespaceSig(p, b, c, d, e, f, g, h)) =
8080
8181let PrependPathToInput x inp =
8282 match inp with
83- | ParsedInput.ImplFile ( ParsedImplFileInput ( b, c, q, d, hd, impls, e)) ->
84- ParsedInput.ImplFile ( ParsedImplFileInput ( b, c, PrependPathToQualFileName x q, d, hd, List.map ( PrependPathToImpl x) impls, e))
83+ | ParsedInput.ImplFile ( ParsedImplFileInput ( b, c, q, d, hd, impls, e, trivia )) ->
84+ ParsedInput.ImplFile ( ParsedImplFileInput ( b, c, PrependPathToQualFileName x q, d, hd, List.map ( PrependPathToImpl x) impls, e, trivia ))
8585
86- | ParsedInput.SigFile ( ParsedSigFileInput ( b, q, d, hd, specs)) ->
87- ParsedInput.SigFile ( ParsedSigFileInput ( b, PrependPathToQualFileName x q, d, hd, List.map ( PrependPathToSpec x) specs))
86+ | ParsedInput.SigFile ( ParsedSigFileInput ( b, q, d, hd, specs, trivia )) ->
87+ ParsedInput.SigFile ( ParsedSigFileInput ( b, PrependPathToQualFileName x q, d, hd, List.map ( PrependPathToSpec x) specs, trivia ))
8888
8989let ComputeAnonModuleName check defaultNamespace filename ( m : range ) =
9090 let modname = CanonicalizeFilename filename
@@ -178,7 +178,7 @@ let GetScopedPragmasForHashDirective hd =
178178 | Some n -> yield ScopedPragma.WarningOff( m, n)
179179 | _ -> () ]
180180
181- let PostParseModuleImpls ( defaultNamespace , filename , isLastCompiland , ParsedImplFile ( hashDirectives , impls )) =
181+ let PostParseModuleImpls ( defaultNamespace , filename , isLastCompiland , ParsedImplFile ( hashDirectives , impls ), lexbuf : UnicodeLexing.Lexbuf ) =
182182 match impls |> List.rev |> List.tryPick ( function ParsedImplFileFragment.NamedModule( SynModuleOrNamespace( lid, _, _, _, _, _, _, _)) -> Some lid | _ -> None) with
183183 | Some lid when impls.Length > 1 ->
184184 errorR( Error( FSComp.SR.buildMultipleToplevelModules(), rangeOfLid lid))
@@ -197,9 +197,11 @@ let PostParseModuleImpls (defaultNamespace, filename, isLastCompiland, ParsedImp
197197 for hd in hashDirectives do
198198 yield ! GetScopedPragmasForHashDirective hd ]
199199
200- ParsedInput.ImplFile ( ParsedImplFileInput ( filename, isScript, qualName, scopedPragmas, hashDirectives, impls, isLastCompiland))
200+ let conditionalDirectives = LexbufIfdefStore.GetTrivia( lexbuf)
201+
202+ ParsedInput.ImplFile ( ParsedImplFileInput ( filename, isScript, qualName, scopedPragmas, hashDirectives, impls, isLastCompiland, { ConditionalDirectives = conditionalDirectives }))
201203
202- let PostParseModuleSpecs ( defaultNamespace , filename , isLastCompiland , ParsedSigFile ( hashDirectives , specs )) =
204+ let PostParseModuleSpecs ( defaultNamespace , filename , isLastCompiland , ParsedSigFile ( hashDirectives , specs ), lexbuf : UnicodeLexing.Lexbuf ) =
203205 match specs |> List.rev |> List.tryPick ( function ParsedSigFileFragment.NamedModule( SynModuleOrNamespaceSig( lid, _, _, _, _, _, _, _)) -> Some lid | _ -> None) with
204206 | Some lid when specs.Length > 1 ->
205207 errorR( Error( FSComp.SR.buildMultipleToplevelModules(), rangeOfLid lid))
@@ -217,7 +219,9 @@ let PostParseModuleSpecs (defaultNamespace, filename, isLastCompiland, ParsedSig
217219 for hd in hashDirectives do
218220 yield ! GetScopedPragmasForHashDirective hd ]
219221
220- ParsedInput.SigFile ( ParsedSigFileInput ( filename, qualName, scopedPragmas, hashDirectives, specs))
222+ let conditionalDirectives = LexbufIfdefStore.GetTrivia( lexbuf)
223+
224+ ParsedInput.SigFile ( ParsedSigFileInput ( filename, qualName, scopedPragmas, hashDirectives, specs, { ConditionalDirectives = conditionalDirectives }))
221225
222226type ModuleNamesDict = Map< string, Map< string, QualifiedNameOfFile>>
223227
@@ -242,13 +246,13 @@ let DeduplicateModuleName (moduleNamesDict: ModuleNamesDict) fileName (qualNameO
242246/// Checks if a ParsedInput is using a module name that was already given and deduplicates the name if needed.
243247let DeduplicateParsedInputModuleName ( moduleNamesDict : ModuleNamesDict ) input =
244248 match input with
245- | ParsedInput.ImplFile ( ParsedImplFileInput.ParsedImplFileInput ( fileName, isScript, qualNameOfFile, scopedPragmas, hashDirectives, modules, ( isLastCompiland, isExe))) ->
249+ | ParsedInput.ImplFile ( ParsedImplFileInput.ParsedImplFileInput ( fileName, isScript, qualNameOfFile, scopedPragmas, hashDirectives, modules, ( isLastCompiland, isExe), trivia )) ->
246250 let qualNameOfFileT , moduleNamesDictT = DeduplicateModuleName moduleNamesDict fileName qualNameOfFile
247- let inputT = ParsedInput.ImplFile ( ParsedImplFileInput.ParsedImplFileInput ( fileName, isScript, qualNameOfFileT, scopedPragmas, hashDirectives, modules, ( isLastCompiland, isExe)))
251+ let inputT = ParsedInput.ImplFile ( ParsedImplFileInput.ParsedImplFileInput ( fileName, isScript, qualNameOfFileT, scopedPragmas, hashDirectives, modules, ( isLastCompiland, isExe), trivia ))
248252 inputT, moduleNamesDictT
249- | ParsedInput.SigFile ( ParsedSigFileInput.ParsedSigFileInput ( fileName, qualNameOfFile, scopedPragmas, hashDirectives, modules)) ->
253+ | ParsedInput.SigFile ( ParsedSigFileInput.ParsedSigFileInput ( fileName, qualNameOfFile, scopedPragmas, hashDirectives, modules, trivia )) ->
250254 let qualNameOfFileT , moduleNamesDictT = DeduplicateModuleName moduleNamesDict fileName qualNameOfFile
251- let inputT = ParsedInput.SigFile ( ParsedSigFileInput.ParsedSigFileInput ( fileName, qualNameOfFileT, scopedPragmas, hashDirectives, modules))
255+ let inputT = ParsedInput.SigFile ( ParsedSigFileInput.ParsedSigFileInput ( fileName, qualNameOfFileT, scopedPragmas, hashDirectives, modules, trivia ))
252256 inputT, moduleNamesDictT
253257
254258let ParseInput ( lexer , diagnosticOptions : FSharpDiagnosticOptions , errorLogger : ErrorLogger , lexbuf : UnicodeLexing.Lexbuf , defaultNamespace , filename , isLastCompiland ) =
@@ -279,11 +283,11 @@ let ParseInput (lexer, diagnosticOptions:FSharpDiagnosticOptions, errorLogger: E
279283 if FSharpImplFileSuffixes |> List.exists ( FileSystemUtils.checkSuffix lower) then
280284 let impl = Parser.implementationFile lexer lexbuf
281285 LexbufLocalXmlDocStore.ReportInvalidXmlDocPositions( lexbuf)
282- PostParseModuleImpls ( defaultNamespace, filename, isLastCompiland, impl)
286+ PostParseModuleImpls ( defaultNamespace, filename, isLastCompiland, impl, lexbuf )
283287 elif FSharpSigFileSuffixes |> List.exists ( FileSystemUtils.checkSuffix lower) then
284288 let intfs = Parser.signatureFile lexer lexbuf
285289 LexbufLocalXmlDocStore.ReportInvalidXmlDocPositions( lexbuf)
286- PostParseModuleSpecs ( defaultNamespace, filename, isLastCompiland, intfs)
290+ PostParseModuleSpecs ( defaultNamespace, filename, isLastCompiland, intfs, lexbuf )
287291 else
288292 if lexbuf.SupportsFeature LanguageFeature.MLCompatRevisions then
289293 error( Error( FSComp.SR.buildInvalidSourceFileExtensionUpdated filename, rangeStartup))
@@ -329,7 +333,7 @@ let ReportParsingStatistics res =
329333 let flattenModSpec ( SynModuleOrNamespaceSig ( _ , _ , _ , decls , _ , _ , _ , _ )) = flattenSpecs decls
330334 let flattenModImpl ( SynModuleOrNamespace ( _ , _ , _ , decls , _ , _ , _ , _ )) = flattenDefns decls
331335 match res with
332- | ParsedInput.SigFile ( ParsedSigFileInput (_, _, _, _, specs)) ->
336+ | ParsedInput.SigFile ( ParsedSigFileInput ( modules = specs)) ->
333337 printfn " parsing yielded %d specs" ( List.collect flattenModSpec specs) .Length
334338 | ParsedInput.ImplFile ( ParsedImplFileInput ( modules = impls)) ->
335339 printfn " parsing yielded %d definitions" ( List.collect flattenModImpl impls) .Length
@@ -343,7 +347,8 @@ let EmptyParsedInput(filename, isLastCompiland) =
343347 QualFileNameOfImpls filename [],
344348 [],
345349 [],
346- []
350+ [],
351+ { ConditionalDirectives = [] }
347352 )
348353 )
349354 else
@@ -355,7 +360,8 @@ let EmptyParsedInput(filename, isLastCompiland) =
355360 [],
356361 [],
357362 [],
358- isLastCompiland
363+ isLastCompiland,
364+ { ConditionalDirectives = [] }
359365 )
360366 )
361367
@@ -645,11 +651,11 @@ let ProcessMetaCommandsFromInput
645651 decls
646652
647653 match inp with
648- | ParsedInput.SigFile ( ParsedSigFileInput (_, _, _, hashDirectives, specs)) ->
654+ | ParsedInput.SigFile ( ParsedSigFileInput ( hashDirectives = hashDirectives; modules = specs)) ->
649655 let state = List.fold ProcessMetaCommand state0 hashDirectives
650656 let state = List.fold ProcessMetaCommandsFromModuleSpec state specs
651657 state
652- | ParsedInput.ImplFile ( ParsedImplFileInput (_, _, _, _, hashDirectives , impls, _ )) ->
658+ | ParsedInput.ImplFile ( ParsedImplFileInput ( hashDirectives = hashDirectives ; modules = impls)) ->
653659 let state = List.fold ProcessMetaCommand state0 hashDirectives
654660 let state = List.fold ProcessMetaCommandsFromModuleImpl state impls
655661 state
@@ -832,7 +838,7 @@ let TypeCheckOneInput(checkForErrors,
832838 let m = inp.Range
833839 let amap = tcImports.GetImportMap()
834840 match inp with
835- | ParsedInput.SigFile ( ParsedSigFileInput (_, qualNameOfFile , _, _, _ ) as file) ->
841+ | ParsedInput.SigFile ( ParsedSigFileInput ( qualifiedNameOfFile = qualNameOfFile ) as file) ->
836842
837843 // Check if we've seen this top module signature before.
838844 if Zmap.mem qualNameOfFile tcState.tcsRootSigs then
@@ -871,7 +877,7 @@ let TypeCheckOneInput(checkForErrors,
871877
872878 return ( tcEnv, EmptyTopAttrs, None, ccuSigForFile), tcState
873879
874- | ParsedInput.ImplFile ( ParsedImplFileInput (_, _, qualNameOfFile, _, _, _, _ ) as file) ->
880+ | ParsedInput.ImplFile ( ParsedImplFileInput ( qualifiedNameOfFile = qualNameOfFile) as file) ->
875881
876882 // Check if we've got an interface for this fragment
877883 let rootSigOpt = tcState.tcsRootSigs.TryFind qualNameOfFile
0 commit comments