Open
Description
Description
In some cases, the key.substructure
document substructure part of SourceKit requests such as editor.open
, include the same attribute multiple times. I noticed this happening on an attribute with multiple arguments.
Reproduction
(sourcekitd-repl request to reproduce)
{
key.request: source.request.editor.open,
key.name: "myname",
key.enablesubstructure: 1,
key.sourcetext: "@available(iOS 16.0, macOS 13.0, *) func foo(){}"
}
Use this swift file as input for a SourceKit editor.open
request:
@available(iOS 16.0, macOS 13.0, *)
func foo(){}
This is part of the editor.open
response:
key.substructure: [
{
key.kind: source.lang.swift.decl.function.free,
key.accessibility: source.lang.swift.accessibility.internal,
key.name: "foo()",
key.offset: 36,
key.length: 12,
key.nameoffset: 41,
key.namelength: 5,
key.bodyoffset: 47,
key.bodylength: 0,
key.attributes: [
{
key.offset: 0,
key.length: 35,
key.attribute: source.decl.attribute.available
},
{
key.offset: 0,
key.length: 35,
key.attribute: source.decl.attribute.available
}
]
}
]
Expected behavior
This includes the exact same attribute twice, in the key.attributes
list, which doesn't seem useful, as there is no information on the attribute arguments anyway. I would either expect the two entries to differ in some way, or for there to only be one entry.
In addressing this, #75470 should also be taken into consideration.
Environment
Swift version 6.0-dev (LLVM b12fb441d8b2d6d
, Swift cd7e4c3)
Target: arm64-apple-macosx14.0
Additional information
No response
Metadata
Metadata
Assignees
Labels
Area → source tooling: SourceKitFeature: Declaration and type attributesThe @available attribute and availability checking in generalA deviation from expected or documented behavior. Also: expected but undesirable behavior.Area: IDE support, SourceKit, and other source toolingBug: Unexpected behavior or incorrect output