Skip to content

[SR-2487] sourcekitd doesn't include __raw_doc_comment in structure #45092

@keith

Description

@keith
Previous ID SR-2487
Radar None
Original Reporter @keith
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 14
Component/s Source Tooling
Labels Bug, Documentation
Assignee @marcelofabri
Priority Medium

md5: 7cb28eacb8646ac198576beb5bef2cf8

Issue Description:

Previously (with Xcode 7.x) if you had a property with a docstring (like this):

struct Foo {
    /// Some var
    var bar: String
}

And you got its structure for sourcekit (using sourcekitten) the output would look like this:

% sourcekitten structure --file foo.swift
{
  "key.substructure" : [
    {
      "key.kind" : "source.lang.swift.decl.struct",
      "key.offset" : 0,
      "key.nameoffset" : 7,
      "key.namelength" : 3,
      "key.bodyoffset" : 12,
      "key.bodylength" : 38,
      "key.accessibility" : "source.lang.swift.accessibility.internal",
      "key.substructure" : [
        {
          "key.kind" : "source.lang.swift.decl.var.instance",
          "key.offset" : 34,
          "key.attributes" : [
            {
              "key.attribute" : "source.decl.attribute.__raw_doc_comment"
            }
          ],
          "key.nameoffset" : 38,
          "key.namelength" : 3,
          "key.length" : 15,
          "key.accessibility" : "source.lang.swift.accessibility.internal",
          "key.setter_accessibility" : "source.lang.swift.accessibility.internal",
          "key.typename" : "String",
          "key.name" : "bar"
        }
      ],
      "key.name" : "Foo",
      "key.length" : 51
    }
  ],
  "key.offset" : 0,
  "key.diagnostic_stage" : "source.diagnostic.stage.swift.parse",
  "key.length" : 52
}

Notice this attribute:

            {
              "key.attribute" : "source.decl.attribute.__raw_doc_comment"
            }

With the Xcode 8.x betas, or building from the swift repo, the output for the same source now looks like this:

% ./sourcekitd-test -req=structure foo.swift
{
  key.request: source.request.editor.open,
  key.name: "foo.swift",
  key.sourcefile: "foo.swift",
  key.enablesyntaxmap: 0,
  key.enablesubstructure: 1,
  key.syntactic_only: 1
}
{
  key.offset: 0,
  key.length: 52,
  key.diagnostic_stage: source.diagnostic.stage.swift.parse,
  key.substructure: [
    {
      key.kind: source.lang.swift.decl.struct,
      key.accessibility: source.lang.swift.accessibility.internal,
      key.name: "Foo",
      key.offset: 0,
      key.length: 51,
      key.nameoffset: 7,
      key.namelength: 3,
      key.bodyoffset: 12,
      key.bodylength: 38,
      key.substructure: [
        {
          key.kind: source.lang.swift.decl.var.instance,
          key.accessibility: source.lang.swift.accessibility.internal,
          key.setter_accessibility: source.lang.swift.accessibility.internal,
          key.name: "bar",
          key.offset: 34,
          key.length: 15,
          key.typename: "String",
          key.nameoffset: 38,
          key.namelength: 3
        }
      ]
    }
  ]
}

Which doesn't include the `__raw_doc_comment` attribute.

I also noticed that if I use the sourcekitd-repl and pass `key.enablesyntaxmap: 1`, it does provide some information about the doccomment:

    {
      key.kind: source.lang.swift.syntaxtype.doccomment,
      key.offset: 17,
      key.length: 13
    },

But it is in a top level array of elements, and not directly associated with the key that it's documenting.

Is this new behavior expected? Or is this a bug?

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions