Skip to content

Commit 2c56a2b

Browse files
authored
Merge pull request #7577 from bitjammer/syntax-remove-dummy-indent
[Syntax] Remove dummy indent implementation
2 parents 3afb557 + d715046 commit 2c56a2b

File tree

6 files changed

+3
-60
lines changed

6 files changed

+3
-60
lines changed

include/swift/Syntax/RawSyntax.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,6 @@ struct RawSyntax : public llvm::ThreadSafeRefCountedBase<RawSyntax> {
230230
return Kind >= SyntaxKind::First_Stmt && Kind <= SyntaxKind::Last_Stmt;
231231
}
232232

233-
234-
RC<RawSyntax> indent(unsigned Count, TriviaKind TrivKind,
235-
unsigned Depth = 0) const;
236-
237233
/// Get the absolute position of this raw syntax: its offset, line,
238234
/// and column.
239235
AbsolutePosition getAbsolutePosition(RC<RawSyntax> Root) const;

include/swift/Syntax/TokenSyntax.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -178,27 +178,6 @@ struct TokenSyntax final : public RawSyntax {
178178
}
179179
}
180180

181-
/// A dummy implementation for indenting a token with some amount
182-
/// of trivia.
183-
RC<TokenSyntax> indent(unsigned Count, syntax::TriviaKind TrivKind) const {
184-
Trivia NewLeadingTrivia { LeadingTrivia };
185-
if (NewLeadingTrivia.empty()) {
186-
NewLeadingTrivia.push_back(
187-
syntax::TriviaPiece {TrivKind, Count, OwnedString{}});
188-
} else {
189-
auto Last = NewLeadingTrivia.back();
190-
if (Last.Kind == TrivKind) {
191-
NewLeadingTrivia.pop_back();
192-
NewLeadingTrivia.push_back(
193-
syntax::TriviaPiece {TrivKind, Count + Last.Count, OwnedString{}});
194-
} else {
195-
NewLeadingTrivia.push_back(
196-
syntax::TriviaPiece {TrivKind, Count, OwnedString{}});
197-
}
198-
}
199-
return make(TokenKind, Text, Presence, NewLeadingTrivia, TrailingTrivia);
200-
}
201-
202181
/// Advance the provided AbsolutePosition by the token's full width and
203182
/// return the AbsolutePosition of the start of the token's nontrivial text.
204183
AbsolutePosition accumulateAbsolutePosition(AbsolutePosition &Pos) const;

lib/Syntax/RawSyntax.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -80,38 +80,6 @@ void RawSyntax::dump(llvm::raw_ostream &OS, unsigned Indent) const {
8080
OS << ')';
8181
}
8282

83-
RC<RawSyntax> RawSyntax::indent(unsigned Count, TriviaKind TrivKind,
84-
unsigned Depth) const {
85-
LayoutList NewLayout;
86-
bool IsFirst = Depth == 0;
87-
88-
for (const auto LE : Layout) {
89-
switch (LE->Kind) {
90-
case SyntaxKind::Token: {
91-
auto Tok = llvm::cast<TokenSyntax>(LE);
92-
auto Leading = Tok->LeadingTrivia;
93-
auto LeadingNewline = Leading.find(TriviaKind::Newline);
94-
auto FoundNewline = LeadingNewline != Leading.end();
95-
96-
if (IsFirst || FoundNewline) {
97-
IsFirst = false;
98-
RC<TokenSyntax> IndentedToken = Tok->indent(Count, TrivKind);
99-
NewLayout.push_back(IndentedToken);
100-
} else {
101-
NewLayout.push_back(LE);
102-
}
103-
104-
break;
105-
}
106-
default:
107-
NewLayout.push_back(LE->indent(Count, TrivKind, Depth + 1));
108-
break;
109-
}
110-
}
111-
112-
return RawSyntax::make(Kind, NewLayout, Presence);
113-
}
114-
11583
bool RawSyntax::accumulateAbsolutePosition(
11684
AbsolutePosition &Pos, const RawSyntax *UpToTargetNode) const {
11785
auto Found = this == UpToTargetNode;

tools/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
add_swift_tool_subdirectory(driver)
22
add_swift_tool_subdirectory(sil-opt)
33
add_swift_tool_subdirectory(swift-ide-test)
4-
add_swift_tool_subdirectory(swift-format)
4+
add_swift_tool_subdirectory(swift-syntax-format)
55
add_swift_tool_subdirectory(swift-remoteast-test)
66
add_swift_tool_subdirectory(swift-demangle)
77
add_swift_tool_subdirectory(lldb-moduleimport-test)

tools/swift-format/CMakeLists.txt renamed to tools/swift-syntax-format/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
add_swift_host_tool(swift-format
2-
swift-format.cpp
1+
add_swift_host_tool(swift-syntax-format
2+
swift-syntax-format.cpp
33
LINK_LIBRARIES
44
swiftAST
55
swiftDriver

0 commit comments

Comments
 (0)