-
Notifications
You must be signed in to change notification settings - Fork 116
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
Correct source code locations of link diagnostics for Objective-C doc comments #734
Merged
patshaughnessy
merged 4 commits into
apple:main
from
patshaughnessy:fix-objc-diagnostic-locations
Oct 17, 2023
Merged
Correct source code locations of link diagnostics for Objective-C doc comments #734
patshaughnessy
merged 4 commits into
apple:main
from
patshaughnessy:fix-objc-diagnostic-locations
Oct 17, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Correct the line and character locations of invalid link diagnostics in Objective-C source code doc comments. Previously, DocumentationContext#resolveLinks would use the default symbol to calculate the offset of each doc comment in the source file. However, the default symbol is always set to a Swift symbol even for Objective-C source code doc comments. This lead to a bug when Objective-C diagnostics would always use a zero offset. Instead, save the offset of each doc comment in the DocumentationChunk structure, which is initialized using the documented symbol, i.e. the Swift or Objective-C symbol which actually contains the doc comment. Also decrement the line and character indexes by 1 for both Objective-C doc comments so Xcode displays them in the proper location.
@swift-ci please test |
d-ronnqvist
reviewed
Oct 10, 2023
Tests/SwiftDocCTests/Test Bundles/ObjCFrameworkWithInvalidLink.docc/Info.plist
Outdated
Show resolved
Hide resolved
d-ronnqvist
reviewed
Oct 10, 2023
d-ronnqvist
reviewed
Oct 10, 2023
Tests/SwiftDocCTests/Infrastructure/DocumentationContext/DocumentationContextTests.swift
Show resolved
Hide resolved
d-ronnqvist
reviewed
Oct 10, 2023
- Removed Test Bundles/ObjCFrameworkWithInvalidLink.docc/Info.plist - SymbolGraph.Symbol#offsetAdjustedForInterfaceLanguage uses the SourceLanguage struct as a type safe way of checking the source language vs. a string comparison. - Clean up SymbolExtensionsTests.swift a bit so it uses more accurate path fixture values.
@swift-ci please test |
d-ronnqvist
approved these changes
Oct 12, 2023
franklinsch
approved these changes
Oct 17, 2023
@swift-ci please test |
patshaughnessy
added a commit
to patshaughnessy/swift-docc
that referenced
this pull request
Oct 25, 2023
… comments (apple#734) * rdar://102855081 Correct the line and character locations of invalid link diagnostics in Objective-C source code doc comments. Previously, DocumentationContext#resolveLinks would use the default symbol to calculate the offset of each doc comment in the source file. However, the default symbol is always set to a Swift symbol even for Objective-C source code doc comments. This lead to a bug when Objective-C diagnostics would always use a zero offset. Instead, save the offset of each doc comment in the DocumentationChunk structure, which is initialized using the documented symbol, i.e. the Swift or Objective-C symbol which actually contains the doc comment. Also decrement the line and character indexes by 1 for both Objective-C doc comments so Xcode displays them in the proper location.
patshaughnessy
added a commit
that referenced
this pull request
Nov 9, 2023
… comments (#734) (#747) * rdar://102855081 Correct the line and character locations of invalid link diagnostics in Objective-C source code doc comments. Previously, DocumentationContext#resolveLinks would use the default symbol to calculate the offset of each doc comment in the source file. However, the default symbol is always set to a Swift symbol even for Objective-C source code doc comments. This lead to a bug when Objective-C diagnostics would always use a zero offset. Instead, save the offset of each doc comment in the DocumentationChunk structure, which is initialized using the documented symbol, i.e. the Swift or Objective-C symbol which actually contains the doc comment. Also decrement the line and character indexes by 1 for both Objective-C doc comments so Xcode displays them in the proper location.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation: Fix the source location for some Obj-C diagnostics.
Scope: Fixes the line and column numbers that appear in the diagnostics.json file, used by Xcode to determine where to show them in the editor.
GitHub Issue: none.
Risk: Low. Minor code changes impacting diagnostic source locations only..
Testing: Ran the ./bin/test script and it succeeded
Reviewer: @d-ronnqvist
Bug/issue #, if applicable:
rdar://102855081
Summary
Correct the line and character locations of invalid link diagnostics in Objective-C source code doc comments.
Previously,
DocumentationContext#resolveLinks
would use the default symbol to calculate the offset of each doc comment in a source file. However, the default symbol is always set to a Swift symbol even for Objective-C source code. This lead to a bug when Objective-C diagnostics would always use a zero offset.Example:
Instead, save the offset of each doc comment in the
DocumentationChunk
structure, which is initialized using the documented symbol, i.e. the Swift or Objective-C symbol which actually contains the doc comment.Also decrement the line and character indexes by 1 for both Objective-C doc comments so Xcode displays them in the proper location.
Same example with the fix in place:
Dependencies
None.
Testing
Introduced invalid links into doc comments inside of various Objective-C header files, and built the documentation. Tested that Xcode displayed the diagnostics in the proper location in the source code editor.
Steps:
invalid-link
or some other invalid DocC link in a doc comment in an Objective-C header file.Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/test
script and it succeeded[ ] Updated documentation if necessary