-
Notifications
You must be signed in to change notification settings - Fork 789
/
SyntaxTree.fs
1855 lines (1402 loc) · 57.3 KB
/
SyntaxTree.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespace rec FSharp.Compiler.Syntax
open System
open System.Diagnostics
open FSharp.Compiler.Syntax
open FSharp.Compiler.Text
open FSharp.Compiler.Text.Range
open FSharp.Compiler.Xml
open FSharp.Compiler.SyntaxTrivia
[<Struct; NoEquality; NoComparison; DebuggerDisplay("{idText}")>]
type Ident(text: string, range: range) =
member _.idText = text
member _.idRange = range
override _.ToString() = text
type SynIdent =
| SynIdent of ident: Ident * trivia: IdentTrivia option
member this.Range =
match this with
| SynIdent(ident, trivia) ->
match trivia with
| Some value ->
match value with
| IdentTrivia.OriginalNotationWithParen(leftParen, _, rightParen)
| IdentTrivia.HasParenthesis(leftParen, rightParen) -> unionRanges leftParen rightParen
| _ -> ident.idRange
| None -> ident.idRange
type LongIdent = Ident list
type SynLongIdent =
| SynLongIdent of id: LongIdent * dotRanges: range list * trivia: IdentTrivia option list
member this.Range =
match this with
| SynLongIdent([], _, _) -> failwith "rangeOfLid"
| SynLongIdent([ id ], [], _) -> id.idRange
| SynLongIdent([ id ], [ m ], _) -> unionRanges id.idRange m
| SynLongIdent(h :: t, [], _) -> unionRanges h.idRange (List.last t).idRange
| SynLongIdent(h :: t, dotRanges, _) -> unionRanges h.idRange (List.last t).idRange |> unionRanges (List.last dotRanges)
member this.LongIdent =
match this with
| SynLongIdent(lid, _, _) -> lid
member this.Dots =
match this with
| SynLongIdent(dotRanges = dots) -> dots
member this.Trivia =
match this with
| SynLongIdent(trivia = trivia) -> List.choose id trivia
member this.IdentsWithTrivia =
let (SynLongIdent(lid, _, trivia)) = this
if lid.Length = trivia.Length then
List.zip lid trivia |> List.map SynIdent
elif lid.Length > trivia.Length then
let delta = lid.Length - trivia.Length
let trivia = [ yield! trivia; yield! List.replicate delta None ]
List.zip lid trivia |> List.map SynIdent
else
failwith "difference between idents and trivia"
member this.ThereIsAnExtraDotAtTheEnd =
match this with
| SynLongIdent(lid, dots, _) -> lid.Length = dots.Length
member this.RangeWithoutAnyExtraDot =
match this with
| SynLongIdent([], _, _) -> failwith "rangeOfLidwd"
| SynLongIdent([ id ], _, _) -> id.idRange
| SynLongIdent(h :: t, dotRanges, _) ->
let nonExtraDots =
if dotRanges.Length = t.Length then
dotRanges
else
List.truncate t.Length dotRanges
unionRanges h.idRange (List.last t).idRange
|> unionRanges (List.last nonExtraDots)
[<AutoOpen>]
module SynLongIdentHelpers =
[<Obsolete("Please use SynLongIdent or define a custom active pattern")>]
let (|LongIdentWithDots|) =
function
| SynLongIdent(lid, dots, _) -> lid, dots
[<Obsolete("Please use SynLongIdent")>]
let LongIdentWithDots (lid, dots) =
SynLongIdent(lid, dots, List.replicate lid.Length None)
[<RequireQualifiedAccess>]
type ParserDetail =
| Ok
| ErrorRecovery
[<RequireQualifiedAccess>]
type TyparStaticReq =
| None
| HeadType
[<NoEquality; NoComparison>]
type SynTypar =
| SynTypar of ident: Ident * staticReq: TyparStaticReq * isCompGen: bool
member this.Range =
match this with
| SynTypar(id, _, _) -> id.idRange
[<Struct; RequireQualifiedAccess>]
type SynStringKind =
| Regular
| Verbatim
| TripleQuote
[<Struct; RequireQualifiedAccess>]
type SynByteStringKind =
| Regular
| Verbatim
[<NoEquality; NoComparison; RequireQualifiedAccess>]
type SynConst =
| Unit
| Bool of bool
| SByte of sbyte
| Byte of byte
| Int16 of int16
| UInt16 of uint16
| Int32 of int32
| UInt32 of uint32
| Int64 of int64
| UInt64 of uint64
| IntPtr of int64
| UIntPtr of uint64
| Single of single
| Double of double
| Char of char
| Decimal of System.Decimal
| UserNum of value: string * suffix: string
| String of text: string * synStringKind: SynStringKind * range: range
| Bytes of bytes: byte[] * synByteStringKind: SynByteStringKind * range: range
| UInt16s of uint16[]
| Measure of constant: SynConst * constantRange: range * synMeasure: SynMeasure * trivia: SynMeasureConstantTrivia
| SourceIdentifier of constant: string * value: string * range: range
member c.Range dflt =
match c with
| SynConst.String(_, _, m0)
| SynConst.Bytes(_, _, m0)
| SynConst.SourceIdentifier(_, _, m0) -> m0
| _ -> dflt
[<NoEquality; NoComparison; RequireQualifiedAccess>]
type SynMeasure =
| Named of longId: LongIdent * range: range
| Product of measure1: SynMeasure * mAsterisk: range * measure2: SynMeasure * range: range
| Seq of measures: SynMeasure list * range: range
| Divide of measure1: SynMeasure option * mSlash: range * measure2: SynMeasure * range: range
| Power of measure: SynMeasure * caretRange: range * power: SynRationalConst * range: range
| One of range: range
| Anon of range: range
| Var of typar: SynTypar * range: range
| Paren of measure: SynMeasure * range: range
[<NoEquality; NoComparison; RequireQualifiedAccess>]
type SynRationalConst =
| Integer of value: int32 * range: range
| Rational of numerator: int32 * numeratorRange: range * divRange: range * denominator: int32 * denominatorRange: range * range: range
| Negate of rationalConst: SynRationalConst * range: range
| Paren of rationalConst: SynRationalConst * range: range
[<RequireQualifiedAccess>]
type SynAccess =
| Public of range: range
| Internal of range: range
| Private of range: range
override this.ToString() =
match this with
| Public _ -> "Public"
| Internal _ -> "Internal"
| Private _ -> "Private"
member this.Range: range =
match this with
| Public m
| Internal m
| Private m -> m
[<RequireQualifiedAccess>]
type DebugPointAtTarget =
| Yes
| No
[<RequireQualifiedAccess>]
type DebugPointAtSequential =
| SuppressNeither
| SuppressStmt
| SuppressBoth
| SuppressExpr
[<RequireQualifiedAccess>]
type DebugPointAtTry =
| Yes of range: range
| No
[<RequireQualifiedAccess>]
type DebugPointAtLeafExpr = Yes of range
[<RequireQualifiedAccess>]
type DebugPointAtWith =
| Yes of range: range
| No
[<RequireQualifiedAccess>]
type DebugPointAtFinally =
| Yes of range: range
| No
[<RequireQualifiedAccess>]
type DebugPointAtFor =
| Yes of range: range
| No
[<RequireQualifiedAccess>]
type DebugPointAtInOrTo =
| Yes of range: range
| No
[<RequireQualifiedAccess>]
type DebugPointAtWhile =
| Yes of range: range
| No
[<RequireQualifiedAccess>]
type DebugPointAtBinding =
| Yes of range: range
| NoneAtDo
| NoneAtLet
| NoneAtSticky
| NoneAtInvisible
member x.Combine(y: DebugPointAtBinding) =
match x, y with
| DebugPointAtBinding.Yes _ as g, _ -> g
| _, (DebugPointAtBinding.Yes _ as g) -> g
| _ -> x
type SeqExprOnly = SeqExprOnly of bool
type BlockSeparator = range * pos option
type RecordFieldName = SynLongIdent * bool
type ExprAtomicFlag =
| Atomic = 0
| NonAtomic = 1
[<RequireQualifiedAccess>]
type SynBindingKind =
// Indicates 'expr' in a module, via ElimSynModuleDeclExpr
| StandaloneExpression
| Normal
// Covers 'do expr' in class or let-rec but not in a module.
//
// Note, in a module 'expr' corresponds to SynModuleDecl.Expr
// Note, in a module 'do expr' corresponds to SynModuleDecl.Expr with expression SynExpr.Do
// These are eliminated to bindings with 'StandaloneExpression' by ElimSynModuleDeclExpr
| Do
[<NoEquality; NoComparison>]
type SynTyparDecl =
| SynTyparDecl of attributes: SynAttributes * typar: SynTypar * intersectionConstraints: SynType list * trivia: SynTyparDeclTrivia
[<NoEquality; NoComparison; RequireQualifiedAccess>]
type SynTypeConstraint =
| WhereTyparIsValueType of typar: SynTypar * range: range
| WhereTyparIsReferenceType of typar: SynTypar * range: range
| WhereTyparIsUnmanaged of typar: SynTypar * range: range
| WhereTyparSupportsNull of typar: SynTypar * range: range
| WhereTyparNotSupportsNull of genericName: SynTypar * range: range * trivia: SynTypeConstraintWhereTyparNotSupportsNullTrivia
| WhereTyparIsComparable of typar: SynTypar * range: range
| WhereTyparIsEquatable of typar: SynTypar * range: range
| WhereTyparDefaultsToType of typar: SynTypar * typeName: SynType * range: range
| WhereTyparSubtypeOfType of typar: SynTypar * typeName: SynType * range: range
| WhereTyparSupportsMember of typars: SynType * memberSig: SynMemberSig * range: range
| WhereTyparIsEnum of typar: SynTypar * typeArgs: SynType list * range: range
| WhereTyparIsDelegate of typar: SynTypar * typeArgs: SynType list * range: range
| WhereSelfConstrained of selfConstraint: SynType * range: range
member x.Range =
match x with
| WhereTyparIsValueType(range = range)
| WhereTyparIsReferenceType(range = range)
| WhereTyparIsUnmanaged(range = range)
| WhereTyparSupportsNull(range = range)
| WhereTyparNotSupportsNull(range = range)
| WhereTyparIsComparable(range = range)
| WhereTyparIsEquatable(range = range)
| WhereTyparDefaultsToType(range = range)
| WhereTyparSubtypeOfType(range = range)
| WhereTyparSupportsMember(range = range)
| WhereTyparIsEnum(range = range)
| WhereTyparIsDelegate(range = range) -> range
| WhereSelfConstrained(range = range) -> range
[<RequireQualifiedAccess>]
type SynTyparDecls =
| PostfixList of decls: SynTyparDecl list * constraints: SynTypeConstraint list * range: range
| PrefixList of decls: SynTyparDecl list * range: range
| SinglePrefix of decl: SynTyparDecl * range: range
member x.TyparDecls =
match x with
| PostfixList(decls = decls)
| PrefixList(decls = decls) -> decls
| SinglePrefix(decl, _) -> [ decl ]
member x.Constraints =
match x with
| PostfixList(decls = decls; constraints = constraints) ->
// Synthesize SynTypeConstraints implied with any intersection constraints in SynTyparDecl
// The parser makes sure we're only dealing with hash constraints here
let intersectionConstraints =
decls
|> List.collect (fun (SynTyparDecl(typar = tp; intersectionConstraints = tys)) ->
tys
|> List.map (fun ty ->
let ty =
match ty with
| SynType.HashConstraint(ty, _) -> ty
| _ -> ty
SynTypeConstraint.WhereTyparSubtypeOfType(tp, ty, ty.Range)))
List.append intersectionConstraints constraints
| _ -> []
member x.Range =
match x with
| PostfixList(range = range)
| PrefixList(range = range)
| SinglePrefix(range = range) -> range
[<NoEquality; NoComparison; RequireQualifiedAccess>]
type SynTupleTypeSegment =
| Type of typeName: SynType
| Star of range: range
| Slash of range: range
member this.Range =
match this with
| SynTupleTypeSegment.Type t -> t.Range
| SynTupleTypeSegment.Star(range = range)
| SynTupleTypeSegment.Slash(range = range) -> range
[<NoEquality; NoComparison; RequireQualifiedAccess>]
type SynType =
| LongIdent of longDotId: SynLongIdent
| App of
typeName: SynType *
lessRange: range option *
typeArgs: SynType list *
commaRanges: range list * // interstitial commas
greaterRange: range option *
isPostfix: bool *
range: range
| LongIdentApp of
typeName: SynType *
longDotId: SynLongIdent *
lessRange: range option *
typeArgs: SynType list *
commaRanges: range list * // interstitial commas
greaterRange: range option *
range: range
| Tuple of isStruct: bool * path: SynTupleTypeSegment list * range: range
| AnonRecd of isStruct: bool * fields: (Ident * SynType) list * range: range
| Array of rank: int * elementType: SynType * range: range
| Fun of argType: SynType * returnType: SynType * range: range * trivia: SynTypeFunTrivia
| Var of typar: SynTypar * range: range
| Anon of range: range
| WithGlobalConstraints of typeName: SynType * constraints: SynTypeConstraint list * range: range
| HashConstraint of innerType: SynType * range: range
| MeasurePower of baseMeasure: SynType * exponent: SynRationalConst * range: range
| StaticConstant of constant: SynConst * range: range
| StaticConstantNull of range: range
| StaticConstantExpr of expr: SynExpr * range: range
| StaticConstantNamed of ident: SynType * value: SynType * range: range
| WithNull of innerType: SynType * ambivalent: bool * range: range * trivia: SynTypeWithNullTrivia
| Paren of innerType: SynType * range: range
| SignatureParameter of attributes: SynAttributes * optional: bool * id: Ident option * usedType: SynType * range: range
| Or of lhsType: SynType * rhsType: SynType * range: range * trivia: SynTypeOrTrivia
| FromParseError of range: range
| Intersection of typar: SynTypar option * types: SynType list * range: range * trivia: SynTyparDeclTrivia
member x.Range =
match x with
| SynType.App(range = m)
| SynType.LongIdentApp(range = m)
| SynType.Tuple(range = m)
| SynType.Array(range = m)
| SynType.AnonRecd(range = m)
| SynType.Fun(range = m)
| SynType.Var(range = m)
| SynType.Anon(range = m)
| SynType.WithGlobalConstraints(range = m)
| SynType.StaticConstant(range = m)
| SynType.StaticConstantNull(range = m)
| SynType.StaticConstantExpr(range = m)
| SynType.StaticConstantNamed(range = m)
| SynType.HashConstraint(range = m)
| SynType.WithNull(range = m)
| SynType.MeasurePower(range = m)
| SynType.Paren(range = m)
| SynType.SignatureParameter(range = m)
| SynType.Or(range = m)
| SynType.Intersection(range = m)
| SynType.FromParseError(range = m) -> m
| SynType.LongIdent lidwd -> lidwd.Range
[<NoEquality; NoComparison; RequireQualifiedAccess>]
type SynExpr =
| Paren of expr: SynExpr * leftParenRange: range * rightParenRange: range option * range: range
| Quote of operator: SynExpr * isRaw: bool * quotedExpr: SynExpr * isFromQueryExpression: bool * range: range
| Const of constant: SynConst * range: range
| Typed of expr: SynExpr * targetType: SynType * range: range
| Tuple of
isStruct: bool *
exprs: SynExpr list *
commaRanges: range list * // interstitial commas
range: range
| AnonRecd of
isStruct: bool *
copyInfo: (SynExpr * BlockSeparator) option *
recordFields: (SynLongIdent * range option * SynExpr) list *
range: range *
trivia: SynExprAnonRecdTrivia
| ArrayOrList of isArray: bool * exprs: SynExpr list * range: range
| Record of
baseInfo: (SynType * SynExpr * range * BlockSeparator option * range) option *
copyInfo: (SynExpr * BlockSeparator) option *
recordFields: SynExprRecordField list *
range: range
| New of isProtected: bool * targetType: SynType * expr: SynExpr * range: range
| ObjExpr of
objType: SynType *
argOptions: (SynExpr * Ident option) option *
withKeyword: range option *
bindings: SynBinding list *
members: SynMemberDefns *
extraImpls: SynInterfaceImpl list *
newExprRange: range *
range: range
| While of whileDebugPoint: DebugPointAtWhile * whileExpr: SynExpr * doExpr: SynExpr * range: range
| For of
forDebugPoint: DebugPointAtFor *
toDebugPoint: DebugPointAtInOrTo *
ident: Ident *
equalsRange: range option *
identBody: SynExpr *
direction: bool *
toBody: SynExpr *
doBody: SynExpr *
range: range
| ForEach of
forDebugPoint: DebugPointAtFor *
inDebugPoint: DebugPointAtInOrTo *
seqExprOnly: SeqExprOnly *
isFromSource: bool *
pat: SynPat *
enumExpr: SynExpr *
bodyExpr: SynExpr *
range: range
| ArrayOrListComputed of isArray: bool * expr: SynExpr * range: range
| IndexRange of expr1: SynExpr option * opm: range * expr2: SynExpr option * range1: range * range2: range * range: range
| IndexFromEnd of expr: SynExpr * range: range
| ComputationExpr of hasSeqBuilder: bool * expr: SynExpr * range: range
| Lambda of
fromMethod: bool *
inLambdaSeq: bool *
args: SynSimplePats *
body: SynExpr *
parsedData: (SynPat list * SynExpr) option *
range: range *
trivia: SynExprLambdaTrivia
| MatchLambda of
isExnMatch: bool *
keywordRange: range *
matchClauses: SynMatchClause list *
matchDebugPoint: DebugPointAtBinding *
range: range
| Match of
matchDebugPoint: DebugPointAtBinding *
expr: SynExpr *
clauses: SynMatchClause list *
range: range *
trivia: SynExprMatchTrivia
| Do of expr: SynExpr * range: range
| Assert of expr: SynExpr * range: range
| App of flag: ExprAtomicFlag * isInfix: bool * funcExpr: SynExpr * argExpr: SynExpr * range: range
| TypeApp of
expr: SynExpr *
lessRange: range *
typeArgs: SynType list *
commaRanges: range list *
greaterRange: range option *
typeArgsRange: range *
range: range
| LetOrUse of isRecursive: bool * isUse: bool * bindings: SynBinding list * body: SynExpr * range: range * trivia: SynExprLetOrUseTrivia
| TryWith of
tryExpr: SynExpr *
withCases: SynMatchClause list *
range: range *
tryDebugPoint: DebugPointAtTry *
withDebugPoint: DebugPointAtWith *
trivia: SynExprTryWithTrivia
| TryFinally of
tryExpr: SynExpr *
finallyExpr: SynExpr *
range: range *
tryDebugPoint: DebugPointAtTry *
finallyDebugPoint: DebugPointAtFinally *
trivia: SynExprTryFinallyTrivia
| Lazy of expr: SynExpr * range: range
| Sequential of
debugPoint: DebugPointAtSequential *
isTrueSeq: bool *
expr1: SynExpr *
expr2: SynExpr *
range: range *
trivia: SynExprSequentialTrivia
| IfThenElse of
ifExpr: SynExpr *
thenExpr: SynExpr *
elseExpr: SynExpr option *
spIfToThen: DebugPointAtBinding *
isFromErrorRecovery: bool *
range: range *
trivia: SynExprIfThenElseTrivia
| Typar of typar: SynTypar * range: range
| Ident of ident: Ident
| LongIdent of isOptional: bool * longDotId: SynLongIdent * altNameRefCell: SynSimplePatAlternativeIdInfo ref option * range: range
| LongIdentSet of longDotId: SynLongIdent * expr: SynExpr * range: range
| DotGet of expr: SynExpr * rangeOfDot: range * longDotId: SynLongIdent * range: range
| DotLambda of expr: SynExpr * range: range * trivia: SynExprDotLambdaTrivia
| DotSet of targetExpr: SynExpr * longDotId: SynLongIdent * rhsExpr: SynExpr * range: range
| Set of targetExpr: SynExpr * rhsExpr: SynExpr * range: range
| DotIndexedGet of objectExpr: SynExpr * indexArgs: SynExpr * dotRange: range * range: range
| DotIndexedSet of
objectExpr: SynExpr *
indexArgs: SynExpr *
valueExpr: SynExpr *
leftOfSetRange: range *
dotRange: range *
range: range
| NamedIndexedPropertySet of longDotId: SynLongIdent * expr1: SynExpr * expr2: SynExpr * range: range
| DotNamedIndexedPropertySet of targetExpr: SynExpr * longDotId: SynLongIdent * argExpr: SynExpr * rhsExpr: SynExpr * range: range
| TypeTest of expr: SynExpr * targetType: SynType * range: range
| Upcast of expr: SynExpr * targetType: SynType * range: range
| Downcast of expr: SynExpr * targetType: SynType * range: range
| InferredUpcast of expr: SynExpr * range: range
| InferredDowncast of expr: SynExpr * range: range
| Null of range: range
| AddressOf of isByref: bool * expr: SynExpr * opRange: range * range: range
| TraitCall of supportTys: SynType * traitSig: SynMemberSig * argExpr: SynExpr * range: range
| JoinIn of lhsExpr: SynExpr * lhsRange: range * rhsExpr: SynExpr * range: range
| ImplicitZero of range: range
| SequentialOrImplicitYield of debugPoint: DebugPointAtSequential * expr1: SynExpr * expr2: SynExpr * ifNotStmt: SynExpr * range: range
| YieldOrReturn of flags: (bool * bool) * expr: SynExpr * range: range * trivia: SynExprYieldOrReturnTrivia
| YieldOrReturnFrom of flags: (bool * bool) * expr: SynExpr * range: range * trivia: SynExprYieldOrReturnFromTrivia
| LetOrUseBang of
bindDebugPoint: DebugPointAtBinding *
isUse: bool *
isFromSource: bool *
pat: SynPat *
rhs: SynExpr *
andBangs: SynExprAndBang list *
body: SynExpr *
range: range *
trivia: SynExprLetOrUseBangTrivia
| MatchBang of
matchDebugPoint: DebugPointAtBinding *
expr: SynExpr *
clauses: SynMatchClause list *
range: range *
trivia: SynExprMatchBangTrivia
| DoBang of expr: SynExpr * range: range * trivia: SynExprDoBangTrivia
| WhileBang of whileDebugPoint: DebugPointAtWhile * whileExpr: SynExpr * doExpr: SynExpr * range: range
| LibraryOnlyILAssembly of
ilCode: obj * // this type is ILInstr[] but is hidden to avoid the representation of AbstractIL being public
typeArgs: SynType list *
args: SynExpr list *
retTy: SynType list *
range: range
| LibraryOnlyStaticOptimization of
constraints: SynStaticOptimizationConstraint list *
expr: SynExpr *
optimizedExpr: SynExpr *
range: range
| LibraryOnlyUnionCaseFieldGet of expr: SynExpr * longId: LongIdent * fieldNum: int * range: range
| LibraryOnlyUnionCaseFieldSet of expr: SynExpr * longId: LongIdent * fieldNum: int * rhsExpr: SynExpr * range: range
| ArbitraryAfterError of debugStr: string * range: range
| FromParseError of expr: SynExpr * range: range
| DiscardAfterMissingQualificationAfterDot of expr: SynExpr * dotRange: range * range: range
| Fixed of expr: SynExpr * range: range
| InterpolatedString of contents: SynInterpolatedStringPart list * synStringKind: SynStringKind * range: range
| DebugPoint of debugPoint: DebugPointAtLeafExpr * isControlFlow: bool * innerExpr: SynExpr
| Dynamic of funcExpr: SynExpr * qmark: range * argExpr: SynExpr * range: range
member e.Range =
match e with
| SynExpr.Paren(_, leftParenRange, rightParenRange, r) ->
match rightParenRange with
| Some rightParenRange when leftParenRange.FileIndex <> rightParenRange.FileIndex -> leftParenRange
| _ -> r
| SynExpr.Quote(range = m)
| SynExpr.Const(range = m)
| SynExpr.Typed(range = m)
| SynExpr.Tuple(range = m)
| SynExpr.AnonRecd(range = m)
| SynExpr.ArrayOrList(range = m)
| SynExpr.Record(range = m)
| SynExpr.New(range = m)
| SynExpr.ObjExpr(range = m)
| SynExpr.While(range = m)
| SynExpr.For(range = m)
| SynExpr.ForEach(range = m)
| SynExpr.ComputationExpr(range = m)
| SynExpr.ArrayOrListComputed(range = m)
| SynExpr.Lambda(range = m)
| SynExpr.Match(range = m)
| SynExpr.MatchLambda(range = m)
| SynExpr.Do(range = m)
| SynExpr.Assert(range = m)
| SynExpr.App(range = m)
| SynExpr.TypeApp(range = m)
| SynExpr.LetOrUse(range = m)
| SynExpr.TryWith(range = m)
| SynExpr.TryFinally(range = m)
| SynExpr.Sequential(range = m)
| SynExpr.SequentialOrImplicitYield(range = m)
| SynExpr.ArbitraryAfterError(range = m)
| SynExpr.FromParseError(range = m)
| SynExpr.DiscardAfterMissingQualificationAfterDot(range = m)
| SynExpr.IfThenElse(range = m)
| SynExpr.LongIdent(range = m)
| SynExpr.LongIdentSet(range = m)
| SynExpr.NamedIndexedPropertySet(range = m)
| SynExpr.DotIndexedGet(range = m)
| SynExpr.DotIndexedSet(range = m)
| SynExpr.DotGet(range = m)
| SynExpr.DotLambda(range = m)
| SynExpr.DotSet(range = m)
| SynExpr.Set(range = m)
| SynExpr.DotNamedIndexedPropertySet(range = m)
| SynExpr.LibraryOnlyUnionCaseFieldGet(range = m)
| SynExpr.LibraryOnlyUnionCaseFieldSet(range = m)
| SynExpr.LibraryOnlyILAssembly(range = m)
| SynExpr.LibraryOnlyStaticOptimization(range = m)
| SynExpr.IndexRange(range = m)
| SynExpr.IndexFromEnd(range = m)
| SynExpr.TypeTest(range = m)
| SynExpr.Upcast(range = m)
| SynExpr.AddressOf(range = m)
| SynExpr.Downcast(range = m)
| SynExpr.JoinIn(range = m)
| SynExpr.InferredUpcast(range = m)
| SynExpr.InferredDowncast(range = m)
| SynExpr.Null(range = m)
| SynExpr.Lazy(range = m)
| SynExpr.TraitCall(range = m)
| SynExpr.ImplicitZero(range = m)
| SynExpr.YieldOrReturn(range = m)
| SynExpr.YieldOrReturnFrom(range = m)
| SynExpr.LetOrUseBang(range = m)
| SynExpr.MatchBang(range = m)
| SynExpr.DoBang(range = m)
| SynExpr.WhileBang(range = m)
| SynExpr.Fixed(range = m)
| SynExpr.InterpolatedString(range = m)
| SynExpr.Dynamic(range = m) -> m
| SynExpr.Ident id -> id.idRange
| SynExpr.Typar(range = m) -> m
| SynExpr.DebugPoint(_, _, innerExpr) -> innerExpr.Range
member e.RangeWithoutAnyExtraDot =
match e with
| SynExpr.DiscardAfterMissingQualificationAfterDot(expr, _, _) -> expr.Range
| _ -> e.Range
member e.RangeOfFirstPortion =
match e with
// these are better than just .Range, and also commonly applicable inside queries
| SynExpr.Paren(_, m, _, _) -> m
| SynExpr.Sequential(expr1 = e1)
| SynExpr.SequentialOrImplicitYield(expr1 = e1)
| SynExpr.App(funcExpr = e1) -> e1.RangeOfFirstPortion
| SynExpr.ForEach(pat = pat; range = r) ->
let e = (pat.Range: range).Start
withEnd e r
| _ -> e.Range
member this.IsArbExprAndThusAlreadyReportedError =
match this with
| SynExpr.ArbitraryAfterError _ -> true
| _ -> false
[<NoEquality; NoComparison>]
type SynExprAndBang =
| SynExprAndBang of
debugPoint: DebugPointAtBinding *
isUse: bool *
isFromSource: bool *
pat: SynPat *
body: SynExpr *
range: range *
trivia: SynExprAndBangTrivia
member x.Range =
match x with
| SynExprAndBang(range = range) -> range
member this.Trivia =
match this with
| SynExprAndBang(trivia = trivia) -> trivia
[<NoEquality; NoComparison>]
type SynExprRecordField =
| SynExprRecordField of
fieldName: RecordFieldName *
equalsRange: range option *
expr: SynExpr option *
blockSeparator: BlockSeparator option
[<NoEquality; NoComparison; RequireQualifiedAccess>]
type SynInterpolatedStringPart =
| String of value: string * range: range
| FillExpr of fillExpr: SynExpr * qualifiers: Ident option
[<NoEquality; NoComparison; RequireQualifiedAccess>]
type SynSimplePat =
| Id of
ident: Ident *
altNameRefCell: SynSimplePatAlternativeIdInfo ref option *
isCompilerGenerated: bool *
isThisVal: bool *
isOptional: bool *
range: range
| Typed of pat: SynSimplePat * targetType: SynType * range: range
| Attrib of pat: SynSimplePat * attributes: SynAttributes * range: range
member x.Range =
match x with
| SynSimplePat.Id(range = range)
| SynSimplePat.Typed(range = range)
| SynSimplePat.Attrib(range = range) -> range
[<RequireQualifiedAccess>]
type SynSimplePatAlternativeIdInfo =
| Undecided of Ident
| Decided of Ident
[<NoEquality; NoComparison; RequireQualifiedAccess>]
type SynStaticOptimizationConstraint =
| WhenTyparTyconEqualsTycon of typar: SynTypar * rhsType: SynType * range: range
| WhenTyparIsStruct of typar: SynTypar * range: range
[<NoEquality; NoComparison; RequireQualifiedAccess>]
type SynSimplePats =
| SimplePats of pats: SynSimplePat list * commaRanges: range list * range: range
member x.Range =
match x with
| SynSimplePats.SimplePats(range = range) -> range
[<RequireQualifiedAccess>]
type SynArgPats =
| Pats of pats: SynPat list
| NamePatPairs of pats: (Ident * range option * SynPat) list * range: range * trivia: SynArgPatsNamePatPairsTrivia
member x.Patterns =
match x with
| Pats pats -> pats
| NamePatPairs(pats = pats) -> pats |> List.map (fun (_, _, pat) -> pat)
[<NoEquality; NoComparison; RequireQualifiedAccess>]
type SynPat =
| Const of constant: SynConst * range: range
| Wild of range: range
| Named of ident: SynIdent * isThisVal: bool * accessibility: SynAccess option * range: range
| Typed of pat: SynPat * targetType: SynType * range: range
| Attrib of pat: SynPat * attributes: SynAttributes * range: range
| Or of lhsPat: SynPat * rhsPat: SynPat * range: range * trivia: SynPatOrTrivia
| ListCons of lhsPat: SynPat * rhsPat: SynPat * range: range * trivia: SynPatListConsTrivia
| Ands of pats: SynPat list * range: range
| As of lhsPat: SynPat * rhsPat: SynPat * range: range
| LongIdent of
longDotId: SynLongIdent *
extraId: Ident option * // holds additional ident for tooling
typarDecls: SynValTyparDecls option * // usually None: temporary used to parse "f<'a> x = x"
argPats: SynArgPats *
accessibility: SynAccess option *
range: range
| Tuple of isStruct: bool * elementPats: SynPat list * commaRanges: range list * range: range
| Paren of pat: SynPat * range: range
| ArrayOrList of isArray: bool * elementPats: SynPat list * range: range
| Record of fieldPats: ((LongIdent * Ident) * range option * SynPat) list * range: range
| Null of range: range
| OptionalVal of ident: Ident * range: range
| IsInst of pat: SynType * range: range
| QuoteExpr of expr: SynExpr * range: range
| InstanceMember of
thisId: Ident *
memberId: Ident *
toolingId: Ident option * // holds additional ident for tooling
accessibility: SynAccess option *
range: range
| FromParseError of pat: SynPat * range: range