Skip to content

Commit af6b30a

Browse files
committed
[Code completion] Add code completion support for macro expansions.
1 parent a9ee5dd commit af6b30a

File tree

9 files changed

+167
-25
lines changed

9 files changed

+167
-25
lines changed

include/swift/IDE/CodeCompletionCache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ struct RequestedCachedModule {
118118
const ModuleDecl *TheModule;
119119
bool OnlyTypes;
120120
bool OnlyPrecedenceGroups;
121+
bool OnlyMacros;
121122
};
122123

123124
} // end namespace ide

include/swift/IDE/CompletionLookup.h

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ bool DefaultFilter(ValueDecl *VD, DeclVisibilityKind Kind,
4343
bool KeyPathFilter(ValueDecl *decl, DeclVisibilityKind,
4444
DynamicLookupInfo dynamicLookupInfo);
4545

46+
bool MacroFilter(ValueDecl *decl, DeclVisibilityKind,
47+
DynamicLookupInfo dynamicLookupInfo);
48+
4649
/// Returns \c true only if the completion is happening for top-level
4750
/// declrarations. i.e.:
4851
///
@@ -134,6 +137,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
134137
bool IsUnwrappedOptional = false;
135138
SourceLoc DotLoc;
136139
bool NeedLeadingDot = false;
140+
bool NeedLeadingMacroPound = false;
137141

138142
bool NeedOptionalUnwrap = false;
139143
unsigned NumBytesToEraseForOptionalUnwrap = 0;
@@ -184,41 +188,50 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
184188
const ModuleDecl *TheModule;
185189
bool OnlyTypes;
186190
bool OnlyPrecedenceGroups;
191+
bool OnlyMacros;
187192
bool NeedLeadingDot;
193+
bool NeedPound;
188194
bool IncludeModuleQualifier;
189195

190196
static RequestedResultsTy fromModule(const ModuleDecl *TheModule) {
191-
return {TheModule, false, false, false, true};
197+
return {TheModule, false, false, false, false, false, true};
192198
}
193199

194200
RequestedResultsTy onlyTypes() const {
195-
return {TheModule, true, false, NeedLeadingDot, IncludeModuleQualifier};
201+
return {TheModule, true, false, false, NeedLeadingDot, false,
202+
IncludeModuleQualifier};
196203
}
197204

198205
RequestedResultsTy onlyPrecedenceGroups() const {
199206
assert(!OnlyTypes && "onlyTypes() already includes precedence groups");
200-
return {TheModule, false, true, false, true};
207+
return {TheModule, false, true, false, false, false, true};
208+
}
209+
210+
RequestedResultsTy onlyMacros(bool needPound) const {
211+
return {TheModule, false, false, true, false, needPound, false};
201212
}
202213

203214
RequestedResultsTy needLeadingDot(bool NeedDot) const {
204-
return {TheModule, OnlyTypes, OnlyPrecedenceGroups, NeedDot,
205-
IncludeModuleQualifier};
215+
return {TheModule, OnlyTypes, OnlyPrecedenceGroups, OnlyMacros, NeedDot,
216+
NeedPound, IncludeModuleQualifier};
206217
}
207218

208219
RequestedResultsTy withModuleQualifier(bool IncludeModule) const {
209-
return {TheModule, OnlyTypes, OnlyPrecedenceGroups, NeedLeadingDot,
210-
IncludeModule};
220+
return {TheModule, OnlyTypes, OnlyPrecedenceGroups, OnlyMacros,
221+
NeedLeadingDot, NeedPound, IncludeModule};
211222
}
212223

213224
static RequestedResultsTy toplevelResults() {
214-
return {nullptr, false, false, false, true};
225+
return {nullptr, false, false, false, false, true, true};
215226
}
216227

217228
friend bool operator==(const RequestedResultsTy &LHS,
218229
const RequestedResultsTy &RHS) {
219230
return LHS.TheModule == RHS.TheModule && LHS.OnlyTypes == RHS.OnlyTypes &&
220231
LHS.OnlyPrecedenceGroups == RHS.OnlyPrecedenceGroups &&
232+
LHS.OnlyMacros == RHS.OnlyMacros &&
221233
LHS.NeedLeadingDot == RHS.NeedLeadingDot &&
234+
LHS.NeedPound == RHS.NeedPound &&
222235
LHS.IncludeModuleQualifier == RHS.IncludeModuleQualifier;
223236
}
224237
};
@@ -450,6 +463,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
450463
void addEnumElementRef(const EnumElementDecl *EED, DeclVisibilityKind Reason,
451464
DynamicLookupInfo dynamicLookupInfo,
452465
bool HasTypeContext);
466+
void addMacroExpansion(const MacroDecl *MD, DeclVisibilityKind Reason);
453467

454468
void addKeyword(
455469
StringRef Name, Type TypeAnnotation = Type(),
@@ -551,6 +565,8 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
551565

552566
void addObjCPoundKeywordCompletions(bool needPound);
553567

568+
void getMacroCompletions(bool needPound);
569+
554570
struct FilteredDeclConsumer : public swift::VisibleDeclConsumer {
555571
swift::VisibleDeclConsumer &Consumer;
556572
DeclFilter Filter;
@@ -612,7 +628,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
612628
void getTypeCompletionsInDeclContext(SourceLoc Loc,
613629
bool ModuleQualifier = true);
614630

615-
void getToplevelCompletions(bool OnlyTypes);
631+
void getToplevelCompletions(bool OnlyTypes, bool OnlyMacros);
616632

617633
void lookupExternalModuleDecls(const ModuleDecl *TheModule,
618634
ArrayRef<std::string> AccessPath,
@@ -632,17 +648,17 @@ template <>
632648
struct DenseMapInfo<RequestedResultsTy> {
633649
static inline RequestedResultsTy getEmptyKey() {
634650
return {DenseMapInfo<swift::ModuleDecl *>::getEmptyKey(), false, false,
635-
false, false};
651+
false, false, false, false};
636652
}
637653
static inline RequestedResultsTy getTombstoneKey() {
638654
return {DenseMapInfo<swift::ModuleDecl *>::getTombstoneKey(), false, false,
639-
false, false};
655+
false, false, false, false};
640656
}
641657
static unsigned getHashValue(const RequestedResultsTy &Val) {
642658
return hash_combine(
643659
DenseMapInfo<swift::ModuleDecl *>::getHashValue(Val.TheModule),
644-
Val.OnlyTypes, Val.OnlyPrecedenceGroups, Val.NeedLeadingDot,
645-
Val.IncludeModuleQualifier);
660+
Val.OnlyTypes, Val.OnlyPrecedenceGroups, Val.OnlyMacros,
661+
Val.NeedLeadingDot, Val.NeedPound, Val.IncludeModuleQualifier);
646662
}
647663
static bool isEqual(const RequestedResultsTy &LHS,
648664
const RequestedResultsTy &RHS) {

lib/IDE/AfterPoundExprCompletion.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ void AfterPoundExprCompletion::deliverResults(
5353
Lookup.addPoundAvailable(ParentStmtKind);
5454
Lookup.addPoundLiteralCompletions(/*needPound=*/false);
5555
Lookup.addObjCPoundKeywordCompletions(/*needPound=*/false);
56+
Lookup.getMacroCompletions(/*needPound=*/false);
5657
}
5758

5859
deliverCompletionResults(CompletionCtx, Lookup, DC, Consumer);

lib/IDE/CodeCompletion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ void swift::ide::deliverCompletionResults(
13321332
if (!Result.second)
13331333
return; // already handled.
13341334
RequestedModules.push_back({std::move(K), TheModule,
1335-
Request.OnlyTypes, Request.OnlyPrecedenceGroups});
1335+
Request.OnlyTypes, Request.OnlyPrecedenceGroups, Request.OnlyMacros});
13361336

13371337
auto TheModuleName = TheModule->getName();
13381338
if (Request.IncludeModuleQualifier &&
@@ -1350,7 +1350,7 @@ void swift::ide::deliverCompletionResults(
13501350
}
13511351
} else {
13521352
// Add results from current module.
1353-
Lookup.getToplevelCompletions(Request.OnlyTypes);
1353+
Lookup.getToplevelCompletions(Request.OnlyTypes, Request.OnlyMacros);
13541354

13551355
// Add the qualifying module name
13561356
auto curModule = SF.getParentModule();

lib/IDE/CodeCompletionConsumer.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using namespace swift::ide;
1818

1919
static MutableArrayRef<CodeCompletionResult *> copyCodeCompletionResults(
2020
CodeCompletionResultSink &targetSink, CodeCompletionCache::Value &source,
21-
bool onlyTypes, bool onlyPrecedenceGroups,
21+
bool onlyTypes, bool onlyPrecedenceGroups, bool onlyMacros,
2222
const ExpectedTypeContext *TypeContext, const DeclContext *DC,
2323
bool CanCurrDeclContextHandleAsync) {
2424

@@ -69,7 +69,12 @@ static MutableArrayRef<CodeCompletionResult *> copyCodeCompletionResults(
6969
} else if (onlyPrecedenceGroups) {
7070
shouldIncludeResult = [](const ContextFreeCodeCompletionResult *R) -> bool {
7171
return R->getAssociatedDeclKind() ==
72-
CodeCompletionDeclKind::PrecedenceGroup;
72+
CodeCompletionDeclKind::PrecedenceGroup;
73+
};
74+
} else if (onlyMacros) {
75+
shouldIncludeResult = [](const ContextFreeCodeCompletionResult *R) -> bool {
76+
return R->getAssociatedDeclKind() ==
77+
CodeCompletionDeclKind::Macro;
7378
};
7479
} else {
7580
shouldIncludeResult = [](const ContextFreeCodeCompletionResult *R) -> bool {
@@ -148,7 +153,7 @@ void SimpleCachingCodeCompletionConsumer::handleResultsAndModules(
148153
assert(V.has_value());
149154
auto newItems = copyCodeCompletionResults(
150155
context.getResultSink(), **V, R.OnlyTypes, R.OnlyPrecedenceGroups,
151-
TypeContext, DC, CanCurrDeclContextHandleAsync);
156+
R.OnlyMacros, TypeContext, DC, CanCurrDeclContextHandleAsync);
152157
postProcessCompletionResults(newItems, context.CodeCompletionKind, DC,
153158
&context.getResultSink());
154159
}

lib/IDE/CompletionLookup.cpp

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ bool swift::ide::KeyPathFilter(ValueDecl *decl, DeclVisibilityKind,
127127
(isa<VarDecl>(decl) && decl->getDeclContext()->isTypeContext());
128128
}
129129

130+
bool swift::ide::MacroFilter(ValueDecl *decl, DeclVisibilityKind,
131+
DynamicLookupInfo dynamicLookupInfo) {
132+
return isa<MacroDecl>(decl);
133+
}
134+
130135
bool swift::ide::isCodeCompletionAtTopLevel(const DeclContext *DC) {
131136
if (DC->isModuleScopeContext())
132137
return true;
@@ -1773,6 +1778,36 @@ void CompletionLookup::addEnumElementRef(const EnumElementDecl *EED,
17731778
Builder.addFlair(CodeCompletionFlairBit::ExpressionSpecific);
17741779
}
17751780

1781+
void CompletionLookup::addMacroExpansion(const MacroDecl *MD,
1782+
DeclVisibilityKind Reason) {
1783+
if (!MD->hasName() || !MD->isAccessibleFrom(CurrDeclContext) ||
1784+
MD->shouldHideFromEditor())
1785+
return;
1786+
1787+
CodeCompletionResultBuilder Builder(
1788+
Sink, CodeCompletionResultKind::Declaration,
1789+
getSemanticContext(MD, Reason, DynamicLookupInfo()));
1790+
Builder.setAssociatedDecl(MD);
1791+
1792+
if (NeedLeadingMacroPound) {
1793+
Builder.addTextChunk("#");
1794+
}
1795+
1796+
addValueBaseName(Builder, MD->getBaseIdentifier());
1797+
1798+
Type macroType = MD->getInterfaceType();
1799+
if (MD->parameterList && macroType->is<FunctionType>()) {
1800+
Builder.addLeftParen();
1801+
addCallArgumentPatterns(Builder, macroType->castTo<FunctionType>(),
1802+
MD->parameterList,
1803+
MD->getGenericSignature());
1804+
Builder.addRightParen();
1805+
}
1806+
1807+
addTypeAnnotation(
1808+
Builder, MD->getResultInterfaceType(), MD->getGenericSignature());
1809+
}
1810+
17761811
void CompletionLookup::addKeyword(StringRef Name, Type TypeAnnotation,
17771812
SemanticContextKind SK,
17781813
CodeCompletionKeywordKind KeyKind,
@@ -2056,6 +2091,11 @@ void CompletionLookup::foundDecl(ValueDecl *D, DeclVisibilityKind Reason,
20562091
addSubscriptCall(SD, Reason, dynamicLookupInfo);
20572092
return;
20582093
}
2094+
2095+
if (auto *MD = dyn_cast<MacroDecl>(D)) {
2096+
addMacroExpansion(MD, Reason);
2097+
return;
2098+
}
20592099
return;
20602100

20612101
case LookupKind::EnumElement:
@@ -2724,6 +2764,11 @@ void CompletionLookup::addObjCPoundKeywordCompletions(bool needPound) {
27242764
}
27252765
}
27262766

2767+
void CompletionLookup::getMacroCompletions(bool needPound) {
2768+
RequestedCachedResults.insert(
2769+
RequestedResultsTy::toplevelResults().onlyMacros(needPound));
2770+
}
2771+
27272772
void CompletionLookup::getValueCompletionsInDeclContext(SourceLoc Loc,
27282773
DeclFilter Filter,
27292774
bool LiteralCompletions,
@@ -3137,18 +3182,21 @@ void CompletionLookup::getTypeCompletionsInDeclContext(SourceLoc Loc,
31373182
ModuleQualifier));
31383183
}
31393184

3140-
void CompletionLookup::getToplevelCompletions(bool OnlyTypes) {
3185+
void CompletionLookup::getToplevelCompletions(bool OnlyTypes, bool OnlyMacros) {
31413186
Kind = OnlyTypes ? LookupKind::TypeInDeclContext
31423187
: LookupKind::ValueInDeclContext;
31433188
NeedLeadingDot = false;
3189+
NeedLeadingMacroPound = !OnlyMacros;
31443190

31453191
UsableFilteringDeclConsumer UsableFilteringConsumer(
31463192
Ctx.SourceMgr, CurrDeclContext, Ctx.SourceMgr.getCodeCompletionLoc(),
31473193
*this);
31483194
AccessFilteringDeclConsumer AccessFilteringConsumer(CurrDeclContext,
31493195
UsableFilteringConsumer);
3196+
DeclFilter Filter = OnlyMacros ? MacroFilter : DefaultFilter;
3197+
FilteredDeclConsumer FilteringConsumer(AccessFilteringConsumer, Filter);
31503198

3151-
CurrModule->lookupVisibleDecls({}, AccessFilteringConsumer,
3199+
CurrModule->lookupVisibleDecls({}, FilteringConsumer,
31523200
NLKind::UnqualifiedLookup);
31533201
}
31543202

lib/Parse/ParseExpr.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,17 +1775,17 @@ ParserResult<Expr> Parser::parseExprPrimary(Diag<> ID, bool isExprBasic) {
17751775
}
17761776

17771777
case tok::pound:
1778+
if (peekToken().is(tok::code_complete) &&
1779+
Tok.getLoc().getAdvancedLoc(1) == peekToken().getLoc()) {
1780+
return parseExprPoundCodeCompletion(/*ParentKind*/None);
1781+
}
17781782
if (Context.LangOpts.hasFeature(Feature::Macros)) {
17791783
return parseExprMacroExpansion(isExprBasic);
17801784
}
17811785
if (peekToken().is(tok::identifier) && !peekToken().isEscapedIdentifier() &&
17821786
Tok.getLoc().getAdvancedLoc(1) == peekToken().getLoc()) {
17831787
return parseExprPoundUnknown(SourceLoc());
17841788
}
1785-
if (peekToken().is(tok::code_complete) &&
1786-
Tok.getLoc().getAdvancedLoc(1) == peekToken().getLoc()) {
1787-
return parseExprPoundCodeCompletion(/*ParentKind*/None);
1788-
}
17891789
goto UnknownCharacter;
17901790

17911791
// Eat an invalid token in an expression context. Error tokens are diagnosed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=POUND_EXPR_1 -enable-experimental-feature Macros| %FileCheck %s -check-prefix=POUND_EXPR_INTCONTEXT
2+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=POUND_EXPR_2 -enable-experimental-feature Macros | %FileCheck %s -check-prefix=POUND_EXPR_STRINGCONTEXT
3+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=BARE_EXPR_1 -enable-experimental-feature Macros| %FileCheck %s -check-prefix=BARE_EXPR_INTCONTEXT
4+
// REQUIRES: objc_interop
5+
6+
import ObjectiveC
7+
8+
macro myLine: Int = A.B
9+
macro myFilename<T: ExpressiblyByStringLiteral>: T = A.B
10+
macro myStringify<T>(_: T) -> (T, String) = A.B
11+
12+
struct Color { }
13+
14+
macro myColorLiteral(red: Float, green: Float, blue: Float, alpha: Float) -> Color = A.B
15+
16+
func useInt(_ str: Int) -> Bool {}
17+
func useString(_ str: String) -> Bool {}
18+
19+
func test1() {
20+
let _ = useInt(##^POUND_EXPR_1^#)
21+
let _ = useString(##^POUND_EXPR_2^#)
22+
let _ = useInt(#^BARE_EXPR_1^#)
23+
}
24+
25+
// POUND_EXPR_INTCONTEXT: Begin completions, 11 items
26+
// POUND_EXPR_INTCONTEXT-DAG: Keyword[#function]/None: function[#String#]; name=function
27+
// POUND_EXPR_INTCONTEXT-DAG: Keyword[#file]/None: file[#String#]; name=file
28+
// POUND_EXPR_INTCONTEXT-DAG: Keyword[#fileID]/None: fileID[#String#]; name=fileID
29+
// POUND_EXPR_INTCONTEXT-DAG: Keyword[#filePath]/None: filePath[#String#]; name=filePath
30+
// POUND_EXPR_INTCONTEXT-DAG: Keyword[#line]/None/TypeRelation[Convertible]: line[#Int#]; name=line
31+
// POUND_EXPR_INTCONTEXT-DAG: Keyword[#column]/None/TypeRelation[Convertible]: column[#Int#]; name=column
32+
// POUND_EXPR_INTCONTEXT-DAG: Keyword[#dsohandle]/None: dsohandle[#UnsafeRawPointer#]; name=dsohandle
33+
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/CurrModule: myFilename[#T#]; name=myFilename
34+
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/CurrModule/TypeRelation[Convertible]: myLine[#Int#]; name=myLine
35+
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/CurrModule: myStringify({#T#})[#(T, String)#]; name=myStringify()
36+
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/CurrModule: myColorLiteral({#red: Float#}, {#green: Float#}, {#blue: Float#}, {#alpha: Float#})[#Color#]; name=myColorLiteral(red:green:blue:alpha:)
37+
38+
// POUND_EXPR_INTCONTEXT: End completions
39+
40+
// POUND_EXPR_STRINGCONTEXT: Begin completions, 12 items
41+
// POUND_EXPR_STRINGCONTEXT-DAG: Keyword[#function]/None/TypeRelation[Convertible]: function[#String#];
42+
// POUND_EXPR_STRINGCONTEXT-DAG: Keyword[#file]/None/TypeRelation[Convertible]: file[#String#];
43+
// POUND_EXPR_STRINGCONTEXT-DAG: Keyword[#fileID]/None/TypeRelation[Convertible]: fileID[#String#];
44+
// POUND_EXPR_STRINGCONTEXT-DAG: Keyword[#filePath]/None/TypeRelation[Convertible]: filePath[#String#];
45+
// POUND_EXPR_STRINGCONTEXT-DAG: Keyword[#line]/None: line[#Int#];
46+
// POUND_EXPR_STRINGCONTEXT-DAG: Keyword[#column]/None: column[#Int#];
47+
// POUND_EXPR_STRINGCONTEXT-DAG: Keyword[#dsohandle]/None: dsohandle[#UnsafeRawPointer#];
48+
// POUND_EXPR_STRINGCONTEXT-DAG: Keyword/None/TypeRelation[Convertible]: keyPath({#@objc property sequence#})[#String#];
49+
// POUND_EXPR_STRINGCONTEXT-DAG: Decl[Macro]/CurrModule: myColorLiteral({#red: Float#}, {#green: Float#}, {#blue: Float#}, {#alpha: Float#})[#Color#]; name=myColorLiteral(red:green:blue:alpha:)
50+
// POUND_EXPR_STRINGCONTEXT-DAG: Decl[Macro]/CurrModule: myFilename[#T#]; name=myFilename
51+
// POUND_EXPR_STRINGCONTEXT-DAG: Decl[Macro]/CurrModule: myLine[#Int#]; name=myLine
52+
// POUND_EXPR_STRINGCONTEXT-DAG: Decl[Macro]/CurrModule: myStringify({#T#})[#(T, String)#]; name=myStringify()
53+
// POUND_EXPR_STRINGCONTEXT: End completions
54+
55+
// BARE_EXPR_INTCONTEXT: Begin completions,
56+
// BARE_EXPR_INTCONTEXT-DAG: Keyword[#fileID]/None: #fileID[#String#]; name=#fileID
57+
// BARE_EXPR_INTCONTEXT-DAG: Keyword[#file]/None: #file[#String#]; name=#file
58+
// BARE_EXPR_INTCONTEXT-DAG: Keyword[#filePath]/None: #filePath[#String#]; name=#filePath
59+
// BARE_EXPR_INTCONTEXT-DAG: Keyword[#function]/None: #function[#String#]; name=#function
60+
// BARE_EXPR_INTCONTEXT-DAG: Keyword[#line]/None/TypeRelation[Convertible]: #line[#Int#]; name=#line
61+
// BARE_EXPR_INTCONTEXT-DAG: Keyword[#column]/None/TypeRelation[Convertible]: #column[#Int#]; name=#column
62+
// BARE_EXPR_INTCONTEXT-DAG: Keyword[#dsohandle]/None: #dsohandle[#UnsafeRawPointer#]; name=#dsohandle
63+
// BARE_EXPR_INTCONTEXT-DAG: Decl[Macro]/CurrModule: #myFilename[#T#]; name=#myFilename
64+
// BARE_EXPR_INTCONTEXT-DAG: Decl[Struct]/CurrModule: Color[#Color#]; name=Color
65+
// BARE_EXPR_INTCONTEXT-DAG: Decl[FreeFunction]/CurrModule/TypeRelation[Invalid]: test1()[#Void#]; name=test1()
66+
// BARE_EXPR_INTCONTEXT-DAG: Decl[Macro]/CurrModule/TypeRelation[Convertible]: #myLine[#Int#]; name=#myLine
67+
// BARE_EXPR_INTCONTEXT-DAG: Decl[FreeFunction]/CurrModule: useInt({#(str): Int#})[#Bool#]; name=useInt(:)
68+
// BARE_EXPR_INTCONTEXT-DAG: Decl[Macro]/CurrModule: #myStringify({#T#})[#(T, String)#]; name=#myStringify()
69+
// BARE_EXPR_INTCONTEXT-DAG: Decl[FreeFunction]/CurrModule: useString({#(str): String#})[#Bool#]; name=useString(:)
70+
// BARE_EXPR_INTCONTEXT-DAG: Decl[Macro]/CurrModule: #myColorLiteral({#red: Float#}, {#green: Float#}, {#blue: Float#}, {#alpha: Float#})[#Color#]; name=#myColorLiteral(red:green:blue:alpha:)
71+
// BARE_EXPR_INTCONTEXT: End completions

tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ UIdent SwiftLangSupport::getUIDForCodeCompletionDeclKind(
412412
case CodeCompletionDeclKind::InstanceVar: return KindRefVarInstance;
413413
case CodeCompletionDeclKind::LocalVar: return KindRefVarLocal;
414414
case CodeCompletionDeclKind::GlobalVar: return KindRefVarGlobal;
415-
case CodeCompletionDeclKind::Macro: return KindRefMacro;
415+
case CodeCompletionDeclKind::Macro: return KindRefMacro;
416416
}
417417
}
418418

0 commit comments

Comments
 (0)