Skip to content

Commit aa0ed90

Browse files
authored
Merge pull request #1236 from ahoppen/6.0/merge-main-2024-05-07
Merge `main` into `release/6.0`
2 parents 0ccbf68 + 714ff2a commit aa0ed90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2087
-239
lines changed

CODEOWNERS renamed to .github/CODEOWNERS

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,4 @@
88
# Order is important. The last matching pattern has the most precedence.
99

1010
# Owner of anything in SourceKit-LSP not owned by anyone else.
11-
# N: Ben Langmuir
12-
13-
# N: Alex Hoppen
14-
1511
* @benlangmuir @ahoppen

.github/ISSUE_TEMPLATE/BUG_REPORT.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Bug Report
2+
description: Something isn't working as expected
3+
labels: [bug]
4+
body:
5+
- type: input
6+
id: version
7+
attributes:
8+
label: Swift version
9+
description: Which version of Swift are you using? If you are unsure, insert the output of `path/to/swift --version`
10+
placeholder: Eg. swiftlang-5.10.0.13, swift-DEVELOPMENT-SNAPSHOT-2024-05-01-a
11+
- type: input
12+
id: platform
13+
attributes:
14+
label: Platform
15+
description: What operating system are you seeing the issue on?
16+
placeholder: Eg. Ubuntu 22.04, Windows 11, macOS 14
17+
- type: input
18+
id: editor
19+
attributes:
20+
label: Editor
21+
description: Which text editor are you using?
22+
placeholder: Eg. Visual Studio Code with Swift plugin 1.9.0, neovim
23+
- type: dropdown
24+
id: reproduces-with-swift-6
25+
attributes:
26+
label: Does the issue reproduce with Swift 6?
27+
description: |
28+
Does the issue also reproduce using a [recent Swift 6 Development Snapshot](https://www.swift.org/download/#swift-60-development)?
29+
30+
We have made significant changes to SourceKit-LSP in Swift 6 and the issue might have already been fixed. If you didn’t try, that is fine.
31+
options:
32+
- "Yes"
33+
- "No"
34+
- I didn’t try
35+
- type: textarea
36+
id: description
37+
attributes:
38+
label: Description
39+
description: |
40+
A short description of the incorrect behavior.
41+
If you think this issue has been recently introduced and did not occur in an earlier version, please note that. If possible, include the last version that the behavior was correct in addition to your current version.
42+
- type: textarea
43+
id: steps-to-reproduce
44+
attributes:
45+
label: Steps to Reproduce
46+
description: If you have steps that reproduce the issue, please add them here. If you can share a project that reproduces the issue, please attach it.
47+
- type: textarea
48+
id: logging
49+
attributes:
50+
label: Logging
51+
description: |
52+
If you are using SourceKit-LSP from Swift 6, running `sourcekit-lsp diagnose` in terminal and attaching the generated bundle helps us diagnose the issue.
53+
The generated bundle might contain portions of your source code, so please only attach it if you feel comfortable sharing it.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Feature Request
2+
description: A suggestion for a new feature
3+
labels: [enhancement]
4+
body:
5+
- type: textarea
6+
id: description
7+
attributes:
8+
label: Description
9+
description: |
10+
A description of your proposed feature.
11+
Examples that show what's missing, or what new capabilities will be possible, are very helpful!
12+
If this feature unlocks new use-cases please describe them.
13+
Provide links to existing issues or external references/discussions, if appropriate.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This source file is part of the Swift.org open source project
2+
#
3+
# Copyright (c) 2024 Apple Inc. and the Swift project authors
4+
# Licensed under Apache License v2.0 with Runtime Library Exception
5+
#
6+
# See https://swift.org/LICENSE.txt for license information
7+
# See https://swift.org/CONTRIBUTORS.txt for Swift project authors
8+
9+
contact_links:
10+
- name: Discussion Forum
11+
url: https://forums.swift.org/c/development/sourcekit-lsp
12+
about: Ask and answer questions about SourceKit-LSP

Package.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ let package = Package(
168168
]
169169
),
170170

171+
// MARK: SemanticIndex
172+
173+
.target(
174+
name: "SemanticIndex",
175+
dependencies: [
176+
"LSPLogging",
177+
"SKCore",
178+
.product(name: "IndexStoreDB", package: "indexstore-db"),
179+
],
180+
exclude: ["CMakeLists.txt"]
181+
),
182+
171183
// MARK: SKCore
172184
// Data structures and algorithms useful across the project, but not necessarily
173185
// suitable for use in other packages.
@@ -300,9 +312,11 @@ let package = Package(
300312
name: "SourceKitLSP",
301313
dependencies: [
302314
"BuildServerProtocol",
315+
"CAtomics",
303316
"LanguageServerProtocol",
304317
"LanguageServerProtocolJSONRPC",
305318
"LSPLogging",
319+
"SemanticIndex",
306320
"SKCore",
307321
"SKSupport",
308322
"SKSwiftPMWorkspace",

Sources/CAtomics/include/CAtomics.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,32 @@ static inline void atomic_uint8_set(AtomicUInt8 *atomic, uint8_t newValue) {
6363
atomic->value = newValue;
6464
}
6565

66+
// MARK: AtomicInt
67+
68+
typedef struct {
69+
_Atomic(int) value;
70+
} AtomicUInt32;
71+
72+
__attribute__((swift_name("AtomicUInt32.init(initialValue:)")))
73+
static inline AtomicUInt32 atomic_int_create(uint8_t initialValue) {
74+
AtomicUInt32 atomic;
75+
atomic.value = initialValue;
76+
return atomic;
77+
}
78+
79+
__attribute__((swift_name("getter:AtomicUInt32.value(self:)")))
80+
static inline uint32_t atomic_int_get(AtomicUInt32 *atomic) {
81+
return atomic->value;
82+
}
83+
84+
__attribute__((swift_name("setter:AtomicUInt32.value(self:_:)")))
85+
static inline void atomic_uint32_set(AtomicUInt32 *atomic, uint32_t newValue) {
86+
atomic->value = newValue;
87+
}
88+
89+
__attribute__((swift_name("AtomicUInt32.fetchAndIncrement(self:)")))
90+
static inline uint32_t atomic_uint32_fetch_and_increment(AtomicUInt32 *atomic) {
91+
return atomic->value++;
92+
}
93+
6694
#endif // SOURCEKITLSP_CATOMICS_H

Sources/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ add_subdirectory(Diagnose)
55
add_subdirectory(LanguageServerProtocol)
66
add_subdirectory(LanguageServerProtocolJSONRPC)
77
add_subdirectory(LSPLogging)
8+
add_subdirectory(SemanticIndex)
89
add_subdirectory(SKCore)
910
add_subdirectory(SKSupport)
1011
add_subdirectory(SKSwiftPMWorkspace)

Sources/Diagnose/DiagnoseCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public struct DiagnoseCommand: AsyncParsableCommand {
309309
dateFormatter.timeZone = NSTimeZone.local
310310
let date = dateFormatter.string(from: Date()).replacingOccurrences(of: ":", with: "-")
311311
let bundlePath = FileManager.default.temporaryDirectory
312-
.appendingPathComponent("sourcekitd-reproducer-\(date)")
312+
.appendingPathComponent("sourcekit-lsp-diagnose-\(date)")
313313
try FileManager.default.createDirectory(at: bundlePath, withIntermediateDirectories: true)
314314

315315
if components.isEmpty || components.contains(.crashReports) {

Sources/LSPLogging/Logging.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121

2222
import Foundation
2323

24-
/// The subsystem that should be used for any logging by default.
25-
public let subsystem = "org.swift.sourcekit-lsp"
26-
2724
#if canImport(os) && !SOURCEKITLSP_FORCE_NON_DARWIN_LOGGER
2825
import os // os_log
2926

@@ -44,5 +41,5 @@ public typealias Signposter = NonDarwinSignposter
4441

4542
/// The logger that is used to log any messages.
4643
public var logger: Logger {
47-
Logger(subsystem: subsystem, category: LoggingScope.scope)
44+
Logger(subsystem: LoggingScope.subsystem, category: LoggingScope.scope)
4845
}

Sources/LSPLogging/LoggingScope.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,50 @@
1313
import Foundation
1414

1515
public final class LoggingScope {
16+
/// The name of the current logging subsystem or `nil` if no logging scope is set.
17+
@TaskLocal fileprivate static var _subsystem: String?
18+
1619
/// The name of the current logging scope or `nil` if no logging scope is set.
1720
@TaskLocal fileprivate static var _scope: String?
1821

22+
/// The name of the current logging subsystem.
23+
public static var subsystem: String {
24+
return _subsystem ?? "org.swift.sourcekit-lsp"
25+
}
26+
1927
/// The name of the current logging scope.
2028
public static var scope: String {
2129
return _scope ?? "default"
2230
}
2331
}
2432

33+
/// Logs all messages created from the operation to the given subsystem.
34+
///
35+
/// This overrides the current logging subsystem.
36+
///
37+
/// - Note: Since this stores the logging subsystem in a task-local value, it only works when run inside a task.
38+
/// Outside a task, this is a no-op.
39+
public func withLoggingSubsystemAndScope<Result>(
40+
subsystem: String,
41+
scope: String?,
42+
_ operation: () throws -> Result
43+
) rethrows -> Result {
44+
return try LoggingScope.$_subsystem.withValue(subsystem) {
45+
return try LoggingScope.$_scope.withValue(scope, operation: operation)
46+
}
47+
}
48+
49+
/// Same as `withLoggingSubsystemAndScope` but allows the operation to be `async`.
50+
public func withLoggingSubsystemAndScope<Result>(
51+
subsystem: String,
52+
scope: String?,
53+
_ operation: () async throws -> Result
54+
) async rethrows -> Result {
55+
return try await LoggingScope.$_subsystem.withValue(subsystem) {
56+
return try await LoggingScope.$_scope.withValue(scope, operation: operation)
57+
}
58+
}
59+
2560
/// Create a new logging scope, which will be used as the category in any log messages created from the operation.
2661
///
2762
/// This overrides the current logging scope.

0 commit comments

Comments
 (0)