Skip to content

Commit 5f9ac48

Browse files
committed
[Completion] NFC: Factor out addMacroCallArguments
1 parent d6cb6be commit 5f9ac48

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

include/swift/IDE/CompletionLookup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
458458
void addEnumElementRef(const EnumElementDecl *EED, DeclVisibilityKind Reason,
459459
DynamicLookupInfo dynamicLookupInfo,
460460
bool HasTypeContext);
461+
void addMacroCallArguments(const MacroDecl *MD, DeclVisibilityKind Reason);
461462
void addMacroExpansion(const MacroDecl *MD, DeclVisibilityKind Reason);
462463

463464
void addKeyword(

lib/IDE/CompletionLookup.cpp

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,22 +1946,8 @@ static StringRef getTypeAnnotationString(const MacroDecl *MD,
19461946
return {stash.data(), stash.size()};
19471947
}
19481948

1949-
void CompletionLookup::addMacroExpansion(const MacroDecl *MD,
1950-
DeclVisibilityKind Reason) {
1951-
if (!MD->hasName() || !MD->isAccessibleFrom(CurrDeclContext) ||
1952-
MD->shouldHideFromEditor())
1953-
return;
1954-
1955-
OptionSet<CustomAttributeKind> expectedKinds =
1956-
expectedTypeContext.getExpectedCustomAttributeKinds();
1957-
if (expectedKinds) {
1958-
CodeCompletionMacroRoles expectedRoles =
1959-
getCompletionMacroRoles(expectedKinds);
1960-
CodeCompletionMacroRoles roles = getCompletionMacroRoles(MD);
1961-
if (!(roles & expectedRoles))
1962-
return;
1963-
}
1964-
1949+
void CompletionLookup::addMacroCallArguments(const MacroDecl *MD,
1950+
DeclVisibilityKind Reason) {
19651951
CodeCompletionResultBuilder Builder =
19661952
makeResultBuilder(CodeCompletionResultKind::Declaration,
19671953
getSemanticContext(MD, Reason, DynamicLookupInfo()));
@@ -1988,6 +1974,25 @@ void CompletionLookup::addMacroExpansion(const MacroDecl *MD,
19881974
}
19891975
}
19901976

1977+
void CompletionLookup::addMacroExpansion(const MacroDecl *MD,
1978+
DeclVisibilityKind Reason) {
1979+
if (!MD->hasName() || !MD->isAccessibleFrom(CurrDeclContext) ||
1980+
MD->shouldHideFromEditor())
1981+
return;
1982+
1983+
OptionSet<CustomAttributeKind> expectedKinds =
1984+
expectedTypeContext.getExpectedCustomAttributeKinds();
1985+
if (expectedKinds) {
1986+
CodeCompletionMacroRoles expectedRoles =
1987+
getCompletionMacroRoles(expectedKinds);
1988+
CodeCompletionMacroRoles roles = getCompletionMacroRoles(MD);
1989+
if (!(roles & expectedRoles))
1990+
return;
1991+
}
1992+
1993+
addMacroCallArguments(MD, Reason);
1994+
}
1995+
19911996
void CompletionLookup::addKeyword(StringRef Name, Type TypeAnnotation,
19921997
SemanticContextKind SK,
19931998
CodeCompletionKeywordKind KeyKind,

0 commit comments

Comments
 (0)