mirror of
https://github.com/github/codeql.git
synced 2026-04-17 21:14:02 +02:00
Swift: add cross-referencing test
This commit is contained in:
6
swift/integration-tests/.gitignore
vendored
6
swift/integration-tests/.gitignore
vendored
@@ -1,7 +1,7 @@
|
||||
.DS_Store
|
||||
/.build
|
||||
/Packages
|
||||
/*.xcodeproj
|
||||
.build
|
||||
Packages
|
||||
*.xcodeproj
|
||||
xcuserdata/
|
||||
DerivedData/
|
||||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
| Sources/cross-references/lib.swift:3:1:6:1 | C |
|
||||
5
swift/integration-tests/cross-references/Classes.ql
Normal file
5
swift/integration-tests/cross-references/Classes.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import swift
|
||||
|
||||
from ClassDecl d
|
||||
where d.getLocation().getFile().getBaseName() != "Package.swift"
|
||||
select d
|
||||
@@ -0,0 +1,3 @@
|
||||
| Sources/cross-references/lib.swift:4:5:4:13 | init |
|
||||
| Sources/cross-references/lib.swift:14:8:14:8 | init |
|
||||
| Sources/cross-references/main.swift:11:8:11:8 | init |
|
||||
5
swift/integration-tests/cross-references/Constructors.ql
Normal file
5
swift/integration-tests/cross-references/Constructors.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import swift
|
||||
|
||||
from ConstructorDecl d
|
||||
where d.getLocation().getFile().getBaseName() != "Package.swift"
|
||||
select d
|
||||
@@ -0,0 +1 @@
|
||||
| Sources/cross-references/lib.swift:5:5:5:13 | deinit |
|
||||
5
swift/integration-tests/cross-references/Destructors.ql
Normal file
5
swift/integration-tests/cross-references/Destructors.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import swift
|
||||
|
||||
from DestructorDecl d
|
||||
where d.getLocation().getFile().getBaseName() != "Package.swift"
|
||||
select d
|
||||
1
swift/integration-tests/cross-references/Enums.expected
Normal file
1
swift/integration-tests/cross-references/Enums.expected
Normal file
@@ -0,0 +1 @@
|
||||
| Sources/cross-references/lib.swift:8:1:8:17 | E |
|
||||
5
swift/integration-tests/cross-references/Enums.ql
Normal file
5
swift/integration-tests/cross-references/Enums.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import swift
|
||||
|
||||
from EnumDecl d
|
||||
where d.getLocation().getFile().getBaseName() != "Package.swift"
|
||||
select d
|
||||
@@ -0,0 +1,4 @@
|
||||
| Sources/cross-references/lib.swift:1:1:1:11 | f |
|
||||
| Sources/cross-references/lib.swift:17:8:19:1 | ~ |
|
||||
| Sources/cross-references/lib.swift:22:9:24:1 | ~ |
|
||||
| Sources/cross-references/lib.swift:27:1:29:1 | ~ |
|
||||
5
swift/integration-tests/cross-references/Functions.ql
Normal file
5
swift/integration-tests/cross-references/Functions.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import swift
|
||||
|
||||
from FuncDecl f
|
||||
where f.getLocation().getFile().getBaseName() != "Package.swift"
|
||||
select f
|
||||
@@ -0,0 +1,3 @@
|
||||
| Sources/cross-references/lib.swift:16:8:16:17 | ~ |
|
||||
| Sources/cross-references/lib.swift:21:9:21:18 | ~ |
|
||||
| Sources/cross-references/lib.swift:26:7:26:16 | ~ |
|
||||
5
swift/integration-tests/cross-references/Operators.ql
Normal file
5
swift/integration-tests/cross-references/Operators.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import swift
|
||||
|
||||
from OperatorDecl d
|
||||
where d.getLocation().getFile().getBaseName() != "Package.swift"
|
||||
select d
|
||||
21
swift/integration-tests/cross-references/Package.swift
Normal file
21
swift/integration-tests/cross-references/Package.swift
Normal file
@@ -0,0 +1,21 @@
|
||||
// swift-tools-version:5.5
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "cross-references",
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||
.executable(
|
||||
name: "cross-references",
|
||||
targets: ["cross-references"]),
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products in packages this package depends on.
|
||||
.executableTarget(
|
||||
name: "cross-references",
|
||||
dependencies: []),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
| Sources/cross-references/lib.swift:12:1:12:13 | P |
|
||||
5
swift/integration-tests/cross-references/Protocols.ql
Normal file
5
swift/integration-tests/cross-references/Protocols.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import swift
|
||||
|
||||
from ProtocolDecl d
|
||||
where d.getLocation().getFile().getBaseName() != "Package.swift"
|
||||
select d
|
||||
@@ -0,0 +1,30 @@
|
||||
func f() {}
|
||||
|
||||
class C {
|
||||
init() {}
|
||||
deinit {}
|
||||
}
|
||||
|
||||
enum E { case e }
|
||||
|
||||
let X = 42
|
||||
|
||||
protocol P {}
|
||||
|
||||
struct S : P {}
|
||||
|
||||
prefix operator ~
|
||||
prefix func ~ (v: Int) -> Int {
|
||||
return v
|
||||
}
|
||||
|
||||
postfix operator ~
|
||||
postfix func ~(v: Int) -> Int {
|
||||
return v
|
||||
}
|
||||
|
||||
infix operator ~
|
||||
func ~(lhs: Int, rhs: Int) -> Int {
|
||||
return lhs
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
f()
|
||||
|
||||
C()
|
||||
|
||||
E.e
|
||||
|
||||
X
|
||||
|
||||
S()
|
||||
|
||||
struct s : P {}
|
||||
|
||||
~42
|
||||
|
||||
42~
|
||||
|
||||
15 ~ 42
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
| Sources/cross-references/lib.swift:14:1:14:15 | S |
|
||||
| Sources/cross-references/main.swift:11:1:11:15 | s |
|
||||
5
swift/integration-tests/cross-references/Structs.ql
Normal file
5
swift/integration-tests/cross-references/Structs.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import swift
|
||||
|
||||
from StructDecl d
|
||||
where d.getLocation().getFile().getBaseName() != "Package.swift"
|
||||
select d
|
||||
@@ -0,0 +1,6 @@
|
||||
| Sources/cross-references/lib.swift:10:5:10:5 | X |
|
||||
| Sources/cross-references/lib.swift:10:5:10:5 | X |
|
||||
| Sources/cross-references/lib.swift:17:16:17:19 | v |
|
||||
| Sources/cross-references/lib.swift:22:16:22:19 | v |
|
||||
| Sources/cross-references/lib.swift:27:8:27:13 | lhs |
|
||||
| Sources/cross-references/lib.swift:27:18:27:23 | rhs |
|
||||
5
swift/integration-tests/cross-references/VarDecls.ql
Normal file
5
swift/integration-tests/cross-references/VarDecls.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import swift
|
||||
|
||||
from VarDecl d
|
||||
where d.getLocation().getFile().getBaseName() != "Package.swift"
|
||||
select d
|
||||
7
swift/integration-tests/cross-references/test.py
Normal file
7
swift/integration-tests/cross-references/test.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create([
|
||||
'swift package clean',
|
||||
'swift build'
|
||||
], lang='swift')
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
| Sources/hello-world/hello_world.swift:0:0:0:0 | Sources/hello-world/hello_world.swift |
|
||||
| file://:0:0:0:0 | |
|
||||
|
||||
Reference in New Issue
Block a user