-
Notifications
You must be signed in to change notification settings - Fork 314
Return diagnostics if SwiftPM project is opened from a symlinked URL #1915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
If you have a SwiftPM project at `/projects/myProject` and a symlink pointing from `/myProject` to `/projects/myProject`, we would correctly get build settings etc for the files. But, when getting diagnostics, sourcekitd would return these diagnostics for the full `/projects/myProject` path. We would then decide that those diagnostics didn’t matched the file you opened (inside `/myProject`) and thus suppress them. Show diagnostics diagnostics if the originated from a file with the same realpath as the file you opened. Fixes swiftlang#1910 rdar://142386278
@swift-ci Please test |
|
||
guard | ||
filePath == snapshot.uri.pseudoPath | ||
|| haveSameRealpath(DocumentURI(filePath: filePath, isDirectory: false), snapshot.uri) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to use the realpath here at all?
Separately, this will allow diagnostics for symlinks across targets. Maybe that's fine though, since ... that really shouldn't happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to use the realpath here at all?
What do you mean?
Separately, this will allow diagnostics for symlinks across targets. Maybe that's fine though, since ... that really shouldn't happen?
Yes, but I really wouldn’t expect that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean?
I swear I had "realpath cache" here. I remember reading it back 😭! (ie. the realpath cache we have on the workspace)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we can’t. We can only use the realpath cache for files that we watch, so we get notified about changes to them. But the paths we are inspecting here are arbitrary and might thus not be in our watch patterns. Using a realpath cache would thus mean that we could get out-of-date file system information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ahoppen Are symlinked URLs supposed to work on Windows at this point?
DocumentDiagnosticsRequest(textDocument: TextDocumentIdentifier(uri)) | ||
) | ||
let diagnostic = try XCTUnwrap(diagnostics.fullReport?.items.only) | ||
XCTAssertEqual(diagnostic.message, "Cannot convert value of type 'Int' to specified type 'String'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test failed in my PR test: swiftlang/swift#78630 (comment)
If you have a SwiftPM project at
/projects/myProject
and a symlink pointing from/myProject
to/projects/myProject
, we would correctly get build settings etc for the files. But, when getting diagnostics, sourcekitd would return these diagnostics for the full/projects/myProject
path. We would then decide that those diagnostics didn’t matched the file you opened (inside/myProject
) and thus suppress them.Show diagnostics diagnostics if the originated from a file with the same realpath as the file you opened.
Fixes #1910
rdar://142386278