File tree 3 files changed +10
-9
lines changed
3 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ public class AbsolutePositionTestCase: XCTestCase {
69
69
node. position. utf8Offset + node. leadingTrivia. byteSize)
70
70
}
71
71
}
72
- Visitor ( ) . visit ( parsed )
72
+ parsed . walk ( Visitor ( ) )
73
73
} ( ) )
74
74
}
75
75
Original file line number Diff line number Diff line change @@ -76,19 +76,20 @@ public class DiagnosticTestCase: XCTestCase {
76
76
self . url = url
77
77
self . engine = engine
78
78
}
79
- override func visit( _ function: FunctionDeclSyntax ) {
79
+ override func visit( _ function: FunctionDeclSyntax ) -> Bool {
80
80
let startLoc = function. identifier. startLocation ( in: url)
81
81
let endLoc = function. endLocation ( in: url)
82
82
engine. diagnose ( . badFunction( function. identifier) , location: startLoc) {
83
83
$0. highlight ( function. identifier. sourceRange ( in: self . url) )
84
84
}
85
85
engine. diagnose ( . endOfFunction( function. identifier) , location: endLoc)
86
+ return true
86
87
}
87
88
}
88
89
89
90
XCTAssertNoThrow ( try {
90
91
let file = try SyntaxTreeParser . parse ( url)
91
- Visitor ( url: url, engine: engine) . visit ( file )
92
+ file . walk ( Visitor ( url: url, engine: engine) )
92
93
} ( ) )
93
94
94
95
XCTAssertEqual ( 6 , engine. diagnostics. count)
Original file line number Diff line number Diff line change @@ -13,16 +13,16 @@ public class SyntaxVisitorTestCase: XCTestCase {
13
13
public func testBasic( ) {
14
14
class FuncCounter : SyntaxVisitor {
15
15
var funcCount = 0
16
- override func visit( _ node: FunctionDeclSyntax ) {
16
+ override func visit( _ node: FunctionDeclSyntax ) -> Bool {
17
17
funcCount += 1
18
- super . visit ( node )
18
+ return true
19
19
}
20
20
}
21
21
XCTAssertNoThrow ( try {
22
22
let parsed = try SyntaxTreeParser . parse ( getInput ( " visitor.swift " ) )
23
23
let counter = FuncCounter ( )
24
24
let hashBefore = parsed. hashValue
25
- counter . visit ( parsed )
25
+ parsed . walk ( counter )
26
26
XCTAssertEqual ( counter. funcCount, 3 )
27
27
XCTAssertEqual ( hashBefore, parsed. hashValue)
28
28
} ( ) )
@@ -70,16 +70,16 @@ public class SyntaxVisitorTestCase: XCTestCase {
70
70
class VisitCollections : SyntaxVisitor {
71
71
var numberOfCodeBlockItems = 0
72
72
73
- override func visit( _ items: CodeBlockItemListSyntax ) {
73
+ override func visit( _ items: CodeBlockItemListSyntax ) -> Bool {
74
74
numberOfCodeBlockItems += items. count
75
- super . visit ( items )
75
+ return true
76
76
}
77
77
}
78
78
79
79
XCTAssertNoThrow ( try {
80
80
let parsed = try SyntaxTreeParser . parse ( getInput ( " nested-blocks.swift " ) )
81
81
let visitor = VisitCollections ( )
82
- visitor . visit ( parsed )
82
+ parsed . walk ( visitor )
83
83
XCTAssertEqual ( 4 , visitor. numberOfCodeBlockItems)
84
84
} ( ) )
85
85
}
You can’t perform that action at this time.
0 commit comments