Skip to content

Commit f042ffd

Browse files
authored
Enable AccessLevelOnImport in SourceKitLSPAPI (#7366)
This prevents unnecessary API details from leaking outside of the SwiftPM package via `SourceKitLSPAPI` product.
1 parent b9fc53b commit f042ffd

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

Package.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ let package = Package(
168168
"Build",
169169
"SPMBuildCore"
170170
],
171-
exclude: ["CMakeLists.txt"]
171+
exclude: ["CMakeLists.txt"],
172+
swiftSettings: [.enableExperimentalFeature("AccessLevelOnImport")]
172173
),
173174

174175
// MARK: SwiftPM specific support libraries

Sources/SourceKitLSPAPI/BuildDescription.swift

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@
22
//
33
// This source file is part of the Swift open source project
44
//
5-
// Copyright (c) 2023 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2023-2024 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
99
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
import Foundation
13+
import struct Foundation.URL
1414

15-
/*private*/ import struct Basics.AbsolutePath
16-
/*private*/ import func Basics.resolveSymlinks
17-
// FIXME: should not import this module
18-
import Build
19-
// FIXME: should be internal imports
20-
import PackageGraph
21-
/*private*/ import SPMBuildCore
15+
private import struct Basics.AbsolutePath
16+
private import func Basics.resolveSymlinks
17+
18+
private import SPMBuildCore
19+
20+
// FIXME: should import these module with `private` or `internal` access control
21+
import class Build.BuildPlan
22+
import class Build.ClangTargetBuildDescription
23+
import class Build.SwiftTargetBuildDescription
24+
import struct PackageGraph.ResolvedTarget
2225

2326
public protocol BuildTarget {
2427
var sources: [URL] { get }
@@ -49,7 +52,8 @@ private struct WrappedSwiftTargetBuildDescription: BuildTarget {
4952
}
5053

5154
func compileArguments(for fileURL: URL) throws -> [String] {
52-
// Note: we ignore the `fileURL` here as the expectation is that we get a commandline for the entire target in case of Swift.
55+
// Note: we ignore the `fileURL` here as the expectation is that we get a command line for the entire target
56+
// in case of Swift.
5357
return try description.emitCommandLine(scanInvocation: false)
5458
}
5559
}

Sources/SourceKitLSPAPI/PluginTargetBuildDescription.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
import Foundation
13+
import struct Foundation.URL
1414

15-
// FIXME: should be an internal import
1615
import struct PackageGraph.ResolvedTarget
1716

18-
/*private*/ import class PackageLoading.ManifestLoader
19-
/*private*/ import struct PackageModel.ToolsVersion
20-
/*private*/ import class PackageModel.UserToolchain
17+
private import class PackageLoading.ManifestLoader
18+
internal import struct PackageModel.ToolsVersion
19+
private import class PackageModel.UserToolchain
2120

2221
struct PluginTargetBuildDescription: BuildTarget {
2322
private let target: ResolvedTarget

0 commit comments

Comments
 (0)