You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/SwiftLexicalLookup/SimpleLookupQueries.swift
+47-61Lines changed: 47 additions & 61 deletions
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,8 @@ import SwiftSyntax
16
16
extensionSyntaxProtocol{
17
17
/// Returns all labeled statements available at a particular syntax node.
18
18
///
19
-
/// - Returns: Available labeled statements at a particular syntax node in the exact order they appear in the source code, starting with the innermost statement.
19
+
/// - Returns: Available labeled statements at a particular syntax node
20
+
/// in the exact order they appear in the source code, starting with the innermost statement.
20
21
///
21
22
/// Example usage:
22
23
/// ```swift
@@ -32,15 +33,19 @@ extension SyntaxProtocol {
32
33
/// break // 3
33
34
/// }
34
35
/// ```
35
-
/// When calling this function at the first `break`, it returns `three` and `two` in this exact order. For the second `break`, it returns only `two`. The results don't include `one`, which is unavailable at both locations due to the encapsulating function body. For `break` numbered 3, the result is `one`, as it's outside the function body and within the labeled statement. The function returns an empty array when there are no available labeled statements.
36
-
///
36
+
/// When calling this function at the first `break`, it returns `three` and `two` in this exact order.
37
+
/// For the second `break`, it returns only `two`.
38
+
/// The results don't include `one`, which is unavailable at both locations due to the encapsulating function body.
39
+
/// For `break` numbered 3, the result is `one`, as it's outside the function body and within the labeled statement.
40
+
/// The function returns an empty array when there are no available labeled statements.
/// Returns the catch node responsible for handling an error thrown at a particular syntax node.
42
46
///
43
-
/// - Returns: The catch node responsible for handling an error thrown at the lookup source node. This could be a `do` statement, `try?`, `try!`, `init`, `deinit`, accessors, closures, or function declarations.
47
+
/// - Returns: The catch node responsible for handling an error thrown at the lookup source node.
48
+
/// This could be a `do` statement, `try?`, `try!`, `init`, `deinit`, accessors, closures, or function declarations.
44
49
///
45
50
/// Example usage:
46
51
/// ```swift
@@ -53,89 +58,80 @@ extension SyntaxProtocol {
53
58
/// }
54
59
/// }
55
60
/// ```
56
-
/// When calling this function on `foo`, it returns the `do` statement. Calling the function on `bar` results in `try?`. When used on `error`, the function returns the function declaration `x`. The function returns `nil` when there's no available catch node.
57
-
///
61
+
/// When calling this function on `foo`, it returns the `do` statement.
62
+
/// Calling the function on `bar` results in `try?`.
63
+
/// When used on `error`, the function returns the function declaration `x`.
64
+
/// The function returns `nil` when there's no available catch node.
/// Collect syntax nodes matching the collection type up until encountering one of the specified syntax nodes. The nodes in the array are inside out, with the innermost node being the first.
/// Callect syntax nodes matching the collection type up until encountering one of the specified syntax nodes.
136
-
privatefunc walkParentTree<T:SyntaxProtocol>(
132
+
privatefunc collectNodes<T:SyntaxProtocol>(
133
+
ofType type:T.Type,
137
134
upTo stopAt:[SyntaxProtocol.Type],
138
-
collect:T.Type,
139
135
stopWithFirstMatch:Bool=false
140
136
)->[T]{
141
137
varmatches:[T]=[]
@@ -162,7 +158,8 @@ extension SyntaxProtocol {
162
158
extensionFallThroughStmtSyntax{
163
159
/// Returns the source and destination of a `fallthrough`.
164
160
///
165
-
/// - Returns: `source` as the switch case that encapsulates the `fallthrough` keyword and `destination` as the switch case that the `fallthrough` directs to.
161
+
/// - Returns: `source` as the switch case that encapsulates the `fallthrough` keyword and
162
+
/// `destination` as the switch case that the `fallthrough` directs to.
/// When calling this function at the `fallthrough`, it returns `case 2` and `case 1` in this exact order. The `nil` results handle ill-formed code: there's no `source` if the `fallthrough` is outside of a case. There's no `destination` if there is no case or `default` after the source case.
Copy file name to clipboardExpand all lines: Tests/SwiftLexicalLookupTest/Assertions.swift
+14-14Lines changed: 14 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -17,16 +17,10 @@ import SwiftSyntax
17
17
import XCTest
18
18
import _SwiftSyntaxTestSupport
19
19
20
-
/// Parse `source` and check if the method passed as `methodUnderTest` produces the same results as indicated in `expected`.
21
-
///
22
-
/// The `methodUnderTest` provides test inputs taken from the `expected` dictionary. The closure should return result produced by the tested method as an array with the same ordering.
23
-
///
24
-
/// - Parameters:
25
-
/// - methodUnderTest: Closure with the tested method. Provides test argument from `expected` to the tested function. Should return method result as an array.
26
-
/// - expected: A dictionary with parameter markers as keys and expected results as marker arrays ordered as returned by the test method.
20
+
/// `methodUnderTest` is called with the token at every position marker in the keys of `expected`. It then asserts that the positions of the syntax nodes returned by `methodUnderTest` are the values in `expected`.
"For marker \(marker), actual result: \(actual?.firstToken(viewMode:.sourceAccurate)??"nil")doesn't match expected value: \(expected?.firstToken(viewMode:.sourceAccurate)??"nil")"
0 commit comments