realm / jazzy

Soulful docs for Swift & Objective-C
https://realm.io
MIT License
7.35k stars 413 forks source link

editor.open request doesn't return global declarations or enum cases #74

Closed jpsim closed 9 years ago

jpsim commented 10 years ago

Sending a request to SourceKit for source.request.editor.open with the following key.sourcefile contents:

let global = false

enum MyEnum {
    case First
}

will return the following response:

{
  "key.substructure" : [
    {
      "key.kind" : 4303392864,
      "key.offset" : 20,
      "key.nameoffset" : 25,
      "key.namelength" : 6,
      "key.bodyoffset" : 33,
      "key.bodylength" : 16,
      "key.length" : 30,
      "key.substructure" : [

      ],
      "key.name" : "MyEnum"
    }
  ],
  "key.offset" : 0,
  "key.diagnostic_stage" : 4303392912,
  "key.length" : 51
}

Missing are the substructures for the global (source.lang.swift.decl.var.global) and enum element (source.lang.swift.decl.enumelement).

This makes it difficult to determine the structure of this file and sourcekitten does something pretty hacky to work around this issue.

This is rdar://18845613

jpsim commented 9 years ago

This is a bug in SourceKit on Apple's side, unfortunately. See rdar://18845613.

We could add a workaround to sourcekitten by making cursorinfo requests for offsets at case * when an source.lang.swift.decl.enum is detected. Only searching for case * inside the enum body based on its bodyoffset and bodylength.

jpsim commented 9 years ago

This is resolved as of Xcode 7 Beta 3 and ship with jazzy along with Swift 2.0 support.

segiddins commented 9 years ago

Does it return them as functions now?

jpsim commented 9 years ago

No, see https://github.com/jpsim/SourceKitten/commit/fe140070b06340b02d3f677e0e5a98a3144ecbe2