[CodeCompletion] Add assignment to experimental operator completion

When the LHS is an lvalue/assignable tuple and there is no leading
sequence of binary expressions.

It's a bit hacky right now since we don't have a good way to
differentiate general pattern completions from builtin operators.

rdar://problem/23209683
This commit is contained in:
Ben Langmuir
2016-03-02 17:29:46 -08:00
parent d88d5052aa
commit 8f9299cc97
11 changed files with 79 additions and 8 deletions

View File

@@ -1026,9 +1026,14 @@ void CompletionBuilder::getFilterName(CodeCompletionString *str,
if (FirstTextChunk.hasValue()) {
for (auto C : str->getChunks().slice(*FirstTextChunk)) {
if (C.getKind() == ChunkKind::BraceStmtWithCursor)
if (C.is(ChunkKind::BraceStmtWithCursor))
break;
if (C.is(ChunkKind::Equal)) {
OS << C.getText();
break;
}
bool shouldPrint = !C.isAnnotation();
switch (C.getKind()) {
case ChunkKind::TypeAnnotation:
@@ -1064,8 +1069,13 @@ void CompletionBuilder::getDescription(SwiftResult *result, raw_ostream &OS,
if (FirstTextChunk.hasValue()) {
for (auto C : str->getChunks().slice(*FirstTextChunk)) {
using ChunkKind = CodeCompletionString::Chunk::ChunkKind;
if (C.getKind() == ChunkKind::BraceStmtWithCursor)
if (C.is(ChunkKind::BraceStmtWithCursor))
break;
// FIXME: we need a more uniform way to handle operator completions.
if (C.is(ChunkKind::Equal))
isOperator = true;
if (C.getKind() == ChunkKind::TypeAnnotation ||
C.getKind() == ChunkKind::CallParameterClosureType ||
C.getKind() == ChunkKind::Whitespace)