Skip to content

Commit b9962e5

Browse files
committed
Unified: Extract init keywords
1 parent e258ded commit b9962e5

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎unified/extractor/src/languages/swift/swift.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,13 +1274,15 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
12741274
// nest under `signature` (as for `functionDecl`).
12751275
rule!(
12761276
(initializerDecl
1277+
initKeyword: @initK
12771278
modifiers: _* @mods
12781279
signature: (functionSignature
12791280
parameterClause: (functionParameterClause parameters: _* @params))
12801281
body: (codeBlock statements: _* @body_stmts)?)
12811282
=>
12821283
(constructor_declaration
12831284
modifier: {mods}
1285+
name_node: (identifier #{initK})
12841286
parameter: {params}
12851287
body: (block stmt: {body_stmts}))
12861288
),

‎unified/ql/test/library-tests/controlflow/cfg.expected‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@ noCfg
153153
| cfg.swift:358:6:358:28 | loop_with_identity_expr |
154154
| cfg.swift:371:8:371:18 | getOptional |
155155
| cfg.swift:380:45:380:47 | Int |
156+
| cfg.swift:391:3:391:6 | init |
157+
| cfg.swift:408:3:408:6 | init |
156158
| cfg.swift:421:6:421:22 | localDeclarations |
159+
| cfg.swift:424:5:424:8 | init |
160+
| cfg.swift:431:5:431:8 | init |
157161
| cfg.swift:468:6:468:17 | testIfConfig |
158162
| cfg.swift:497:6:497:18 | testAvailable |
159163
| cfg.swift:524:6:524:17 | testAsyncFor |

‎unified/ql/test/library-tests/controlflow/cfg.swift‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ func testTupleElement(t : (a: Int, Int, c: Int)) -> Int {
388388
}
389389

390390
class Derived : C { // $ nonSimple='ClassLikeDeclaration -V Derived -^ BaseType -V C'
391-
init() {
391+
init() { // $ noCfg
392392
super.init(n: 0)
393393
}
394394
}
@@ -405,7 +405,7 @@ func doWithoutCatch(x : Int) throws -> Int {
405405

406406
class Structors {
407407
var field: Int
408-
init() {
408+
init() { // $ noCfg
409409
field = 10
410410
}
411411

@@ -421,14 +421,14 @@ func dictionaryLiteral(x: Int, y: Int) -> [String: Int] {
421421
func localDeclarations() -> Int { // $ noCfg
422422
class MyLocalClass {
423423
var x: Int
424-
init() {
424+
init() { // $ noCfg
425425
x = 10
426426
}
427427
}
428428

429429
struct MyLocalStruct {
430430
var x: Int
431-
init() {
431+
init() { // $ noCfg
432432
x = 10
433433
}
434434
}

0 commit comments

Comments
 (0)