@@ -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