Skip to content

Commit cd0502a

Browse files
committed
Project Panel
Convert the dependencies panel in to the new project panel. This rolls the dependencies up in to its own top level item in the tree, and places it along side Targets, Tasks, Commands and Snippets. Tasks, Commands and Snippets can be run directly from the panel, and update their icon to show their running status. Clicking a test target will run all the tests in the target.
1 parent 4fa67ac commit cd0502a

File tree

26 files changed

+1143
-500
lines changed

26 files changed

+1143
-500
lines changed

assets/test/targets/Package.swift

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// swift-tools-version: 5.6
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "targets",
8+
products: [
9+
.library(
10+
name: "LibraryTarget",
11+
targets: ["LibraryTarget"]
12+
),
13+
.executable(
14+
name: "ExecutableTarget",
15+
targets: ["ExecutableTarget"]
16+
),
17+
.plugin(
18+
name: "PluginTarget",
19+
targets: ["PluginTarget"]
20+
),
21+
],
22+
dependencies: [
23+
.package(url: "https://github.com/swiftlang/swift-markdown.git", branch: "main"),
24+
.package(path: "../defaultPackage"),
25+
],
26+
targets: [
27+
.target(
28+
name: "LibraryTarget"
29+
),
30+
.executableTarget(
31+
name: "ExecutableTarget"
32+
),
33+
.plugin(
34+
name: "PluginTarget",
35+
capability: .command(
36+
intent: .custom(verb: "testing", description: "A plugin for testing plugins")
37+
)
38+
),
39+
.testTarget(
40+
name: "TargetsTests",
41+
dependencies: ["LibraryTarget"]
42+
),
43+
]
44+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import PackagePlugin
2+
import Foundation
3+
4+
@main
5+
struct MyCommandPlugin: CommandPlugin {
6+
func performCommand(context: PluginContext, arguments: [String]) throws {
7+
print("Plugin Target Hello World")
8+
}
9+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("Another Snippet Hello World")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("Snippet Hello World")

assets/test/targets/Sources/CommandPluginTarget/CommandPluginTarget.swift

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("Executable Target Hello World!")
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// The Swift Programming Language
2+
// https://docs.swift.org/swift-book
3+
4+
func foo() {
5+
print("foo")
6+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Testing
2+
3+
@Test func example() async throws {
4+
}

package.json

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@
266266
"command": "swift.runAllTestsParallel",
267267
"title": "Run All Tests in Parallel",
268268
"category": "Test"
269+
},
270+
{
271+
"command": "swift.runAllTests",
272+
"title": "Run All Tests",
273+
"category": "Test"
269274
}
270275
],
271276
"configuration": [
@@ -917,50 +922,50 @@
917922
"view/title": [
918923
{
919924
"command": "swift.updateDependencies",
920-
"when": "view == packageDependencies",
925+
"when": "view == projectPanel",
921926
"group": "navigation@1"
922927
},
923928
{
924929
"command": "swift.resolveDependencies",
925-
"when": "view == packageDependencies",
930+
"when": "view == projectPanel",
926931
"group": "navigation@2"
927932
},
928933
{
929934
"command": "swift.resetPackage",
930-
"when": "view == packageDependencies",
935+
"when": "view == projectPanel",
931936
"group": "navigation@3"
932937
},
933938
{
934939
"command": "swift.flatDependenciesList",
935-
"when": "view == packageDependencies && !swift.flatDependenciesList",
940+
"when": "view == projectPanel && !swift.flatDependenciesList",
936941
"group": "navigation@4"
937942
},
938943
{
939944
"command": "swift.nestedDependenciesList",
940-
"when": "view == packageDependencies && swift.flatDependenciesList",
945+
"when": "view == projectPanel && swift.flatDependenciesList",
941946
"group": "navigation@5"
942947
}
943948
],
944949
"view/item/context": [
945950
{
946951
"command": "swift.useLocalDependency",
947-
"when": "view == packageDependencies && viewItem == remote"
952+
"when": "view == projectPanel && viewItem == remote"
948953
},
949954
{
950955
"command": "swift.uneditDependency",
951-
"when": "view == packageDependencies && viewItem == editing"
956+
"when": "view == projectPanel && viewItem == editing"
952957
},
953958
{
954959
"command": "swift.openInWorkspace",
955-
"when": "view == packageDependencies && viewItem == editing"
960+
"when": "view == projectPanel && viewItem == editing"
956961
},
957962
{
958963
"command": "swift.openInWorkspace",
959-
"when": "view == packageDependencies && viewItem == local"
964+
"when": "view == projectPanel && viewItem == local"
960965
},
961966
{
962967
"command": "swift.openExternal",
963-
"when": "view == packageDependencies && viewItem != local"
968+
"when": "view == projectPanel && (viewItem == 'editing' || viewItem == 'remote')"
964969
}
965970
]
966971
},
@@ -1157,8 +1162,8 @@
11571162
"views": {
11581163
"explorer": [
11591164
{
1160-
"id": "packageDependencies",
1161-
"name": "Package Dependencies",
1165+
"id": "projectPanel",
1166+
"name": "Swift Project",
11621167
"icon": "$(archive)",
11631168
"when": "swift.hasPackage"
11641169
}

src/SwiftPackage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface Target {
4141
c99name: string;
4242
path: string;
4343
sources: string[];
44-
type: "executable" | "test" | "library" | "snippet";
44+
type: "executable" | "test" | "library" | "snippet" | "plugin";
4545
}
4646

4747
/** Swift Package Manager dependency */

0 commit comments

Comments
 (0)