Skip to content

Commit 8ec800d

Browse files
committed
Remove bespoke handling of IfConfigDecl within code formatting
The SourceKit code formatting tools have effectively been replaced by swift-syntax's basic formatting functionality and more full-featured formatters like swift-format and SwiftFormat. Remove the special handling of IfConfigDecl as staging for the removal of IfConfigDecl.
1 parent 9936f64 commit 8ec800d

File tree

2 files changed

+3
-36
lines changed

2 files changed

+3
-36
lines changed

lib/IDE/Formatting.cpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -487,15 +487,6 @@ class RangeWalker: protected ASTWalker {
487487
if (D->isImplicit())
488488
return Action::Continue();
489489

490-
// Walk into inactive config regions.
491-
if (auto *ICD = dyn_cast<IfConfigDecl>(D)) {
492-
for (auto Clause : ICD->getClauses()) {
493-
for (auto Member : Clause.Elements)
494-
Member.walk(*this);
495-
}
496-
return Action::SkipNode();
497-
}
498-
499490
SourceLoc ContextLoc = D->getStartLoc();
500491

501492
if (auto *GC = D->getAsGenericContext()) {
@@ -1396,17 +1387,6 @@ class FormatWalker : public ASTWalker {
13961387
}
13971388
}
13981389

1399-
// Walk into inactive config regions.
1400-
if (auto *ICD = dyn_cast<IfConfigDecl>(D)) {
1401-
if (Action.shouldVisitChildren()) {
1402-
for (auto Clause : ICD->getClauses()) {
1403-
for (auto Member : Clause.Elements)
1404-
Member.walk(*this);
1405-
}
1406-
}
1407-
return Action::SkipNode();
1408-
}
1409-
14101390
// FIXME: We ought to be able to use Action::VisitChildrenIf here, but we'd
14111391
// need to ensure the AST is walked in source order (currently not the case
14121392
// for things like postfix operators).
@@ -1933,19 +1913,6 @@ class FormatWalker : public ASTWalker {
19331913
return IndentContext {ContextLoc, !OutdentChecker::hasOutdent(SM, D)};
19341914
}
19351915

1936-
if (auto *ICD = dyn_cast<IfConfigDecl>(D)) {
1937-
for (auto &Clause: ICD->getClauses()) {
1938-
if (Clause.Loc == TargetLocation)
1939-
break;
1940-
if (auto *Cond = Clause.Cond) {
1941-
SourceRange CondRange = Cond->getSourceRange();
1942-
if (CondRange.isValid() && overlapsTarget(CondRange))
1943-
return IndentContext {Clause.Loc, true};
1944-
}
1945-
}
1946-
return IndentContext { ICD->getStartLoc(), false };
1947-
}
1948-
19491916
switch (D->getKind()) {
19501917
case DeclKind::InfixOperator:
19511918
case DeclKind::PostfixOperator:

test/SourceKit/CodeFormat/indent-pound-if.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ print(false)
3535
// RUN: %FileCheck --strict-whitespace %s <%t.response
3636

3737
// CHECK: key.sourcetext: "#else"
38-
// CHECK: key.sourcetext: " let i = 3"
39-
// CHECK: key.sourcetext: " func b () {"
38+
// CHECK: key.sourcetext: "let i = 3"
39+
// CHECK: key.sourcetext: "func b () {"
4040
// CHECK: key.sourcetext: "#elseif os(OSX)"
41-
// CHECK: key.sourcetext: " func b () {"
41+
// CHECK: key.sourcetext: "func b () {"

0 commit comments

Comments
 (0)