mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SourceKit][CodeFormat] When indenting a getter without the leading keyword, first check if the getter is implicit. rdar://24348021
This commit is contained in:
@@ -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()"
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user