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
[SR-13619] Using SwiftSyntax to parse a definition file, results in unknown declarations #403
Comments
@swift-ci create |
As you also pointed out the interface generation source output is not valid syntax, it is intended for displaying-to-the-user purposes, not for consumption by tools. Could you clarify what exactly you are trying to achieve? We may be able to point you to another direction. |
Comment by Javier (JIRA) Thanks Argyrios. Yes you're right, that's why I was hesitant to catalog the issue as a bug. I work on the documentation of a framework (SwiftUI). I use SwiftSyntax to extract every method, property, initializer and protocol from the SwiftUI definition file generated by Xcode, in order to create the Table of Contents of my documentation. This is not a big issue for me. To work around it, previous to parsing, I automatically edit the definition file and change all occurrences of: { get nonmutating set } with { get /* nonmutating set */ } |
You should find useful the `swift-symbolgraph-extract` tool, part of Xcode 12/swift 5.3 toolchain. It outputs a json file that describes the API and documentation of a module. See a possible use for it in jazzy: realm/jazzy#1171 Feel free to ask questions about it in the forums. |
Comment by Javier (JIRA) Thanks a lot for the pointer, that did not exist when I originally implemented my solution using SwiftSyntax. I performed a quick test and it looks promising (although a lot, lot, lot slower). I'll keep it in mind for a future rewrite of my extractor. For the time being, I'll keep using SwiftSyntax. The only unknown declarations I get are those mentioned, but they can be easily workaround. Thanks again for your help! |
AFAICT the issue appears to be resolved, so I’m closing this issue. Please re-open it if you don’t agree. |
Specifically, this will now find imports of specific decls (e.g., `import class XCTest.XCTestCase`) and imports inside `#if` blocks. Also add some tests specifically for this logic, instead of testing it only in the context of other rules. Fixes apple#403.
Additional Detail from JIRA
md5: 57f6cbe2a43f7ef6bb506bf778d15230
Issue Description:
Not sure if this is a bug, or a feature request, so I'm filing it as a bug for the moment.
I am using SwiftSyntax to parse a definition file (to be clear, I'm talking about the file generated by Xcode when you right click on a symbol and select "jump to definition").
For example, a stripped-down piece of the SwiftUI definition file looks like this:
The projectedValue variable is properly parsed as VariableDeclSyntax, but wrappedValue is parsed as UnknownDeclSyntax. The "set" part is what makes SwiftSyntax to not detect a variable.
This makes sense in a way, as that is not a valid syntax to use while writing code. However, in the context of the definition file it is ok. The color coding in Xcode also provides a hint, as the "nonmutating set" shows uncolored.
I tried to dig a little more, but I think the problem (if it is such), resides in the lib_InternalSwiftSyntaxParser.dylib library.
The text was updated successfully, but these errors were encountered: