Skip to content

Commit 527cce4

Browse files
[Syntax] Don't pretty-print -emit-syntax JSON output (#15380)
1 parent bdfa6cd commit 527cce4

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

Diff for: lib/FrontendTool/FrontendTool.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ static bool emitSyntax(SourceFile *SF, LangOptions &LangOpts,
288288
auto os = getFileOutputStream(OutputFilename, SF->getASTContext());
289289
if (!os) return true;
290290

291-
json::Output jsonOut(*os);
291+
json::Output jsonOut(*os, /*PrettyPrint=*/false);
292292
auto Root = SF->getSyntaxRoot().getRaw();
293293
jsonOut << *Root;
294294
*os << "\n";

Diff for: test/Frontend/emit-syntax.swift

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
// RUN: %target-swift-frontend -emit-syntax %s | %FileCheck %s
22

3-
// CHECK: "kind": "kw_struct"
4-
// CHECK: "kind": "identifier",
5-
// CHECK: "text": "Foo"
6-
// CHECK: "kind": "l_brace"
3+
// CHECK: "kind":"kw_struct"
4+
// CHECK: "kind":"identifier",
5+
// CHECK: "text":"Foo"
6+
// CHECK: "kind":"l_brace"
77
struct Foo {
8-
// CHECK: "kind": "kw_let"
9-
// CHECK: "kind": "colon"
10-
// CHECK: "kind": "identifier"
11-
// CHECK: "text": "Int"
8+
// CHECK: "kind":"kw_let"
9+
// CHECK: "kind":"colon"
10+
// CHECK: "kind":"identifier"
11+
// CHECK: "text":"Int"
1212
let x: Int
13-
// CHECK: "kind": "r_brace"
13+
// CHECK: "kind":"r_brace"
1414
}
1515

16-
// CHECK: "leadingTrivia": [
17-
// CHECK: "kind": "LineComment",
18-
// CHECK: "value": "\/\/ Comment at the end of the file"
16+
// CHECK: "leadingTrivia":[
17+
// CHECK: "kind":"LineComment",
18+
// CHECK: "value":"\/\/ Comment at the end of the file"
1919

20-
// Comment at the end of the file
20+
// Comment at the end of the file

Diff for: test/SourceKit/SyntaxTree/basic.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %swift-syntax-test -input-source-filename %s -serialize-raw-tree > %t.emit
1+
// RUN: %target-swift-frontend -emit-syntax %s > %t.emit
22
// RUN: %sourcekitd-test -req=syntax-tree %s > %t.sourcekit
33
// RUN: diff %t.emit %t.sourcekit
44

Diff for: tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1798,7 +1798,7 @@ void SwiftEditorDocument::readSyntaxInfo(EditorConsumer &Consumer) {
17981798
if (Consumer.syntaxTreeEnabled()) {
17991799
std::string SyntaxContent;
18001800
llvm::raw_string_ostream OS(SyntaxContent);
1801-
json::Output JsonOut(OS);
1801+
json::Output JsonOut(OS, /*PrettyPrint=*/false);
18021802
auto Root = Impl.SyntaxInfo->getSourceFile().getSyntaxRoot().getRaw();
18031803
JsonOut << *Root;
18041804
Consumer.handleSerializedSyntaxTree(OS.str());

0 commit comments

Comments
 (0)