Skip to content

Commit 1aad3b3

Browse files
authored
---
yaml --- r: 303071 b: refs/heads/tensorflow c: 95efeda h: refs/heads/master i: 303069: c0e06af 303067: a85c492 303063: d6531b6 303055: 3977d8a 303039: fa17b2e
1 parent fa3cb4d commit 1aad3b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+339
-242
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a: 22f738a831d43aff2b9c9773bcb65
816816
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a: 7d98cc16689baba5c8a3b90a9329bdcc1a12b4e9
817817
refs/heads/cherr42: a566ad54b073c2c56ac0a705d0a5bed9743135a5
818818
"refs/heads/codable_test_comment_fix": fc8f6824f7f347e1e8db55bff62db385c5728b5a
819-
refs/heads/tensorflow: 616877af4ad8ad6178d12bf62e264d199d84731f
819+
refs/heads/tensorflow: 95efeda33bfd2db19913bc45bf354fbe46fc10b5
820820
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-11-a: 8126fd7a652e2f70ad6d76505239e34fb2ef3e1a
821821
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-12-a: b3fd3dd84df6717f2e2e9df58c6d7e99fed57086
822822
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-13-a: 71135119579039dc321c5f65d870050fe36efda2

branches/tensorflow/include/swift/Parse/CodeCompletionCallbacks.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ class CodeCompletionCallbacks {
115115
}
116116
};
117117

118+
/// Set target decl for attribute if the CC token is in attribute of the decl.
119+
virtual void setAttrTargetDecl(Decl *D) {}
120+
118121
/// Complete the whole expression. This is a fallback that should
119122
/// produce results when more specific completion methods failed.
120123
virtual void completeExpr() {};
@@ -186,7 +189,7 @@ class CodeCompletionCallbacks {
186189
virtual void completeAccessorBeginning(CodeCompletionExpr *E) {};
187190

188191
/// Complete the keyword in attribute, for instance, @available.
189-
virtual void completeDeclAttrKeyword(Decl *D, bool Sil, bool Param) {};
192+
virtual void completeDeclAttrBeginning(bool Sil) {};
190193

191194
/// Complete the parameters in attribute, for instance, version specifier for
192195
/// @available.

branches/tensorflow/include/swift/Parse/Parser.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,8 +904,7 @@ class Parser {
904904
void setLocalDiscriminatorToParamList(ParameterList *PL);
905905

906906
/// Parse the optional attributes before a declaration.
907-
bool parseDeclAttributeList(DeclAttributes &Attributes,
908-
bool &FoundCodeCompletionToken);
907+
ParserStatus parseDeclAttributeList(DeclAttributes &Attributes);
909908

910909
/// Parse the optional modifiers before a declaration.
911910
bool parseDeclModifierList(DeclAttributes &Attributes, SourceLoc &StaticLoc,
@@ -941,7 +940,7 @@ class Parser {
941940
SourceLoc Loc);
942941

943942
/// Parse a specific attribute.
944-
bool parseDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc);
943+
ParserStatus parseDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc);
945944

946945
bool parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
947946
DeclAttrKind DK);

branches/tensorflow/lib/AST/ASTWalker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
126126
// Attributes
127127
//===--------------------------------------------------------------------===//
128128
bool visitCustomAttributes(Decl *D) {
129-
for (auto *customAttr : D->getAttrs().getAttributes<CustomAttr>()) {
129+
for (auto *customAttr : D->getAttrs().getAttributes<CustomAttr, true>()) {
130130
CustomAttr *mutableCustomAttr = const_cast<CustomAttr *>(customAttr);
131131
if (doIt(mutableCustomAttr->getTypeLoc()))
132132
return true;

branches/tensorflow/lib/AST/Decl.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ SourceRange Decl::getSourceRangeIncludingAttrs() const {
441441
}
442442

443443
// Attributes on VarDecl syntactically belong to PatternBindingDecl.
444-
if (isa<VarDecl>(this))
444+
if (isa<VarDecl>(this) && !isa<ParamDecl>(this))
445445
return Range;
446446

447447
// Attributes on PatternBindingDecls are attached to VarDecls in AST.
@@ -2758,6 +2758,11 @@ bool ValueDecl::shouldHideFromEditor() const {
27582758
if (getBaseName().isEditorPlaceholder())
27592759
return true;
27602760

2761+
// '$__' names are reserved by compiler internal.
2762+
if (!getBaseName().isSpecial() &&
2763+
getBaseName().getIdentifier().str().startswith("$__"))
2764+
return true;
2765+
27612766
return false;
27622767
}
27632768

branches/tensorflow/lib/IDE/CodeCompletion.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,17 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks {
13481348
Consumer(Consumer) {
13491349
}
13501350

1351+
void setAttrTargetDecl(Decl *D) override {
1352+
if (D == nullptr) {
1353+
AttTargetDK = None;
1354+
return;
1355+
}
1356+
auto DK = D->getKind();
1357+
if (DK == DeclKind::PatternBinding)
1358+
DK = DeclKind::Var;
1359+
AttTargetDK = DK;
1360+
}
1361+
13511362
void completeExpr() override;
13521363
void completeDotExpr(Expr *E, SourceLoc DotLoc) override;
13531364
void completeStmtOrExpr(CodeCompletionExpr *E) override;
@@ -1367,7 +1378,7 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks {
13671378
void completeCaseStmtKeyword() override;
13681379
void completeCaseStmtBeginning() override;
13691380
void completeCaseStmtDotPrefix() override;
1370-
void completeDeclAttrKeyword(Decl *D, bool Sil, bool Param) override;
1381+
void completeDeclAttrBeginning(bool Sil) override;
13711382
void completeDeclAttrParam(DeclAttrKind DK, int Index) override;
13721383
void completeInPrecedenceGroup(SyntaxKind SK) override;
13731384
void completeNominalMemberBeginning(
@@ -4601,16 +4612,9 @@ void CodeCompletionCallbacksImpl::completeDeclAttrParam(DeclAttrKind DK,
46014612
CurDeclContext = P.CurDeclContext;
46024613
}
46034614

4604-
void CodeCompletionCallbacksImpl::completeDeclAttrKeyword(Decl *D,
4605-
bool Sil,
4606-
bool Param) {
4615+
void CodeCompletionCallbacksImpl::completeDeclAttrBeginning(bool Sil) {
46074616
Kind = CompletionKind::AttributeBegin;
46084617
IsInSil = Sil;
4609-
if (Param) {
4610-
AttTargetDK = DeclKind::Param;
4611-
} else if (D) {
4612-
AttTargetDK = D->getKind();
4613-
}
46144618
CurDeclContext = P.CurDeclContext;
46154619
}
46164620

@@ -5376,6 +5380,11 @@ void CodeCompletionCallbacksImpl::doneParsing() {
53765380

53775381
case CompletionKind::AttributeBegin: {
53785382
Lookup.getAttributeDeclCompletions(IsInSil, AttTargetDK);
5383+
5384+
// Provide any type name for property delegate.
5385+
if (!AttTargetDK || *AttTargetDK == DeclKind::Var)
5386+
Lookup.getTypeCompletionsInDeclContext(
5387+
P.Context.SourceMgr.getCodeCompletionLoc());
53795388
break;
53805389
}
53815390
case CompletionKind::AttributeDeclParen: {
@@ -5686,7 +5695,6 @@ void swift::ide::copyCodeCompletionResults(CodeCompletionResultSink &targetSink,
56865695
if (R->getKind() != CodeCompletionResult::Declaration)
56875696
return false;
56885697
switch(R->getAssociatedDeclKind()) {
5689-
case CodeCompletionDeclKind::PrecedenceGroup:
56905698
case CodeCompletionDeclKind::Module:
56915699
case CodeCompletionDeclKind::Class:
56925700
case CodeCompletionDeclKind::Struct:
@@ -5696,6 +5704,7 @@ void swift::ide::copyCodeCompletionResults(CodeCompletionResultSink &targetSink,
56965704
case CodeCompletionDeclKind::AssociatedType:
56975705
case CodeCompletionDeclKind::GenericTypeParam:
56985706
return true;
5707+
case CodeCompletionDeclKind::PrecedenceGroup:
56995708
case CodeCompletionDeclKind::EnumElement:
57005709
case CodeCompletionDeclKind::Constructor:
57015710
case CodeCompletionDeclKind::Destructor:

branches/tensorflow/lib/IDE/ExprContextAnalysis.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,15 @@ void typeCheckContextImpl(DeclContext *DC, SourceLoc Loc) {
5757

5858
case DeclContextKind::Initializer:
5959
if (auto *patternInit = dyn_cast<PatternBindingInitializer>(DC)) {
60-
auto *PBD = patternInit->getBinding();
61-
auto i = patternInit->getBindingIndex();
62-
if (PBD->getInit(i)) {
63-
PBD->getPattern(i)->forEachVariable([](VarDecl *VD) {
64-
typeCheckCompletionDecl(VD);
65-
});
66-
if (!PBD->isInitializerChecked(i))
67-
typeCheckPatternBinding(PBD, i);
60+
if (auto *PBD = patternInit->getBinding()) {
61+
auto i = patternInit->getBindingIndex();
62+
if (PBD->getInit(i)) {
63+
PBD->getPattern(i)->forEachVariable([](VarDecl *VD) {
64+
typeCheckCompletionDecl(VD);
65+
});
66+
if (!PBD->isInitializerChecked(i))
67+
typeCheckPatternBinding(PBD, i);
68+
}
6869
}
6970
}
7071
break;

branches/tensorflow/lib/IDE/SyntaxModel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ bool ModelASTWalker::handleSpecialDeclAttribute(const DeclAttribute *D,
10261026
ArrayRef<Token> Toks) {
10271027
if (!D)
10281028
return false;
1029-
if (isa<AvailableAttr>(D)) {
1029+
if (isa<AvailableAttr>(D) || isa<CustomAttr>(D)) {
10301030
unsigned I = 0;
10311031
for (; I < TokenNodes.size(); ++ I) {
10321032
auto Node = TokenNodes[I];

0 commit comments

Comments
 (0)