SourceKit editor.open request doesn't return global declarations or enum cases
| Originator: | jp | ||
| Number: | rdar://18845613 | Date Originated: | 01-Nov-2014 00:12 AM |
| Status: | Resolved | Resolved: | 14-Jul-2015 00:12 AM |
| Product: | Developer Tools | Product Version: | |
| Classification: | Reproducible: |
Summary:
Sending a request to SourceKit for `source.request.editor.open` with the following `key.sourcefile` contents:
```swift
let global = false
enum MyEnum {
case First
}
```
will return the following response:
```json
{
"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
}
```
This makes it difficult to determine the structure of this file because enum cases and global variables/constants aren't included in the structure.
This results in user-facing bugs in Xcode, such as enums not collapsing in Xcode when hitting command-option-shift-left since the enum is deemed to have no substructure.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Closed
This is fixed as of Xcode 7 Beta 3. Yay!
Posted on 01-Mar-2015 03:07 PM
Odds are you're well aware of this, but posting this comment as a "paper trail". There's no change between Xcode 6.3 Beta 1 and Beta 2.
Here's the SourceKit output for Xcode 6.3 Beta 2 (6D532l):
`
swift { key.offset: 0, key.length: 51, key.diagnostic_stage: source.diagnostic.stage.swift.parse, key.syntaxmap: [ { key.kind: source.lang.swift.syntaxtype.keyword, key.offset: 0, key.length: 3 }, { key.kind: source.lang.swift.syntaxtype.identifier, key.offset: 4, key.length: 6 }, { key.kind: source.lang.swift.syntaxtype.keyword, key.offset: 13, key.length: 5 }, { key.kind: source.lang.swift.syntaxtype.keyword, key.offset: 20, key.length: 4 }, { key.kind: source.lang.swift.syntaxtype.identifier, key.offset: 25, key.length: 6 }, { key.kind: source.lang.swift.syntaxtype.keyword, key.offset: 38, key.length: 4 }, { key.kind: source.lang.swift.syntaxtype.identifier, key.offset: 43, key.length: 5 } ], key.substructure: [ { key.kind: source.lang.swift.decl.var.global, key.accessibility: source.lang.swift.accessibility.internal, key.name: "global", key.offset: 0, key.length: 18, key.typename: "global", key.nameoffset: 4, key.namelength: 6, key.substructure: [ ] }, { key.kind: source.lang.swift.decl.enum, key.accessibility: source.lang.swift.accessibility.internal, key.name: "MyEnum", key.offset: 20, key.length: 30, key.nameoffset: 25, key.namelength: 6, key.bodyoffset: 33, key.bodylength: 16, key.substructure: [ ] } ] } `Note that
MyEnumhas an empty substructure, missing theFirstenum element.As of Xcode 6.3b1, globals are included but enum elements are still ignored.