Uploaded image for project: 'Swift'
  1. Swift
  2. SR-13619

Using SwiftSyntax to parse a definition file, results in unknown declarations

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: SwiftSyntax
    • Labels:
      None

      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:

      public struct Binding<Value> {
        public var wrappedValue: Value { get nonmutating set }
        public var projectedValue: Binding<Value> { get }
      }

      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.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            swiftuilab Javier
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: