Skip to content

[Syntax] Don't pretty-print -emit-syntax JSON output #15380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/FrontendTool/FrontendTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ static bool emitSyntax(SourceFile *SF, LangOptions &LangOpts,
auto os = getFileOutputStream(OutputFilename, SF->getASTContext());
if (!os) return true;

json::Output jsonOut(*os);
json::Output jsonOut(*os, /*PrettyPrint=*/false);
auto Root = SF->getSyntaxRoot().getRaw();
jsonOut << *Root;
*os << "\n";
Expand Down
26 changes: 13 additions & 13 deletions test/Frontend/emit-syntax.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// RUN: %target-swift-frontend -emit-syntax %s | %FileCheck %s

// CHECK: "kind": "kw_struct"
// CHECK: "kind": "identifier",
// CHECK: "text": "Foo"
// CHECK: "kind": "l_brace"
// CHECK: "kind":"kw_struct"
// CHECK: "kind":"identifier",
// CHECK: "text":"Foo"
// CHECK: "kind":"l_brace"
struct Foo {
// CHECK: "kind": "kw_let"
// CHECK: "kind": "colon"
// CHECK: "kind": "identifier"
// CHECK: "text": "Int"
// CHECK: "kind":"kw_let"
// CHECK: "kind":"colon"
// CHECK: "kind":"identifier"
// CHECK: "text":"Int"
let x: Int
// CHECK: "kind": "r_brace"
// CHECK: "kind":"r_brace"
}

// CHECK: "leadingTrivia": [
// CHECK: "kind": "LineComment",
// CHECK: "value": "\/\/ Comment at the end of the file"
// CHECK: "leadingTrivia":[
// CHECK: "kind":"LineComment",
// CHECK: "value":"\/\/ Comment at the end of the file"

// Comment at the end of the file
// Comment at the end of the file
2 changes: 1 addition & 1 deletion test/SourceKit/SyntaxTree/basic.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %swift-syntax-test -input-source-filename %s -serialize-raw-tree > %t.emit
// RUN: %target-swift-frontend -emit-syntax %s > %t.emit
// RUN: %sourcekitd-test -req=syntax-tree %s > %t.sourcekit
// RUN: diff %t.emit %t.sourcekit

Expand Down
2 changes: 1 addition & 1 deletion tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,7 @@ void SwiftEditorDocument::readSyntaxInfo(EditorConsumer &Consumer) {
if (Consumer.syntaxTreeEnabled()) {
std::string SyntaxContent;
llvm::raw_string_ostream OS(SyntaxContent);
json::Output JsonOut(OS);
json::Output JsonOut(OS, /*PrettyPrint=*/false);
auto Root = Impl.SyntaxInfo->getSourceFile().getSyntaxRoot().getRaw();
JsonOut << *Root;
Consumer.handleSerializedSyntaxTree(OS.str());
Expand Down