未验证 提交 d307f8d5 编写于 作者: F Florian Verdonck 提交者: GitHub

Add trivia for SynModuleOrNamespace. (#13085)

上级 7b53294b
......@@ -5247,7 +5247,7 @@ let rec TcSignatureElementNonMutRec (cenv: cenv) parent typeNames endm (env: TcE
return env
| SynModuleSigDecl.NamespaceFragment (SynModuleOrNamespaceSig(longId, isRec, kind, defs, xml, attribs, vis, m)) ->
| SynModuleSigDecl.NamespaceFragment (SynModuleOrNamespaceSig(longId, isRec, kind, defs, xml, attribs, vis, m, _)) ->
do for id in longId do
CheckNamespaceModuleOrTypeName g id
......@@ -5560,7 +5560,7 @@ let rec TcModuleOrNamespaceElementNonMutRec (cenv: cenv) parent typeNames scopem
return ((fun modDefs -> modDefn :: modDefs), topAttrsNew), env, envAtEnd
| SynModuleDecl.NamespaceFragment(SynModuleOrNamespace(longId, isRec, kind, 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
......
......@@ -60,24 +60,24 @@ let ComputeQualifiedNameOfFileFromUniquePath (m, p: string list) =
let QualFileNameOfSpecs filename specs =
match specs with
| [SynModuleOrNamespaceSig(modname, _, kind, _, _, _, _, m)] when kind.IsModule -> QualFileNameOfModuleName m filename modname
| [SynModuleOrNamespaceSig(_, _, kind, _, _, _, _, m)] when not kind.IsModule -> QualFileNameOfFilename m filename
| [SynModuleOrNamespaceSig(longId = modname; kind = kind; range = m)] when kind.IsModule -> QualFileNameOfModuleName m filename modname
| [SynModuleOrNamespaceSig(kind = kind; range = m)] when not kind.IsModule -> QualFileNameOfFilename m filename
| _ -> QualFileNameOfFilename (mkRange filename pos0 pos0) filename
let QualFileNameOfImpls filename specs =
match specs with
| [SynModuleOrNamespace(modname, _, kind, _, _, _, _, m)] when kind.IsModule -> QualFileNameOfModuleName m filename modname
| [SynModuleOrNamespace(_, _, kind, _, _, _, _, m)] when not kind.IsModule -> QualFileNameOfFilename m filename
| [SynModuleOrNamespace(longId = modname; kind = kind; range = m)] when kind.IsModule -> QualFileNameOfModuleName m filename modname
| [SynModuleOrNamespace(kind = kind; range = m)] when not kind.IsModule -> QualFileNameOfFilename m filename
| _ -> QualFileNameOfFilename (mkRange filename pos0 pos0) filename
let PrependPathToQualFileName x (QualifiedNameOfFile q) =
ComputeQualifiedNameOfFileFromUniquePath (q.idRange, pathOfLid x@[q.idText])
let PrependPathToImpl x (SynModuleOrNamespace(p, b, c, d, e, f, g, h)) =
SynModuleOrNamespace(x@p, b, c, d, e, f, g, h)
let PrependPathToImpl x (SynModuleOrNamespace(longId, isRecursive, kind, decls, xmlDoc, attribs, accessibility, range, trivia)) =
SynModuleOrNamespace(x@longId, isRecursive, kind, decls, xmlDoc, attribs, accessibility, range, trivia)
let PrependPathToSpec x (SynModuleOrNamespaceSig(p, b, c, d, e, f, g, h)) =
SynModuleOrNamespaceSig(x@p, b, c, d, e, f, g, h)
let PrependPathToSpec x (SynModuleOrNamespaceSig(longId, isRecursive, kind, decls, xmlDoc, attribs, accessibility, range, trivia)) =
SynModuleOrNamespaceSig(x@longId, isRecursive, kind, decls, xmlDoc, attribs, accessibility, range, trivia)
let PrependPathToInput x inp =
match inp with
......@@ -104,14 +104,14 @@ let ComputeAnonModuleName check defaultNamespace filename (m: range) =
let PostParseModuleImpl (_i, defaultNamespace, isLastCompiland, filename, impl) =
match impl with
| ParsedImplFileFragment.NamedModule(SynModuleOrNamespace(lid, isRec, kind, decls, xmlDoc, attribs, access, m)) ->
| ParsedImplFileFragment.NamedModule(SynModuleOrNamespace(lid, isRec, kind, decls, xmlDoc, attribs, access, m, trivia)) ->
let lid =
match lid with
| [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, kind, decls, xmlDoc, attribs, access, m)
SynModuleOrNamespace(lid, isRec, kind, decls, xmlDoc, attribs, access, m, trivia)
| ParsedImplFileFragment.AnonModule (defs, m)->
let isLast, isExe = isLastCompiland
......@@ -121,26 +121,27 @@ 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, SynModuleOrNamespaceKind.AnonModule, defs, PreXmlDoc.Empty, [], None, m)
let trivia: SynModuleOrNamespaceTrivia = { ModuleKeyword = None; NamespaceKeyword = None }
SynModuleOrNamespace(modname, false, SynModuleOrNamespaceKind.AnonModule, defs, PreXmlDoc.Empty, [], None, m, trivia)
| ParsedImplFileFragment.NamespaceFragment (lid, a, kind, c, d, e, m)->
| ParsedImplFileFragment.NamespaceFragment (lid, isRecursive, kind, decls, xmlDoc, attributes, range, trivia)->
let lid, kind =
match lid with
| id :: rest when id.idText = MangledGlobalName ->
rest, if List.isEmpty rest then SynModuleOrNamespaceKind.GlobalNamespace else kind
| _ -> lid, kind
SynModuleOrNamespace(lid, a, kind, c, d, e, None, m)
SynModuleOrNamespace(lid, isRecursive, kind, decls, xmlDoc, attributes, None, range, trivia)
let PostParseModuleSpec (_i, defaultNamespace, isLastCompiland, filename, intf) =
match intf with
| ParsedSigFileFragment.NamedModule(SynModuleOrNamespaceSig(lid, isRec, kind, decls, xmlDoc, attribs, access, m)) ->
| ParsedSigFileFragment.NamedModule(SynModuleOrNamespaceSig(lid, isRec, kind, decls, xmlDoc, attribs, access, m, trivia)) ->
let lid =
match lid with
| [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, SynModuleOrNamespaceKind.NamedModule, decls, xmlDoc, attribs, access, m)
SynModuleOrNamespaceSig(lid, isRec, SynModuleOrNamespaceKind.NamedModule, decls, xmlDoc, attribs, access, m, trivia)
| ParsedSigFileFragment.AnonModule (defs, m) ->
let isLast, isExe = isLastCompiland
......@@ -150,15 +151,16 @@ 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, SynModuleOrNamespaceKind.AnonModule, defs, PreXmlDoc.Empty, [], None, m)
let trivia: SynModuleOrNamespaceSigTrivia = { ModuleKeyword = None; NamespaceKeyword = None }
SynModuleOrNamespaceSig(modname, false, SynModuleOrNamespaceKind.AnonModule, defs, PreXmlDoc.Empty, [], None, m, trivia)
| ParsedSigFileFragment.NamespaceFragment (lid, a, kind, c, d, e, m)->
| ParsedSigFileFragment.NamespaceFragment (lid, isRecursive, kind, decls, xmlDoc, attributes, range, trivia)->
let lid, kind =
match lid with
| id :: rest when id.idText = MangledGlobalName ->
rest, if List.isEmpty rest then SynModuleOrNamespaceKind.GlobalNamespace else kind
| _ -> lid, kind
SynModuleOrNamespaceSig(lid, a, kind, c, d, e, None, m)
SynModuleOrNamespaceSig(lid, isRecursive, kind, decls, xmlDoc, attributes, None, range, trivia)
let GetScopedPragmasForInput input =
match input with
......@@ -184,7 +186,7 @@ let private collectCodeComments (lexbuf: UnicodeLexing.Lexbuf) (tripleSlashComme
| CommentTrivia.BlockComment r -> r.StartLine, r.StartColumn)
let PostParseModuleImpls (defaultNamespace, filename, isLastCompiland, ParsedImplFile (hashDirectives, impls), lexbuf: UnicodeLexing.Lexbuf, tripleSlashComments: range list) =
match impls |> List.rev |> List.tryPick (function ParsedImplFileFragment.NamedModule(SynModuleOrNamespace(lid, _, _, _, _, _, _, _)) -> Some lid | _ -> None) with
match impls |> List.rev |> List.tryPick (function ParsedImplFileFragment.NamedModule(SynModuleOrNamespace(longId = lid)) -> Some lid | _ -> None) with
| Some lid when impls.Length > 1 ->
errorR(Error(FSComp.SR.buildMultipleToplevelModules(), rangeOfLid lid))
| _ ->
......@@ -194,7 +196,7 @@ let PostParseModuleImpls (defaultNamespace, filename, isLastCompiland, ParsedImp
let isScript = IsScript filename
let scopedPragmas =
[ for SynModuleOrNamespace(_, _, _, decls, _, _, _, _) in impls do
[ for SynModuleOrNamespace(decls = decls) in impls do
for d in decls do
match d with
| SynModuleDecl.HashDirective (hd, _) -> yield! GetScopedPragmasForHashDirective hd
......@@ -209,7 +211,7 @@ let PostParseModuleImpls (defaultNamespace, filename, isLastCompiland, ParsedImp
ParsedInput.ImplFile (ParsedImplFileInput (filename, isScript, qualName, scopedPragmas, hashDirectives, impls, isLastCompiland, trivia))
let PostParseModuleSpecs (defaultNamespace, filename, isLastCompiland, ParsedSigFile (hashDirectives, specs), lexbuf: UnicodeLexing.Lexbuf, tripleSlashComments: range list) =
match specs |> List.rev |> List.tryPick (function ParsedSigFileFragment.NamedModule(SynModuleOrNamespaceSig(lid, _, _, _, _, _, _, _)) -> Some lid | _ -> None) with
match specs |> List.rev |> List.tryPick (function ParsedSigFileFragment.NamedModule(SynModuleOrNamespaceSig(longId = lid)) -> Some lid | _ -> None) with
| Some lid when specs.Length > 1 ->
errorR(Error(FSComp.SR.buildMultipleToplevelModules(), rangeOfLid lid))
| _ ->
......@@ -218,7 +220,7 @@ let PostParseModuleSpecs (defaultNamespace, filename, isLastCompiland, ParsedSig
let specs = specs |> List.mapi (fun i x -> PostParseModuleSpec(i, defaultNamespace, isLastCompiland, filename, x))
let qualName = QualFileNameOfSpecs filename specs
let scopedPragmas =
[ for SynModuleOrNamespaceSig(_, _, _, decls, _, _, _, _) in specs do
[ for SynModuleOrNamespaceSig(decls = decls) in specs do
for d in decls do
match d with
| SynModuleSigDecl.HashDirective(hd, _) -> yield! GetScopedPragmasForHashDirective hd
......@@ -338,8 +340,8 @@ let ReportParsingStatistics res =
let rec flattenDefns specs =
specs |> List.collect (function SynModuleDecl.NestedModule (decls=subDecls) -> flattenDefns subDecls | defn -> [defn])
let flattenModSpec (SynModuleOrNamespaceSig(_, _, _, decls, _, _, _, _)) = flattenSpecs decls
let flattenModImpl (SynModuleOrNamespace(_, _, _, decls, _, _, _, _)) = flattenDefns decls
let flattenModSpec (SynModuleOrNamespaceSig(decls = decls)) = flattenSpecs decls
let flattenModImpl (SynModuleOrNamespace(decls = decls)) = flattenDefns decls
match res with
| ParsedInput.SigFile (ParsedSigFileInput (modules = specs)) ->
printfn "parsing yielded %d specs" (List.collect flattenModSpec specs).Length
......@@ -640,7 +642,7 @@ let ProcessMetaCommandsFromInput
| SynModuleDecl.NestedModule (decls=subDecls) -> WarnOnIgnoredImplDecls subDecls
| _ -> ())
let ProcessMetaCommandsFromModuleSpec state (SynModuleOrNamespaceSig(_, _, _, decls, _, _, _, _)) =
let ProcessMetaCommandsFromModuleSpec state (SynModuleOrNamespaceSig(decls = decls)) =
List.fold (fun s d ->
match d with
| SynModuleSigDecl.HashDirective (h, _) -> ProcessMetaCommand s h
......@@ -649,7 +651,7 @@ let ProcessMetaCommandsFromInput
state
decls
let ProcessMetaCommandsFromModuleImpl state (SynModuleOrNamespace(_, _, _, decls, _, _, _, _)) =
let ProcessMetaCommandsFromModuleImpl state (SynModuleOrNamespace(decls = decls)) =
List.fold (fun s d ->
match d with
| SynModuleDecl.HashDirective (h, _) -> ProcessMetaCommand s h
......
......@@ -1925,7 +1925,8 @@ type SynModuleOrNamespace =
xmlDoc: PreXmlDoc *
attribs: SynAttributes *
accessibility: SynAccess option *
range: range
range: range *
trivia: SynModuleOrNamespaceTrivia
member this.Range =
match this with
......@@ -1941,7 +1942,8 @@ type SynModuleOrNamespaceSig =
xmlDoc: PreXmlDoc *
attribs: SynAttributes *
accessibility: SynAccess option *
range: range
range: range *
trivia: SynModuleOrNamespaceSigTrivia
member this.Range =
match this with
......@@ -1981,7 +1983,8 @@ type ParsedImplFileFragment =
decls: SynModuleDecl list *
xmlDoc: PreXmlDoc *
attributes: SynAttributes *
range: range
range: range *
trivia: SynModuleOrNamespaceTrivia
[<NoEquality; NoComparison; RequireQualifiedAccess>]
type ParsedSigFileFragment =
......@@ -2000,7 +2003,8 @@ type ParsedSigFileFragment =
decls: SynModuleSigDecl list *
xmlDoc: PreXmlDoc *
attributes: SynAttributes *
range: range
range: range *
trivia: SynModuleOrNamespaceSigTrivia
[<NoEquality; NoComparison; RequireQualifiedAccess>]
type ParsedScriptInteraction =
......
......@@ -1727,7 +1727,8 @@ type SynModuleOrNamespace =
xmlDoc: PreXmlDoc *
attribs: SynAttributes *
accessibility: SynAccess option *
range: range
range: range *
trivia: SynModuleOrNamespaceTrivia
/// Gets the syntax range of this construct
member Range: range
......@@ -1743,7 +1744,8 @@ type SynModuleOrNamespaceSig =
xmlDoc: PreXmlDoc *
attribs: SynAttributes *
accessibility: SynAccess option *
range: range
range: range *
trivia: SynModuleOrNamespaceSigTrivia
/// Gets the syntax range of this construct
member Range: range
......@@ -1779,7 +1781,8 @@ type ParsedImplFileFragment =
decls: SynModuleDecl list *
xmlDoc: PreXmlDoc *
attributes: SynAttributes *
range: range
range: range *
trivia: SynModuleOrNamespaceTrivia
/// Represents the syntax tree for the contents of a parsed signature file
[<NoEquality; NoComparison; RequireQualifiedAccess>]
......@@ -1799,7 +1802,8 @@ type ParsedSigFileFragment =
decls: SynModuleSigDecl list *
xmlDoc: PreXmlDoc *
attributes: SynAttributes *
range: range
range: range *
trivia: SynModuleOrNamespaceSigTrivia
/// Represents a parsed syntax tree for an F# Interactive interaction
[<NoEquality; NoComparison; RequireQualifiedAccess>]
......
......@@ -147,3 +147,13 @@ type SynModuleSigDeclNestedModuleTrivia =
{ ModuleKeyword: range option
EqualsRange: range option }
static member Zero: SynModuleSigDeclNestedModuleTrivia = { ModuleKeyword = None; EqualsRange = None }
[<NoEquality; NoComparison>]
type SynModuleOrNamespaceTrivia =
{ ModuleKeyword: range option
NamespaceKeyword: range option }
[<NoEquality; NoComparison>]
type SynModuleOrNamespaceSigTrivia =
{ ModuleKeyword: range option
NamespaceKeyword: range option }
......@@ -212,3 +212,19 @@ type SynModuleSigDeclNestedModuleTrivia =
/// The syntax range of the `=` token.
EqualsRange: range option }
static member Zero: SynModuleSigDeclNestedModuleTrivia
/// Represents additional information for SynModuleOrNamespace
[<NoEquality; NoComparison>]
type SynModuleOrNamespaceTrivia =
{ /// The syntax range of the `module` keyword
ModuleKeyword: range option
/// The syntax range of the `namespace` keyword
NamespaceKeyword: range option }
/// Represents additional information for SynModuleOrNamespaceSig
[<NoEquality; NoComparison>]
type SynModuleOrNamespaceSigTrivia =
{ /// The syntax range of the `module` keyword
ModuleKeyword: range option
/// The syntax range of the `namespace` keyword
NamespaceKeyword: range option }
......@@ -1783,7 +1783,7 @@ type internal FsiDynamicCompiler
let m = match defs with [] -> rangeStdin0 | _ -> List.reduce unionRanges [for d in defs -> d.Range]
let prefix = mkFragmentPath m i
let prefixPath = pathOfLid prefix
let impl = SynModuleOrNamespace(prefix,(*isRec*)false, SynModuleOrNamespaceKind.NamedModule,defs,PreXmlDoc.Empty,[],None,m)
let impl = SynModuleOrNamespace(prefix,(*isRec*)false, SynModuleOrNamespaceKind.NamedModule,defs,PreXmlDoc.Empty,[],None,m, { ModuleKeyword = None; NamespaceKeyword = None })
let isLastCompiland = true
let isExe = false
let input = ParsedInput.ImplFile (ParsedImplFileInput (filename,true, ComputeQualifiedNameOfFileFromUniquePath (m,prefixPath),[],[],[impl],(isLastCompiland, isExe), { ConditionalDirectives = []; CodeComments = [] }))
......
......@@ -695,21 +695,22 @@ moduleIntro:
/* The start of a namespace declaration */
namespaceIntro:
| NAMESPACE opt_rec path
{ $2, $3.LongIdent, grabXmlDoc(parseState, [], 1) }
{ let mNamespace = rhs parseState 1
mNamespace, $2, $3.LongIdent, grabXmlDoc(parseState, [], 1) }
/* The contents of a signature file */
fileNamespaceSpecs:
| fileModuleSpec
{ ParsedSigFile ([], [ ($1 (false, [], PreXmlDoc.Empty)) ]) }
{ ParsedSigFile ([], [ ($1 (None, false, [], PreXmlDoc.Empty)) ]) }
| fileModuleSpec fileNamespaceSpecList
{ // If there are namespaces, the first fileModuleImpl may only contain # directives
let decls =
match ($1 (false, [], PreXmlDoc.Empty)) with
match ($1 (None, false, [], PreXmlDoc.Empty)) with
| ParsedSigFileFragment.AnonModule(decls, m) -> decls
| ParsedSigFileFragment.NamespaceFragment(_, _, _, decls, _, _, _) -> decls
| ParsedSigFileFragment.NamedModule(SynModuleOrNamespaceSig(_, _, _, _, _, _, _, m)) ->
| ParsedSigFileFragment.NamespaceFragment(decls = decls) -> decls
| ParsedSigFileFragment.NamedModule(SynModuleOrNamespaceSig(range = m)) ->
raiseParseErrorAt m (FSComp.SR.parsOnlyHashDirectivesAllowed())
let decls =
decls |> List.collect (function
......@@ -729,7 +730,7 @@ fileNamespaceSpecList:
fileNamespaceSpec:
| namespaceIntro deprecated_opt_equals fileModuleSpec
{ let isRec, path, xml = $1 in ($3 (isRec, path, xml)) }
{ let mNamespace, isRec, path, xml = $1 in ($3 (Some mNamespace, isRec, path, xml)) }
/* The single module declaration that can make up a signature file */
......@@ -738,24 +739,26 @@ fileModuleSpec:
{ if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2))
let m2 = rhs parseState 3
let mDeclsAndAttrs = (List.map (fun (a: SynAttributeList) -> a.Range) $1) @ (List.map (fun (d: SynModuleSigDecl) -> d.Range) $4)
let _mModule, isRec, path2, vis, attribs2 = $3
let mModule, isRec, path2, vis, attribs2 = $3
let xmlDoc = grabXmlDoc(parseState, $1, 1)
let m = (m2, mDeclsAndAttrs) ||> unionRangeWithListBy id |> unionRangeWithXmlDoc xmlDoc
(fun (isRec2, path, _) ->
(fun (mNamespaceOpt, isRec2, path, _) ->
if not (isNil path) then errorR(Error(FSComp.SR.parsNamespaceOrModuleNotBoth(), m2))
let lid = path@path2
ParsedSigFileFragment.NamedModule(SynModuleOrNamespaceSig(lid, (isRec || isRec2), SynModuleOrNamespaceKind.NamedModule, $4, xmlDoc, $1 @ attribs2, vis, m))) }
let lid = path@path2
let trivia: SynModuleOrNamespaceSigTrivia = { ModuleKeyword = Some mModule; NamespaceKeyword = mNamespaceOpt }
ParsedSigFileFragment.NamedModule(SynModuleOrNamespaceSig(lid, (isRec || isRec2), SynModuleOrNamespaceKind.NamedModule, $4, xmlDoc, $1 @ attribs2, vis, m, trivia))) }
| moduleSpfnsPossiblyEmptyBlock
{ let m = (rhs parseState 1)
(fun (isRec, path, xml) ->
(fun (mNamespaceOpt, isRec, path, xml) ->
match path with
| [] -> ParsedSigFileFragment.AnonModule($1, m)
| _ ->
let lastDeclRange = List.tryLast $1 |> Option.map (fun decl -> decl.Range) |> Option.defaultValue (rhs parseState 1)
let m = mkRange lastDeclRange.FileName (lhs parseState).Start lastDeclRange.End
xml.MarkAsInvalid()
ParsedSigFileFragment.NamespaceFragment(path, isRec, SynModuleOrNamespaceKind.DeclaredNamespace, $1, PreXmlDoc.Empty, [], m)) }
let trivia = { ModuleKeyword = None; NamespaceKeyword = mNamespaceOpt }
ParsedSigFileFragment.NamespaceFragment(path, isRec, SynModuleOrNamespaceKind.DeclaredNamespace, $1, PreXmlDoc.Empty, [], m, trivia)) }
moduleSpfnsPossiblyEmptyBlock:
......@@ -1188,15 +1191,15 @@ implementationFile:
/* The sequence of namespace definitions or a single module definition that makes up an implementation file */
fileNamespaceImpls:
| fileModuleImpl
{ ParsedImplFile ([], [ ($1 (false, [], PreXmlDoc.Empty)) ]) }
{ ParsedImplFile ([], [ ($1 (None, false, [], PreXmlDoc.Empty)) ]) }
| fileModuleImpl fileNamespaceImplList
{ // If there are namespaces, the first fileModuleImpl may only contain # directives
let decls =
match ($1 (false, [], PreXmlDoc.Empty)) with
match ($1 (None, false, [], PreXmlDoc.Empty)) with
| ParsedImplFileFragment.AnonModule(decls, m) -> decls
| ParsedImplFileFragment.NamespaceFragment(_, _, _, decls, _, _, _) -> decls
| ParsedImplFileFragment.NamedModule(SynModuleOrNamespace(_, _, _, _, _, _, _, m)) ->
| ParsedImplFileFragment.NamespaceFragment(decls = decls) -> decls
| ParsedImplFileFragment.NamedModule(SynModuleOrNamespace(range = m)) ->
raiseParseErrorAt m (FSComp.SR.parsOnlyHashDirectivesAllowed())
let decls =
decls |> List.collect (function
......@@ -1219,7 +1222,7 @@ fileNamespaceImplList:
/* A single namespace definition in an implementation file */
fileNamespaceImpl:
| namespaceIntro deprecated_opt_equals fileModuleImpl
{ let isRec, path, xml = $1 in ($3 (isRec, path, xml)) }
{ let mNamespace, isRec, path, xml = $1 in ($3 (Some mNamespace, isRec, path, xml)) }
/* A single module definition in an implementation file */
......@@ -1230,22 +1233,24 @@ fileModuleImpl:
let mDeclsAndAttrs = (List.map (fun (a: SynAttributeList) -> a.Range) $1) @ (List.map (fun (d: SynModuleDecl) -> d.Range) $4)
let xmlDoc = grabXmlDoc(parseState, $1, 1)
let m = (m2, mDeclsAndAttrs) ||> unionRangeWithListBy id |> unionRangeWithXmlDoc xmlDoc
let _mModule, isRec2, path2, vis, attribs2 = $3
(fun (isRec, path, _) ->
let mModule, isRec2, path2, vis, attribs2 = $3
(fun (mNamespaceOpt, isRec, path, _) ->
if not (isNil path) then errorR(Error(FSComp.SR.parsNamespaceOrModuleNotBoth(), m2))
let lid = path@path2
ParsedImplFileFragment.NamedModule(SynModuleOrNamespace(lid, (isRec || isRec2), SynModuleOrNamespaceKind.NamedModule, $4, xmlDoc, $1@attribs2, vis, m))) }
let lid = path@path2
let trivia: SynModuleOrNamespaceTrivia = { ModuleKeyword = Some mModule; NamespaceKeyword = mNamespaceOpt }
ParsedImplFileFragment.NamedModule(SynModuleOrNamespace(lid, (isRec || isRec2), SynModuleOrNamespaceKind.NamedModule, $4, xmlDoc, $1@attribs2, vis, m, trivia))) }
| moduleDefnsOrExprPossiblyEmptyOrBlock
{ let m = (rhs parseState 1)
(fun (isRec, path, xml) ->
(fun (mNamespaceOpt, isRec, path, xml) ->
match path with
| [] -> ParsedImplFileFragment.AnonModule($1, m)
| _ ->
let lastDeclRange = List.tryLast $1 |> Option.map (fun decl -> decl.Range) |> Option.defaultValue (rhs parseState 1)
let m = mkRange lastDeclRange.FileName (lhs parseState).Start lastDeclRange.End
xml.MarkAsInvalid()
ParsedImplFileFragment.NamespaceFragment(path, isRec, SynModuleOrNamespaceKind.DeclaredNamespace, $1, PreXmlDoc.Empty, [], m)) }
let trivia: SynModuleOrNamespaceTrivia = { ModuleKeyword = None; NamespaceKeyword = mNamespaceOpt }
ParsedImplFileFragment.NamespaceFragment(path, isRec, SynModuleOrNamespaceKind.DeclaredNamespace, $1, PreXmlDoc.Empty, [], m, trivia)) }
/* A collection/block of definitions or expressions making up a module or namespace, possibly empty */
......
......@@ -793,7 +793,7 @@ type FSharpParseFileResults(diagnostics: FSharpDiagnostic[], input: ParsedInput,
| _ -> () ]
// Collect all the items in a module
let walkModule (SynModuleOrNamespace(_, _, _, decls, _, _, _, m)) =
let walkModule (SynModuleOrNamespace(decls = decls; range = m)) =
if isMatchRange m then
List.collect walkDecl decls
else
......
......@@ -284,7 +284,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, kind, 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)
......@@ -429,7 +429,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, kind, 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)
......@@ -593,7 +593,7 @@ module NavigateTo =
for item in moduleOrNamespaceList do
walkSynModuleOrNamespaceSig item { Type = NavigableContainerType.File; Name = fileName }
and walkSynModuleOrNamespaceSig (SynModuleOrNamespaceSig(lid, _, kind, decls, _, _, _, _)) container =
and walkSynModuleOrNamespaceSig (SynModuleOrNamespaceSig(longId = lid; kind = kind; decls = decls)) container =
let isModule = kind.IsModule
if isModule then
addModule lid true container
......@@ -651,7 +651,7 @@ module NavigateTo =
for item in moduleOrNamespaceList do
walkSynModuleOrNamespace item container
and walkSynModuleOrNamespace(SynModuleOrNamespace(lid, _, kind, decls, _, _, _, _)) container =
and walkSynModuleOrNamespace(SynModuleOrNamespace(longId = lid; kind = kind; decls = decls)) container =
let isModule = kind.IsModule
if isModule then
addModule lid false container
......
......@@ -238,7 +238,7 @@ module SyntaxTraversal =
| SynModuleDecl.NamespaceFragment(synModuleOrNamespace) -> traverseSynModuleOrNamespace path synModuleOrNamespace
visitor.VisitModuleDecl(origPath, defaultTraverse, decl)
and traverseSynModuleOrNamespace origPath (SynModuleOrNamespace(_longIdent, _isRec, _isModule, synModuleDecls, _preXmlDoc, _synAttributes, _synAccessOpt, range) as mors) =
and traverseSynModuleOrNamespace origPath (SynModuleOrNamespace(decls = synModuleDecls; range = range) as mors) =
match visitor.VisitModuleOrNamespace(origPath, mors) with
| Some x -> Some x
| None ->
......
......@@ -466,7 +466,7 @@ module ParsedInput =
let rec walkImplFileInput (ParsedImplFileInput (modules = moduleOrNamespaceList)) =
List.tryPick (walkSynModuleOrNamespace true) moduleOrNamespaceList
and walkSynModuleOrNamespace isTopLevel (SynModuleOrNamespace(_, _, _, decls, _, Attributes attrs, _, r)) =
and walkSynModuleOrNamespace isTopLevel (SynModuleOrNamespace(decls = decls; attribs = Attributes attrs; range = r)) =
List.tryPick walkAttribute attrs
|> Option.orElseWith (fun () -> ifPosInRange r (fun _ -> List.tryPick (walkSynModuleDecl isTopLevel) decls))
......@@ -1262,7 +1262,7 @@ module ParsedInput =
let rec walkImplFileInput (ParsedImplFileInput (modules = moduleOrNamespaceList)) =
List.iter walkSynModuleOrNamespace moduleOrNamespaceList
and walkSynModuleOrNamespace (SynModuleOrNamespace(_, _, _, decls, _, Attributes attrs, _, _)) =
and walkSynModuleOrNamespace (SynModuleOrNamespace(decls = decls; attribs = Attributes attrs)) =
List.iter walkAttribute attrs
List.iter walkSynModuleDecl decls
......@@ -1656,7 +1656,7 @@ module ParsedInput =
let rec walkImplFileInput (ParsedImplFileInput (modules = moduleOrNamespaceList)) =
List.iter (walkSynModuleOrNamespace []) moduleOrNamespaceList
and walkSynModuleOrNamespace (parent: LongIdent) (SynModuleOrNamespace(ident, _, kind, decls, _, _, _, range)) =
and walkSynModuleOrNamespace (parent: LongIdent) (SynModuleOrNamespace(longId = ident; kind = kind; decls = decls; range = range)) =
if range.EndLine >= currentLine then
let isModule = kind.IsModule
match isModule, parent, ident with
......
......@@ -625,7 +625,7 @@ module Structure =
| _ -> ()
let parseModuleOrNamespace (SynModuleOrNamespace (longId, _, kind, decls, _, attribs, _, r)) =
let parseModuleOrNamespace (SynModuleOrNamespace (longId, _, kind, decls, _, attribs, _, r, _)) =
parseAttributes attribs
let idRange = longIdentRange longId
let fullrange = Range.startToEnd idRange r
......@@ -848,7 +848,7 @@ module Structure =
List.iter parseModuleSigDeclaration decls
| _ -> ()
let parseModuleOrNamespaceSigs (SynModuleOrNamespaceSig(longId, _, kind, decls, _, attribs, _, r)) =
let parseModuleOrNamespaceSigs (SynModuleOrNamespaceSig(longId, _, kind, decls, _, attribs, _, r, _)) =
parseAttributes attribs
let rangeEnd = lastModuleSigDeclRangeElse r decls
let idrange = longIdentRange longId
......
......@@ -95,7 +95,7 @@ module XmlDocParsing =
| SynModuleDecl.Attributes _
| SynModuleDecl.HashDirective _ -> []
and getXmlDocablesSynModuleOrNamespace (SynModuleOrNamespace(_, _, _, synModuleDecls, _, _, _, _)) =
and getXmlDocablesSynModuleOrNamespace (SynModuleOrNamespace(decls = synModuleDecls)) =
(synModuleDecls |> List.collect getXmlDocablesSynModuleDecl)
and getXmlDocablesSynTypeDefn (SynTypeDefn(typeInfo=SynComponentInfo(attributes=synAttributes; xmlDoc=preXmlDoc; range=compRange); typeRepr=synTypeDefnRepr; members=synMemberDefns; range=tRange)) =
......
......@@ -2653,8 +2653,8 @@ FSharp.Compiler.EditorServices.FSharpGlyph+Tags: Int32 OverridenMethod
FSharp.Compiler.EditorServices.FSharpGlyph+Tags: Int32 Property
FSharp.Compiler.EditorServices.FSharpGlyph+Tags: Int32 Struct
FSharp.Compiler.EditorServices.FSharpGlyph+Tags: Int32 Type
FSharp.Compiler.EditorServices.FSharpGlyph+Tags: Int32 Typedef
FSharp.Compiler.EditorServices.FSharpGlyph+Tags: Int32 TypeParameter
FSharp.Compiler.EditorServices.FSharpGlyph+Tags: Int32 Typedef
FSharp.Compiler.EditorServices.FSharpGlyph+Tags: Int32 Union
FSharp.Compiler.EditorServices.FSharpGlyph+Tags: Int32 Variable
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean Equals(FSharp.Compiler.EditorServices.FSharpGlyph)
......@@ -2678,8 +2678,8 @@ FSharp.Compiler.EditorServices.FSharpGlyph: Boolean IsOverridenMethod
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean IsProperty
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean IsStruct
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean IsType
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean IsTypedef
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean IsTypeParameter
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean IsTypedef
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean IsUnion
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean IsVariable
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean get_IsClass()
......@@ -2700,8 +2700,8 @@ FSharp.Compiler.EditorServices.FSharpGlyph: Boolean get_IsOverridenMethod()
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean get_IsProperty()
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean get_IsStruct()
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean get_IsType()
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean get_IsTypedef()
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean get_IsTypeParameter()
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean get_IsTypedef()
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean get_IsUnion()
FSharp.Compiler.EditorServices.FSharpGlyph: Boolean get_IsVariable()
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph Class
......@@ -2722,8 +2722,8 @@ FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FShar
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph Property
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph Struct
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph Type
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph Typedef
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph TypeParameter
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph Typedef
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph Union
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph Variable
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph get_Class()
......@@ -2744,8 +2744,8 @@ FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FShar
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph get_Property()
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph get_Struct()
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph get_Type()
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph get_Typedef()
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph get_TypeParameter()
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph get_Typedef()
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph get_Union()
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph get_Variable()
FSharp.Compiler.EditorServices.FSharpGlyph: FSharp.Compiler.EditorServices.FSharpGlyph+Tags
......@@ -5488,6 +5488,8 @@ FSharp.Compiler.Syntax.ParsedImplFileFragment+NamespaceFragment: Boolean get_isR
FSharp.Compiler.Syntax.ParsedImplFileFragment+NamespaceFragment: Boolean isRecursive
FSharp.Compiler.Syntax.ParsedImplFileFragment+NamespaceFragment: FSharp.Compiler.Syntax.SynModuleOrNamespaceKind get_kind()
FSharp.Compiler.Syntax.ParsedImplFileFragment+NamespaceFragment: FSharp.Compiler.Syntax.SynModuleOrNamespaceKind kind
FSharp.Compiler.Syntax.ParsedImplFileFragment+NamespaceFragment: FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceTrivia get_trivia()
FSharp.Compiler.Syntax.ParsedImplFileFragment+NamespaceFragment: FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceTrivia trivia
FSharp.Compiler.Syntax.ParsedImplFileFragment+NamespaceFragment: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.ParsedImplFileFragment+NamespaceFragment: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.ParsedImplFileFragment+NamespaceFragment: FSharp.Compiler.Xml.PreXmlDoc get_xmlDoc()
......@@ -5509,7 +5511,7 @@ FSharp.Compiler.Syntax.ParsedImplFileFragment: Boolean get_IsNamedModule()
FSharp.Compiler.Syntax.ParsedImplFileFragment: Boolean get_IsNamespaceFragment()
FSharp.Compiler.Syntax.ParsedImplFileFragment: FSharp.Compiler.Syntax.ParsedImplFileFragment NewAnonModule(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynModuleDecl], FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.ParsedImplFileFragment: FSharp.Compiler.Syntax.ParsedImplFileFragment NewNamedModule(FSharp.Compiler.Syntax.SynModuleOrNamespace)
FSharp.Compiler.Syntax.ParsedImplFileFragment: FSharp.Compiler.Syntax.ParsedImplFileFragment NewNamespaceFragment(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident], Boolean, FSharp.Compiler.Syntax.SynModuleOrNamespaceKind, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynModuleDecl], FSharp.Compiler.Xml.PreXmlDoc, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.ParsedImplFileFragment: FSharp.Compiler.Syntax.ParsedImplFileFragment NewNamespaceFragment(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident], Boolean, FSharp.Compiler.Syntax.SynModuleOrNamespaceKind, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynModuleDecl], FSharp.Compiler.Xml.PreXmlDoc, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceTrivia)
FSharp.Compiler.Syntax.ParsedImplFileFragment: FSharp.Compiler.Syntax.ParsedImplFileFragment+AnonModule
FSharp.Compiler.Syntax.ParsedImplFileFragment: FSharp.Compiler.Syntax.ParsedImplFileFragment+NamedModule
FSharp.Compiler.Syntax.ParsedImplFileFragment: FSharp.Compiler.Syntax.ParsedImplFileFragment+NamespaceFragment
......@@ -5604,6 +5606,8 @@ FSharp.Compiler.Syntax.ParsedSigFileFragment+NamespaceFragment: Boolean get_isRe
FSharp.Compiler.Syntax.ParsedSigFileFragment+NamespaceFragment: Boolean isRecursive
FSharp.Compiler.Syntax.ParsedSigFileFragment+NamespaceFragment: FSharp.Compiler.Syntax.SynModuleOrNamespaceKind get_kind()
FSharp.Compiler.Syntax.ParsedSigFileFragment+NamespaceFragment: FSharp.Compiler.Syntax.SynModuleOrNamespaceKind kind
FSharp.Compiler.Syntax.ParsedSigFileFragment+NamespaceFragment: FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceSigTrivia get_trivia()
FSharp.Compiler.Syntax.ParsedSigFileFragment+NamespaceFragment: FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceSigTrivia trivia
FSharp.Compiler.Syntax.ParsedSigFileFragment+NamespaceFragment: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.ParsedSigFileFragment+NamespaceFragment: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.ParsedSigFileFragment+NamespaceFragment: FSharp.Compiler.Xml.PreXmlDoc get_xmlDoc()
......@@ -5625,7 +5629,7 @@ FSharp.Compiler.Syntax.ParsedSigFileFragment: Boolean get_IsNamedModule()
FSharp.Compiler.Syntax.ParsedSigFileFragment: Boolean get_IsNamespaceFragment()
FSharp.Compiler.Syntax.ParsedSigFileFragment: FSharp.Compiler.Syntax.ParsedSigFileFragment NewAnonModule(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynModuleSigDecl], FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.ParsedSigFileFragment: FSharp.Compiler.Syntax.ParsedSigFileFragment NewNamedModule(FSharp.Compiler.Syntax.SynModuleOrNamespaceSig)
FSharp.Compiler.Syntax.ParsedSigFileFragment: FSharp.Compiler.Syntax.ParsedSigFileFragment NewNamespaceFragment(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident], Boolean, FSharp.Compiler.Syntax.SynModuleOrNamespaceKind, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynModuleSigDecl], FSharp.Compiler.Xml.PreXmlDoc, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.ParsedSigFileFragment: FSharp.Compiler.Syntax.ParsedSigFileFragment NewNamespaceFragment(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident], Boolean, FSharp.Compiler.Syntax.SynModuleOrNamespaceKind, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynModuleSigDecl], FSharp.Compiler.Xml.PreXmlDoc, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceSigTrivia)
FSharp.Compiler.Syntax.ParsedSigFileFragment: FSharp.Compiler.Syntax.ParsedSigFileFragment+AnonModule
FSharp.Compiler.Syntax.ParsedSigFileFragment: FSharp.Compiler.Syntax.ParsedSigFileFragment+NamedModule
FSharp.Compiler.Syntax.ParsedSigFileFragment: FSharp.Compiler.Syntax.ParsedSigFileFragment+NamespaceFragment
......@@ -7692,9 +7696,11 @@ FSharp.Compiler.Syntax.SynModuleDecl: System.String ToString()
FSharp.Compiler.Syntax.SynModuleOrNamespace
FSharp.Compiler.Syntax.SynModuleOrNamespace: Boolean get_isRecursive()
FSharp.Compiler.Syntax.SynModuleOrNamespace: Boolean isRecursive
FSharp.Compiler.Syntax.SynModuleOrNamespace: FSharp.Compiler.Syntax.SynModuleOrNamespace NewSynModuleOrNamespace(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident], Boolean, FSharp.Compiler.Syntax.SynModuleOrNamespaceKind, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynModuleDecl], FSharp.Compiler.Xml.PreXmlDoc, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess], FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynModuleOrNamespace: FSharp.Compiler.Syntax.SynModuleOrNamespace NewSynModuleOrNamespace(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident], Boolean, FSharp.Compiler.Syntax.SynModuleOrNamespaceKind, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynModuleDecl], FSharp.Compiler.Xml.PreXmlDoc, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceTrivia)
FSharp.Compiler.Syntax.SynModuleOrNamespace: FSharp.Compiler.Syntax.SynModuleOrNamespaceKind get_kind()
FSharp.Compiler.Syntax.SynModuleOrNamespace: FSharp.Compiler.Syntax.SynModuleOrNamespaceKind kind
FSharp.Compiler.Syntax.SynModuleOrNamespace: FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceTrivia get_trivia()
FSharp.Compiler.Syntax.SynModuleOrNamespace: FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceTrivia trivia
FSharp.Compiler.Syntax.SynModuleOrNamespace: FSharp.Compiler.Text.Range Range
FSharp.Compiler.Syntax.SynModuleOrNamespace: FSharp.Compiler.Text.Range get_Range()
FSharp.Compiler.Syntax.SynModuleOrNamespace: FSharp.Compiler.Text.Range get_range()
......@@ -7752,7 +7758,9 @@ FSharp.Compiler.Syntax.SynModuleOrNamespaceSig: Boolean get_isRecursive()
FSharp.Compiler.Syntax.SynModuleOrNamespaceSig: Boolean isRecursive
FSharp.Compiler.Syntax.SynModuleOrNamespaceSig: FSharp.Compiler.Syntax.SynModuleOrNamespaceKind get_kind()
FSharp.Compiler.Syntax.SynModuleOrNamespaceSig: FSharp.Compiler.Syntax.SynModuleOrNamespaceKind kind
FSharp.Compiler.Syntax.SynModuleOrNamespaceSig: FSharp.Compiler.Syntax.SynModuleOrNamespaceSig NewSynModuleOrNamespaceSig(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident], Boolean, FSharp.Compiler.Syntax.SynModuleOrNamespaceKind, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynModuleSigDecl], FSharp.Compiler.Xml.PreXmlDoc, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess], FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynModuleOrNamespaceSig: FSharp.Compiler.Syntax.SynModuleOrNamespaceSig NewSynModuleOrNamespaceSig(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident], Boolean, FSharp.Compiler.Syntax.SynModuleOrNamespaceKind, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynModuleSigDecl], FSharp.Compiler.Xml.PreXmlDoc, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceSigTrivia)
FSharp.Compiler.Syntax.SynModuleOrNamespaceSig: FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceSigTrivia get_trivia()
FSharp.Compiler.Syntax.SynModuleOrNamespaceSig: FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceSigTrivia trivia
FSharp.Compiler.Syntax.SynModuleOrNamespaceSig: FSharp.Compiler.Text.Range Range
FSharp.Compiler.Syntax.SynModuleOrNamespaceSig: FSharp.Compiler.Text.Range get_Range()
FSharp.Compiler.Syntax.SynModuleOrNamespaceSig: FSharp.Compiler.Text.Range get_range()
......@@ -9394,6 +9402,20 @@ FSharp.Compiler.SyntaxTrivia.SynModuleDeclNestedModuleTrivia: Microsoft.FSharp.C
FSharp.Compiler.SyntaxTrivia.SynModuleDeclNestedModuleTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_ModuleKeyword()
FSharp.Compiler.SyntaxTrivia.SynModuleDeclNestedModuleTrivia: System.String ToString()
FSharp.Compiler.SyntaxTrivia.SynModuleDeclNestedModuleTrivia: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range])
FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceSigTrivia
FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceSigTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] ModuleKeyword
FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceSigTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] NamespaceKeyword
FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceSigTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_ModuleKeyword()
FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceSigTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_NamespaceKeyword()
FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceSigTrivia: System.String ToString()
FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceSigTrivia: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range])
FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceTrivia
FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] ModuleKeyword
FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] NamespaceKeyword
FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_ModuleKeyword()
FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_NamespaceKeyword()
FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceTrivia: System.String ToString()
FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceTrivia: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range])
FSharp.Compiler.SyntaxTrivia.SynModuleSigDeclNestedModuleTrivia
FSharp.Compiler.SyntaxTrivia.SynModuleSigDeclNestedModuleTrivia: FSharp.Compiler.SyntaxTrivia.SynModuleSigDeclNestedModuleTrivia Zero
FSharp.Compiler.SyntaxTrivia.SynModuleSigDeclNestedModuleTrivia: FSharp.Compiler.SyntaxTrivia.SynModuleSigDeclNestedModuleTrivia get_Zero()
......
......@@ -47,7 +47,7 @@ let internal identsAndRanges (input: ParsedInput) =
| SynModuleDecl.Attributes _ -> failwith "Not implemented yet"
| SynModuleDecl.HashDirective _ -> failwith "Not implemented yet"
| SynModuleDecl.NamespaceFragment(moduleOrNamespace) -> extractFromModuleOrNamespace moduleOrNamespace
and extractFromModuleOrNamespace (SynModuleOrNamespace(longIdent, _, _, moduleDecls, _, _, _, _)) =
and extractFromModuleOrNamespace (SynModuleOrNamespace(longId = longIdent; decls = moduleDecls)) =
let xs = moduleDecls |> List.collect extractFromModuleDecl
if longIdent.IsEmpty then xs
else
......
......@@ -1352,6 +1352,47 @@ let s : string = "s"
assertRange (2, 0) (5, 20) r
| _ -> Assert.Fail "Could not get valid AST"
[<Test>]
let ``Module should contain module keyword`` () =
let parseResults =
getParseResults
"""
/// this file contains patches to the F# Compiler Service that have not yet made it into
/// published nuget packages. We source-copy them here to have a consistent location for our to-be-removed extensions
module FsAutoComplete.FCSPatches
open FSharp.Compiler.Syntax
open FSharp.Compiler.Text
open FsAutoComplete.UntypedAstUtils
open FSharp.Compiler.CodeAnalysis
module internal SynExprAppLocationsImpl =
let a = 42
"""
match parseResults with
| ParsedInput.ImplFile (ParsedImplFileInput (modules = [
SynModuleOrNamespace.SynModuleOrNamespace(kind = SynModuleOrNamespaceKind.NamedModule; trivia = { ModuleKeyword = Some mModule; NamespaceKeyword = None }) ])) ->
assertRange (5, 0) (5, 6) mModule
| _ -> Assert.Fail "Could not get valid AST"
[<Test>]
let ``Namespace should contain namespace keyword`` () =
let parseResults =
getParseResults
"""
namespace Foo
module Bar =
let a = 42
"""
match parseResults with
| ParsedInput.ImplFile (ParsedImplFileInput (modules = [
SynModuleOrNamespace.SynModuleOrNamespace(kind = SynModuleOrNamespaceKind.DeclaredNamespace; trivia = { ModuleKeyword = None; NamespaceKeyword = Some mNamespace }) ])) ->
assertRange (2, 0) (2, 9) mNamespace
| _ -> Assert.Fail "Could not get valid AST"
module SynConsts =
[<Test>]
let ``Measure contains the range of the constant`` () =
......@@ -1423,6 +1464,38 @@ val s : string
assertRange (2, 1) (5, 14) r
| _ -> Assert.Fail "Could not get valid AST"
[<Test>]
let ``Module should contain module keyword`` () =
let parseResults =
getParseResultsOfSignatureFile
"""
module Bar
val a: int
"""
match parseResults with
| ParsedInput.SigFile (ParsedSigFileInput (modules = [
SynModuleOrNamespaceSig(kind = SynModuleOrNamespaceKind.NamedModule; trivia = { ModuleKeyword = Some mModule; NamespaceKeyword = None }) ])) ->
assertRange (2, 0) (2, 6) mModule
| _ -> Assert.Fail "Could not get valid AST"
[<Test>]
let ``Namespace should contain namespace keyword`` () =
let parseResults =
getParseResultsOfSignatureFile
"""
namespace Foo
module Bar =
val a: int
"""
match parseResults with
| ParsedInput.SigFile (ParsedSigFileInput (modules = [
SynModuleOrNamespaceSig(kind = SynModuleOrNamespaceKind.DeclaredNamespace; trivia = { ModuleKeyword = None; NamespaceKeyword = Some mNamespace }) ])) ->
assertRange (2, 0) (2, 9) mNamespace
| _ -> Assert.Fail "Could not get valid AST"
module SignatureTypes =
[<Test>]
let ``Range of Type should end at end keyword`` () =
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册