diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 200d4f5a69e..8c09fc98531 100644 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -3376,14 +3376,14 @@ let ComputeQualifiedNameOfFileFromUniquePath (m, p: string list) = QualifiedName let QualFileNameOfSpecs filename specs = match specs with - | [SynModuleOrNamespaceSig(modname, _, true, _, _, _, _, m)] -> QualFileNameOfModuleName m filename modname - | [SynModuleOrNamespaceSig(_, _, false, _, _, _, _, m)] -> QualFileNameOfFilename m filename + | [SynModuleOrNamespaceSig(modname, _, kind, _, _, _, _, m)] when kind.IsModule -> QualFileNameOfModuleName m filename modname + | [SynModuleOrNamespaceSig(_, _, kind, _, _, _, _, m)] when not kind.IsModule -> QualFileNameOfFilename m filename | _ -> QualFileNameOfFilename (mkRange filename pos0 pos0) filename let QualFileNameOfImpls filename specs = match specs with - | [SynModuleOrNamespace(modname, _, true, _, _, _, _, m)] -> QualFileNameOfModuleName m filename modname - | [SynModuleOrNamespace(_, _, false, _, _, _, _, m)] -> QualFileNameOfFilename m filename + | [SynModuleOrNamespace(modname, _, kind, _, _, _, _, m)] when kind.IsModule -> QualFileNameOfModuleName m filename modname + | [SynModuleOrNamespace(_, _, kind, _, _, _, _, m)] when not kind.IsModule -> QualFileNameOfFilename m filename | _ -> QualFileNameOfFilename (mkRange filename pos0 pos0) filename let PrepandPathToQualFileName x (QualifiedNameOfFile(q)) = ComputeQualifiedNameOfFileFromUniquePath (q.idRange, pathOfLid x@[q.idText]) @@ -3412,13 +3412,14 @@ let ComputeAnonModuleName check defaultNamespace filename (m: range) = let PostParseModuleImpl (_i, defaultNamespace, isLastCompiland, filename, impl) = match impl with - | ParsedImplFileFragment.NamedModule(SynModuleOrNamespace(lid, isRec, isModule, decls, xmlDoc, attribs, access, m)) -> + | ParsedImplFileFragment.NamedModule(SynModuleOrNamespace(lid, isRec, kind, decls, xmlDoc, attribs, access, m)) -> let lid = match lid with - | [id] when isModule && id.idText = MangledGlobalName -> error(Error(FSComp.SR.buildInvalidModuleOrNamespaceName(), id.idRange)) + | [id] when kind.IsModule && id.idText = MangledGlobalName -> + error(Error(FSComp.SR.buildInvalidModuleOrNamespaceName(), id.idRange)) | id :: rest when id.idText = MangledGlobalName -> rest | _ -> lid - SynModuleOrNamespace(lid, isRec, isModule, decls, xmlDoc, attribs, access, m) + SynModuleOrNamespace(lid, isRec, kind, decls, xmlDoc, attribs, access, m) | ParsedImplFileFragment.AnonModule (defs, m)-> let isLast, isExe = isLastCompiland @@ -3429,24 +3430,26 @@ let PostParseModuleImpl (_i, defaultNamespace, isLastCompiland, filename, impl) | _ -> errorR(Error(FSComp.SR.buildMultiFileRequiresNamespaceOrModule(), trimRangeToLine m)) let modname = ComputeAnonModuleName (not (isNil defs)) defaultNamespace filename (trimRangeToLine m) - SynModuleOrNamespace(modname, false, true, defs, PreXmlDoc.Empty, [], None, m) + SynModuleOrNamespace(modname, false, AnonModule, defs, PreXmlDoc.Empty, [], None, m) - | ParsedImplFileFragment.NamespaceFragment (lid, a, b, c, d, e, m)-> - let lid = + | ParsedImplFileFragment.NamespaceFragment (lid, a, kind, c, d, e, m)-> + let lid, kind = match lid with - | id :: rest when id.idText = MangledGlobalName -> rest - | _ -> lid - SynModuleOrNamespace(lid, a, b, c, d, e, None, m) + | id :: rest when id.idText = MangledGlobalName -> + rest, if List.isEmpty rest then GlobalNamespace else kind + | _ -> lid, kind + SynModuleOrNamespace(lid, a, kind, c, d, e, None, m) let PostParseModuleSpec (_i, defaultNamespace, isLastCompiland, filename, intf) = match intf with - | ParsedSigFileFragment.NamedModule(SynModuleOrNamespaceSig(lid, isRec, isModule, decls, xmlDoc, attribs, access, m)) -> + | ParsedSigFileFragment.NamedModule(SynModuleOrNamespaceSig(lid, isRec, kind, decls, xmlDoc, attribs, access, m)) -> let lid = match lid with - | [id] when isModule && id.idText = MangledGlobalName -> error(Error(FSComp.SR.buildInvalidModuleOrNamespaceName(), id.idRange)) + | [id] when kind.IsModule && id.idText = MangledGlobalName -> + error(Error(FSComp.SR.buildInvalidModuleOrNamespaceName(), id.idRange)) | id :: rest when id.idText = MangledGlobalName -> rest | _ -> lid - SynModuleOrNamespaceSig(lid, isRec, isModule, decls, xmlDoc, attribs, access, m) + SynModuleOrNamespaceSig(lid, isRec, NamedModule, decls, xmlDoc, attribs, access, m) | ParsedSigFileFragment.AnonModule (defs, m) -> let isLast, isExe = isLastCompiland @@ -3457,14 +3460,15 @@ let PostParseModuleSpec (_i, defaultNamespace, isLastCompiland, filename, intf) | _ -> errorR(Error(FSComp.SR.buildMultiFileRequiresNamespaceOrModule(), m)) let modname = ComputeAnonModuleName (not (isNil defs)) defaultNamespace filename (trimRangeToLine m) - SynModuleOrNamespaceSig(modname, false, true, defs, PreXmlDoc.Empty, [], None, m) + SynModuleOrNamespaceSig(modname, false, AnonModule, defs, PreXmlDoc.Empty, [], None, m) - | ParsedSigFileFragment.NamespaceFragment (lid, a, b, c, d, e, m)-> - let lid = + | ParsedSigFileFragment.NamespaceFragment (lid, a, kind, c, d, e, m)-> + let lid, kind = match lid with - | id :: rest when id.idText = MangledGlobalName -> rest - | _ -> lid - SynModuleOrNamespaceSig(lid, a, b, c, d, e, None, m) + | id :: rest when id.idText = MangledGlobalName -> + rest, if List.isEmpty rest then GlobalNamespace else kind + | _ -> lid, kind + SynModuleOrNamespaceSig(lid, a, kind, c, d, e, None, m) diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index 495e0d4c470..c55cd9e63b4 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -16713,7 +16713,7 @@ let rec TcSignatureElementNonMutRec cenv parent typeNames endm (env: TcEnv) synS return env - | SynModuleSigDecl.NamespaceFragment (SynModuleOrNamespaceSig(longId, isRec, isModule, defs, xml, attribs, vis, m)) -> + | SynModuleSigDecl.NamespaceFragment (SynModuleOrNamespaceSig(longId, isRec, kind, defs, xml, attribs, vis, m)) -> do for id in longId do CheckNamespaceModuleOrTypeName cenv.g id @@ -16725,7 +16725,7 @@ let rec TcSignatureElementNonMutRec cenv parent typeNames endm (env: TcEnv) synS // namespace [rec] A.B // module M = ... let enclosingNamespacePath, defs = - if isModule then + if kind.IsModule then let nsp, modName = List.frontAndBack longId let modDecl = [SynModuleSigDecl.NestedModule(ComponentInfo(attribs, [], [], [modName], xml, false, vis, m), false, defs, m)] nsp, modDecl @@ -17022,7 +17022,7 @@ let rec TcModuleOrNamespaceElementNonMutRec (cenv:cenv) parent typeNames scopem return ((fun modDefs -> modDefn :: modDefs), topAttrsNew), env, envAtEnd - | SynModuleDecl.NamespaceFragment(SynModuleOrNamespace(longId, isRec, isModule, defs, xml, attribs, vis, m)) -> + | SynModuleDecl.NamespaceFragment(SynModuleOrNamespace(longId, isRec, kind, defs, xml, attribs, vis, m)) -> if !progress then dprintn ("Typecheck implementation " + textOfLid longId) let endm = m.EndRange @@ -17037,7 +17037,7 @@ let rec TcModuleOrNamespaceElementNonMutRec (cenv:cenv) parent typeNames scopem // namespace [rec] A.B // module M = ... let enclosingNamespacePath, defs = - if isModule then + if kind.IsModule then let nsp, modName = List.frontAndBack longId let modDecl = [SynModuleDecl.NestedModule(ComponentInfo(attribs, [], [], [modName], xml, false, vis, m), false, defs, true, m)] nsp, modDecl diff --git a/src/fsharp/ast.fs b/src/fsharp/ast.fs index f7fbbdd6491..43b7aab87d1 100644 --- a/src/fsharp/ast.fs +++ b/src/fsharp/ast.fs @@ -1462,11 +1462,23 @@ and and SynModuleSigDecls = SynModuleSigDecl list -/// SynModuleOrNamespace(lid,isRec,isModule,decls,xmlDoc,attribs,SynAccess,m) +and + [] + SynModuleOrNamespaceKind = + | NamedModule + | AnonModule + | DeclaredNamespace + | GlobalNamespace + + member x.IsModule = + match x with + | NamedModule | AnonModule -> true + | _ -> false + and [] SynModuleOrNamespace = - | SynModuleOrNamespace of longId:LongIdent * isRecursive:bool * isModule:bool * decls:SynModuleDecls * xmlDoc:PreXmlDoc * attribs:SynAttributes * accessibility:SynAccess option * range:range + | SynModuleOrNamespace of longId:LongIdent * isRecursive:bool * kind:SynModuleOrNamespaceKind * decls:SynModuleDecls * xmlDoc:PreXmlDoc * attribs:SynAttributes * accessibility:SynAccess option * range:range member this.Range = match this with | SynModuleOrNamespace (range=m) -> m @@ -1474,7 +1486,7 @@ and and [] SynModuleOrNamespaceSig = - | SynModuleOrNamespaceSig of longId:LongIdent * isRecursive:bool * isModule:bool * SynModuleSigDecls * xmlDoc:PreXmlDoc * attribs:SynAttributes * accessibility:SynAccess option * range:range + | SynModuleOrNamespaceSig of longId:LongIdent * isRecursive:bool * kind:SynModuleOrNamespaceKind * SynModuleSigDecls * xmlDoc:PreXmlDoc * attribs:SynAttributes * accessibility:SynAccess option * range:range and [] ParsedHashDirective = @@ -1484,13 +1496,13 @@ and [] type ParsedImplFileFragment = | AnonModule of SynModuleDecls * range:range | NamedModule of SynModuleOrNamespace - | NamespaceFragment of longId:LongIdent * bool * bool * SynModuleDecls * xmlDoc:PreXmlDoc * SynAttributes * range:range + | NamespaceFragment of longId:LongIdent * bool * SynModuleOrNamespaceKind * SynModuleDecls * xmlDoc:PreXmlDoc * SynAttributes * range:range [] type ParsedSigFileFragment = | AnonModule of SynModuleSigDecls * range:range | NamedModule of SynModuleOrNamespaceSig - | NamespaceFragment of longId:LongIdent * bool * bool * SynModuleSigDecls * xmlDoc:PreXmlDoc * SynAttributes * range:range + | NamespaceFragment of longId:LongIdent * bool * SynModuleOrNamespaceKind * SynModuleSigDecls * xmlDoc:PreXmlDoc * SynAttributes * range:range [] type ParsedFsiInteraction = diff --git a/src/fsharp/fsi/fsi.fs b/src/fsharp/fsi/fsi.fs index b2df5102032..8190be40784 100644 --- a/src/fsharp/fsi/fsi.fs +++ b/src/fsharp/fsi/fsi.fs @@ -1154,7 +1154,7 @@ type internal FsiDynamicCompiler let i = nextFragmentId() let prefix = mkFragmentPath i let prefixPath = pathOfLid prefix - let impl = SynModuleOrNamespace(prefix,(*isRec*)false, (* isModule: *) true,defs,PreXmlDoc.Empty,[],None,rangeStdin) + let impl = SynModuleOrNamespace(prefix,(*isRec*)false, NamedModule,defs,PreXmlDoc.Empty,[],None,rangeStdin) let input = ParsedInput.ImplFile(ParsedImplFileInput(filename,true, ComputeQualifiedNameOfFileFromUniquePath (rangeStdin,prefixPath),[],[],[impl],(true (* isLastCompiland *), false (* isExe *)) )) let istate,tcEnvAtEndOfLastInput,declaredImpls = ProcessInputs (ctok, errorLogger, istate, [input], showTypes, true, isInteractiveItExpr, prefix) let tcState = istate.tcState diff --git a/src/fsharp/pars.fsy b/src/fsharp/pars.fsy index 9e75787d29f..25c8ce10a8c 100644 --- a/src/fsharp/pars.fsy +++ b/src/fsharp/pars.fsy @@ -675,14 +675,14 @@ fileModuleSpec: (fun (isRec2,path,_) -> if not (isNil path) then errorR(Error(FSComp.SR.parsNamespaceOrModuleNotBoth(),m2)) let lid = path@path2 - ParsedSigFileFragment.NamedModule(SynModuleOrNamespaceSig(lid, (isRec || isRec2), true, $4, xml,$1,vis,m))) } + ParsedSigFileFragment.NamedModule(SynModuleOrNamespaceSig(lid, (isRec || isRec2), NamedModule, $4, xml,$1,vis,m))) } | moduleSpfnsPossiblyEmptyBlock { let m = (rhs parseState 1) (fun (isRec, path, xml) -> match path with | [] -> ParsedSigFileFragment.AnonModule($1, m) - | _ -> ParsedSigFileFragment.NamespaceFragment(path, isRec, false, $1, xml,[],m)) } + | _ -> ParsedSigFileFragment.NamespaceFragment(path, isRec, DeclaredNamespace, $1, xml,[],m)) } moduleSpfnsPossiblyEmptyBlock: @@ -1097,14 +1097,14 @@ fileModuleImpl: (fun (isRec, path, _) -> if not (isNil path) then errorR(Error(FSComp.SR.parsNamespaceOrModuleNotBoth(),m2)) let lid = path@path2 - ParsedImplFileFragment.NamedModule(SynModuleOrNamespace(lid, (isRec || isRec2), true, $4, xml,$1,vis,m))) } + ParsedImplFileFragment.NamedModule(SynModuleOrNamespace(lid, (isRec || isRec2), NamedModule, $4, xml,$1,vis,m))) } | moduleDefnsOrExprPossiblyEmptyOrBlock { let m = (rhs parseState 1) (fun (isRec, path, xml) -> match path with | [] -> ParsedImplFileFragment.AnonModule($1,m) - | _ -> ParsedImplFileFragment.NamespaceFragment(path, isRec, false, $1, xml,[],m)) } + | _ -> ParsedImplFileFragment.NamespaceFragment(path, isRec, DeclaredNamespace, $1, xml,[],m)) } /* A collection/block of definitions or expressions making up a module or namespace, possibly empty */ diff --git a/src/fsharp/service/ServiceAssemblyContent.fs b/src/fsharp/service/ServiceAssemblyContent.fs index b85396c26e7..663ed82a941 100644 --- a/src/fsharp/service/ServiceAssemblyContent.fs +++ b/src/fsharp/service/ServiceAssemblyContent.fs @@ -914,8 +914,9 @@ module ParsedInput = let rec walkImplFileInput (ParsedImplFileInput(modules = moduleOrNamespaceList)) = List.iter (walkSynModuleOrNamespace []) moduleOrNamespaceList - and walkSynModuleOrNamespace (parent: LongIdent) (SynModuleOrNamespace(ident, _, isModule, decls, _, _, _, range)) = + and walkSynModuleOrNamespace (parent: LongIdent) (SynModuleOrNamespace(ident, _, kind, decls, _, _, _, range)) = if range.EndLine >= currentLine then + let isModule = kind.IsModule match isModule, parent, ident with | false, _, _ -> ns := Some (longIdentToIdents ident) // top level module with "inlined" namespace like Ns1.Ns2.TopModule diff --git a/src/fsharp/service/ServiceNavigation.fs b/src/fsharp/service/ServiceNavigation.fs index 24d83f532bd..e0e1feb1b32 100755 --- a/src/fsharp/service/ServiceNavigation.fs +++ b/src/fsharp/service/ServiceNavigation.fs @@ -270,7 +270,7 @@ module NavigationImpl = let items = // Show base name for this module only if it's not the root one let singleTopLevel = (modules.Length = 1) - modules |> List.collect (fun (SynModuleOrNamespace(id, _isRec, isModule, decls, _, _, access, m)) -> + modules |> List.collect (fun (SynModuleOrNamespace(id, _isRec, kind, decls, _, _, access, m)) -> let baseName = if (not singleTopLevel) then textOfLid id else "" // Find let bindings (for the right dropdown) let nested = processNestedDeclarations(decls) @@ -283,7 +283,7 @@ module NavigationImpl = | _ -> let decl = FSharpNavigationDeclarationItem.Create - (textOfLid id, (if isModule then ModuleFileDecl else NamespaceDecl), + (textOfLid id, (if kind.IsModule then ModuleFileDecl else NamespaceDecl), FSharpGlyph.Module, m, unionRangesChecked (rangeOfDecls nested) (moduleRange (rangeOfLid id) other), singleTopLevel, FSharpEnclosingEntityKind.Module, false, access), (addItemName(textOfLid id)), nested @@ -410,7 +410,7 @@ module NavigationImpl = let items = // Show base name for this module only if it's not the root one let singleTopLevel = (modules.Length = 1) - modules |> List.collect (fun (SynModuleOrNamespaceSig(id, _isRec, isModule, decls, _, _, access, m)) -> + modules |> List.collect (fun (SynModuleOrNamespaceSig(id, _isRec, kind, decls, _, _, access, m)) -> let baseName = if (not singleTopLevel) then textOfLid id else "" // Find let bindings (for the right dropdown) let nested = processNestedSigDeclarations(decls) @@ -420,7 +420,7 @@ module NavigationImpl = // Create explicitly - it can be 'single top level' thing that is hidden let decl = FSharpNavigationDeclarationItem.Create - (textOfLid id, (if isModule then ModuleFileDecl else NamespaceDecl), + (textOfLid id, (if kind.IsModule then ModuleFileDecl else NamespaceDecl), FSharpGlyph.Module, m, unionRangesChecked (rangeOfDecls nested) (moduleRange (rangeOfLid id) other), singleTopLevel, FSharpEnclosingEntityKind.Module, false, access), (addItemName(textOfLid id)), nested @@ -574,7 +574,8 @@ module NavigateTo = for item in moduleOrNamespaceList do walkSynModuleOrNamespaceSig item { Type = ContainerType.File; Name = fileName } - and walkSynModuleOrNamespaceSig (SynModuleOrNamespaceSig(lid, _, isModule, decls, _, _, _, _)) container = + and walkSynModuleOrNamespaceSig (SynModuleOrNamespaceSig(lid, _, kind, decls, _, _, _, _)) container = + let isModule = kind.IsModule if isModule then addModule lid true container let container = @@ -631,7 +632,8 @@ module NavigateTo = for item in moduleOrNamespaceList do walkSynModuleOrNamespace item container - and walkSynModuleOrNamespace(SynModuleOrNamespace(lid, _, isModule, decls, _, _, _, _)) container = + and walkSynModuleOrNamespace(SynModuleOrNamespace(lid, _, kind, decls, _, _, _, _)) container = + let isModule = kind.IsModule if isModule then addModule lid false container let container = diff --git a/src/fsharp/service/ServiceStructure.fs b/src/fsharp/service/ServiceStructure.fs index f225c87b6d0..a89afd44c54 100644 --- a/src/fsharp/service/ServiceStructure.fs +++ b/src/fsharp/service/ServiceStructure.fs @@ -610,14 +610,14 @@ module Structure = parseAttributes attrs | _ -> () - let parseModuleOrNamespace isScript (SynModuleOrNamespace (longId,_,isModule,decls,_,attribs,_,r)) = + let parseModuleOrNamespace (SynModuleOrNamespace (longId,_,kind,decls,_,attribs,_,r)) = parseAttributes attribs let idRange = longIdentRange longId let fullrange = Range.startToEnd idRange r let collapse = Range.endToEnd idRange r // do not return range for top level implicit module in scripts - if isModule && not isScript then + if kind = NamedModule then rcheck Scope.Module Collapse.Below fullrange collapse collectHashDirectives decls @@ -833,14 +833,14 @@ module Structure = List.iter parseModuleSigDeclaration decls | _ -> () - let parseModuleOrNamespaceSigs (SynModuleOrNamespaceSig(longId,_,isModule,decls,_,attribs,_,r)) = + let parseModuleOrNamespaceSigs (SynModuleOrNamespaceSig(longId,_,kind,decls,_,attribs,_,r)) = parseAttributes attribs let rangeEnd = lastModuleSigDeclRangeElse r decls let idrange = longIdentRange longId let fullrange = Range.startToEnd idrange rangeEnd let collapse = Range.endToEnd idrange rangeEnd - if isModule then + if kind.IsModule then rcheck Scope.Module Collapse.Below fullrange collapse collectSigHashDirectives decls @@ -848,8 +848,8 @@ module Structure = List.iter parseModuleSigDeclaration decls match parsedInput with - | ParsedInput.ImplFile (ParsedImplFileInput (modules = modules; isScript = isScript)) -> - modules |> List.iter (parseModuleOrNamespace isScript) + | ParsedInput.ImplFile (ParsedImplFileInput (modules = modules)) -> + modules |> List.iter parseModuleOrNamespace getCommentRanges sourceLines | ParsedInput.SigFile (ParsedSigFileInput (modules = moduleSigs)) -> List.iter parseModuleOrNamespaceSigs moduleSigs diff --git a/tests/service/StructureTests.fs b/tests/service/StructureTests.fs index d87c3c18e78..83f518f276f 100644 --- a/tests/service/StructureTests.fs +++ b/tests/service/StructureTests.fs @@ -60,7 +60,7 @@ let (=>) (source: string) (expectedRanges: (Range * Range) list) = reraise() [] -let ``empty file``() = "" => [ (1, 0, 2, 0), (1, 0, 2, 0) ] +let ``empty file``() = "" => [] [] let ``nested module``() = @@ -68,8 +68,7 @@ let ``nested module``() = module MyModule = () """ - => [ (1, 0, 4, 0), (1, 0, 4, 0) - (2, 0, 3, 6), (2, 15, 3, 6) ] + => [ (2, 0, 3, 6), (2, 15, 3, 6) ] [] let ``module with multiline function``() = @@ -78,8 +77,7 @@ module MyModule = let foo() = foo() """ - => [ (1, 0, 5, 0), (1, 0, 5, 0) - (2, 0, 4, 13), (2, 15, 4, 13) + => [ (2, 0, 4, 13), (2, 15, 4, 13) (3, 4, 4, 13), (3, 13, 4, 13) (3, 8, 4, 13), (3, 13, 4, 13) ] @@ -91,8 +89,7 @@ type Color = | Green | Blue """ - => [ (1, 0, 6, 0), (1, 0, 6, 0) - (2, 5, 5, 10), (2, 11, 5, 10) + => [ (2, 5, 5, 10), (2, 11, 5, 10) (3, 4, 5, 10), (3, 4, 5, 10) ] [] @@ -107,8 +104,7 @@ type Color = member __.Dispose() = (docEventListener :> IDisposable).Dispose() """ - => [ (1, 0, 10, 0), (1, 0, 10, 0) - (2, 5, 9, 55), (2, 11, 9, 55) + => [ (2, 5, 9, 55), (2, 11, 9, 55) (3, 4, 5, 10), (3, 4, 5, 10) (7, 4, 9, 55), (7, 25, 9, 55) (8, 15, 9, 55), (8, 27, 9, 55) @@ -128,8 +124,7 @@ type Color = (docEventListener :> IDisposable).Dispose() """ => - [ (1, 0, 11, 0), (1, 0, 11, 0) - (2, 5, 10, 55), (2, 11, 10, 55) + [ (2, 5, 10, 55), (2, 11, 10, 55) (3, 4, 4, 14), (3, 4, 4, 14) (3, 6, 4, 13), (3, 6, 4, 13) (8, 4, 10, 55), (8, 25, 10, 55) @@ -147,8 +142,7 @@ type Color() = // 2 foo() () // 8 """ - => [ (1, 0, 9, 0), (1, 0, 9, 0) - (2, 5, 8, 10), (2, 11, 8, 10) + => [ (2, 5, 8, 10), (2, 11, 8, 10) (3, 8, 4, 10), (3, 13, 4, 10) (6, 4, 8, 10), (6, 6, 8, 10) ] @@ -182,8 +176,7 @@ module MyModule = // 2 member __.Dispose() = (docEventListener :> IDisposable).Dispose() """ - => [ (1, 0, 28, 0), (1, 0, 28, 0) - (2, 0, 27, 63), (2, 15, 27, 63) + => [ (2, 0, 27, 63), (2, 15, 27, 63) (4, 4, 5, 10), (4, 13, 5, 10) (4, 8, 5, 10), (4, 13, 5, 10) (7, 9, 15, 59), (7, 15, 15, 59) @@ -228,8 +221,7 @@ open H open G open H """ - => [ (1, 0, 26, 6), (1, 0, 26, 6) - (2, 5, 3, 6), (2, 5, 3, 6) + => [ (2, 5, 3, 6), (2, 5, 3, 6) (5, 0, 19, 17), (5, 8, 19, 17) (8, 9, 9, 10), (8, 9, 9, 10) (11, 4, 14, 17), (11, 12, 14, 17) @@ -263,8 +255,7 @@ let x = 1 "c" #r "d" """ - => [ (1, 0, 23, 6), (1, 0, 23, 6) - (2, 3, 8, 6), (2, 3, 8, 6) + => [ (2, 3, 8, 6), (2, 3, 8, 6) (11, 3, 23, 6), (11, 3, 23, 6) ] [] @@ -277,8 +268,7 @@ let f x = // 2 () // 6 x // 7 """ - => [ (1, 0, 8, 0), (1, 0, 8, 0) - (2, 0, 7, 5), (2, 7, 7, 5) + => [ (2, 0, 7, 5), (2, 7, 7, 5) (2, 4, 7, 5), (2, 7, 7, 5) (3, 8, 6, 10), (3, 11, 6, 10) (4, 12, 5, 14), (4, 13, 5, 14) ] @@ -296,8 +286,7 @@ match None with // 2 let x = () // 9 () // 10 """ - => [ (1, 0, 11, 0), (1, 0, 11, 0) - (2, 0, 10, 10), (2, 15, 10, 10) + => [ (2, 0, 10, 10), (2, 15, 10, 10) (6, 4, 10, 10), (5, 6, 10, 10) (6, 4, 10, 10), (6, 19, 10, 10) (9, 8, 10, 10), (8, 10, 10, 10) ] @@ -317,8 +306,7 @@ async { // 2 () // 11 } // 12 """ - => [ (1, 0, 12, 1), (1, 0, 12, 1) - (2, 0, 12, 1), (2, 7, 12, 0) + => [ (2, 0, 12, 1), (2, 7, 12, 0) (3, 4, 11, 14), (3, 37, 11, 14) (7, 8, 11, 14), (6, 10, 11, 14) (7, 8, 11, 14), (7, 23, 11, 14) @@ -335,8 +323,7 @@ seq { // 2 yield () } // 7 } // 8 """ - => [ (1, 0, 8, 1), (1, 0, 8, 1) - (2, 0, 8, 1), (2, 5, 8, 0) + => [ (2, 0, 8, 1), (2, 5, 8, 0) (4, 8, 5, 10), (4, 11, 5, 10) (6, 4, 7, 18), (6, 4, 7, 18) (6, 11, 7, 18), (6, 16, 7, 17) ] @@ -348,8 +335,7 @@ let _ = [ 1; 2 3 ] """ - => [ (1, 0, 5, 0), (1, 0, 5, 0) - (2, 0, 4, 9), (2, 5, 4, 9) + => [ (2, 0, 4, 9), (2, 5, 4, 9) (2, 4, 4, 9), (2, 5, 4, 9) (3, 4, 4, 9), (3, 5, 4, 8) ] @@ -360,8 +346,7 @@ let _ = { new System.IDisposable with member __.Dispose() = () } """ - => [ (1, 0, 5, 0), (1, 0, 5, 0) - (2, 0, 4, 34), (2, 5, 4, 34) + => [ (2, 0, 4, 34), (2, 5, 4, 34) (2, 4, 4, 34), (2, 5, 4, 34) (3, 4, 4, 34), (3, 28, 4, 34) ] @@ -376,8 +361,7 @@ with _ -> // 5 () // 7 () // 8 """ - => [ (1, 0, 9, 0), (1, 0, 9, 0) - (2, 0, 5, 0), (2, 3, 5, 0) + => [ (2, 0, 5, 0), (2, 3, 5, 0) (2, 0, 8, 6), (2, 3, 8, 6) (3, 8, 4, 10), (3, 11, 4, 10) (5, 0, 8, 6), (5, 4, 8, 6) @@ -395,8 +379,7 @@ finally // 5 () // 7 () // 8 """ - => [ (1, 0, 9, 0), (1, 0, 9, 0) - (2, 0, 8, 6), (2, 3, 8, 6) + => [ (2, 0, 8, 6), (2, 3, 8, 6) (3, 8, 4, 10), (3, 11, 4, 10) (5, 0, 8, 6), (5, 7, 8, 6) (6, 8, 7, 10), (6, 11, 7, 10) ] @@ -413,8 +396,7 @@ else () () """ - => [ (1, 0, 10, 0), (1, 0, 10, 0) - (2, 0, 9, 6), (2, 7, 9, 6) + => [ (2, 0, 9, 6), (2, 7, 9, 6) (2, 8, 5, 6), (2, 12, 5, 6) (3, 8, 4, 10), (3, 11, 4, 10) (7, 8, 8, 10), (7, 11, 8, 10) ] @@ -426,8 +408,7 @@ let ``code quotation``() = "code" @> """ - => [ (1, 0, 4, 10), (1, 0, 4, 10) - (2, 0, 4, 10), (2, 2, 4, 8) ] + => [ (2, 0, 4, 10), (2, 2, 4, 8) ] [] let ``raw code quotation``() = @@ -436,8 +417,7 @@ let ``raw code quotation``() = "code" @@> """ - => [ (1, 0, 4, 11), (1, 0, 4, 11) - (2, 0, 4, 11), (2, 3, 4, 8) ] + => [ (2, 0, 4, 11), (2, 3, 4, 8) ] [] let ``match lambda aka function``() = @@ -446,8 +426,7 @@ function | 0 -> () () """ - => [ (1, 0, 5, 0), (1, 0, 5, 0) - (2, 0, 4, 10), (2, 8, 4, 10) + => [ (2, 0, 4, 10), (2, 8, 4, 10) (3, 8, 4, 10), (3, 3, 4, 10) ] [] @@ -458,8 +437,7 @@ let matchwith num = | 0 -> () () """ - => [ (1, 0, 6, 0), (1, 0, 6, 0) - (2, 0, 5, 13), (2, 17, 5, 13) + => [ (2, 0, 5, 13), (2, 17, 5, 13) (2, 4, 5, 13), (2, 17, 5, 13) (3, 4, 5, 13), (3, 18, 5, 13) (4, 11, 5, 13), (4, 7, 5, 13) ] @@ -471,8 +449,7 @@ for x = 100 downto 10 do () () """ - => [ (1, 0, 5, 0), (1, 0, 5, 0) - (2, 0, 4, 6), (2, 0, 4, 6) ] + => [ (2, 0, 4, 6), (2, 0, 4, 6) ] [] let ``for each``() = @@ -481,8 +458,7 @@ for x in 0 .. 100 -> () () """ - => [ (1, 0, 5, 0), (1, 0, 5, 0) - (2, 0, 4, 14), (2, 0, 4, 14) + => [ (2, 0, 4, 14), (2, 0, 4, 14) (2, 18, 4, 14), (2, 18, 4, 14) ] [] @@ -492,8 +468,7 @@ let ``tuple``() = , 322 , 123123 ) """ - => [ (1, 0, 4, 10), (1, 0, 4, 10) - (2, 2, 4, 8), (2, 2, 4, 8) ] + => [ (2, 2, 4, 8), (2, 2, 4, 8) ] [] let ``do!``() = @@ -502,8 +477,7 @@ do! printfn "allo" printfn "allo" """ - => [(1, 0, 5, 0), (1, 0, 5, 0) - (2, 0, 4, 18), (2, 3, 4, 18)] + => [ (2, 0, 4, 18), (2, 3, 4, 18) ] [] let ``cexpr yield yield!``() = @@ -517,11 +491,10 @@ cexpr{ } } """ - => [(1, 0, 9, 5), (1, 0, 9, 5) - (2, 0, 9, 5), (2, 6, 9, 4) - (3, 4, 8, 17), (3, 4, 8, 17) - (4, 8, 8, 17), (4, 14, 8, 16) - (5, 20, 7, 26), (5, 20, 7, 26)] + => [ (2, 0, 9, 5), (2, 6, 9, 4) + (3, 4, 8, 17), (3, 4, 8, 17) + (4, 8, 8, 17), (4, 14, 8, 16) + (5, 20, 7, 26), (5, 20, 7, 26) ] [] let ``XML doc comments``() = @@ -539,8 +512,7 @@ module M = /// Single line comment let f x = x """ - => [ (1, 0, 14, 0), (1, 0, 14, 0) - (2, 0, 3, 10), (2, 0, 3, 10) + => [ (2, 0, 3, 10), (2, 0, 3, 10) (4, 0, 13, 15), (4, 8, 13, 15) (5, 4, 6, 14), (5, 4, 6, 14) (7, 9, 11, 19), (7, 11, 11, 19) @@ -562,8 +534,7 @@ module M = // Single line comment let f x = x """ - => [ (1, 0, 14, 0), (1, 0, 14, 0) - (2, 0, 3, 9), (2, 0, 3, 9) + => [ (2, 0, 3, 9), (2, 0, 3, 9) (4, 0, 13, 15), (4, 8, 13, 15) (5, 4, 6, 13), (5, 4, 6, 13) (7, 9, 11, 19), (7, 11, 11, 19) @@ -582,8 +553,7 @@ let ``XML doc and regular comments in one block``() = /// Line 8 /// Line 9 """ - => [ (1, 0, 11, 0), (1, 0, 11, 0) - (2, 0, 3, 9), (2, 0, 3, 9) + => [ (2, 0, 3, 9), (2, 0, 3, 9) (4, 0, 5, 10), (4, 0, 5, 10) (7, 0, 10, 10), (7, 0, 10, 10) ] @@ -596,9 +566,45 @@ module M = 'c', 1) """ - => [ (1, 0, 7, 0), (1, 0, 7, 0) - (2, 0, 6, 14), (2, 8, 6, 14) + => [ (2, 0, 6, 14), (2, 8, 6, 14) (3, 4, 6, 14), (3, 9, 6, 14) (3, 8, 6, 14), (3, 9, 6, 14) (4, 8, 6, 14), (4, 25, 6, 14) (5, 12, 6, 13), (5, 12, 6, 13) ] + +[] +let ``Top level module`` () = + """ +module TopLevelModule + +module Nested = + let x = 123 +""" + => [ (2, 7, 5, 15), (2, 21, 5, 15) + (4, 0, 5, 15), (4, 13, 5, 15) ] + +[] +let ``Top level namespace`` () = + """ +namespace TopLevelNamespace.Another + +module Nested = + let x = 123 +""" + => [ (4, 0, 5, 15), (4, 13, 5, 15) ] + +[] +let ``Multiple namespaces`` () = + """ +namespace TopLevelNamespace.Another + +module Nested = + let x = 123 + +namespace AnotherTopLevel.Nested + +module NestedModule = + let x = 123 +""" + => [ (4, 0, 5, 15), (4, 13, 5, 15) + (9, 0, 10, 15), (9, 19, 10, 15) ]