Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit507ea9e

Browse files
forkiKevinRansom
authored andcommitted
*Fixdotnet#2274* Use unionRanges from compiler* cleanup* cleanup
1 parent861b265 commit507ea9e

File tree

1 file changed

+26
-39
lines changed

1 file changed

+26
-39
lines changed

‎vsintegration/src/FSharp.Editor/Structure/Structure.fs‎

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,16 @@ module internal Structure =
1111
/// from an untyped AST for the purposes of block structure.
1212
[<RequireQualifiedAccess>]
1313
moduleprivateRange=
14-
let inlineunion(r1:range)(r2:range)=
15-
letstartPos=
16-
if r1.StartLine<= r2.StartLine
17-
&& r1.StartColumn<= r2.StartColumnthen r1.Startelse r2.Start
18-
letendPos=
19-
if r1.EndLine>= r2.EndLine
20-
&& r1.EndColumn>= r2.EndColumnthen r1.Endelse r2.End
21-
mkFileIndexRange r1.FileIndex startPos endPos
2214

2315
letunionOpts(r1:range option)(r2:range option)=
2416
match r1, r2with
2517
| None, None-> None
2618
| Some r, None-> Some r
2719
| None, Some r-> Some r
28-
| Some r1, Some r2->union r1 r2|> Some
20+
| Some r1, Some r2->unionRanges r1 r2|> Some
2921

3022
/// Create a range starting at the end of r1 and finishing at the end of r2
31-
let inlineendToEnd(r1:range)(r2:range)= mkFileIndexRange r1.FileIndex r1.Endr2.End
23+
let inlineendToEnd(r1:range)(r2:range)= mkFileIndexRange r1.FileIndex r1.End r2.End
3224

3325
/// Create a range starting at the end of r1 and finishing at the start of r2
3426
let inlineendToStart(r1:range)(r2:range)= mkFileIndexRange r1.FileIndex r1.End r2.Start
@@ -57,26 +49,30 @@ module internal Structure =
5749
letrEnd= Range.mkPos r.EndLine(r.EndColumn- modEnd)
5850
mkFileIndexRange r.FileIndex rStart rEnd
5951

60-
6152
letlongIdentRange(longId:LongIdent)=
62-
Range.startToEnd(List.head longId).idRange(List.last longId).idRange
53+
match longIdwith
54+
|[]-> Range.range0
55+
| head::_-> Range.startToEnd head.idRange(List.last longId).idRange
6356

6457
letrangeOfTypeArgsElse other(typeArgs:SynTyparDecl list)=
6558
match typeArgswith
6659
|[]-> other
6760
| ls->
68-
ls|> List.map(fun(TyparDecl(_,typarg))-> typarg.Range)
69-
|> List.reduce Range.union
61+
ls
62+
|> List.map(fun(TyparDecl(_,typarg))-> typarg.Range)
63+
|> List.reduce Range.unionRanges
7064

7165
letrangeOfSynPatsElse other(synPats:SynSimplePat list)=
7266
match synPatswith
7367
|[]-> other
7468
| ls->
75-
ls|> List.map(
76-
fun(SynSimplePat.Attrib(range=r)
77-
|SynSimplePat.Id(range=r)
78-
|SynSimplePat.Typed(range=r))-> r)
79-
|> List.reduce Range.union
69+
ls
70+
|> List.map(fun x->
71+
match xwith
72+
| SynSimplePat.Attrib(range= r)
73+
| SynSimplePat.Id(range= r)
74+
| SynSimplePat.Typed(range= r)-> r)
75+
|> List.reduce Range.unionRanges
8076

8177

8278
/// Scope indicates the way a range/snapshot should be collapsed. |Scope.Scope.Same| is for a scope inside
@@ -346,10 +342,7 @@ module internal Structure =
346342
// This is not the best way to establish the position of `else`
347343
// the AST doesn't provide an easy way to find the position of the keyword
348344
// as such `else` will be left out of block structuring and outlining until a
349-
// a suitible approach is determined
350-
// let elseRange = Range.endToEnd elseExpr.Range r
351-
// let elseCollapse = Range.startToEnd elseExpr.Range r
352-
// yield! rcheck Scope.ElseInIfThenElse Collapse.Same elseExpr.Range elseExpr.Range
345+
// a suitable approach is determined
353346
yield! parseExpr elseExpr
354347
| None->()
355348
| SynExpr.While(_,_,e,r)->
@@ -615,22 +608,16 @@ module internal Structure =
615608

616609
letprivateparseModuleOrNamespace(SynModuleOrNamespace.SynModuleOrNamespace(longId,_,isModule,decls,_,attribs,_,r))=
617610
seq{
618-
match longIdwith
619-
|[]->()
620-
|_->
621-
yield! parseAttributes attribs
622-
letidRange= longIdentRange longId
623-
letfullrange= Range.startToEnd idRange r
624-
letcollapse= Range.endToEnd idRange r
625-
if isModulethen
626-
yield! rcheck Scope.Module Collapse.Below fullrange collapse
627-
//else
628-
// //yield! rcheck Scope.Namespace Collapse.Below (Range.modEnd -1 fullrange) (Range.modEnd -1 collapse)
629-
// yield! rcheck Scope.Namespace Collapse.Below (fullrange) (collapse)
630-
631-
yield! collectHashDirectives decls
632-
yield! collectOpens decls
633-
yield! Seq.collect parseDeclaration decls
611+
yield! parseAttributes attribs
612+
letidRange= longIdentRange longId
613+
letfullrange= Range.startToEnd idRange r
614+
letcollapse= Range.endToEnd idRange r
615+
if isModulethen
616+
yield! rcheck Scope.Module Collapse.Below fullrange collapse
617+
618+
yield! collectHashDirectives decls
619+
yield! collectOpens decls
620+
yield! Seq.collect parseDeclaration decls
634621
}
635622

636623
typeprivateLineNum= int

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp