Skip to content

Commit 6bbc651

Browse files
committed
[SourceKit] Report comment tags in 'indexsource' request
Comment tags weren't handled at all in SourceKit's 'request.indexsource' request. rdar://88728047
1 parent 5d72984 commit 6bbc651

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %sourcekitd-test -req=index %s -- %s | %FileCheck %s
2+
3+
4+
/// - Tag: SomeTag
5+
/// - Tag: Other
6+
func testFunc() {}
7+
8+
// CHECK-LABEL: key.entities: [
9+
10+
// CHECK: {
11+
// CHECK-DAG: key.kind: source.lang.swift.commenttag
12+
// CHECK-DAG: key.usr: "t:SomeTag"
13+
// CHECK: }
14+
15+
// CHECK: {
16+
// CHECK-DAG: key.kind: source.lang.swift.commenttag
17+
// CHECK-DAG: key.usr: "t:Other"
18+
// CHECK: }
19+
20+
// CHECK: {
21+
// CHECK-DAG: key.kind: source.lang.swift.decl.function.free
22+
// CHECK-DAG: key.name: "testFunc()"
23+
// CHECK-DAG: key.effective_access: source.decl.effective_access.internal
24+
// CHECK: }
25+
26+
// CHECK: ]

tools/SourceKit/lib/SwiftLang/SwiftIndexing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class SKIndexDataConsumer : public IndexDataConsumer {
131131
info.IsImplicit = symbol.roles & (unsigned)SymbolRole::Implicit;
132132
info.IsTestCandidate = symbol.symInfo.Properties & SymbolProperty::UnitTest;
133133
std::vector<UIdent> uidAttrs;
134-
if (!isRef) {
134+
if (!isRef && symbol.decl) {
135135
uidAttrs = getDeclAttributeUIDs(symbol.decl);
136136
info.Attrs = uidAttrs;
137137
if (auto *VD = dyn_cast<ValueDecl>(symbol.decl)) {
@@ -194,7 +194,7 @@ class SKIndexDataConsumer : public IndexDataConsumer {
194194
info.IsDynamic = relation.roles & (unsigned)SymbolRole::Dynamic;
195195
info.IsTestCandidate = relation.symInfo.Properties & SymbolProperty::UnitTest;
196196
std::vector<UIdent> uidAttrs;
197-
if (!isRef) {
197+
if (!isRef && relation.decl) {
198198
uidAttrs = getDeclAttributeUIDs(relation.decl);
199199
info.Attrs = uidAttrs;
200200
}

tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,9 +721,12 @@ UIdent SwiftLangSupport::getUIDForSymbol(SymbolInfo sym, bool isRef) {
721721
case SymbolKind::Module:
722722
return KindRefModule;
723723

724+
case SymbolKind::CommentTag:
725+
return KindCommentTag;
726+
724727
default:
725728
// TODO: reconsider whether having a default case is a good idea.
726-
return UIdent();
729+
llvm_unreachable("unhandled symbol kind Swift doesn't use");
727730
}
728731

729732
#undef SIMPLE_CASE

utils/gyb_sourcekit_support/UIDs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ def __init__(self, internal_name, external_name):
371371
KIND('DeclGenericTypeParam', 'source.lang.swift.decl.generic_type_param'),
372372
KIND('RefGenericTypeParam', 'source.lang.swift.ref.generic_type_param'),
373373
KIND('RefModule', 'source.lang.swift.ref.module'),
374+
KIND('CommentTag', 'source.lang.swift.commenttag'),
374375
KIND('StmtForEach', 'source.lang.swift.stmt.foreach'),
375376
KIND('StmtFor', 'source.lang.swift.stmt.for'),
376377
KIND('StmtWhile', 'source.lang.swift.stmt.while'),

0 commit comments

Comments
 (0)