File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -106,4 +106,30 @@ final class PullDiagnosticsTests: XCTestCase {
106
106
] . contains ( action. title)
107
107
)
108
108
}
109
+
110
+ func testNotesFromIntegratedSwiftSyntaxDiagnostics( ) async throws {
111
+ // Create a workspace that has compile_commands.json so that it has a build system but no compiler arguments
112
+ // for test.swift so that we fall back to producing diagnostics from the built-in swift-syntax.
113
+ let ws = try await MultiFileTestWorkspace ( files: [
114
+ " test.swift " : " func foo() 1️⃣{2️⃣ " ,
115
+ " compile_commands.json " : " [] "
116
+ ] )
117
+
118
+ let ( uri, positions) = try ws. openDocument ( " test.swift " )
119
+
120
+ let report = try await ws. testClient. send ( DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( uri) ) )
121
+ guard case . full( let fullReport) = report else {
122
+ XCTFail ( " Expected full diagnostics report " )
123
+ return
124
+ }
125
+ XCTAssertEqual ( fullReport. items. count, 1 )
126
+ let diagnostic = try XCTUnwrap ( fullReport. items. first)
127
+ XCTAssertEqual ( diagnostic. message, " expected '}' to end function " )
128
+ XCTAssertEqual ( diagnostic. range, Range ( positions [ " 2️⃣ " ] ) )
129
+
130
+ XCTAssertEqual ( diagnostic. relatedInformation? . count, 1 )
131
+ let note = try XCTUnwrap ( diagnostic. relatedInformation? . first)
132
+ XCTAssertEqual ( note. message, " to match this opening '{' " )
133
+ XCTAssertEqual ( note. location. range, positions [ " 1️⃣ " ] ..< positions [ " 2️⃣ " ] )
134
+ }
109
135
}
You can’t perform that action at this time.
0 commit comments