Skip to content

Commit d3de458

Browse files
committed
Rename note to notification throughout the codebase wherever necessary
1 parent 84007ca commit d3de458

File tree

9 files changed

+93
-93
lines changed

9 files changed

+93
-93
lines changed

Sources/LSPTestSupport/TestJSONRPCConnection.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ public actor TestClient: MessageHandler {
111111
}
112112

113113
public func appendOneShotNotificationHandler<N: NotificationType>(_ handler: @escaping (N) -> Void) {
114-
oneShotNotificationHandlers.append({ anyNote in
115-
guard let note = anyNote as? N else {
116-
fatalError("received notification of the wrong type \(anyNote); expected \(N.self)")
114+
oneShotNotificationHandlers.append({ anyNotification in
115+
guard let notification = anyNotification as? N else {
116+
fatalError("received notification of the wrong type \(anyNotification); expected \(N.self)")
117117
}
118-
handler(note)
118+
handler(notification)
119119
})
120120
}
121121

Sources/SourceKitLSP/Clang/ClangLanguageService.swift

+16-16
Original file line numberDiff line numberDiff line change
@@ -464,30 +464,30 @@ extension ClangLanguageService {
464464

465465
// MARK: - Text synchronization
466466

467-
public func openDocument(_ note: DidOpenTextDocumentNotification) async {
468-
openDocuments[note.textDocument.uri] = note.textDocument.language
467+
public func openDocument(_ notification: DidOpenTextDocumentNotification) async {
468+
openDocuments[notification.textDocument.uri] = notification.textDocument.language
469469
// Send clangd the build settings for the new file. We need to do this before
470470
// sending the open notification, so that the initial diagnostics already
471471
// have build settings.
472-
await documentUpdatedBuildSettings(note.textDocument.uri)
473-
clangd.send(note)
472+
await documentUpdatedBuildSettings(notification.textDocument.uri)
473+
clangd.send(notification)
474474
}
475475

476-
public func closeDocument(_ note: DidCloseTextDocumentNotification) {
477-
openDocuments[note.textDocument.uri] = nil
478-
clangd.send(note)
476+
public func closeDocument(_ notification: DidCloseTextDocumentNotification) {
477+
openDocuments[notification.textDocument.uri] = nil
478+
clangd.send(notification)
479479
}
480480

481-
public func changeDocument(_ note: DidChangeTextDocumentNotification) {
482-
clangd.send(note)
481+
public func changeDocument(_ notification: DidChangeTextDocumentNotification) {
482+
clangd.send(notification)
483483
}
484484

485-
public func willSaveDocument(_ note: WillSaveTextDocumentNotification) {
485+
public func willSaveDocument(_ notification: WillSaveTextDocumentNotification) {
486486

487487
}
488488

489-
public func didSaveDocument(_ note: DidSaveTextDocumentNotification) {
490-
clangd.send(note)
489+
public func didSaveDocument(_ notification: DidSaveTextDocumentNotification) {
490+
clangd.send(notification)
491491
}
492492

493493
// MARK: - Build System Integration
@@ -505,26 +505,26 @@ extension ClangLanguageService {
505505
if let compileCommand = clangBuildSettings?.compileCommand,
506506
let pathString = (try? AbsolutePath(validating: url.path))?.pathString
507507
{
508-
let note = DidChangeConfigurationNotification(
508+
let notification = DidChangeConfigurationNotification(
509509
settings: .clangd(
510510
ClangWorkspaceSettings(
511511
compilationDatabaseChanges: [pathString: compileCommand])
512512
)
513513
)
514-
clangd.send(note)
514+
clangd.send(notification)
515515
}
516516
}
517517

518518
public func documentDependenciesUpdated(_ uri: DocumentURI) {
519519
// In order to tell clangd to reload an AST, we send it an empty `didChangeTextDocument`
520520
// with `forceRebuild` set in case any missing header files have been added.
521521
// This works well for us as the moment since clangd ignores the document version.
522-
let note = DidChangeTextDocumentNotification(
522+
let notification = DidChangeTextDocumentNotification(
523523
textDocument: VersionedTextDocumentIdentifier(uri, version: 0),
524524
contentChanges: [],
525525
forceRebuild: true
526526
)
527-
clangd.send(note)
527+
clangd.send(notification)
528528
}
529529

530530
// MARK: - Text Document

Sources/SourceKitLSP/DocumentManager.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -210,31 +210,31 @@ extension DocumentManager {
210210

211211
/// Convenience wrapper for `open(_:language:version:text:)` that logs on failure.
212212
@discardableResult
213-
func open(_ note: DidOpenTextDocumentNotification) -> DocumentSnapshot? {
214-
let doc = note.textDocument
213+
func open(_ notification: DidOpenTextDocumentNotification) -> DocumentSnapshot? {
214+
let doc = notification.textDocument
215215
return orLog("failed to open document", level: .error) {
216216
try open(doc.uri, language: doc.language, version: doc.version, text: doc.text)
217217
}
218218
}
219219

220220
/// Convenience wrapper for `close(_:)` that logs on failure.
221-
func close(_ note: DidCloseTextDocumentNotification) {
221+
func close(_ notification: DidCloseTextDocumentNotification) {
222222
orLog("failed to close document", level: .error) {
223-
try close(note.textDocument.uri)
223+
try close(notification.textDocument.uri)
224224
}
225225
}
226226

227227
/// Convenience wrapper for `edit(_:newVersion:edits:updateDocumentTokens:)`
228228
/// that logs on failure.
229229
@discardableResult
230230
func edit(
231-
_ note: DidChangeTextDocumentNotification
231+
_ notification: DidChangeTextDocumentNotification
232232
) -> (preEditSnapshot: DocumentSnapshot, postEditSnapshot: DocumentSnapshot, edits: [SourceEdit])? {
233233
return orLog("failed to edit document", level: .error) {
234234
return try edit(
235-
note.textDocument.uri,
236-
newVersion: note.textDocument.version,
237-
edits: note.contentChanges
235+
notification.textDocument.uri,
236+
newVersion: notification.textDocument.version,
237+
edits: notification.contentChanges
238238
)
239239
}
240240
}

Sources/SourceKitLSP/LanguageService.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ public protocol LanguageService: AnyObject, Sendable {
9898
/// Sent to open up a document on the Language Server.
9999
/// This may be called before or after a corresponding
100100
/// `documentUpdatedBuildSettings` call for the same document.
101-
func openDocument(_ note: DidOpenTextDocumentNotification) async
101+
func openDocument(_ notification: DidOpenTextDocumentNotification) async
102102

103103
/// Sent to close a document on the Language Server.
104-
func closeDocument(_ note: DidCloseTextDocumentNotification) async
105-
func changeDocument(_ note: DidChangeTextDocumentNotification) async
106-
func willSaveDocument(_ note: WillSaveTextDocumentNotification) async
107-
func didSaveDocument(_ note: DidSaveTextDocumentNotification) async
104+
func closeDocument(_ notification: DidCloseTextDocumentNotification) async
105+
func changeDocument(_ notification: DidChangeTextDocumentNotification) async
106+
func willSaveDocument(_ notification: WillSaveTextDocumentNotification) async
107+
func didSaveDocument(_ notification: DidSaveTextDocumentNotification) async
108108

109109
// MARK: - Build System Integration
110110

Sources/SourceKitLSP/SourceKitLSPServer.swift

+10-10
Original file line numberDiff line numberDiff line change
@@ -1574,12 +1574,12 @@ extension SourceKitLSPServer {
15741574
await openDocument(notification, workspace: workspace)
15751575
}
15761576

1577-
private func openDocument(_ note: DidOpenTextDocumentNotification, workspace: Workspace) async {
1577+
private func openDocument(_ notification: DidOpenTextDocumentNotification, workspace: Workspace) async {
15781578
// Immediately open the document even if the build system isn't ready. This is important since
15791579
// we check that the document is open when we receive messages from the build system.
1580-
documentManager.open(note)
1580+
documentManager.open(notification)
15811581

1582-
let textDocument = note.textDocument
1582+
let textDocument = notification.textDocument
15831583
let uri = textDocument.uri
15841584
let language = textDocument.language
15851585

@@ -1591,7 +1591,7 @@ extension SourceKitLSPServer {
15911591
await workspace.buildSystemManager.registerForChangeNotifications(for: uri, language: language)
15921592

15931593
// If the document is ready, we can immediately send the notification.
1594-
await service.openDocument(note)
1594+
await service.openDocument(notification)
15951595
}
15961596

15971597
func closeDocument(_ notification: DidCloseTextDocumentNotification) async {
@@ -1605,16 +1605,16 @@ extension SourceKitLSPServer {
16051605
await self.closeDocument(notification, workspace: workspace)
16061606
}
16071607

1608-
func closeDocument(_ note: DidCloseTextDocumentNotification, workspace: Workspace) async {
1608+
func closeDocument(_ notification: DidCloseTextDocumentNotification, workspace: Workspace) async {
16091609
// Immediately close the document. We need to be sure to clear our pending work queue in case
16101610
// the build system still isn't ready.
1611-
documentManager.close(note)
1611+
documentManager.close(notification)
16121612

1613-
let uri = note.textDocument.uri
1613+
let uri = notification.textDocument.uri
16141614

16151615
await workspace.buildSystemManager.unregisterForChangeNotifications(for: uri)
16161616

1617-
await workspace.documentService.value[uri]?.closeDocument(note)
1617+
await workspace.documentService.value[uri]?.closeDocument(notification)
16181618
}
16191619

16201620
func changeDocument(_ notification: DidChangeTextDocumentNotification) async {
@@ -1641,10 +1641,10 @@ extension SourceKitLSPServer {
16411641
}
16421642

16431643
func didSaveDocument(
1644-
_ note: DidSaveTextDocumentNotification,
1644+
_ notification: DidSaveTextDocumentNotification,
16451645
languageService: LanguageService
16461646
) async {
1647-
await languageService.didSaveDocument(note)
1647+
await languageService.didSaveDocument(notification)
16481648
}
16491649

16501650
func didChangeWorkspaceFolders(_ notification: DidChangeWorkspaceFoldersNotification) async {

Sources/SourceKitLSP/Swift/SwiftLanguageService.swift

+19-19
Original file line numberDiff line numberDiff line change
@@ -387,17 +387,17 @@ extension SwiftLanguageService {
387387
])
388388
}
389389

390-
public func openDocument(_ note: DidOpenTextDocumentNotification) async {
391-
cancelInFlightPublishDiagnosticsTask(for: note.textDocument.uri)
392-
await diagnosticReportManager.removeItemsFromCache(with: note.textDocument.uri)
390+
public func openDocument(_ notification: DidOpenTextDocumentNotification) async {
391+
cancelInFlightPublishDiagnosticsTask(for: notification.textDocument.uri)
392+
await diagnosticReportManager.removeItemsFromCache(with: notification.textDocument.uri)
393393

394-
guard let snapshot = self.documentManager.open(note) else {
394+
guard let snapshot = self.documentManager.open(notification) else {
395395
// Already logged failure.
396396
return
397397
}
398398

399399
let buildSettings = await self.buildSettings(for: snapshot.uri)
400-
if buildSettings == nil || buildSettings!.isFallback, let fileUrl = note.textDocument.uri.fileURL {
400+
if buildSettings == nil || buildSettings!.isFallback, let fileUrl = notification.textDocument.uri.fileURL {
401401
// Do not show this notification for non-file URIs to make sure we don't see this notificaiton for newly created
402402
// files (which get opened as with a `untitled:Unitled-1` URI by VS Code.
403403
await sourceKitLSPServer?.sendNotificationToClient(
@@ -414,17 +414,17 @@ extension SwiftLanguageService {
414414

415415
let req = openDocumentSourcekitdRequest(snapshot: snapshot, compileCommand: buildSettings)
416416
_ = try? await self.sourcekitd.send(req, fileContents: snapshot.text)
417-
await publishDiagnosticsIfNeeded(for: note.textDocument.uri)
417+
await publishDiagnosticsIfNeeded(for: notification.textDocument.uri)
418418
}
419419

420-
public func closeDocument(_ note: DidCloseTextDocumentNotification) async {
421-
cancelInFlightPublishDiagnosticsTask(for: note.textDocument.uri)
422-
inFlightPublishDiagnosticsTasks[note.textDocument.uri] = nil
423-
await diagnosticReportManager.removeItemsFromCache(with: note.textDocument.uri)
420+
public func closeDocument(_ notification: DidCloseTextDocumentNotification) async {
421+
cancelInFlightPublishDiagnosticsTask(for: notification.textDocument.uri)
422+
inFlightPublishDiagnosticsTasks[notification.textDocument.uri] = nil
423+
await diagnosticReportManager.removeItemsFromCache(with: notification.textDocument.uri)
424424

425-
self.documentManager.close(note)
425+
self.documentManager.close(notification)
426426

427-
let req = closeDocumentSourcekitdRequest(uri: note.textDocument.uri)
427+
let req = closeDocumentSourcekitdRequest(uri: notification.textDocument.uri)
428428
_ = try? await self.sourcekitd.send(req, fileContents: nil)
429429
}
430430

@@ -506,8 +506,8 @@ extension SwiftLanguageService {
506506
}
507507
}
508508

509-
public func changeDocument(_ note: DidChangeTextDocumentNotification) async {
510-
cancelInFlightPublishDiagnosticsTask(for: note.textDocument.uri)
509+
public func changeDocument(_ notification: DidChangeTextDocumentNotification) async {
510+
cancelInFlightPublishDiagnosticsTask(for: notification.textDocument.uri)
511511

512512
let keys = self.keys
513513
struct Edit {
@@ -516,14 +516,14 @@ extension SwiftLanguageService {
516516
let replacement: String
517517
}
518518

519-
guard let (preEditSnapshot, postEditSnapshot, edits) = self.documentManager.edit(note) else {
519+
guard let (preEditSnapshot, postEditSnapshot, edits) = self.documentManager.edit(notification) else {
520520
return
521521
}
522522

523523
for edit in edits {
524524
let req = sourcekitd.dictionary([
525525
keys.request: self.requests.editorReplaceText,
526-
keys.name: note.textDocument.uri.pseudoPath,
526+
keys.name: notification.textDocument.uri.pseudoPath,
527527
keys.enableSyntaxMap: 0,
528528
keys.enableStructure: 0,
529529
keys.enableDiagnostics: 0,
@@ -553,14 +553,14 @@ extension SwiftLanguageService {
553553
edits: concurrentEdits
554554
)
555555

556-
await publishDiagnosticsIfNeeded(for: note.textDocument.uri)
556+
await publishDiagnosticsIfNeeded(for: notification.textDocument.uri)
557557
}
558558

559-
public func willSaveDocument(_ note: WillSaveTextDocumentNotification) {
559+
public func willSaveDocument(_ notification: WillSaveTextDocumentNotification) {
560560

561561
}
562562

563-
public func didSaveDocument(_ note: DidSaveTextDocumentNotification) {
563+
public func didSaveDocument(_ notification: DidSaveTextDocumentNotification) {
564564

565565
}
566566

0 commit comments

Comments
 (0)