mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Completion] Only provide macro completions when they are valid
Only return macros that are valid in their current position, ie. an attached macro is not valid on a nominal. Also return freestanding expression macros in code block item position and handle the new freestanding code item macros. Resolves rdar://105563583.
This commit is contained in:
@@ -116,9 +116,7 @@ public:
|
|||||||
struct RequestedCachedModule {
|
struct RequestedCachedModule {
|
||||||
CodeCompletionCache::Key Key;
|
CodeCompletionCache::Key Key;
|
||||||
const ModuleDecl *TheModule;
|
const ModuleDecl *TheModule;
|
||||||
bool OnlyTypes;
|
CodeCompletionFilter Filter;
|
||||||
bool OnlyPrecedenceGroups;
|
|
||||||
bool OnlyMacros;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace ide
|
} // end namespace ide
|
||||||
|
|||||||
@@ -316,6 +316,39 @@ enum class CodeCompletionResultKind : uint8_t {
|
|||||||
MAX_VALUE = BuiltinOperator
|
MAX_VALUE = BuiltinOperator
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class CodeCompletionMacroRole : uint8_t {
|
||||||
|
Expression = 1 << 0,
|
||||||
|
Declaration = 1 << 1,
|
||||||
|
CodeItem = 1 << 2,
|
||||||
|
AttachedVar = 1 << 3,
|
||||||
|
AttachedContext = 1 << 4,
|
||||||
|
AttachedDecl = 1 << 5,
|
||||||
|
};
|
||||||
|
using CodeCompletionMacroRoles = OptionSet<CodeCompletionMacroRole>;
|
||||||
|
|
||||||
|
enum class CodeCompletionFilterFlag : uint16_t {
|
||||||
|
Expr = 1 << 0,
|
||||||
|
Type = 1 << 1,
|
||||||
|
PrecedenceGroup = 1 << 2,
|
||||||
|
Module = 1 << 3,
|
||||||
|
ExpressionMacro = 1 << 4,
|
||||||
|
DeclarationMacro = 1 << 5,
|
||||||
|
CodeItemMacro = 1 << 6,
|
||||||
|
AttachedVarMacro = 1 << 7,
|
||||||
|
AttachedContextMacro = 1 << 8,
|
||||||
|
AttachedDeclMacro = 1 << 9,
|
||||||
|
};
|
||||||
|
using CodeCompletionFilter = OptionSet<CodeCompletionFilterFlag>;
|
||||||
|
|
||||||
|
CodeCompletionMacroRoles getCompletionMacroRoles(const Decl *D);
|
||||||
|
|
||||||
|
CodeCompletionMacroRoles
|
||||||
|
getCompletionMacroRoles(OptionSet<CustomAttributeKind> kinds);
|
||||||
|
|
||||||
|
CodeCompletionMacroRoles getCompletionMacroRoles(CodeCompletionFilter filter);
|
||||||
|
|
||||||
|
CodeCompletionFilter getCompletionFilter(CodeCompletionMacroRoles roles);
|
||||||
|
|
||||||
/// The parts of a \c CodeCompletionResult that are not dependent on the context
|
/// The parts of a \c CodeCompletionResult that are not dependent on the context
|
||||||
/// it appears in and can thus be cached.
|
/// it appears in and can thus be cached.
|
||||||
class ContextFreeCodeCompletionResult {
|
class ContextFreeCodeCompletionResult {
|
||||||
@@ -334,6 +367,8 @@ class ContextFreeCodeCompletionResult {
|
|||||||
CodeCompletionOperatorKind KnownOperatorKind : 6;
|
CodeCompletionOperatorKind KnownOperatorKind : 6;
|
||||||
static_assert(int(CodeCompletionOperatorKind::MAX_VALUE) < 1 << 6, "");
|
static_assert(int(CodeCompletionOperatorKind::MAX_VALUE) < 1 << 6, "");
|
||||||
|
|
||||||
|
CodeCompletionMacroRoles MacroRoles;
|
||||||
|
|
||||||
bool IsSystem : 1;
|
bool IsSystem : 1;
|
||||||
bool IsAsync : 1;
|
bool IsAsync : 1;
|
||||||
/// Whether the result has been annotated as having an async alternative that
|
/// Whether the result has been annotated as having an async alternative that
|
||||||
@@ -359,17 +394,18 @@ class ContextFreeCodeCompletionResult {
|
|||||||
NullTerminatedStringRef NameForDiagnostics;
|
NullTerminatedStringRef NameForDiagnostics;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Memberwise initializer. \p AssociatedKInd is opaque and will be
|
/// Memberwise initializer. \p AssociatedKind is opaque and will be
|
||||||
/// interpreted based on \p Kind. If \p KnownOperatorKind is \c None and the
|
/// interpreted based on \p Kind. If \p KnownOperatorKind is \c None and the
|
||||||
/// completion item is an operator, it will be determined based on the
|
/// completion item is an operator, it will be determined based on the
|
||||||
/// compleiton string.
|
/// completion string.
|
||||||
///
|
///
|
||||||
/// \note The caller must ensure that the \p CompleitonString and all the
|
/// \note The caller must ensure that the \p CompletionString and all the
|
||||||
/// \c Ref types outlive this result, typically by storing them in the same
|
/// \c Ref types outlive this result, typically by storing them in the same
|
||||||
/// \c CodeCompletionResultSink as the result itself.
|
/// \c CodeCompletionResultSink as the result itself.
|
||||||
ContextFreeCodeCompletionResult(
|
ContextFreeCodeCompletionResult(
|
||||||
CodeCompletionResultKind Kind, uint8_t AssociatedKind,
|
CodeCompletionResultKind Kind, uint8_t AssociatedKind,
|
||||||
CodeCompletionOperatorKind KnownOperatorKind, bool IsSystem, bool IsAsync,
|
CodeCompletionOperatorKind KnownOperatorKind,
|
||||||
|
CodeCompletionMacroRoles MacroRoles, bool IsSystem, bool IsAsync,
|
||||||
bool HasAsyncAlternative, CodeCompletionString *CompletionString,
|
bool HasAsyncAlternative, CodeCompletionString *CompletionString,
|
||||||
NullTerminatedStringRef ModuleName,
|
NullTerminatedStringRef ModuleName,
|
||||||
NullTerminatedStringRef BriefDocComment,
|
NullTerminatedStringRef BriefDocComment,
|
||||||
@@ -380,8 +416,9 @@ public:
|
|||||||
NullTerminatedStringRef DiagnosticMessage,
|
NullTerminatedStringRef DiagnosticMessage,
|
||||||
NullTerminatedStringRef FilterName,
|
NullTerminatedStringRef FilterName,
|
||||||
NullTerminatedStringRef NameForDiagnostics)
|
NullTerminatedStringRef NameForDiagnostics)
|
||||||
: Kind(Kind), KnownOperatorKind(KnownOperatorKind), IsSystem(IsSystem),
|
: Kind(Kind), KnownOperatorKind(KnownOperatorKind),
|
||||||
IsAsync(IsAsync), HasAsyncAlternative(HasAsyncAlternative),
|
MacroRoles(MacroRoles), IsSystem(IsSystem), IsAsync(IsAsync),
|
||||||
|
HasAsyncAlternative(HasAsyncAlternative),
|
||||||
CompletionString(CompletionString), ModuleName(ModuleName),
|
CompletionString(CompletionString), ModuleName(ModuleName),
|
||||||
BriefDocComment(BriefDocComment), AssociatedUSRs(AssociatedUSRs),
|
BriefDocComment(BriefDocComment), AssociatedUSRs(AssociatedUSRs),
|
||||||
ResultType(ResultType), NotRecommended(NotRecommended),
|
ResultType(ResultType), NotRecommended(NotRecommended),
|
||||||
@@ -488,6 +525,8 @@ public:
|
|||||||
return KnownOperatorKind;
|
return KnownOperatorKind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CodeCompletionMacroRoles getMacroRoles() const { return MacroRoles; }
|
||||||
|
|
||||||
bool isSystem() const { return IsSystem; };
|
bool isSystem() const { return IsSystem; };
|
||||||
|
|
||||||
bool isAsync() const { return IsAsync; };
|
bool isAsync() const { return IsAsync; };
|
||||||
|
|||||||
@@ -28,8 +28,12 @@ enum class CustomAttributeKind : uint8_t {
|
|||||||
ResultBuilder = 1 << 1,
|
ResultBuilder = 1 << 1,
|
||||||
/// A type that can be used as a global actor.
|
/// A type that can be used as a global actor.
|
||||||
GlobalActor = 1 << 2,
|
GlobalActor = 1 << 2,
|
||||||
/// A macro can be used as a custom attribute.
|
/// A macro that can be used on variables or subscripts.
|
||||||
Macro = 1 << 3,
|
VarMacro = 1 << 3,
|
||||||
|
/// A macro that can be used on any type context.
|
||||||
|
ContextMacro = 1 << 4,
|
||||||
|
/// A macro that can be used on any declaration.
|
||||||
|
DeclMacro = 1 << 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The expected contextual type(s) for code-completion.
|
/// The expected contextual type(s) for code-completion.
|
||||||
|
|||||||
@@ -137,7 +137,6 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
|
|||||||
bool IsUnwrappedOptional = false;
|
bool IsUnwrappedOptional = false;
|
||||||
SourceLoc DotLoc;
|
SourceLoc DotLoc;
|
||||||
bool NeedLeadingDot = false;
|
bool NeedLeadingDot = false;
|
||||||
bool NeedLeadingMacroPound = false;
|
|
||||||
|
|
||||||
bool NeedOptionalUnwrap = false;
|
bool NeedOptionalUnwrap = false;
|
||||||
unsigned NumBytesToEraseForOptionalUnwrap = 0;
|
unsigned NumBytesToEraseForOptionalUnwrap = 0;
|
||||||
@@ -186,53 +185,27 @@ private:
|
|||||||
public:
|
public:
|
||||||
struct RequestedResultsTy {
|
struct RequestedResultsTy {
|
||||||
const ModuleDecl *TheModule;
|
const ModuleDecl *TheModule;
|
||||||
bool OnlyTypes;
|
CodeCompletionFilter Filter;
|
||||||
bool OnlyPrecedenceGroups;
|
|
||||||
bool OnlyMacros;
|
|
||||||
bool NeedLeadingDot;
|
bool NeedLeadingDot;
|
||||||
bool NeedPound;
|
|
||||||
bool IncludeModuleQualifier;
|
|
||||||
|
|
||||||
static RequestedResultsTy fromModule(const ModuleDecl *TheModule) {
|
static RequestedResultsTy fromModule(const ModuleDecl *mod,
|
||||||
return {TheModule, false, false, false, false, false, true};
|
CodeCompletionFilter filter) {
|
||||||
|
return {mod, filter, /*NeedLeadingDot=*/false};
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestedResultsTy onlyTypes() const {
|
static RequestedResultsTy topLevelResults(CodeCompletionFilter filter) {
|
||||||
return {TheModule, true, false, false, NeedLeadingDot, false,
|
return {nullptr, filter, /*NeedLeadingDot=*/false};
|
||||||
IncludeModuleQualifier};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestedResultsTy onlyPrecedenceGroups() const {
|
RequestedResultsTy needLeadingDot(bool needDot) const {
|
||||||
assert(!OnlyTypes && "onlyTypes() already includes precedence groups");
|
return {TheModule, Filter, needDot};
|
||||||
return {TheModule, false, true, false, false, false, true};
|
|
||||||
}
|
|
||||||
|
|
||||||
RequestedResultsTy onlyMacros(bool needPound) const {
|
|
||||||
return {TheModule, false, false, true, false, needPound, false};
|
|
||||||
}
|
|
||||||
|
|
||||||
RequestedResultsTy needLeadingDot(bool NeedDot) const {
|
|
||||||
return {TheModule, OnlyTypes, OnlyPrecedenceGroups, OnlyMacros, NeedDot,
|
|
||||||
NeedPound, IncludeModuleQualifier};
|
|
||||||
}
|
|
||||||
|
|
||||||
RequestedResultsTy withModuleQualifier(bool IncludeModule) const {
|
|
||||||
return {TheModule, OnlyTypes, OnlyPrecedenceGroups, OnlyMacros,
|
|
||||||
NeedLeadingDot, NeedPound, IncludeModule};
|
|
||||||
}
|
|
||||||
|
|
||||||
static RequestedResultsTy toplevelResults() {
|
|
||||||
return {nullptr, false, false, false, false, true, true};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator==(const RequestedResultsTy &LHS,
|
friend bool operator==(const RequestedResultsTy &LHS,
|
||||||
const RequestedResultsTy &RHS) {
|
const RequestedResultsTy &RHS) {
|
||||||
return LHS.TheModule == RHS.TheModule && LHS.OnlyTypes == RHS.OnlyTypes &&
|
return LHS.TheModule == RHS.TheModule &&
|
||||||
LHS.OnlyPrecedenceGroups == RHS.OnlyPrecedenceGroups &&
|
LHS.Filter.containsOnly(RHS.Filter) &&
|
||||||
LHS.OnlyMacros == RHS.OnlyMacros &&
|
LHS.NeedLeadingDot == RHS.NeedLeadingDot;
|
||||||
LHS.NeedLeadingDot == RHS.NeedLeadingDot &&
|
|
||||||
LHS.NeedPound == RHS.NeedPound &&
|
|
||||||
LHS.IncludeModuleQualifier == RHS.IncludeModuleQualifier;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -524,7 +497,7 @@ public:
|
|||||||
Type ExprType, const ValueDecl *VD,
|
Type ExprType, const ValueDecl *VD,
|
||||||
Optional<SemanticContextKind> SemanticContext = None);
|
Optional<SemanticContextKind> SemanticContext = None);
|
||||||
|
|
||||||
bool tryModuleCompletions(Type ExprType, bool TypesOnly = false);
|
bool tryModuleCompletions(Type ExprType, CodeCompletionFilter Filter);
|
||||||
|
|
||||||
/// If the given ExprType is optional, this adds completions for the unwrapped
|
/// If the given ExprType is optional, this adds completions for the unwrapped
|
||||||
/// type.
|
/// type.
|
||||||
@@ -562,7 +535,7 @@ public:
|
|||||||
|
|
||||||
void addObjCPoundKeywordCompletions(bool needPound);
|
void addObjCPoundKeywordCompletions(bool needPound);
|
||||||
|
|
||||||
void getMacroCompletions(bool needPound);
|
void getMacroCompletions(CodeCompletionMacroRoles roles);
|
||||||
|
|
||||||
struct FilteredDeclConsumer : public swift::VisibleDeclConsumer {
|
struct FilteredDeclConsumer : public swift::VisibleDeclConsumer {
|
||||||
swift::VisibleDeclConsumer &Consumer;
|
swift::VisibleDeclConsumer &Consumer;
|
||||||
@@ -626,7 +599,7 @@ public:
|
|||||||
void getTypeCompletionsInDeclContext(SourceLoc Loc,
|
void getTypeCompletionsInDeclContext(SourceLoc Loc,
|
||||||
bool ModuleQualifier = true);
|
bool ModuleQualifier = true);
|
||||||
|
|
||||||
void getToplevelCompletions(bool OnlyTypes, bool OnlyMacros);
|
void getToplevelCompletions(CodeCompletionFilter Filter);
|
||||||
|
|
||||||
void lookupExternalModuleDecls(const ModuleDecl *TheModule,
|
void lookupExternalModuleDecls(const ModuleDecl *TheModule,
|
||||||
ArrayRef<std::string> AccessPath,
|
ArrayRef<std::string> AccessPath,
|
||||||
@@ -645,18 +618,15 @@ using RequestedResultsTy = swift::ide::CompletionLookup::RequestedResultsTy;
|
|||||||
template <>
|
template <>
|
||||||
struct DenseMapInfo<RequestedResultsTy> {
|
struct DenseMapInfo<RequestedResultsTy> {
|
||||||
static inline RequestedResultsTy getEmptyKey() {
|
static inline RequestedResultsTy getEmptyKey() {
|
||||||
return {DenseMapInfo<swift::ModuleDecl *>::getEmptyKey(), false, false,
|
return {DenseMapInfo<swift::ModuleDecl *>::getEmptyKey(), {}, false};
|
||||||
false, false, false, false};
|
|
||||||
}
|
}
|
||||||
static inline RequestedResultsTy getTombstoneKey() {
|
static inline RequestedResultsTy getTombstoneKey() {
|
||||||
return {DenseMapInfo<swift::ModuleDecl *>::getTombstoneKey(), false, false,
|
return {DenseMapInfo<swift::ModuleDecl *>::getTombstoneKey(), {}, false};
|
||||||
false, false, false, false};
|
|
||||||
}
|
}
|
||||||
static unsigned getHashValue(const RequestedResultsTy &Val) {
|
static unsigned getHashValue(const RequestedResultsTy &Val) {
|
||||||
return hash_combine(
|
return hash_combine(
|
||||||
DenseMapInfo<swift::ModuleDecl *>::getHashValue(Val.TheModule),
|
DenseMapInfo<swift::ModuleDecl *>::getHashValue(Val.TheModule),
|
||||||
Val.OnlyTypes, Val.OnlyPrecedenceGroups, Val.OnlyMacros,
|
Val.Filter.toRaw(), Val.NeedLeadingDot);
|
||||||
Val.NeedLeadingDot, Val.NeedPound, Val.IncludeModuleQualifier);
|
|
||||||
}
|
}
|
||||||
static bool isEqual(const RequestedResultsTy &LHS,
|
static bool isEqual(const RequestedResultsTy &LHS,
|
||||||
const RequestedResultsTy &RHS) {
|
const RequestedResultsTy &RHS) {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ void AfterPoundExprCompletion::deliverResults(
|
|||||||
/*expectsNonVoid=*/true);
|
/*expectsNonVoid=*/true);
|
||||||
Lookup.addPoundAvailable(ParentStmtKind);
|
Lookup.addPoundAvailable(ParentStmtKind);
|
||||||
Lookup.addObjCPoundKeywordCompletions(/*needPound=*/false);
|
Lookup.addObjCPoundKeywordCompletions(/*needPound=*/false);
|
||||||
Lookup.getMacroCompletions(/*needPound=*/false);
|
Lookup.getMacroCompletions(CodeCompletionMacroRole::Expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
deliverCompletionResults(CompletionCtx, Lookup, DC, Consumer);
|
deliverCompletionResults(CompletionCtx, Lookup, DC, Consumer);
|
||||||
|
|||||||
@@ -1130,6 +1130,8 @@ static void addPoundDirectives(CodeCompletionResultSink &Sink) {
|
|||||||
Builder.addSimpleTypedParameter("Int");
|
Builder.addSimpleTypedParameter("Int");
|
||||||
Builder.addRightParen();
|
Builder.addRightParen();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#ifndef SWIFT_SWIFT_PARSER
|
||||||
addWithName("warning", CodeCompletionKeywordKind::pound_warning,
|
addWithName("warning", CodeCompletionKeywordKind::pound_warning,
|
||||||
[&] (CodeCompletionResultBuilder &Builder) {
|
[&] (CodeCompletionResultBuilder &Builder) {
|
||||||
Builder.addLeftParen();
|
Builder.addLeftParen();
|
||||||
@@ -1146,6 +1148,7 @@ static void addPoundDirectives(CodeCompletionResultSink &Sink) {
|
|||||||
Builder.addTextChunk("\"");
|
Builder.addTextChunk("\"");
|
||||||
Builder.addRightParen();
|
Builder.addRightParen();
|
||||||
});
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
addWithName("if ", CodeCompletionKeywordKind::pound_if,
|
addWithName("if ", CodeCompletionKeywordKind::pound_if,
|
||||||
[&] (CodeCompletionResultBuilder &Builder) {
|
[&] (CodeCompletionResultBuilder &Builder) {
|
||||||
@@ -1352,11 +1355,10 @@ void swift::ide::deliverCompletionResults(
|
|||||||
std::pair<PairType, bool> Result = ImportsSeen.insert(K);
|
std::pair<PairType, bool> Result = ImportsSeen.insert(K);
|
||||||
if (!Result.second)
|
if (!Result.second)
|
||||||
return; // already handled.
|
return; // already handled.
|
||||||
RequestedModules.push_back({std::move(K), TheModule,
|
RequestedModules.push_back({std::move(K), TheModule, Request.Filter});
|
||||||
Request.OnlyTypes, Request.OnlyPrecedenceGroups, Request.OnlyMacros});
|
|
||||||
|
|
||||||
auto TheModuleName = TheModule->getName();
|
auto TheModuleName = TheModule->getName();
|
||||||
if (Request.IncludeModuleQualifier &&
|
if (Request.Filter.contains(CodeCompletionFilterFlag::Module) &&
|
||||||
(!Lookup.isHiddenModuleName(TheModuleName) ||
|
(!Lookup.isHiddenModuleName(TheModuleName) ||
|
||||||
explictlyImportedModules.contains(TheModule)) &&
|
explictlyImportedModules.contains(TheModule)) &&
|
||||||
seenModuleNames.insert(TheModuleName).second)
|
seenModuleNames.insert(TheModuleName).second)
|
||||||
@@ -1371,11 +1373,11 @@ void swift::ide::deliverCompletionResults(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Add results from current module.
|
// Add results from current module.
|
||||||
Lookup.getToplevelCompletions(Request.OnlyTypes, Request.OnlyMacros);
|
Lookup.getToplevelCompletions(Request.Filter);
|
||||||
|
|
||||||
// Add the qualifying module name
|
// Add the qualifying module name
|
||||||
auto curModule = SF.getParentModule();
|
auto curModule = SF.getParentModule();
|
||||||
if (Request.IncludeModuleQualifier &&
|
if (Request.Filter.contains(CodeCompletionFilterFlag::Module) &&
|
||||||
seenModuleNames.insert(curModule->getName()).second)
|
seenModuleNames.insert(curModule->getName()).second)
|
||||||
Lookup.addModuleName(curModule);
|
Lookup.addModuleName(curModule);
|
||||||
|
|
||||||
@@ -1790,15 +1792,35 @@ void CodeCompletionCallbacksImpl::doneParsing(SourceFile *SrcFile) {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (*AttTargetDK) {
|
||||||
|
case DeclKind::Var:
|
||||||
|
case DeclKind::Subscript:
|
||||||
|
ExpectedCustomAttributeKinds |= CustomAttributeKind::VarMacro;
|
||||||
|
break;
|
||||||
|
case DeclKind::Struct:
|
||||||
|
case DeclKind::Class:
|
||||||
|
case DeclKind::Protocol:
|
||||||
|
case DeclKind::Enum:
|
||||||
|
case DeclKind::Extension:
|
||||||
|
ExpectedCustomAttributeKinds |= CustomAttributeKind::ContextMacro;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!ExpectedCustomAttributeKinds) {
|
if (*AttTargetDK != DeclKind::Param) {
|
||||||
|
ExpectedCustomAttributeKinds |= CustomAttributeKind::DeclMacro;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// If we don't know on which decl kind we are completing, suggest all
|
// If we don't know on which decl kind we are completing, suggest all
|
||||||
// attribute kinds.
|
// attribute kinds.
|
||||||
ExpectedCustomAttributeKinds |= CustomAttributeKind::PropertyWrapper;
|
ExpectedCustomAttributeKinds |= CustomAttributeKind::PropertyWrapper;
|
||||||
ExpectedCustomAttributeKinds |= CustomAttributeKind::ResultBuilder;
|
ExpectedCustomAttributeKinds |= CustomAttributeKind::ResultBuilder;
|
||||||
ExpectedCustomAttributeKinds |= CustomAttributeKind::GlobalActor;
|
ExpectedCustomAttributeKinds |= CustomAttributeKind::GlobalActor;
|
||||||
|
ExpectedCustomAttributeKinds |= CustomAttributeKind::VarMacro;
|
||||||
|
ExpectedCustomAttributeKinds |= CustomAttributeKind::ContextMacro;
|
||||||
|
ExpectedCustomAttributeKinds |= CustomAttributeKind::DeclMacro;
|
||||||
}
|
}
|
||||||
ExpectedCustomAttributeKinds |= CustomAttributeKind::Macro;
|
|
||||||
|
|
||||||
Lookup.setExpectedTypes(/*Types=*/{},
|
Lookup.setExpectedTypes(/*Types=*/{},
|
||||||
/*isImplicitSingleExpressionReturn=*/false,
|
/*isImplicitSingleExpressionReturn=*/false,
|
||||||
@@ -1814,8 +1836,11 @@ void CodeCompletionCallbacksImpl::doneParsing(SourceFile *SrcFile) {
|
|||||||
P.Context.SourceMgr.getIDEInspectionTargetLoc());
|
P.Context.SourceMgr.getIDEInspectionTargetLoc());
|
||||||
|
|
||||||
// Macro name at attribute position after '@'.
|
// Macro name at attribute position after '@'.
|
||||||
Lookup.getToplevelCompletions(
|
CodeCompletionMacroRoles macroRoles =
|
||||||
/*OnlyTypes=*/false, /*OnlyMacros=*/true);
|
getCompletionMacroRoles(ExpectedCustomAttributeKinds);
|
||||||
|
if (macroRoles) {
|
||||||
|
Lookup.getMacroCompletions(macroRoles);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CompletionKind::AttributeDeclParen: {
|
case CompletionKind::AttributeDeclParen: {
|
||||||
@@ -1968,6 +1993,15 @@ void CodeCompletionCallbacksImpl::doneParsing(SourceFile *SrcFile) {
|
|||||||
|
|
||||||
case CompletionKind::AfterPoundDirective: {
|
case CompletionKind::AfterPoundDirective: {
|
||||||
addPoundDirectives(CompletionContext.getResultSink());
|
addPoundDirectives(CompletionContext.getResultSink());
|
||||||
|
|
||||||
|
CodeCompletionMacroRoles roles;
|
||||||
|
if (!CurDeclContext || !CurDeclContext->isTypeContext()) {
|
||||||
|
roles |= CodeCompletionMacroRole::Expression;
|
||||||
|
roles |= CodeCompletionMacroRole::CodeItem;
|
||||||
|
}
|
||||||
|
roles |= CodeCompletionMacroRole::Declaration;
|
||||||
|
Lookup.getMacroCompletions(roles);
|
||||||
|
|
||||||
// FIXME: Add pound expressions (e.g. '#selector()') if it's at statements
|
// FIXME: Add pound expressions (e.g. '#selector()') if it's at statements
|
||||||
// position.
|
// position.
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ CodeCompletionCache::~CodeCompletionCache() {}
|
|||||||
/// This should be incremented any time we commit a change to the format of the
|
/// This should be incremented any time we commit a change to the format of the
|
||||||
/// cached results. This isn't expected to change very often.
|
/// cached results. This isn't expected to change very often.
|
||||||
static constexpr uint32_t onDiskCompletionCacheVersion =
|
static constexpr uint32_t onDiskCompletionCacheVersion =
|
||||||
10; // Store if decl has an async alternative
|
11; // Added macro roles
|
||||||
|
|
||||||
/// Deserializes CodeCompletionResults from \p in and stores them in \p V.
|
/// Deserializes CodeCompletionResults from \p in and stores them in \p V.
|
||||||
/// \see writeCacheModule.
|
/// \see writeCacheModule.
|
||||||
@@ -230,6 +230,7 @@ static bool readCachedModule(llvm::MemoryBuffer *in,
|
|||||||
auto kind = static_cast<CodeCompletionResultKind>(*cursor++);
|
auto kind = static_cast<CodeCompletionResultKind>(*cursor++);
|
||||||
auto associatedKind = static_cast<uint8_t>(*cursor++);
|
auto associatedKind = static_cast<uint8_t>(*cursor++);
|
||||||
auto opKind = static_cast<CodeCompletionOperatorKind>(*cursor++);
|
auto opKind = static_cast<CodeCompletionOperatorKind>(*cursor++);
|
||||||
|
auto roles = CodeCompletionMacroRoles(*cursor++);
|
||||||
auto notRecommended =
|
auto notRecommended =
|
||||||
static_cast<ContextFreeNotRecommendedReason>(*cursor++);
|
static_cast<ContextFreeNotRecommendedReason>(*cursor++);
|
||||||
auto diagSeverity =
|
auto diagSeverity =
|
||||||
@@ -266,7 +267,7 @@ static bool readCachedModule(llvm::MemoryBuffer *in,
|
|||||||
|
|
||||||
ContextFreeCodeCompletionResult *result =
|
ContextFreeCodeCompletionResult *result =
|
||||||
new (*V.Allocator) ContextFreeCodeCompletionResult(
|
new (*V.Allocator) ContextFreeCodeCompletionResult(
|
||||||
kind, associatedKind, opKind, isSystem, isAsync,
|
kind, associatedKind, opKind, roles, isSystem, isAsync,
|
||||||
hasAsyncAlternative, string, moduleName, briefDocComment,
|
hasAsyncAlternative, string, moduleName, briefDocComment,
|
||||||
makeArrayRef(assocUSRs).copy(*V.Allocator),
|
makeArrayRef(assocUSRs).copy(*V.Allocator),
|
||||||
CodeCompletionResultType(resultTypes), notRecommended, diagSeverity,
|
CodeCompletionResultType(resultTypes), notRecommended, diagSeverity,
|
||||||
@@ -423,6 +424,7 @@ static void writeCachedModule(llvm::raw_ostream &out,
|
|||||||
} else {
|
} else {
|
||||||
LE.write(static_cast<uint8_t>(CodeCompletionOperatorKind::None));
|
LE.write(static_cast<uint8_t>(CodeCompletionOperatorKind::None));
|
||||||
}
|
}
|
||||||
|
LE.write(static_cast<uint8_t>(R->getMacroRoles().toRaw()));
|
||||||
LE.write(static_cast<uint8_t>(R->getNotRecommendedReason()));
|
LE.write(static_cast<uint8_t>(R->getNotRecommendedReason()));
|
||||||
LE.write(static_cast<uint8_t>(R->getDiagnosticSeverity()));
|
LE.write(static_cast<uint8_t>(R->getDiagnosticSeverity()));
|
||||||
LE.write(static_cast<uint8_t>(R->isSystem()));
|
LE.write(static_cast<uint8_t>(R->isSystem()));
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ using namespace swift::ide;
|
|||||||
|
|
||||||
static MutableArrayRef<CodeCompletionResult *> copyCodeCompletionResults(
|
static MutableArrayRef<CodeCompletionResult *> copyCodeCompletionResults(
|
||||||
CodeCompletionResultSink &targetSink, CodeCompletionCache::Value &source,
|
CodeCompletionResultSink &targetSink, CodeCompletionCache::Value &source,
|
||||||
bool onlyTypes, bool onlyPrecedenceGroups, bool onlyMacros,
|
CodeCompletionFilter filter, const ExpectedTypeContext *TypeContext,
|
||||||
const ExpectedTypeContext *TypeContext, const DeclContext *DC,
|
const DeclContext *DC, bool CanCurrDeclContextHandleAsync) {
|
||||||
bool CanCurrDeclContextHandleAsync) {
|
assert(filter && "Should never have an empty filter");
|
||||||
|
|
||||||
// We will be adding foreign results (from another sink) into TargetSink.
|
// We will be adding foreign results (from another sink) into TargetSink.
|
||||||
// TargetSink should have an owning pointer to the allocator that keeps the
|
// TargetSink should have an owning pointer to the allocator that keeps the
|
||||||
@@ -28,13 +28,22 @@ static MutableArrayRef<CodeCompletionResult *> copyCodeCompletionResults(
|
|||||||
targetSink.ForeignAllocators.push_back(source.Allocator);
|
targetSink.ForeignAllocators.push_back(source.Allocator);
|
||||||
auto startSize = targetSink.Results.size();
|
auto startSize = targetSink.Results.size();
|
||||||
|
|
||||||
|
CodeCompletionMacroRoles expectedMacroRoles = getCompletionMacroRoles(filter);
|
||||||
std::function<bool(const ContextFreeCodeCompletionResult *)>
|
std::function<bool(const ContextFreeCodeCompletionResult *)>
|
||||||
shouldIncludeResult;
|
shouldIncludeResult =
|
||||||
if (onlyTypes) {
|
[filter, expectedMacroRoles](
|
||||||
shouldIncludeResult = [](const ContextFreeCodeCompletionResult *R) -> bool {
|
const ContextFreeCodeCompletionResult *R) -> bool {
|
||||||
if (R->getKind() != CodeCompletionResultKind::Declaration)
|
if (R->getKind() != CodeCompletionResultKind::Declaration)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch (R->getAssociatedDeclKind()) {
|
switch (R->getAssociatedDeclKind()) {
|
||||||
|
case CodeCompletionDeclKind::PrefixOperatorFunction:
|
||||||
|
case CodeCompletionDeclKind::PostfixOperatorFunction:
|
||||||
|
case CodeCompletionDeclKind::InfixOperatorFunction:
|
||||||
|
case CodeCompletionDeclKind::FreeFunction:
|
||||||
|
case CodeCompletionDeclKind::GlobalVar:
|
||||||
|
return filter.contains(CodeCompletionFilterFlag::Expr);
|
||||||
|
|
||||||
case CodeCompletionDeclKind::Module:
|
case CodeCompletionDeclKind::Module:
|
||||||
case CodeCompletionDeclKind::Class:
|
case CodeCompletionDeclKind::Class:
|
||||||
case CodeCompletionDeclKind::Actor:
|
case CodeCompletionDeclKind::Actor:
|
||||||
@@ -44,45 +53,28 @@ static MutableArrayRef<CodeCompletionResult *> copyCodeCompletionResults(
|
|||||||
case CodeCompletionDeclKind::TypeAlias:
|
case CodeCompletionDeclKind::TypeAlias:
|
||||||
case CodeCompletionDeclKind::AssociatedType:
|
case CodeCompletionDeclKind::AssociatedType:
|
||||||
case CodeCompletionDeclKind::GenericTypeParam:
|
case CodeCompletionDeclKind::GenericTypeParam:
|
||||||
return true;
|
return filter.contains(CodeCompletionFilterFlag::Type);
|
||||||
|
|
||||||
case CodeCompletionDeclKind::PrecedenceGroup:
|
case CodeCompletionDeclKind::PrecedenceGroup:
|
||||||
|
return filter.contains(CodeCompletionFilterFlag::PrecedenceGroup);
|
||||||
|
|
||||||
|
case CodeCompletionDeclKind::Macro:
|
||||||
|
return (bool)(R->getMacroRoles() & expectedMacroRoles);
|
||||||
|
|
||||||
case CodeCompletionDeclKind::EnumElement:
|
case CodeCompletionDeclKind::EnumElement:
|
||||||
case CodeCompletionDeclKind::Constructor:
|
case CodeCompletionDeclKind::Constructor:
|
||||||
case CodeCompletionDeclKind::Destructor:
|
case CodeCompletionDeclKind::Destructor:
|
||||||
case CodeCompletionDeclKind::Subscript:
|
case CodeCompletionDeclKind::Subscript:
|
||||||
case CodeCompletionDeclKind::StaticMethod:
|
case CodeCompletionDeclKind::StaticMethod:
|
||||||
case CodeCompletionDeclKind::InstanceMethod:
|
case CodeCompletionDeclKind::InstanceMethod:
|
||||||
case CodeCompletionDeclKind::PrefixOperatorFunction:
|
|
||||||
case CodeCompletionDeclKind::PostfixOperatorFunction:
|
|
||||||
case CodeCompletionDeclKind::InfixOperatorFunction:
|
|
||||||
case CodeCompletionDeclKind::FreeFunction:
|
|
||||||
case CodeCompletionDeclKind::StaticVar:
|
case CodeCompletionDeclKind::StaticVar:
|
||||||
case CodeCompletionDeclKind::InstanceVar:
|
case CodeCompletionDeclKind::InstanceVar:
|
||||||
case CodeCompletionDeclKind::LocalVar:
|
case CodeCompletionDeclKind::LocalVar:
|
||||||
case CodeCompletionDeclKind::GlobalVar:
|
break;
|
||||||
case CodeCompletionDeclKind::Macro:
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm_unreachable("Unhandled CodeCompletionDeclKind in switch.");
|
return false;
|
||||||
};
|
};
|
||||||
} else if (onlyPrecedenceGroups) {
|
|
||||||
shouldIncludeResult = [](const ContextFreeCodeCompletionResult *R) -> bool {
|
|
||||||
return R->getAssociatedDeclKind() ==
|
|
||||||
CodeCompletionDeclKind::PrecedenceGroup;
|
|
||||||
};
|
|
||||||
} else if (onlyMacros) {
|
|
||||||
shouldIncludeResult = [](const ContextFreeCodeCompletionResult *R) -> bool {
|
|
||||||
return R->getAssociatedDeclKind() ==
|
|
||||||
CodeCompletionDeclKind::Macro;
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
shouldIncludeResult = [](const ContextFreeCodeCompletionResult *R) -> bool {
|
|
||||||
// PrecedenceGroups are only valid in 'onlyPrecedenceGroups'.
|
|
||||||
return R->getAssociatedDeclKind() !=
|
|
||||||
CodeCompletionDeclKind::PrecedenceGroup;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
USRBasedTypeContext USRTypeContext(TypeContext, source.USRTypeArena);
|
USRBasedTypeContext USRTypeContext(TypeContext, source.USRTypeArena);
|
||||||
|
|
||||||
@@ -151,9 +143,9 @@ void SimpleCachingCodeCompletionConsumer::handleResultsAndModules(
|
|||||||
context.Cache.set(R.Key, *V);
|
context.Cache.set(R.Key, *V);
|
||||||
}
|
}
|
||||||
assert(V.has_value());
|
assert(V.has_value());
|
||||||
auto newItems = copyCodeCompletionResults(
|
auto newItems = copyCodeCompletionResults(context.getResultSink(), **V,
|
||||||
context.getResultSink(), **V, R.OnlyTypes, R.OnlyPrecedenceGroups,
|
R.Filter, TypeContext, DC,
|
||||||
R.OnlyMacros, TypeContext, DC, CanCurrDeclContextHandleAsync);
|
CanCurrDeclContextHandleAsync);
|
||||||
postProcessCompletionResults(newItems, context.CodeCompletionKind, DC,
|
postProcessCompletionResults(newItems, context.CodeCompletionKind, DC,
|
||||||
&context.getResultSink());
|
&context.getResultSink());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,100 @@
|
|||||||
using namespace swift;
|
using namespace swift;
|
||||||
using namespace swift::ide;
|
using namespace swift::ide;
|
||||||
|
|
||||||
|
CodeCompletionMacroRoles swift::ide::getCompletionMacroRoles(const Decl *D) {
|
||||||
|
CodeCompletionMacroRoles roles;
|
||||||
|
|
||||||
|
auto *MD = dyn_cast<MacroDecl>(D);
|
||||||
|
if (!MD)
|
||||||
|
return roles;
|
||||||
|
|
||||||
|
MacroRoles macroRoles = MD->getMacroRoles();
|
||||||
|
if (macroRoles.contains(MacroRole::Expression)) {
|
||||||
|
roles |= CodeCompletionMacroRole::Expression;
|
||||||
|
}
|
||||||
|
if (macroRoles.contains(MacroRole::Declaration)) {
|
||||||
|
roles |= CodeCompletionMacroRole::Declaration;
|
||||||
|
}
|
||||||
|
if (macroRoles.contains(MacroRole::CodeItem)) {
|
||||||
|
roles |= CodeCompletionMacroRole::CodeItem;
|
||||||
|
}
|
||||||
|
if (macroRoles.contains(MacroRole::Accessor)) {
|
||||||
|
roles |= CodeCompletionMacroRole::AttachedVar;
|
||||||
|
}
|
||||||
|
if (macroRoles & MacroRoles({MacroRole::MemberAttribute, MacroRole::Member,
|
||||||
|
MacroRole::Conformance})) {
|
||||||
|
roles |= CodeCompletionMacroRole::AttachedContext;
|
||||||
|
}
|
||||||
|
if (macroRoles.contains(MacroRole::Peer)) {
|
||||||
|
roles |= CodeCompletionMacroRole::AttachedDecl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeCompletionMacroRoles
|
||||||
|
swift::ide::getCompletionMacroRoles(OptionSet<CustomAttributeKind> kinds) {
|
||||||
|
CodeCompletionMacroRoles roles;
|
||||||
|
if (kinds.contains(CustomAttributeKind::VarMacro)) {
|
||||||
|
roles |= CodeCompletionMacroRole::AttachedVar;
|
||||||
|
}
|
||||||
|
if (kinds.contains(CustomAttributeKind::ContextMacro)) {
|
||||||
|
roles |= CodeCompletionMacroRole::AttachedContext;
|
||||||
|
}
|
||||||
|
if (kinds.contains(CustomAttributeKind::DeclMacro)) {
|
||||||
|
roles |= CodeCompletionMacroRole::AttachedDecl;
|
||||||
|
}
|
||||||
|
return roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeCompletionMacroRoles
|
||||||
|
swift::ide::getCompletionMacroRoles(CodeCompletionFilter filter) {
|
||||||
|
CodeCompletionMacroRoles roles;
|
||||||
|
if (filter.contains(CodeCompletionFilterFlag::ExpressionMacro)) {
|
||||||
|
roles |= CodeCompletionMacroRole::Expression;
|
||||||
|
}
|
||||||
|
if (filter.contains(CodeCompletionFilterFlag::DeclarationMacro)) {
|
||||||
|
roles |= CodeCompletionMacroRole::Declaration;
|
||||||
|
}
|
||||||
|
if (filter.contains(CodeCompletionFilterFlag::CodeItemMacro)) {
|
||||||
|
roles |= CodeCompletionMacroRole::CodeItem;
|
||||||
|
}
|
||||||
|
if (filter.contains(CodeCompletionFilterFlag::AttachedVarMacro)) {
|
||||||
|
roles |= CodeCompletionMacroRole::AttachedVar;
|
||||||
|
}
|
||||||
|
if (filter.contains(CodeCompletionFilterFlag::AttachedContextMacro)) {
|
||||||
|
roles |= CodeCompletionMacroRole::AttachedContext;
|
||||||
|
}
|
||||||
|
if (filter.contains(CodeCompletionFilterFlag::AttachedDeclMacro)) {
|
||||||
|
roles |= CodeCompletionMacroRole::AttachedDecl;
|
||||||
|
}
|
||||||
|
return roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeCompletionFilter
|
||||||
|
swift::ide::getCompletionFilter(CodeCompletionMacroRoles roles) {
|
||||||
|
CodeCompletionFilter filter;
|
||||||
|
if (roles.contains(CodeCompletionMacroRole::Expression)) {
|
||||||
|
filter |= CodeCompletionFilterFlag::ExpressionMacro;
|
||||||
|
}
|
||||||
|
if (roles.contains(CodeCompletionMacroRole::Declaration)) {
|
||||||
|
filter |= CodeCompletionFilterFlag::DeclarationMacro;
|
||||||
|
}
|
||||||
|
if (roles.contains(CodeCompletionMacroRole::CodeItem)) {
|
||||||
|
filter |= CodeCompletionFilterFlag::CodeItemMacro;
|
||||||
|
}
|
||||||
|
if (roles.contains(CodeCompletionMacroRole::AttachedVar)) {
|
||||||
|
filter |= CodeCompletionFilterFlag::AttachedVarMacro;
|
||||||
|
}
|
||||||
|
if (roles.contains(CodeCompletionMacroRole::AttachedContext)) {
|
||||||
|
filter |= CodeCompletionFilterFlag::AttachedContextMacro;
|
||||||
|
}
|
||||||
|
if (roles.contains(CodeCompletionMacroRole::AttachedDecl)) {
|
||||||
|
filter |= CodeCompletionFilterFlag::AttachedDeclMacro;
|
||||||
|
}
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - ContextFreeCodeCompletionResult
|
// MARK: - ContextFreeCodeCompletionResult
|
||||||
|
|
||||||
ContextFreeCodeCompletionResult *
|
ContextFreeCodeCompletionResult *
|
||||||
@@ -42,8 +136,9 @@ ContextFreeCodeCompletionResult::createPatternOrBuiltInOperatorResult(
|
|||||||
NameForDiagnostics = "operator";
|
NameForDiagnostics = "operator";
|
||||||
}
|
}
|
||||||
return new (Sink.getAllocator()) ContextFreeCodeCompletionResult(
|
return new (Sink.getAllocator()) ContextFreeCodeCompletionResult(
|
||||||
Kind, /*AssociatedKind=*/0, KnownOperatorKind,
|
Kind, /*AssociatedKind=*/0, KnownOperatorKind, /*MacroRoles=*/{},
|
||||||
/*IsSystem=*/false, IsAsync, /*HasAsyncAlternative=*/false, CompletionString,
|
/*IsSystem=*/false, IsAsync, /*HasAsyncAlternative=*/false,
|
||||||
|
CompletionString,
|
||||||
/*ModuleName=*/"", BriefDocComment,
|
/*ModuleName=*/"", BriefDocComment,
|
||||||
/*AssociatedUSRs=*/{}, ResultType, NotRecommended, DiagnosticSeverity,
|
/*AssociatedUSRs=*/{}, ResultType, NotRecommended, DiagnosticSeverity,
|
||||||
DiagnosticMessage,
|
DiagnosticMessage,
|
||||||
@@ -62,7 +157,8 @@ ContextFreeCodeCompletionResult::createKeywordResult(
|
|||||||
}
|
}
|
||||||
return new (Sink.getAllocator()) ContextFreeCodeCompletionResult(
|
return new (Sink.getAllocator()) ContextFreeCodeCompletionResult(
|
||||||
CodeCompletionResultKind::Keyword, static_cast<uint8_t>(Kind),
|
CodeCompletionResultKind::Keyword, static_cast<uint8_t>(Kind),
|
||||||
CodeCompletionOperatorKind::None, /*IsSystem=*/false, /*IsAsync=*/false,
|
CodeCompletionOperatorKind::None, /*MacroRoles=*/{},
|
||||||
|
/*IsSystem=*/false, /*IsAsync=*/false,
|
||||||
/*HasAsyncAlternative=*/false, CompletionString,
|
/*HasAsyncAlternative=*/false, CompletionString,
|
||||||
/*ModuleName=*/"", BriefDocComment,
|
/*ModuleName=*/"", BriefDocComment,
|
||||||
/*AssociatedUSRs=*/{}, ResultType, ContextFreeNotRecommendedReason::None,
|
/*AssociatedUSRs=*/{}, ResultType, ContextFreeNotRecommendedReason::None,
|
||||||
@@ -81,7 +177,7 @@ ContextFreeCodeCompletionResult::createLiteralResult(
|
|||||||
}
|
}
|
||||||
return new (Sink.getAllocator()) ContextFreeCodeCompletionResult(
|
return new (Sink.getAllocator()) ContextFreeCodeCompletionResult(
|
||||||
CodeCompletionResultKind::Literal, static_cast<uint8_t>(LiteralKind),
|
CodeCompletionResultKind::Literal, static_cast<uint8_t>(LiteralKind),
|
||||||
CodeCompletionOperatorKind::None,
|
CodeCompletionOperatorKind::None, /*MacroRoles=*/{},
|
||||||
/*IsSystem=*/false, /*IsAsync=*/false, /*HasAsyncAlternative=*/false,
|
/*IsSystem=*/false, /*IsAsync=*/false, /*HasAsyncAlternative=*/false,
|
||||||
CompletionString,
|
CompletionString,
|
||||||
/*ModuleName=*/"",
|
/*ModuleName=*/"",
|
||||||
@@ -124,10 +220,10 @@ ContextFreeCodeCompletionResult::createDeclResult(
|
|||||||
return new (Sink.getAllocator()) ContextFreeCodeCompletionResult(
|
return new (Sink.getAllocator()) ContextFreeCodeCompletionResult(
|
||||||
CodeCompletionResultKind::Declaration,
|
CodeCompletionResultKind::Declaration,
|
||||||
static_cast<uint8_t>(getCodeCompletionDeclKind(AssociatedDecl)),
|
static_cast<uint8_t>(getCodeCompletionDeclKind(AssociatedDecl)),
|
||||||
CodeCompletionOperatorKind::None, getDeclIsSystem(AssociatedDecl),
|
CodeCompletionOperatorKind::None, getCompletionMacroRoles(AssociatedDecl),
|
||||||
IsAsync, HasAsyncAlternative, CompletionString, ModuleName,
|
getDeclIsSystem(AssociatedDecl), IsAsync, HasAsyncAlternative,
|
||||||
BriefDocComment, AssociatedUSRs, ResultType, NotRecommended,
|
CompletionString, ModuleName, BriefDocComment, AssociatedUSRs, ResultType,
|
||||||
DiagnosticSeverity, DiagnosticMessage,
|
NotRecommended, DiagnosticSeverity, DiagnosticMessage,
|
||||||
getCodeCompletionResultFilterName(CompletionString, Sink.getAllocator()),
|
getCodeCompletionResultFilterName(CompletionString, Sink.getAllocator()),
|
||||||
/*NameForDiagnostics=*/getDeclNameForDiagnostics(AssociatedDecl, Sink));
|
/*NameForDiagnostics=*/getDeclNameForDiagnostics(AssociatedDecl, Sink));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1791,23 +1791,21 @@ void CompletionLookup::addMacroExpansion(const MacroDecl *MD,
|
|||||||
MD->shouldHideFromEditor())
|
MD->shouldHideFromEditor())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If this is the wrong kind of macro, we don't need it.
|
OptionSet<CustomAttributeKind> expectedKinds =
|
||||||
bool wantAttachedMacro =
|
expectedTypeContext.getExpectedCustomAttributeKinds();
|
||||||
expectedTypeContext.getExpectedCustomAttributeKinds()
|
if (expectedKinds) {
|
||||||
.contains(CustomAttributeKind::Macro);
|
CodeCompletionMacroRoles expectedRoles =
|
||||||
if ((wantAttachedMacro && !isAttachedMacro(MD->getMacroRoles())) ||
|
getCompletionMacroRoles(expectedKinds);
|
||||||
(!wantAttachedMacro && !isFreestandingMacro(MD->getMacroRoles())))
|
CodeCompletionMacroRoles roles = getCompletionMacroRoles(MD);
|
||||||
|
if (!(roles & expectedRoles))
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CodeCompletionResultBuilder Builder(
|
CodeCompletionResultBuilder Builder(
|
||||||
Sink, CodeCompletionResultKind::Declaration,
|
Sink, CodeCompletionResultKind::Declaration,
|
||||||
getSemanticContext(MD, Reason, DynamicLookupInfo()));
|
getSemanticContext(MD, Reason, DynamicLookupInfo()));
|
||||||
Builder.setAssociatedDecl(MD);
|
Builder.setAssociatedDecl(MD);
|
||||||
|
|
||||||
if (NeedLeadingMacroPound && !wantAttachedMacro) {
|
|
||||||
Builder.addTextChunk("#");
|
|
||||||
}
|
|
||||||
|
|
||||||
addValueBaseName(Builder, MD->getBaseIdentifier());
|
addValueBaseName(Builder, MD->getBaseIdentifier());
|
||||||
|
|
||||||
Type macroType = MD->getInterfaceType();
|
Type macroType = MD->getInterfaceType();
|
||||||
@@ -2207,7 +2205,8 @@ bool CompletionLookup::tryFunctionCallCompletions(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompletionLookup::tryModuleCompletions(Type ExprType, bool TypesOnly) {
|
bool CompletionLookup::tryModuleCompletions(Type ExprType,
|
||||||
|
CodeCompletionFilter Filter) {
|
||||||
if (auto MT = ExprType->getAs<ModuleType>()) {
|
if (auto MT = ExprType->getAs<ModuleType>()) {
|
||||||
ModuleDecl *M = MT->getModule();
|
ModuleDecl *M = MT->getModule();
|
||||||
|
|
||||||
@@ -2225,11 +2224,8 @@ bool CompletionLookup::tryModuleCompletions(Type ExprType, bool TypesOnly) {
|
|||||||
ShadowingOrOriginal.push_back(M);
|
ShadowingOrOriginal.push_back(M);
|
||||||
}
|
}
|
||||||
for (ModuleDecl *M : ShadowingOrOriginal) {
|
for (ModuleDecl *M : ShadowingOrOriginal) {
|
||||||
RequestedResultsTy Request = RequestedResultsTy::fromModule(M)
|
RequestedResultsTy Request =
|
||||||
.needLeadingDot(needDot())
|
RequestedResultsTy::fromModule(M, Filter).needLeadingDot(needDot());
|
||||||
.withModuleQualifier(false);
|
|
||||||
if (TypesOnly)
|
|
||||||
Request = Request.onlyTypes();
|
|
||||||
RequestedCachedResults.insert(Request);
|
RequestedCachedResults.insert(Request);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -2345,7 +2341,8 @@ void CompletionLookup::getValueExprCompletions(Type ExprType, ValueDecl *VD) {
|
|||||||
bool isIUO = VD && VD->isImplicitlyUnwrappedOptional();
|
bool isIUO = VD && VD->isImplicitlyUnwrappedOptional();
|
||||||
if (tryFunctionCallCompletions(ExprType, VD))
|
if (tryFunctionCallCompletions(ExprType, VD))
|
||||||
return;
|
return;
|
||||||
if (tryModuleCompletions(ExprType))
|
if (tryModuleCompletions(ExprType, {CodeCompletionFilterFlag::Expr,
|
||||||
|
CodeCompletionFilterFlag::Type}))
|
||||||
return;
|
return;
|
||||||
if (tryTupleExprCompletions(ExprType))
|
if (tryTupleExprCompletions(ExprType))
|
||||||
return;
|
return;
|
||||||
@@ -2726,9 +2723,9 @@ void CompletionLookup::addObjCPoundKeywordCompletions(bool needPound) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompletionLookup::getMacroCompletions(bool needPound) {
|
void CompletionLookup::getMacroCompletions(CodeCompletionMacroRoles roles) {
|
||||||
RequestedCachedResults.insert(
|
RequestedCachedResults.insert(
|
||||||
RequestedResultsTy::toplevelResults().onlyMacros(needPound));
|
RequestedResultsTy::topLevelResults(getCompletionFilter(roles)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompletionLookup::getValueCompletionsInDeclContext(SourceLoc Loc,
|
void CompletionLookup::getValueCompletionsInDeclContext(SourceLoc Loc,
|
||||||
@@ -2744,9 +2741,13 @@ void CompletionLookup::getValueCompletionsInDeclContext(SourceLoc Loc,
|
|||||||
|
|
||||||
lookupVisibleDecls(FilteringConsumer, CurrDeclContext,
|
lookupVisibleDecls(FilteringConsumer, CurrDeclContext,
|
||||||
/*IncludeTopLevel=*/false, Loc);
|
/*IncludeTopLevel=*/false, Loc);
|
||||||
RequestedCachedResults.insert(
|
|
||||||
RequestedResultsTy::toplevelResults().withModuleQualifier(
|
CodeCompletionFilter filter{CodeCompletionFilterFlag::Expr,
|
||||||
ModuleQualifier));
|
CodeCompletionFilterFlag::Type};
|
||||||
|
if (ModuleQualifier) {
|
||||||
|
filter |= CodeCompletionFilterFlag::Module;
|
||||||
|
}
|
||||||
|
RequestedCachedResults.insert(RequestedResultsTy::topLevelResults(filter));
|
||||||
|
|
||||||
if (CompletionContext) {
|
if (CompletionContext) {
|
||||||
// FIXME: this is an awful simplification that says all and only enums can
|
// FIXME: this is an awful simplification that says all and only enums can
|
||||||
@@ -2891,7 +2892,7 @@ void CompletionLookup::addCallArgumentCompletionResults(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CompletionLookup::getTypeCompletions(Type BaseType) {
|
void CompletionLookup::getTypeCompletions(Type BaseType) {
|
||||||
if (tryModuleCompletions(BaseType, /*OnlyTypes=*/true))
|
if (tryModuleCompletions(BaseType, CodeCompletionFilterFlag::Type))
|
||||||
return;
|
return;
|
||||||
Kind = LookupKind::Type;
|
Kind = LookupKind::Type;
|
||||||
this->BaseType = BaseType;
|
this->BaseType = BaseType;
|
||||||
@@ -3047,9 +3048,8 @@ void CompletionLookup::collectPrecedenceGroups() {
|
|||||||
if (Module == CurrModule)
|
if (Module == CurrModule)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
RequestedCachedResults.insert(RequestedResultsTy::fromModule(Module)
|
RequestedCachedResults.insert(RequestedResultsTy::fromModule(
|
||||||
.onlyPrecedenceGroups()
|
Module, CodeCompletionFilterFlag::PrecedenceGroup));
|
||||||
.withModuleQualifier(false));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3139,24 +3139,38 @@ void CompletionLookup::getTypeCompletionsInDeclContext(SourceLoc Loc,
|
|||||||
lookupVisibleDecls(AccessFilteringConsumer, CurrDeclContext,
|
lookupVisibleDecls(AccessFilteringConsumer, CurrDeclContext,
|
||||||
/*IncludeTopLevel=*/false, Loc);
|
/*IncludeTopLevel=*/false, Loc);
|
||||||
|
|
||||||
RequestedCachedResults.insert(
|
CodeCompletionFilter filter{CodeCompletionFilterFlag::Type};
|
||||||
RequestedResultsTy::toplevelResults().onlyTypes().withModuleQualifier(
|
if (ModuleQualifier) {
|
||||||
ModuleQualifier));
|
filter |= CodeCompletionFilterFlag::Module;
|
||||||
|
}
|
||||||
|
RequestedCachedResults.insert(RequestedResultsTy::topLevelResults(filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompletionLookup::getToplevelCompletions(bool OnlyTypes, bool OnlyMacros) {
|
void CompletionLookup::getToplevelCompletions(CodeCompletionFilter Filter) {
|
||||||
Kind = OnlyTypes ? LookupKind::TypeInDeclContext
|
Kind = (Filter - CodeCompletionFilterFlag::Module)
|
||||||
|
.containsOnly(CodeCompletionFilterFlag::Type)
|
||||||
|
? LookupKind::TypeInDeclContext
|
||||||
: LookupKind::ValueInDeclContext;
|
: LookupKind::ValueInDeclContext;
|
||||||
NeedLeadingDot = false;
|
NeedLeadingDot = false;
|
||||||
NeedLeadingMacroPound = !OnlyMacros;
|
|
||||||
|
|
||||||
UsableFilteringDeclConsumer UsableFilteringConsumer(
|
UsableFilteringDeclConsumer UsableFilteringConsumer(
|
||||||
Ctx.SourceMgr, CurrDeclContext, Ctx.SourceMgr.getIDEInspectionTargetLoc(),
|
Ctx.SourceMgr, CurrDeclContext, Ctx.SourceMgr.getIDEInspectionTargetLoc(),
|
||||||
*this);
|
*this);
|
||||||
AccessFilteringDeclConsumer AccessFilteringConsumer(CurrDeclContext,
|
AccessFilteringDeclConsumer AccessFilteringConsumer(CurrDeclContext,
|
||||||
UsableFilteringConsumer);
|
UsableFilteringConsumer);
|
||||||
DeclFilter Filter = OnlyMacros ? MacroFilter : DefaultFilter;
|
|
||||||
FilteredDeclConsumer FilteringConsumer(AccessFilteringConsumer, Filter);
|
CodeCompletionMacroRoles ExpectedRoles = getCompletionMacroRoles(Filter);
|
||||||
|
DeclFilter VisibleFilter =
|
||||||
|
[ExpectedRoles](ValueDecl *VD, DeclVisibilityKind Kind,
|
||||||
|
DynamicLookupInfo DynamicLookupInfo) {
|
||||||
|
CodeCompletionMacroRoles Roles = getCompletionMacroRoles(VD);
|
||||||
|
if (!ExpectedRoles)
|
||||||
|
return !Roles;
|
||||||
|
return (bool)(Roles & ExpectedRoles);
|
||||||
|
};
|
||||||
|
|
||||||
|
FilteredDeclConsumer FilteringConsumer(AccessFilteringConsumer,
|
||||||
|
VisibleFilter);
|
||||||
|
|
||||||
CurrModule->lookupVisibleDecls({}, FilteringConsumer,
|
CurrModule->lookupVisibleDecls({}, FilteringConsumer,
|
||||||
NLKind::UnqualifiedLookup);
|
NLKind::UnqualifiedLookup);
|
||||||
|
|||||||
@@ -57,9 +57,6 @@ actor MyGenericGlobalActor<T> {
|
|||||||
static let shared = MyGenricGlobalActor<T>()
|
static let shared = MyGenricGlobalActor<T>()
|
||||||
}
|
}
|
||||||
|
|
||||||
@attached(member)
|
|
||||||
macro MyMacro() = #externalMacro(module: "Macros", type: "MyMacro")
|
|
||||||
|
|
||||||
@available(#^AVAILABILITY1^#)
|
@available(#^AVAILABILITY1^#)
|
||||||
|
|
||||||
// NOTE: Please do not include the ", N items" after "Begin completions". The
|
// NOTE: Please do not include the ", N items" after "Begin completions". The
|
||||||
@@ -81,7 +78,6 @@ macro MyMacro() = #externalMacro(module: "Macros", type: "MyMacro")
|
|||||||
// AVAILABILITY1-NEXT: Keyword/None: macCatalystApplicationExtension[#Platform#]; name=macCatalystApplicationExtension
|
// AVAILABILITY1-NEXT: Keyword/None: macCatalystApplicationExtension[#Platform#]; name=macCatalystApplicationExtension
|
||||||
// AVAILABILITY1-NEXT: Keyword/None: OpenBSD[#Platform#]; name=OpenBSD{{$}}
|
// AVAILABILITY1-NEXT: Keyword/None: OpenBSD[#Platform#]; name=OpenBSD{{$}}
|
||||||
// AVAILABILITY1-NEXT: Keyword/None: Windows[#Platform#]; name=Windows{{$}}
|
// AVAILABILITY1-NEXT: Keyword/None: Windows[#Platform#]; name=Windows{{$}}
|
||||||
// AVAILABILITY1-NEXT: End completions
|
|
||||||
|
|
||||||
@available(*, #^AVAILABILITY2^#)
|
@available(*, #^AVAILABILITY2^#)
|
||||||
|
|
||||||
@@ -91,7 +87,6 @@ macro MyMacro() = #externalMacro(module: "Macros", type: "MyMacro")
|
|||||||
// AVAILABILITY2-NEXT: Keyword/None: renamed: [#Specify replacing name#]; name=renamed{{$}}
|
// AVAILABILITY2-NEXT: Keyword/None: renamed: [#Specify replacing name#]; name=renamed{{$}}
|
||||||
// AVAILABILITY2-NEXT: Keyword/None: introduced: [#Specify version number#]; name=introduced{{$}}
|
// AVAILABILITY2-NEXT: Keyword/None: introduced: [#Specify version number#]; name=introduced{{$}}
|
||||||
// AVAILABILITY2-NEXT: Keyword/None: deprecated: [#Specify version number#]; name=deprecated{{$}}
|
// AVAILABILITY2-NEXT: Keyword/None: deprecated: [#Specify version number#]; name=deprecated{{$}}
|
||||||
// AVAILABILITY2-NEXT: End completions
|
|
||||||
|
|
||||||
@#^KEYWORD2^# func method(){}
|
@#^KEYWORD2^# func method(){}
|
||||||
|
|
||||||
@@ -119,8 +114,6 @@ macro MyMacro() = #externalMacro(module: "Macros", type: "MyMacro")
|
|||||||
// KEYWORD2-DAG: Decl[Struct]/CurrModule: MyPropertyWrapper[#MyPropertyWrapper#]; name=MyPropertyWrapper
|
// KEYWORD2-DAG: Decl[Struct]/CurrModule: MyPropertyWrapper[#MyPropertyWrapper#]; name=MyPropertyWrapper
|
||||||
// KEYWORD2-DAG: Decl[Struct]/CurrModule/TypeRelation[Convertible]: MyResultBuilder[#MyResultBuilder#]; name=MyResultBuilder
|
// KEYWORD2-DAG: Decl[Struct]/CurrModule/TypeRelation[Convertible]: MyResultBuilder[#MyResultBuilder#]; name=MyResultBuilder
|
||||||
// KEYWORD2-DAG: Decl[Actor]/CurrModule/TypeRelation[Convertible]: MyGlobalActor[#MyGlobalActor#]; name=MyGlobalActor
|
// KEYWORD2-DAG: Decl[Actor]/CurrModule/TypeRelation[Convertible]: MyGlobalActor[#MyGlobalActor#]; name=MyGlobalActor
|
||||||
// KEYWORD2-DAG: Decl[Macro]/CurrModule: MyMacro[#Void#]; name=MyMacro
|
|
||||||
// KEYWORD2: End completions
|
|
||||||
|
|
||||||
@#^KEYWORD3^# class C {}
|
@#^KEYWORD3^# class C {}
|
||||||
|
|
||||||
@@ -141,8 +134,6 @@ macro MyMacro() = #externalMacro(module: "Macros", type: "MyMacro")
|
|||||||
// KEYWORD3-NEXT: Keyword/None: globalActor[#Class Attribute#]; name=globalActor
|
// KEYWORD3-NEXT: Keyword/None: globalActor[#Class Attribute#]; name=globalActor
|
||||||
// KEYWORD3-NEXT: Keyword/None: preconcurrency[#Class Attribute#]; name=preconcurrency
|
// KEYWORD3-NEXT: Keyword/None: preconcurrency[#Class Attribute#]; name=preconcurrency
|
||||||
// KEYWORD3-NEXT: Keyword/None: runtimeMetadata[#Class Attribute#]; name=runtimeMetadata
|
// KEYWORD3-NEXT: Keyword/None: runtimeMetadata[#Class Attribute#]; name=runtimeMetadata
|
||||||
// KEYWORD3-NEXT: Decl[Macro]/CurrModule: MyMacro[#Void#]; name=MyMacro
|
|
||||||
// KEYWORD3-NEXT: End completions
|
|
||||||
|
|
||||||
@#^KEYWORD3_2^#IB class C2 {}
|
@#^KEYWORD3_2^#IB class C2 {}
|
||||||
// Same as KEYWORD3.
|
// Same as KEYWORD3.
|
||||||
@@ -161,8 +152,6 @@ macro MyMacro() = #externalMacro(module: "Macros", type: "MyMacro")
|
|||||||
// KEYWORD4-NEXT: Keyword/None: globalActor[#Enum Attribute#]; name=globalActor
|
// KEYWORD4-NEXT: Keyword/None: globalActor[#Enum Attribute#]; name=globalActor
|
||||||
// KEYWORD4-NEXT: Keyword/None: preconcurrency[#Enum Attribute#]; name=preconcurrency
|
// KEYWORD4-NEXT: Keyword/None: preconcurrency[#Enum Attribute#]; name=preconcurrency
|
||||||
// KEYWORD4-NEXT: Keyword/None: runtimeMetadata[#Enum Attribute#]; name=runtimeMetadata
|
// KEYWORD4-NEXT: Keyword/None: runtimeMetadata[#Enum Attribute#]; name=runtimeMetadata
|
||||||
// KEYWORD4-NEXT: Decl[Macro]/CurrModule: MyMacro[#Void#]; name=MyMacro
|
|
||||||
// KEYWORD4-NEXT: End completions
|
|
||||||
|
|
||||||
@#^KEYWORD5^# struct S{}
|
@#^KEYWORD5^# struct S{}
|
||||||
// KEYWORD5: Begin completions
|
// KEYWORD5: Begin completions
|
||||||
@@ -177,8 +166,6 @@ macro MyMacro() = #externalMacro(module: "Macros", type: "MyMacro")
|
|||||||
// KEYWORD5-NEXT: Keyword/None: globalActor[#Struct Attribute#]; name=globalActor
|
// KEYWORD5-NEXT: Keyword/None: globalActor[#Struct Attribute#]; name=globalActor
|
||||||
// KEYWORD5-NEXT: Keyword/None: preconcurrency[#Struct Attribute#]; name=preconcurrency
|
// KEYWORD5-NEXT: Keyword/None: preconcurrency[#Struct Attribute#]; name=preconcurrency
|
||||||
// KEYWORD5-NEXT: Keyword/None: runtimeMetadata[#Struct Attribute#]; name=runtimeMetadata
|
// KEYWORD5-NEXT: Keyword/None: runtimeMetadata[#Struct Attribute#]; name=runtimeMetadata
|
||||||
// KEYWORD5-NEXT: Decl[Macro]/CurrModule: MyMacro[#Void#]; name=MyMacro
|
|
||||||
// KEYWORD5-NEXT: End completions
|
|
||||||
|
|
||||||
@#^ON_GLOBALVAR^# var globalVar
|
@#^ON_GLOBALVAR^# var globalVar
|
||||||
// ON_GLOBALVAR-DAG: Keyword/None: available[#Var Attribute#]; name=available
|
// ON_GLOBALVAR-DAG: Keyword/None: available[#Var Attribute#]; name=available
|
||||||
|
|||||||
172
test/IDE/complete_macros.swift
Normal file
172
test/IDE/complete_macros.swift
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
// RUN: %empty-directory(%t)
|
||||||
|
// RUN: %empty-directory(%t/mods)
|
||||||
|
// RUN: %empty-directory(%t/co-same)
|
||||||
|
// RUN: %empty-directory(%t/co-across)
|
||||||
|
// RUN: split-file %s %t
|
||||||
|
|
||||||
|
// Completion in the current file/module
|
||||||
|
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t/co-same
|
||||||
|
|
||||||
|
// Completion across modules
|
||||||
|
// RUN: %target-swift-frontend -emit-module %t/MacroDefinitions.swift -o %t/mods/ -experimental-allow-module-with-compiler-errors
|
||||||
|
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %t/MacroUses.swift -filecheck %raw-FileCheck -completion-output-dir %t/co-across -I %t/mods -D SEPARATED
|
||||||
|
|
||||||
|
//--- MacroDefinitions.swift
|
||||||
|
@freestanding(expression)
|
||||||
|
public macro freestandingExprIntMacro() -> Int
|
||||||
|
|
||||||
|
@freestanding(expression)
|
||||||
|
public macro freestandingExprStringMacro() -> String
|
||||||
|
|
||||||
|
@freestanding(expression)
|
||||||
|
public macro freestandingExprTMacro<T>(_ value: T) -> T
|
||||||
|
|
||||||
|
@freestanding(declaration)
|
||||||
|
public macro freestandingDeclMacro()
|
||||||
|
|
||||||
|
@freestanding(codeItem)
|
||||||
|
public macro freestandingCodeItemMacro()
|
||||||
|
|
||||||
|
@attached(accessor)
|
||||||
|
public macro AttachedAccessorMacro()
|
||||||
|
|
||||||
|
@attached(member)
|
||||||
|
public macro AttachedMemberMacro()
|
||||||
|
|
||||||
|
@attached(member)
|
||||||
|
public macro AttachedMemberMacroWithArgs(arg1: Int)
|
||||||
|
|
||||||
|
@attached(memberAttribute)
|
||||||
|
public macro AttachedMemberAttributeMacro()
|
||||||
|
|
||||||
|
@attached(peer)
|
||||||
|
public macro AttachedPeerMacro()
|
||||||
|
|
||||||
|
@attached(conformance)
|
||||||
|
public macro AttachedConformanceMacro()
|
||||||
|
|
||||||
|
@freestanding(expression)
|
||||||
|
@freestanding(declaration)
|
||||||
|
@attached(accessor)
|
||||||
|
@attached(member)
|
||||||
|
@attached(memberAttribute)
|
||||||
|
@attached(peer)
|
||||||
|
@attached(conformance)
|
||||||
|
public macro EverythingMacro()
|
||||||
|
|
||||||
|
//--- MacroUses.swift
|
||||||
|
#if SEPARATED
|
||||||
|
import MacroDefinitions
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@#^CLASS_ATTR?check=NOMINAL_ATTR^# class C {}
|
||||||
|
@#^EXTRA_FILTER?check=NOMINAL_ATTR^#IB class C2 {}
|
||||||
|
@#^ENUM_ATTR?check=NOMINAL_ATTR^# enum E {}
|
||||||
|
@#^STRUCT_ATTR?check=NOMINAL_ATTR^# struct S{}
|
||||||
|
// NOMINAL_ATTR-NOT: freestanding
|
||||||
|
// NOMINAL_ATTR-NOT: AttachedAccessorMacro
|
||||||
|
// NOMINAL_ATTR-DAG: Decl[Macro]/{{.*}}: AttachedMemberMacro[#Void#]; name=AttachedMemberMacro
|
||||||
|
// NOMINAL_ATTR-DAG: Decl[Macro]/{{.*}}: AttachedMemberMacroWithArgs({#arg1: Int#})[#Void#]; name=AttachedMemberMacroWithArgs
|
||||||
|
// NOMINAL_ATTR-DAG: Decl[Macro]/{{.*}}: AttachedMemberAttributeMacro[#Void#]; name=AttachedMemberAttributeMacro
|
||||||
|
// NOMINAL_ATTR-DAG: Decl[Macro]/{{.*}}: AttachedPeerMacro[#Void#]; name=AttachedPeerMacro
|
||||||
|
// NOMINAL_ATTR-DAG: Decl[Macro]/{{.*}}: AttachedConformanceMacro[#Void#]; name=AttachedConformanceMacro
|
||||||
|
// NOMINAL_ATTR-DAG: Decl[Macro]/{{.*}}: EverythingMacro[#Void#]; name=EverythingMacro
|
||||||
|
|
||||||
|
@#^FUNC_ATTR?check=DECL_ATTR^# func method() {}
|
||||||
|
struct MethodAttrs {
|
||||||
|
@#^INIT_ATTR?check=DECL_ATTR^# init() {}
|
||||||
|
@#^DEINIT_ATTR?check=DECL_ATTR^# deinit{}
|
||||||
|
@#^METHOD_ATTR?check=DECL_ATTR^# func method() {}
|
||||||
|
}
|
||||||
|
// DECL_ATTR-NOT: freestanding
|
||||||
|
// DECL_ATTR-NOT: AttachedAccessorMacro
|
||||||
|
// DECL_ATTR-NOT: AttachedMemberMacro
|
||||||
|
// DECL_ATTR-NOT: AttachedMemberMacroWithArgs
|
||||||
|
// DECL_ATTR-NOT: AttachedConformanceMacro
|
||||||
|
// DECL_ATTR-DAG: Decl[Macro]/{{.*}}: AttachedPeerMacro[#Void#]; name=AttachedPeerMacro
|
||||||
|
// DECL_ATTR-DAG: Decl[Macro]/{{.*}}: EverythingMacro[#Void#]; name=EverythingMacro
|
||||||
|
|
||||||
|
@#^GLOBAL_ATTR?check=VAR_ATTR^# var globalVar
|
||||||
|
struct PropAttr {
|
||||||
|
@#^PROP_ATTR?check=VAR_ATTR^# var propVar
|
||||||
|
func localAttr() {
|
||||||
|
@#^LOCAL_ATTR?check=VAR_ATTR^# var localVar
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// VAR_ATTR-NOT: freestanding
|
||||||
|
// VAR_ATTR-NOT: AttachedMemberMacro
|
||||||
|
// VAR_ATTR-NOT: AttachedMemberMacroWithArgs
|
||||||
|
// VAR_ATTR-NOT: AttachedMemberAttributeMacro
|
||||||
|
// VAR_ATTR-NOT: AttachedConformanceMacro
|
||||||
|
// VAR_ATTR-DAG: Decl[Macro]/{{.*}}: AttachedAccessorMacro[#Void#]; name=AttachedAccessorMacro
|
||||||
|
// VAR_ATTR-DAG: Decl[Macro]/{{.*}}: AttachedPeerMacro[#Void#]; name=AttachedPeerMacro
|
||||||
|
// VAR_ATTR-DAG: Decl[Macro]/{{.*}}: EverythingMacro[#Void#]; name=EverythingMacro
|
||||||
|
|
||||||
|
func paramAttr(@#^PARAM_ATTR?check=PARAM_ATTR^#) {}
|
||||||
|
func paramAttr2(@#^PARAM2_ATTR?check=PARAM_ATTR^# arg: Int) {}
|
||||||
|
// TODO: These should both be PARAM_ATTR
|
||||||
|
func takeNoArgClosure(_: (Int) -> Void) {
|
||||||
|
takeClosure { @#^NO_ARG_CLOSURE_ATTR?check=INDEPENDENT_ATTR^# in
|
||||||
|
print("x")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func takeNoArgClosure(_: () -> Void) {
|
||||||
|
takeClosure { @#^CLOSURE_ATTR?check=INDEPENDENT_ATTR^# in
|
||||||
|
print("x")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// PARAM_ATTR-NOT: freestanding
|
||||||
|
// PARAM_ATTR-NOT: AttachedAccessorMacro
|
||||||
|
// PARAM_ATTR-NOT: AttachedMemberMacro
|
||||||
|
// PARAM_ATTR-NOT: AttachedMemberMacroWithArgs
|
||||||
|
// PARAM_ATTR-NOT: AttachedMemberAttributeMacro
|
||||||
|
// PARAM_ATTR-NOT: AttachedPeerMacro
|
||||||
|
// PARAM_ATTR-NOT: AttachedConformanceMacro
|
||||||
|
// PARAM_ATTR-NOT: EverythingMacro
|
||||||
|
|
||||||
|
##^TOP_LEVEL_FREESTANDING?check=ALL_FREESTANDING^#
|
||||||
|
func nestedFreestanding() {
|
||||||
|
##^TOP_NESTED_FREESTANDING?check=ALL_FREESTANDING^#
|
||||||
|
}
|
||||||
|
// ALL_FREESTANDING-NOT: Attached
|
||||||
|
// ALL_FREESTANDING-DAG: Decl[Macro]/{{.*}}: freestandingDeclMacro[#Void#]; name=freestandingDeclMacro
|
||||||
|
// ALL_FREESTANDING-DAG: Decl[Macro]/{{.*}}: freestandingCodeItemMacro[#Void#]; name=freestandingCodeItemMacro
|
||||||
|
// ALL_FREESTANDING-DAG: Decl[Macro]/{{.*}}: freestandingExprIntMacro[#Int#]; name=freestandingExprIntMacro
|
||||||
|
// ALL_FREESTANDING-DAG: Decl[Macro]/{{.*}}: freestandingExprStringMacro[#String#]; name=freestandingExprStringMacro
|
||||||
|
// ALL_FREESTANDING-DAG: Decl[Macro]/{{.*}}: freestandingExprTMacro({#(value): T#})[#T#]; name=freestandingExprTMacro(:)
|
||||||
|
// ALL_FREESTANDING-DAG: Decl[Macro]/{{.*}}: EverythingMacro[#Void#]; name=EverythingMacro
|
||||||
|
|
||||||
|
func exprFreestanding(arg: Int) {
|
||||||
|
_ = arg + ##^EXPR_FREESTANDING^#
|
||||||
|
}
|
||||||
|
// EXPR_FREESTANDING-NOT: freestandingDeclMacro
|
||||||
|
// EXPR_FREESTANDING-NOT: freestandingCodeItemMacro
|
||||||
|
// EXPR_FREESTANDING-NOT: Attached
|
||||||
|
// EXPR_FREESTANDING-DAG: Decl[Macro]/{{.*}}/TypeRelation[Convertible]: freestandingExprIntMacro[#Int#]; name=freestandingExprIntMacro
|
||||||
|
// EXPR_FREESTANDING-DAG: Decl[Macro]/{{.*}}: freestandingExprStringMacro[#String#]; name=freestandingExprStringMacro
|
||||||
|
// EXPR_FREESTANDING-DAG: Decl[Macro]/{{.*}}: freestandingExprTMacro({#(value): T#})[#T#]; name=freestandingExprTMacro(:)
|
||||||
|
// TODO: This should be invalid in both same module and across modules
|
||||||
|
// EXPR_FREESTANDING-DAG: Decl[Macro]/{{.*}}: EverythingMacro[#Void#]; name=EverythingMacro
|
||||||
|
|
||||||
|
struct NestedFreestanding {
|
||||||
|
##^TYPE_NESTED_FREESTANDING?check=ITEM_FREESTANDING^#
|
||||||
|
}
|
||||||
|
// ITEM_FREESTANDING-NOT: Attached
|
||||||
|
// ITEM_FREESTANDING-NOT: freestandingExpr
|
||||||
|
// ITEM_FREESTANDING-NOT: freestandingCodeItemMacro
|
||||||
|
// ITEM_FREESTANDING-DAG: Decl[Macro]/{{.*}}: freestandingDeclMacro[#Void#]; name=freestandingDeclMacro
|
||||||
|
// ITEM_FREESTANDING-DAG: Decl[Macro]/{{.*}}: EverythingMacro[#Void#]; name=EverythingMacro
|
||||||
|
|
||||||
|
struct LastMember {
|
||||||
|
@#^LAST_MEMBER_ATTR?check=INDEPENDENT_ATTR^#
|
||||||
|
}
|
||||||
|
@#^INDEPENDENT?check=INDEPENDENT_ATTR^#
|
||||||
|
// INDEPENDENT_ATTR-NOT: freestandingExprMacro
|
||||||
|
// INDEPENDENT_ATTR-NOT: freestandingDeclMacro
|
||||||
|
// INDEPENDENT_ATTR-DAG: Decl[Macro]/{{.*}}: AttachedAccessorMacro[#Void#]; name=AttachedAccessorMacro
|
||||||
|
// INDEPENDENT_ATTR-DAG: Decl[Macro]/{{.*}}: AttachedMemberMacro[#Void#]; name=AttachedMemberMacro
|
||||||
|
// INDEPENDENT_ATTR-DAG: Decl[Macro]/{{.*}}: AttachedMemberMacroWithArgs({#arg1: Int#})[#Void#]; name=AttachedMemberMacroWithArgs
|
||||||
|
// INDEPENDENT_ATTR-DAG: Decl[Macro]/{{.*}}: AttachedMemberAttributeMacro[#Void#]; name=AttachedMemberAttributeMacro
|
||||||
|
// INDEPENDENT_ATTR-DAG: Decl[Macro]/{{.*}}: AttachedPeerMacro[#Void#]; name=AttachedPeerMacro
|
||||||
|
// INDEPENDENT_ATTR-DAG: Decl[Macro]/{{.*}}: AttachedConformanceMacro[#Void#]; name=AttachedConformanceMacro
|
||||||
|
// INDEPENDENT_ATTR-DAG: Decl[Macro]/{{.*}}: EverythingMacro[#Void#]; name=EverythingMacro
|
||||||
@@ -14,14 +14,15 @@
|
|||||||
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-sourcetext -code-completion-token=CONDITION_GLOBAL_2 | %FileCheck %s -check-prefix=CONDITION -check-prefix=NOFLAG
|
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-sourcetext -code-completion-token=CONDITION_GLOBAL_2 | %FileCheck %s -check-prefix=CONDITION -check-prefix=NOFLAG
|
||||||
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-sourcetext -code-completion-token=CONDITION_GLOBAL_2 -D FOO -D BAR | %FileCheck %s -check-prefix=CONDITION -check-prefix=WITHFLAG
|
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-sourcetext -code-completion-token=CONDITION_GLOBAL_2 -D FOO -D BAR | %FileCheck %s -check-prefix=CONDITION -check-prefix=WITHFLAG
|
||||||
|
|
||||||
// POUND_DIRECTIVE: Begin completions, 7 items
|
|
||||||
// POUND_DIRECTIVE-DAG: Keyword[#sourceLocation]/None: sourceLocation(file: {#String#}, line: {#Int#}); name=sourceLocation(file:line:); sourcetext=sourceLocation(file: <#T##String#>, line: <#T##Int#>)
|
// POUND_DIRECTIVE-DAG: Keyword[#sourceLocation]/None: sourceLocation(file: {#String#}, line: {#Int#}); name=sourceLocation(file:line:); sourcetext=sourceLocation(file: <#T##String#>, line: <#T##Int#>)
|
||||||
// POUND_DIRECTIVE-DAG: Keyword[#warning]/None: warning("{#(message)#}"); name=warning(""); sourcetext=warning(\"<#T##message#>\")
|
|
||||||
// POUND_DIRECTIVE-DAG: Keyword[#error]/None: error("{#(message)#}"); name=error(""); sourcetext=error(\"<#T##message#>\")
|
|
||||||
// POUND_DIRECTIVE-DAG: Keyword[#if]/None: if {#(condition)#}; name=if ; sourcetext=if <#T##condition#>
|
// POUND_DIRECTIVE-DAG: Keyword[#if]/None: if {#(condition)#}; name=if ; sourcetext=if <#T##condition#>
|
||||||
// POUND_DIRECTIVE-DAG: Keyword[#elseif]/None: elseif {#(condition)#}; name=elseif ; sourcetext=elseif <#T##condition#>
|
// POUND_DIRECTIVE-DAG: Keyword[#elseif]/None: elseif {#(condition)#}; name=elseif ; sourcetext=elseif <#T##condition#>
|
||||||
// POUND_DIRECTIVE-DAG: Keyword[#else]/None: else; name=else; sourcetext=else
|
// POUND_DIRECTIVE-DAG: Keyword[#else]/None: else; name=else; sourcetext=else
|
||||||
// POUND_DIRECTIVE-DAG: Keyword[#endif]/None: endif; name=endif; sourcetext=endif
|
// POUND_DIRECTIVE-DAG: Keyword[#endif]/None: endif; name=endif; sourcetext=endif
|
||||||
|
// TODO: These currently do not match between when macros are enabled and when
|
||||||
|
// they aren't. Update to macros when
|
||||||
|
// POUND_DIRECTIVE-DAG: name=warning
|
||||||
|
// POUND_DIRECTIVE-DAG: name=error
|
||||||
|
|
||||||
class C {
|
class C {
|
||||||
##^POUND_NOMINAL_TOP^#
|
##^POUND_NOMINAL_TOP^#
|
||||||
|
|||||||
@@ -15,10 +15,9 @@ func test1() {
|
|||||||
let _ = useSelector(##^POUND_EXPR_3^#)
|
let _ = useSelector(##^POUND_EXPR_3^#)
|
||||||
}
|
}
|
||||||
|
|
||||||
// POUND_EXPR_INTCONTEXT: Begin completions, 10 items
|
// POUND_EXPR_INTCONTEXT-NOT: warning
|
||||||
|
// POUND_EXPR_INTCONTEXT-NOT: error
|
||||||
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: function[#ExpressibleByStringLiteral#]; name=function
|
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: function[#ExpressibleByStringLiteral#]; name=function
|
||||||
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: warning({#(message): String#})[#Void#]; name=warning(:)
|
|
||||||
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: error({#(message): String#})[#Void#]; name=error(:)
|
|
||||||
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: fileID[#ExpressibleByStringLiteral#]; name=fileID
|
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: fileID[#ExpressibleByStringLiteral#]; name=fileID
|
||||||
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: file[#ExpressibleByStringLiteral#]; name=file
|
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: file[#ExpressibleByStringLiteral#]; name=file
|
||||||
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: dsohandle[#UnsafeRawPointer#]; name=dsohandle
|
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: dsohandle[#UnsafeRawPointer#]; name=dsohandle
|
||||||
@@ -27,10 +26,9 @@ func test1() {
|
|||||||
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: externalMacro({#module: String#}, {#type: String#})[#T#]; name=externalMacro(module:type:)
|
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: externalMacro({#module: String#}, {#type: String#})[#T#]; name=externalMacro(module:type:)
|
||||||
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: filePath[#ExpressibleByStringLiteral#]; name=filePath
|
// POUND_EXPR_INTCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: filePath[#ExpressibleByStringLiteral#]; name=filePath
|
||||||
|
|
||||||
// POUND_EXPR_STRINGCONTEXT: Begin completions, 11 items
|
// POUND_EXPR_STRINGCONTEXT-NOT: warning
|
||||||
|
// POUND_EXPR_STRINGCONTEXT-NOT: error
|
||||||
// POUND_EXPR_STRINGCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: function[#ExpressibleByStringLiteral#]; name=function
|
// POUND_EXPR_STRINGCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: function[#ExpressibleByStringLiteral#]; name=function
|
||||||
// POUND_EXPR_STRINGCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: warning({#(message): String#})[#Void#]; name=warning(:)
|
|
||||||
// POUND_EXPR_STRINGCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: error({#(message): String#})[#Void#]; name=error(:)
|
|
||||||
// POUND_EXPR_STRINGCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: fileID[#ExpressibleByStringLiteral#]; name=fileID
|
// POUND_EXPR_STRINGCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: fileID[#ExpressibleByStringLiteral#]; name=fileID
|
||||||
// POUND_EXPR_STRINGCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: file[#ExpressibleByStringLiteral#]; name=file
|
// POUND_EXPR_STRINGCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: file[#ExpressibleByStringLiteral#]; name=file
|
||||||
// POUND_EXPR_STRINGCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: dsohandle[#UnsafeRawPointer#]; name=dsohandle
|
// POUND_EXPR_STRINGCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: dsohandle[#UnsafeRawPointer#]; name=dsohandle
|
||||||
@@ -40,10 +38,9 @@ func test1() {
|
|||||||
// POUND_EXPR_STRINGCONTEXT-DAG: Keyword/None/TypeRelation[Convertible]: keyPath({#@objc property sequence#})[#String#];
|
// POUND_EXPR_STRINGCONTEXT-DAG: Keyword/None/TypeRelation[Convertible]: keyPath({#@objc property sequence#})[#String#];
|
||||||
// POUND_EXPR_STRINGCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: externalMacro({#module: String#}, {#type: String#})[#T#]; name=externalMacro(module:type:)
|
// POUND_EXPR_STRINGCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: externalMacro({#module: String#}, {#type: String#})[#T#]; name=externalMacro(module:type:)
|
||||||
|
|
||||||
// POUND_EXPR_SELECTORCONTEXT: Begin completions, 11 items
|
// POUND_EXPR_SELECTORCONTEXT-NOT: warning
|
||||||
|
// POUND_EXPR_SELECTORCONTEXT-NOT: error
|
||||||
// POUND_EXPR_SELECTORCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: function[#ExpressibleByStringLiteral#]; name=function
|
// POUND_EXPR_SELECTORCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: function[#ExpressibleByStringLiteral#]; name=function
|
||||||
// POUND_EXPR_SELECTORCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: warning({#(message): String#})[#Void#]; name=warning(:)
|
|
||||||
// POUND_EXPR_SELECTORCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: error({#(message): String#})[#Void#]; name=error(:)
|
|
||||||
// POUND_EXPR_SELECTORCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: fileID[#ExpressibleByStringLiteral#]; name=fileID
|
// POUND_EXPR_SELECTORCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: fileID[#ExpressibleByStringLiteral#]; name=fileID
|
||||||
// POUND_EXPR_SELECTORCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: file[#ExpressibleByStringLiteral#]; name=file
|
// POUND_EXPR_SELECTORCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: file[#ExpressibleByStringLiteral#]; name=file
|
||||||
// POUND_EXPR_SELECTORCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: dsohandle[#UnsafeRawPointer#]; name=dsohandle
|
// POUND_EXPR_SELECTORCONTEXT-DAG: Decl[Macro]/OtherModule[Swift]/IsSystem: dsohandle[#UnsafeRawPointer#]; name=dsohandle
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ func test() {
|
|||||||
// RUN: %FileCheck -check-prefix=NAME_UNSORTED %s < %t.orig.off
|
// RUN: %FileCheck -check-prefix=NAME_UNSORTED %s < %t.orig.off
|
||||||
// RUN: not %diff -u %t.orig %t.orig.off
|
// RUN: not %diff -u %t.orig %t.orig.off
|
||||||
|
|
||||||
// NAME_SORTED: key.name: "column"
|
|
||||||
// NAME_SORTED: key.name: "foo(a:)"
|
// NAME_SORTED: key.name: "foo(a:)"
|
||||||
// NAME_SORTED-NOT: key.name:
|
// NAME_SORTED-NOT: key.name:
|
||||||
// NAME_SORTED: key.name: "foo(a:)"
|
// NAME_SORTED: key.name: "foo(a:)"
|
||||||
@@ -46,7 +45,6 @@ func test() {
|
|||||||
// CONTEXT: key.name: "foo(b:)"
|
// CONTEXT: key.name: "foo(b:)"
|
||||||
// CONTEXT-NOT: key.name:
|
// CONTEXT-NOT: key.name:
|
||||||
// CONTEXT: key.name: "test()"
|
// CONTEXT: key.name: "test()"
|
||||||
// CONTEXT: key.name: "column"
|
|
||||||
// CONTEXT: key.name: "complete_sort_order"
|
// CONTEXT: key.name: "complete_sort_order"
|
||||||
|
|
||||||
// RUN: %complete-test -tok=STMT_0 %s | %FileCheck %s -check-prefix=STMT
|
// RUN: %complete-test -tok=STMT_0 %s | %FileCheck %s -check-prefix=STMT
|
||||||
@@ -242,7 +240,3 @@ func test8() {
|
|||||||
// CALLARG: String
|
// CALLARG: String
|
||||||
// CALLARG: intVal
|
// CALLARG: intVal
|
||||||
}
|
}
|
||||||
|
|
||||||
// REQUIRES: swift_swift_parser
|
|
||||||
// FIXME: Swift parser is not enabled on Linux CI yet.
|
|
||||||
// REQUIRES: OS=macosx
|
|
||||||
|
|||||||
@@ -1167,9 +1167,9 @@ Completion *CompletionBuilder::finish() {
|
|||||||
new (sink.allocator) ContextFreeCodeCompletionResult(
|
new (sink.allocator) ContextFreeCodeCompletionResult(
|
||||||
contextFreeBase.getKind(),
|
contextFreeBase.getKind(),
|
||||||
contextFreeBase.getOpaqueAssociatedKind(), opKind,
|
contextFreeBase.getOpaqueAssociatedKind(), opKind,
|
||||||
contextFreeBase.isSystem(), contextFreeBase.isAsync(),
|
contextFreeBase.getMacroRoles(), contextFreeBase.isSystem(),
|
||||||
contextFreeBase.hasAsyncAlternative(), newCompletionString,
|
contextFreeBase.isAsync(), contextFreeBase.hasAsyncAlternative(),
|
||||||
contextFreeBase.getModuleName(),
|
newCompletionString, contextFreeBase.getModuleName(),
|
||||||
contextFreeBase.getBriefDocComment(),
|
contextFreeBase.getBriefDocComment(),
|
||||||
contextFreeBase.getAssociatedUSRs(),
|
contextFreeBase.getAssociatedUSRs(),
|
||||||
contextFreeBase.getResultType(),
|
contextFreeBase.getResultType(),
|
||||||
|
|||||||
Reference in New Issue
Block a user