mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Code completion: don't show [byref] on 'self'
Of course, in structs 'self' is a reference to the value, but this is so obvious and natural, that calling out this [byref] in code completion results every single time adds nothing but syntactic noise. We still show [byref] in other cases, for example, when we complete references to user-written function parameters. Swift SVN r8464
This commit is contained in:
@@ -480,6 +480,7 @@ namespace {
|
||||
class CompletionLookup : swift::VisibleDeclConsumer {
|
||||
CodeCompletionContext &CompletionContext;
|
||||
ASTContext &SwiftContext;
|
||||
Identifier SelfIdent;
|
||||
const DeclContext *CurrDeclContext;
|
||||
|
||||
enum class LookupKind {
|
||||
@@ -517,6 +518,7 @@ public:
|
||||
ASTContext &SwiftContext,
|
||||
const DeclContext *CurrDeclContext)
|
||||
: CompletionContext(CompletionContext), SwiftContext(SwiftContext),
|
||||
SelfIdent(SwiftContext.getIdentifier("self")),
|
||||
CurrDeclContext(CurrDeclContext) {
|
||||
// Determine if we are doing code completion inside a static method.
|
||||
if (CurrDeclContext->isLocalContext()) {
|
||||
@@ -575,7 +577,15 @@ public:
|
||||
if (needDot())
|
||||
Builder.addLeadingDot();
|
||||
Builder.addTextChunk(Name);
|
||||
addTypeAnnotation(Builder, VD->getType());
|
||||
|
||||
// Add a type annotation.
|
||||
Type T = VD->getType();
|
||||
if (VD->getName() == SelfIdent) {
|
||||
// Strip [byref] from 'self'. It is useful to show [byref] for function
|
||||
// parameters. But for 'self' it is just noise.
|
||||
T = T->getRValueType();
|
||||
}
|
||||
addTypeAnnotation(Builder, T);
|
||||
}
|
||||
|
||||
void addPatternParameters(CodeCompletionResultBuilder &Builder,
|
||||
|
||||
Reference in New Issue
Block a user