Skip to content

Commit

Permalink
add PluginExample for UseAccessLevelOnImports option
Browse files Browse the repository at this point in the history
  • Loading branch information
Skoti committed Aug 4, 2024
1 parent 2df2aa0 commit 690fe66
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 1 deletion.
15 changes: 14 additions & 1 deletion PluginExamples/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.6
// swift-tools-version: 5.8

import PackageDescription

Expand All @@ -14,6 +14,7 @@ let package = Package(
.target(name: "Simple"),
.target(name: "Nested"),
.target(name: "Import"),
.target(name: "AccessLevelOnImport"),
]
),
.target(
Expand Down Expand Up @@ -43,5 +44,17 @@ let package = Package(
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
]
),
.target(
name: "AccessLevelOnImport",
dependencies: [
.product(name: "SwiftProtobuf", package: "swift-protobuf"),
],
swiftSettings: [
.enableExperimentalFeature("AccessLevelOnImport"),
],
plugins: [
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
]
)
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto3";

import "Dependency/Dependency.proto";

message AccessLevelOnImport {
Dependency dependency = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
syntax = "proto3";

message Dependency {
string name = 1;
}
3 changes: 3 additions & 0 deletions PluginExamples/Sources/AccessLevelOnImport/empty.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// DO NOT DELETE.
///
/// We need to keep this file otherwise the plugin is not running.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"invocations": [
{
"protoFiles": [
"AccessLevelOnImport/AccessLevelOnImport.proto",
"Dependency/Dependency.proto",
],
"visibility": "public",
"useAccessLevelOnImports": true
}
]
}
10 changes: 10 additions & 0 deletions PluginExamples/Sources/ExampleTests/ExampleTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Simple
import Nested
import Import
import AccessLevelOnImport

import XCTest

Expand All @@ -19,4 +20,13 @@ final class ExampleTests: XCTestCase {
let foo = Foo.with { $0.bar = .with { $0.name = "Bar" } }
XCTAssertEqual(foo.bar.name, "Bar")
}

#if compiler(>=5.9)
#if hasFeature(AccessLevelOnImport)
func testAccessLevelOnImport() {
let foo = Foo.with { $0.bar = .with { $0.name = "Bar" } }
XCTAssertEqual(foo.bar.name, "Bar")
}
#endif
#endif
}

0 comments on commit 690fe66

Please sign in to comment.