Skip to content

Detecting doc fails on Swift 3.0 #269

Open
@norio-nomura

Description

@norio-nomura

This is caused by difference of response from SourceKit between Swift 2.3 and Swift 3.0.
Swift 3.0 does not return "key.attribute" : "source.decl.attribute.__raw_doc_comment".

Swift 2.3:

$ TOOLCHAINS=com.apple.dt.toolchain.Swift_2_3 sourcekitten structure --text "
/// docs
public func a() {}
"
{
  "key.substructure" : [
    {
      "key.kind" : "source.lang.swift.decl.function.free",
      "key.offset" : 17,
      "key.attributes" : [
        {
          "key.attribute" : "source.decl.attribute.__raw_doc_comment"
        }
      ],
      "key.nameoffset" : 22,
      "key.namelength" : 3,
      "key.bodyoffset" : 27,
      "key.bodylength" : 0,
      "key.accessibility" : "source.lang.swift.accessibility.public",
      "key.length" : 11,
      "key.name" : "a()"
    }
  ],
  "key.offset" : 0,
  "key.diagnostic_stage" : "source.diagnostic.stage.swift.parse",
  "key.length" : 29
}

Swift 3.0:

$ TOOLCHAINS=com.apple.dt.toolchain.XcodeDefault sourcekitten structure --text "
/// docs
public func a() {}
"
{
  "key.substructure" : [
    {
      "key.kind" : "source.lang.swift.decl.function.free",
      "key.offset" : 17,
      "key.nameoffset" : 22,
      "key.namelength" : 3,
      "key.bodyoffset" : 27,
      "key.bodylength" : 0,
      "key.accessibility" : "source.lang.swift.accessibility.public",
      "key.length" : 11,
      "key.name" : "a()"
    }
  ],
  "key.offset" : 0,
  "key.diagnostic_stage" : "source.diagnostic.stage.swift.parse",
  "key.length" : 29
}

Affected issue: realm/SwiftLint#728

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions