Skip to content

Commit c092851

Browse files
committed
Swift: Add a test for ExtensionDecls.
1 parent fb1a871 commit c092851

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| extensiondecl.swift:11:1:12:1 | extension | getExtendedTypeDecl:MyClass |
2+
| extensiondecl.swift:14:1:15:1 | extension | getExtendedTypeDecl:MyClass, getProtocol(0):MyProtocol1, getProtocol(1):MyProtocol2 |
3+
| extensiondecl.swift:17:1:18:1 | extension | getExtendedTypeDecl:Int |
4+
| extensiondecl.swift:20:1:21:1 | extension | getExtendedTypeDecl:String |
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import swift
2+
3+
string describe(ExtensionDecl e) {
4+
result = "getExtendedTypeDecl:" + e.getExtendedTypeDecl().toString()
5+
or
6+
exists(int ix | result = "getProtocol(" + ix.toString() + "):" + e.getProtocol(ix).toString())
7+
}
8+
9+
from ExtensionDecl e
10+
where not e.getFile() instanceof UnknownFile
11+
select e, concat(describe(e), ", ")
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
protocol MyProtocol1 {
3+
}
4+
5+
protocol MyProtocol2 {
6+
}
7+
8+
class MyClass {
9+
}
10+
11+
extension MyClass {
12+
}
13+
14+
extension MyClass : MyProtocol1, MyProtocol2 {
15+
}
16+
17+
extension Int {
18+
}
19+
20+
extension String {
21+
}

0 commit comments

Comments
 (0)