Skip to content

Commit 07b9cc2

Browse files
committed
Requested changes from PR
rename symbol to symbolUSR Cleanup OpenInterfaceRequest.init
1 parent 0da1d40 commit 07b9cc2

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

Sources/LanguageServerProtocol/Requests/OpenInterfaceRequest.swift

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,16 @@ public struct OpenInterfaceRequest: TextDocumentRequest, Hashable {
2525
/// The module group name.
2626
public var groupNames: [String]
2727

28-
/// The symbol to search for in the generated module interface.
29-
public var symbol: String?
28+
/// The symbol USR to search for in the generated module interface.
29+
public var symbolUSR: String?
3030

31-
public init(textDocument: TextDocumentIdentifier, name: String, symbol: String?) {
31+
public init(textDocument: TextDocumentIdentifier, name: String, symbolUSR: String?) {
3232
self.textDocument = textDocument
33-
self.symbol = symbol
33+
self.symbolUSR = symbolUSR
3434
// Stdlib Swift modules are all in the "Swift" module, but their symbols return a module name `Swift.***`.
3535
let splitName = name.split(separator: ".")
36-
if splitName.count == 1 {
37-
self.moduleName = name
38-
self.groupNames = []
39-
} else {
40-
self.moduleName = String(splitName[0])
41-
self.groupNames = [String.SubSequence](splitName.dropFirst()).map { String($0)}
42-
}
36+
self.moduleName = String(splitName[0])
37+
self.groupNames = [String.SubSequence](splitName.dropFirst()).map(String.init)
4338
}
4439

4540
/// Name of interface module name with group names appended

Sources/SourceKitLSP/SourceKitServer.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ extension SourceKitServer {
13071307

13081308
// If this symbol is a module then generate a textual interface
13091309
if case .success(let symbols) = result, let symbol = symbols.first, symbol.kind == .module, let name = symbol.name {
1310-
self.respondWithInterface(req, moduleName: name, symbol: nil, languageService: languageService)
1310+
self.respondWithInterface(req, moduleName: name, symbolUSR: nil, languageService: languageService)
13111311
return
13121312
}
13131313

@@ -1330,7 +1330,7 @@ extension SourceKitServer {
13301330
self.respondWithInterface(
13311331
req,
13321332
moduleName: moduleName,
1333-
symbol: firstResolved.occurrence?.symbol.usr,
1333+
symbolUSR: firstResolved.occurrence?.symbol.usr,
13341334
languageService: languageService
13351335
)
13361336
return
@@ -1357,10 +1357,10 @@ extension SourceKitServer {
13571357
func respondWithInterface(
13581358
_ req: Request<DefinitionRequest>,
13591359
moduleName: String,
1360-
symbol: String?,
1360+
symbolUSR: String?,
13611361
languageService: ToolchainLanguageServer
13621362
) {
1363-
let openInterface = OpenInterfaceRequest(textDocument: req.params.textDocument, name: moduleName, symbol: symbol)
1363+
let openInterface = OpenInterfaceRequest(textDocument: req.params.textDocument, name: moduleName, symbolUSR: symbolUSR)
13641364
let request = Request(openInterface, id: req.id, clientID: ObjectIdentifier(self),
13651365
cancellation: req.cancellationToken, reply: { (result: Result<OpenInterfaceRequest.Response, ResponseError>) in
13661366
switch result {

Sources/SourceKitLSP/Swift/OpenInterface.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extension SwiftLanguageServer {
2929
let uri = request.params.textDocument.uri
3030
let moduleName = request.params.moduleName
3131
let name = request.params.name
32-
let symbol = request.params.symbol
32+
let symbol = request.params.symbolUSR
3333
self.queue.async {
3434
let interfaceFilePath = self.generatedInterfacesPath.appendingPathComponent("\(name).swiftinterface")
3535
let interfaceDocURI = DocumentURI(interfaceFilePath)

0 commit comments

Comments
 (0)