-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37867 from fwcd/sourcekit-var-types
[SourceKit] Add `CollectVariableType` request
- Loading branch information
Showing
24 changed files
with
717 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
let x: Int = 3 | ||
let y = "abc" | ||
|
||
var foo = ["abc" + "def"] | ||
|
||
struct A { | ||
let x: String = "" | ||
let y = "" | ||
} | ||
|
||
class B { | ||
var x = 4.0 | ||
var y = [A]() | ||
var z: [Int: Int] = [:] | ||
var w: (Int) -> Int { { $0 * 2 } } | ||
} | ||
|
||
func foo() { | ||
var local = 5 | ||
} | ||
|
||
// RUN: %sourcekitd-test -req=collect-var-type %s -- %s | %FileCheck %s | ||
// CHECK: (1:5, 1:6): Int (explicit type: 1) | ||
// CHECK: (2:5, 2:6): String (explicit type: 0) | ||
// CHECK: (4:5, 4:8): [String] (explicit type: 0) | ||
// CHECK: (7:7, 7:8): String (explicit type: 1) | ||
// CHECK: (8:7, 8:8): String (explicit type: 0) | ||
// CHECK: (12:7, 12:8): Double (explicit type: 0) | ||
// CHECK: (13:7, 13:8): [A] (explicit type: 0) | ||
// CHECK: (14:7, 14:8): [Int : Int] (explicit type: 1) | ||
// CHECK: (15:7, 15:8): (Int) -> Int (explicit type: 1) | ||
// CHECK: (19:7, 19:12): Int (explicit type: 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
let x = "an error type" + 3 | ||
let y = "not an error type" | ||
|
||
// RUN: %sourcekitd-test -req=collect-var-type %s -- %s | %FileCheck %s | ||
// CHECK-NOT: (1:5, 1:6) | ||
// CHECK: (2:5, 2:6): String (explicit type: 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
func x(_ param: inout Int) -> Int { | ||
param = 4 | ||
} | ||
|
||
let z = { (param: inout String) in } | ||
|
||
// RUN: %sourcekitd-test -req=collect-var-type %s -- %s | %FileCheck %s | ||
// CHECK: (1:10, 1:15): Int (explicit type: 1) | ||
// CHECK: (5:5, 5:6): (inout String) -> () (explicit type: 0) | ||
// CHECK: (5:12, 5:17): String (explicit type: 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
func x(_ param: Int) -> Int { | ||
param | ||
} | ||
|
||
let y: (String) -> Void = { param in } | ||
|
||
let z = { (param: String) in | ||
param.count | ||
} | ||
|
||
// RUN: %sourcekitd-test -req=collect-var-type %s -- %s | %FileCheck %s | ||
// CHECK: (1:10, 1:15): Int (explicit type: 1) | ||
// CHECK: (5:5, 5:6): (String) -> Void (explicit type: 1) | ||
// CHECK: (5:29, 5:34): String (explicit type: 0) | ||
// CHECK: (7:5, 7:6): (String) -> Int (explicit type: 0) | ||
// CHECK: (7:12, 7:17): String (explicit type: 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
let x = 1 | ||
let y = "abc" | ||
let z: String = "def" | ||
var w = 4 | ||
|
||
// RUN: %sourcekitd-test -req=collect-var-type -pos=2:1 -end-pos=4:1 %s -- %s | %FileCheck %s | ||
// CHECK-NOT: (1:5, 1:6) | ||
// CHECK: (2:5, 2:6): String (explicit type: 0) | ||
// CHECK: (3:5, 3:6): String (explicit type: 1) | ||
// CHECK-NOT: (4:5, 4:6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.