Skip to content

Commit e4fca1a

Browse files
committed
Clean Up Documentation
1 parent 47fb7b2 commit e4fca1a

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

CodeEdit/Features/CEWorkspace/Models/CEWorkspaceFileManager+FileManagement.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ extension CEWorkspaceFileManager {
4646
/// - file: The file to add the new file to.
4747
/// - useExtension: The file extension to use. Leave `nil` to guess using relevant nearby files.
4848
/// - Authors: Mattijs Eikelenboom, KaiTheRedNinja. *Moved from 7c27b1e*
49-
/// - Returns: Boolean indicating whether or not the file was created
49+
/// - Throws: Throws a `CocoaError.fileWriteUnknown` with the file url if creating the file fails, and calls
50+
/// ``rebuildFiles(fromItem:deep:)`` which throws other `FileManager` errors.
5051
func addFile(fileName: String, toFile file: CEWorkspaceFile, useExtension: String? = nil) throws {
5152
// check the folder for other files, and see what the most common file extension is
5253
var fileExtension: String

CodeEdit/Features/LSP/LanguageServer/Capabilities/LanguageServer+DocumentSync.swift

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extension LanguageServer {
1212
// swiftlint:disable line_length
1313
/// Determines the type of document sync the server supports.
1414
/// https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_synchronization_sc
15-
fileprivate func serverDocumentSyncSupport() -> TextDocumentSyncKind {
15+
fileprivate func resolveDocumentSyncKind() -> TextDocumentSyncKind {
1616
// swiftlint:enable line_length
1717
var syncKind: TextDocumentSyncKind = .none
1818
switch serverCapabilities.textDocumentSync {
@@ -26,7 +26,8 @@ extension LanguageServer {
2626
return syncKind
2727
}
2828

29-
fileprivate func serverSupportsOpenClose() -> Bool {
29+
/// Determines whether or not the server supports document tracking.
30+
fileprivate func resolveOpenCloseSupport() -> Bool {
3031
switch serverCapabilities.textDocumentSync {
3132
case .optionA(let options):
3233
return options.openClose ?? false
@@ -37,7 +38,7 @@ extension LanguageServer {
3738
}
3839
}
3940

40-
// Avoids a lint error
41+
// Used to avoid a lint error (`large_tuple`) for the return type of `getIsolatedDocumentContent`
4142
fileprivate struct DocumentContent {
4243
let uri: String
4344
let language: LanguageIdentifier
@@ -46,9 +47,10 @@ extension LanguageServer {
4647

4748
/// Tells the language server we've opened a document and would like to begin working with it.
4849
/// - Parameter document: The code document to open.
50+
/// - Throws: Throws errors produced by the language server connection.
4951
func openDocument(_ document: CodeFileDocument) async throws {
5052
do {
51-
guard serverSupportsOpenClose(), let content = await getIsolatedDocumentContent(document) else {
53+
guard resolveOpenCloseSupport(), let content = await getIsolatedDocumentContent(document) else {
5254
return
5355
}
5456
logger.debug("Opening Document \(content.uri, privacy: .private)")
@@ -81,9 +83,10 @@ extension LanguageServer {
8183

8284
/// Stops tracking a file and notifies the language server.
8385
/// - Parameter uri: The URI of the document to close.
86+
/// - Throws: Throws errors produced by the language server connection.
8487
func closeDocument(_ uri: String) async throws {
8588
do {
86-
guard serverSupportsOpenClose() && openFiles.document(for: uri) != nil else { return }
89+
guard resolveOpenCloseSupport() && openFiles.document(for: uri) != nil else { return }
8790
logger.debug("Closing document \(uri, privacy: .private)")
8891
openFiles.removeDocument(for: uri)
8992
let params = DidCloseTextDocumentParams(textDocument: TextDocumentIdentifier(uri: uri))
@@ -99,15 +102,15 @@ extension LanguageServer {
99102
/// - uri: The URI of the document to update.
100103
/// - range: The range being replaced.
101104
/// - string: The string being inserted into the replacement range.
102-
/// - Returns: `true` if the document was successfully updated, `false`
105+
/// - Throws: Throws errors produced by the language server connection.
103106
func documentChanged(
104107
uri: String,
105108
replacedContentIn range: LSPRange,
106109
with string: String
107110
) async throws {
108111
do {
109112
logger.debug("Document updated, \(uri, privacy: .private)")
110-
switch serverDocumentSyncSupport() {
113+
switch resolveDocumentSyncKind() {
111114
case .full:
112115
guard let file = openFiles.document(for: uri) else { return }
113116
let content = await MainActor.run {

0 commit comments

Comments
 (0)