[SourceKit][CodeFormat] When indenting a getter without the leading keyword, first check if the getter is implicit. rdar://24348021

This commit is contained in:
Xi Ge
2016-02-01 11:56:36 -08:00
parent c0bd16e9cd
commit e92fb8109f
2 changed files with 14 additions and 1 deletions

View File

@@ -19,6 +19,15 @@ struct S {
class C1 {
var total: Int = 0 {
didSet {
print()
}
}
}
class C2 {
var total: Int = 0 {
didSet {
print()
}
}
}
@@ -37,6 +46,7 @@ didSet {
// RUN: %sourcekitd-test -req=format -line=15 -length=1 %s >>%t.response
// RUN: %sourcekitd-test -req=format -line=16 -length=1 %s >>%t.response
// RUN: %sourcekitd-test -req=format -line=21 -length=1 %s >>%t.response
// RUN: %sourcekitd-test -req=format -line=30 -length=1 %s >>%t.response
// RUN: FileCheck --strict-whitespace %s <%t.response
// CHECK: key.sourcetext: "class Foo {"
@@ -54,3 +64,5 @@ didSet {
// CHECK: key.sourcetext: " return 0"
// CHECK: key.sourcetext: " }"
// CHECK: key.sourcetext: " didSet {"
" didSet {"
// CHECK: key.sourcetext: " print()"

View File

@@ -1642,7 +1642,8 @@ public:
// }
if (auto VD = dyn_cast_or_null<VarDecl>(Cursor->getAsDecl())) {
if (auto Getter = VD->getGetter()) {
if (Getter->getAccessorKeywordLoc().isInvalid()) {
if (!Getter->isImplicit() &&
Getter->getAccessorKeywordLoc().isInvalid()) {
LineAndColumn = ParentLineAndColumn;
continue;
}