Skip to content

Commit

Permalink
Revert "Include end in nested module range. (dotnet#14751)"
Browse files Browse the repository at this point in the history
This reverts commit 4247eb9.
  • Loading branch information
KevinRansom committed Feb 20, 2023
1 parent f15e9bc commit 652ac1c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 75 deletions.
26 changes: 9 additions & 17 deletions src/Compiler/pars.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -1273,17 +1273,12 @@ moduleDefn:
| Some vis -> raiseParseErrorAt (rhs parseState 1) (FSComp.SR.parsIgnoreAttributesOnModuleAbbreviationAlwaysPrivate(vis.ToString()))
| None -> ()
[ SynModuleDecl.ModuleAbbrev(List.head path, eqn, (rhs parseState 3, eqn) ||> unionRangeWithListBy (fun id -> id.idRange) ) ]
| Choice2Of2 (def, mEndOpt) ->
| Choice2Of2 def ->
if not (isSingleton path) then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsModuleAbbreviationMustBeSimpleName())
let info = SynComponentInfo(attribs @ attribs2, None, [], path, xmlDoc, false, vis, rhs parseState 3)
let mEquals = rhs parseState 4
let trivia: SynModuleDeclNestedModuleTrivia = { ModuleKeyword = Some mModule; EqualsRange = Some mEquals }
let m =
(rhs2 parseState 1 4, def)
||> unionRangeWithListBy (fun (d: SynModuleDecl) -> d.Range)
|> unionRangeWithXmlDoc xmlDoc
let m = match mEndOpt with | None -> m | Some mEnd -> unionRanges m mEnd
[ SynModuleDecl.NestedModule(info, isRec, def, false, m, trivia) ] }
[ SynModuleDecl.NestedModule(info, isRec, def, false, ((rhs2 parseState 1 4, def) ||> unionRangeWithListBy (fun d -> d.Range) |> unionRangeWithXmlDoc xmlDoc), trivia)] }

/* unattached custom attributes */
| attributes recover
Expand Down Expand Up @@ -1344,18 +1339,17 @@ namedModuleDefnBlock:
match $2 with
| [ SynModuleDecl.Expr (LongOrSingleIdent(false, SynLongIdent(path, _, _), None, _), _) ] ->
Choice1Of2 path
| _ ->
Choice2Of2 ($2, None)
| _ ->
Choice2Of2 $2
}

| OBLOCKBEGIN moduleDefnsOrExpr recover
{ // The lex filter ensures we can only get a mismatch in OBLOCKBEGIN/OBLOCKEND tokens if there was some other kind of error, hence we don't need to report this error
// reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnClosedBlockInHashLight())
Choice2Of2 ($2, None) }
Choice2Of2 $2 }

| OBLOCKBEGIN error oblockend
{ let mEnd = rhs parseState 3
Choice2Of2 ([], Some mEnd) }
{ Choice2Of2 [] }

| wrappedNamedModuleDefn
{ Choice2Of2 $1 }
Expand All @@ -1367,16 +1361,14 @@ namedModuleDefnBlock:
/* A module definition that includes a 'begin'...'end' (rarely used in F# with #light syntax) */
wrappedNamedModuleDefn:
| structOrBegin moduleDefnsOrExprPossiblyEmpty END
{ let mEnd = rhs parseState 3
$2, Some mEnd }
{ $2 }

| structOrBegin moduleDefnsOrExprPossiblyEmpty recover
{ reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnmatchedBeginOrStruct())
$2, None }
$2 }

| structOrBegin error END
{ let mEnd = rhs parseState 3
[], Some mEnd }
{ [] }


tyconDefnAugmentation:
Expand Down

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions tests/service/data/SyntaxTree/NestedModule/RangeOfBeginEnd.fs

This file was deleted.

16 changes: 0 additions & 16 deletions tests/service/data/SyntaxTree/NestedModule/RangeOfBeginEnd.fs.bsl

This file was deleted.

0 comments on commit 652ac1c

Please sign in to comment.