swiftlang/swift

[SR-7933] SourceKit double-counts escaping and autoclosure attributes

Open

#50.468 aperta il 8 giu 2018

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)Swift (10.719 fork)batch import
good first issueimprovement

Metriche repository

Star
 (69.989 star)
Metriche merge PR
 (Merge medio 8g 17h) (510 PR mergiate in 30 g)

Descrizione

Previous ID SR-7933
Radar None
Original Reporter @natecook1000
Type Improvement
Votes 0
Component/s Source Tooling
Labels Improvement, StarterBug
Assignee None
Priority Medium

md5: 065c0c3c9adc792d7d7203c32bd04ee2

Issue Description:

The @escaping and @autoclosure attributes are mapped differently from other attributes. For example, given this source code:

func a(_ b: @escaping () -> Bool) {}
@discardableResult func b() -> Int { return 0 }
func c(_ b: @autoclosure () -> Bool) {}

SourceKit yields this syntax map (unrelated pieces elided):

{
  key.offset: 0,
  key.length: 125,
  key.diagnostic_stage: source.diagnostic.stage.swift.parse,
  key.syntaxmap: [
    ...,
    {
      key.kind: source.lang.swift.syntaxtype.attribute.id,
      key.offset: 12,
      key.length: 9
    },
    {
      key.kind: source.lang.swift.syntaxtype.attribute.builtin,
      key.offset: 13,
      key.length: 8
    },
    ...,
    {
      key.kind: source.lang.swift.syntaxtype.attribute.builtin,
      key.offset: 37,
      key.length: 18
    },
    ...,
    {
      key.kind: source.lang.swift.syntaxtype.attribute.id,
      key.offset: 97,
      key.length: 12
    },
    {
      key.kind: source.lang.swift.syntaxtype.attribute.builtin,
      key.offset: 98,
      key.length: 11
    },
    ...
  ]
}

The "source.lang.swift.syntaxtype.attribute.builtin" keys should have the offset and length of the "source.lang.swift.syntaxtype.attribute.id" keys, which in turn shouldn't be emitted.

Guida contributor