SourceKitten icon indicating copy to clipboard operation
SourceKitten copied to clipboard

Detecting doc fails on Swift 3.0

Open norio-nomura opened this issue 9 years ago • 3 comments

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: https://github.com/realm/SwiftLint/issues/728

norio-nomura avatar Oct 13 '16 14:10 norio-nomura

Oh that sucks. I wonder why that was removed 😞

jpsim avatar Oct 13 '16 17:10 jpsim

Yeah, then this is blocking https://github.com/realm/SwiftLint/pull/832 by failing tests.

norio-nomura avatar Oct 14 '16 00:10 norio-nomura

https://bugs.swift.org/browse/SR-2487

norio-nomura avatar Oct 15 '16 04:10 norio-nomura