File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed
Sources/SourceKitLSP/Swift Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -248,10 +248,19 @@ extension Diagnostic {
248
248
educationalNotePaths. count > 0 ,
249
249
let primaryPath = educationalNotePaths [ 0 ]
250
250
{
251
- let url = URL ( fileURLWithPath: primaryPath)
252
- let name = url. deletingPathExtension ( ) . lastPathComponent
253
- code = . string( name)
254
- codeDescription = . init( href: DocumentURI ( url) )
251
+ // Swift >= 6.2 returns a URL rather than a file path
252
+ let url : URL ? =
253
+ if primaryPath. starts ( with: " http " ) {
254
+ URL ( string: primaryPath)
255
+ } else {
256
+ URL ( fileURLWithPath: primaryPath)
257
+ }
258
+
259
+ if let url {
260
+ let name = url. deletingPathExtension ( ) . lastPathComponent
261
+ code = . string( name)
262
+ codeDescription = . init( href: DocumentURI ( url) )
263
+ }
255
264
}
256
265
257
266
var actions : [ CodeAction ] ? = nil
Original file line number Diff line number Diff line change @@ -379,8 +379,13 @@ final class LocalSwiftTests: XCTestCase {
379
379
XCTAssertEqual ( diags. diagnostics. count, 1 )
380
380
let diag = diags. diagnostics. first!
381
381
XCTAssertEqual ( diag. code, . string( " property-wrapper-requirements " ) )
382
- let filename = try XCTUnwrap ( diag. codeDescription? . href. fileURL? . lastPathComponent)
383
- XCTAssert ( filename. starts ( with: " property-wrapper-requirements " ) )
382
+
383
+ let noteUri = try XCTUnwrap ( diag. codeDescription? . href)
384
+ if noteUri. fileURL != nil {
385
+ // Check we're not creating an absolute path out of a URL
386
+ XCTAssertFalse ( noteUri. stringValue. contains ( " https:// " ) )
387
+ }
388
+ XCTAssert ( noteUri. arbitrarySchemeURL. lastPathComponent. starts ( with: " property-wrapper-requirements " ) )
384
389
}
385
390
386
391
func testFixitsAreIncludedInPublishDiagnostics( ) async throws {
You can’t perform that action at this time.
0 commit comments