@@ -56,7 +56,13 @@ sealed trait SoftAST extends Product { self =>
56
56
* @return `true` if `current`'s position is before `anchor`'s position, `false` otherwise.
57
57
*/
58
58
def isBehind (anchor : SoftAST ): Boolean =
59
- this .index isBehind anchor.index
59
+ isBehind(anchor.index)
60
+
61
+ def isBehind (anchor : SourceIndex ): Boolean =
62
+ this .index isBehind anchor
63
+
64
+ def contains (anchor : Node [SoftAST , SoftAST ]): Boolean =
65
+ contains(anchor.data)
60
66
61
67
def contains (anchor : SoftAST ): Boolean =
62
68
contains(anchor.index)
@@ -87,28 +93,22 @@ object SoftAST {
87
93
88
94
}
89
95
90
- sealed trait BlockPartAST extends SoftAST
96
+ implicit class NodeIdentifierExtensions ( val node : Node [ SoftAST . Identifier , SoftAST ]) extends AnyVal {
91
97
92
- sealed trait ExpressionAST extends BlockPartAST
98
+ def isReferenceCall (): Boolean =
99
+ node.parent match {
100
+ case Some (Node (_ : SoftAST .ReferenceCall , _)) => true
101
+ case _ => false
102
+ }
103
+
104
+ }
93
105
94
106
/**
95
- * Represents an AST that contains a block of code ([[Block ]])
96
- * or a group of type definitions ([[Group ]]) local to the AST identifier.
97
- *
98
- * For example:
99
- *
100
- * {{{
101
- * struct MyStruct {
102
- * type: Name // local to the identifier `MyStruct`
103
- * }
104
- *
105
- * // Parameter `param` is local to the identifier `function`
106
- * fn function(param: Type) -> () {
107
- * let variable = 1 // local to the identifier `function`
108
- * }
109
- * }}}
107
+ * Represents types that can be implemented within a [[Block ]].
110
108
*/
111
- sealed trait IsLocallyScoped extends SoftAST
109
+ sealed trait BlockPartAST extends SoftAST
110
+ sealed trait DeclarationAST extends BlockPartAST
111
+ sealed trait ExpressionAST extends BlockPartAST
112
112
113
113
case class ExpressionExpected (
114
114
index : SourceIndex )
@@ -207,8 +207,7 @@ object SoftAST {
207
207
postParamSpace : Option [Space ],
208
208
inheritance : Seq [Inheritance ],
209
209
block : Option [Block ])
210
- extends BlockPartAST
211
- with IsLocallyScoped
210
+ extends DeclarationAST
212
211
213
212
case class Abstract (
214
213
index : SourceIndex ,
@@ -223,8 +222,7 @@ object SoftAST {
223
222
identifier : IdentifierAST ,
224
223
preParamSpace : Option [Space ],
225
224
params : Group [Token .OpenParen .type , Token .CloseParen .type ])
226
- extends BlockPartAST
227
- with IsLocallyScoped
225
+ extends DeclarationAST
228
226
229
227
case class Struct (
230
228
index : SourceIndex ,
@@ -233,8 +231,7 @@ object SoftAST {
233
231
identifier : IdentifierAST ,
234
232
preParamSpace : Option [Space ],
235
233
params : Group [Token .OpenCurly .type , Token .CloseCurly .type ])
236
- extends BlockPartAST
237
- with IsLocallyScoped
234
+ extends DeclarationAST
238
235
239
236
case class Enum (
240
237
index : SourceIndex ,
@@ -243,15 +240,14 @@ object SoftAST {
243
240
identifier : IdentifierAST ,
244
241
preBlockSpace : Option [Space ],
245
242
block : Option [Block ])
246
- extends BlockPartAST
247
- with IsLocallyScoped
243
+ extends DeclarationAST
248
244
249
245
case class Const (
250
246
index : SourceIndex ,
251
247
constToken : TokenDocumented [Token .Const .type ],
252
248
preAssignmentSpace : Option [Space ],
253
249
assignment : Assignment )
254
- extends BlockPartAST
250
+ extends DeclarationAST
255
251
256
252
case class Import (
257
253
index : SourceIndex ,
@@ -321,7 +317,6 @@ object SoftAST {
321
317
parts : Seq [BlockPartAST ],
322
318
closeCurly : TokenDocExpectedAST [Token .CloseCurly .type ])
323
319
extends BlockAST
324
- with IsLocallyScoped
325
320
326
321
case class ExpressionBlock (
327
322
index : SourceIndex ,
@@ -349,8 +344,7 @@ object SoftAST {
349
344
signature : FunctionSignature ,
350
345
postSignatureSpace : Option [Space ],
351
346
block : Option [Block ])
352
- extends BlockPartAST
353
- with IsLocallyScoped
347
+ extends DeclarationAST
354
348
355
349
case class FunctionSignature (
356
350
index : SourceIndex ,
@@ -531,7 +525,6 @@ object SoftAST {
531
525
postCloseParenSpace : Option [Space ],
532
526
block : Option [Block ])
533
527
extends ExpressionAST
534
- with IsLocallyScoped
535
528
536
529
case class While (
537
530
index : SourceIndex ,
@@ -545,7 +538,6 @@ object SoftAST {
545
538
postCloseParenSpace : Option [Space ],
546
539
block : Option [Block ])
547
540
extends ExpressionAST
548
- with IsLocallyScoped
549
541
550
542
case class Assignment (
551
543
index : SourceIndex ,
@@ -648,15 +640,13 @@ object SoftAST {
648
640
preElseSpace : Option [Space ],
649
641
elseStatement : Option [Else ])
650
642
extends ExpressionAST
651
- with IsLocallyScoped
652
643
653
644
case class Else (
654
645
index : SourceIndex ,
655
646
elseToken : TokenDocumented [Token .Else .type ],
656
647
preBlockSpace : Option [Space ],
657
648
block : Option [Block ])
658
649
extends ExpressionAST
659
- with IsLocallyScoped
660
650
661
651
case class Space (
662
652
code : CodeString )
0 commit comments