Remove trailing spaces from JSON output

This commit is contained in:
Gaith Hallak 2019-09-30 02:32:28 +03:00
parent f884373142
commit 9d34d7de2f
3 changed files with 241 additions and 240 deletions

View File

@ -24,6 +24,7 @@
#include <libsolidity/ast/AST.h> #include <libsolidity/ast/AST.h>
#include <libyul/AsmData.h> #include <libyul/AsmData.h>
#include <libyul/AsmPrinter.h> #include <libyul/AsmPrinter.h>
#include <libdevcore/JSON.h>
#include <libdevcore/UTF8.h> #include <libdevcore/UTF8.h>
#include <boost/algorithm/string/join.hpp> #include <boost/algorithm/string/join.hpp>
@ -189,7 +190,7 @@ Json::Value ASTJsonConverter::inlineAssemblyIdentifierToJson(pair<yul::Identifie
void ASTJsonConverter::print(ostream& _stream, ASTNode const& _node) void ASTJsonConverter::print(ostream& _stream, ASTNode const& _node)
{ {
_stream << toJson(_node); _stream << jsonPrettyPrint(toJson(_node));
} }
Json::Value&& ASTJsonConverter::toJson(ASTNode const& _node) Json::Value&& ASTJsonConverter::toJson(ASTNode const& _node)

View File

@ -6,7 +6,7 @@
REPO_ROOT="$(dirname "$0")"/.. REPO_ROOT="$(dirname "$0")"/..
cd $REPO_ROOT cd $REPO_ROOT
WHITESPACE=$(git grep -n -I -E "^.*[[:space:]]+$" | grep -v "test/libsolidity/ASTJSON\|test/libsolidity/ASTRecoveryTests\|test/compilationTests/zeppelin/LICENSE\|test/cmdlineTests/recovery_ast_constructor/output") WHITESPACE=$(git grep -n -I -E "^.*[[:space:]]+$" | grep -v "test/libsolidity/ASTJSON\|test/libsolidity/ASTRecoveryTests\|test/compilationTests/zeppelin/LICENSE")
if [[ "$WHITESPACE" != "" ]] if [[ "$WHITESPACE" != "" ]]
then then

View File

@ -3,242 +3,242 @@ JSON AST:
======= recovery_ast_constructor/input.sol ======= ======= recovery_ast_constructor/input.sol =======
{ {
"attributes" : "attributes":
{ {
"absolutePath" : "recovery_ast_constructor/input.sol", "absolutePath": "recovery_ast_constructor/input.sol",
"exportedSymbols" : "exportedSymbols":
{ {
"Error1" : "Error1":
[ [
18 18
] ]
} }
}, },
"children" : "children":
[ [
{ {
"attributes" : "attributes":
{ {
"literals" : "literals":
[ [
"solidity", "solidity",
">=", ">=",
"0.0", "0.0",
".0" ".0"
] ]
}, },
"id" : 1, "id": 1,
"name" : "PragmaDirective", "name": "PragmaDirective",
"src" : "0:24:0" "src": "0:24:0"
}, },
{ {
"attributes" : "attributes":
{ {
"baseContracts" : "baseContracts":
[ [
null null
], ],
"contractDependencies" : "contractDependencies":
[ [
null null
], ],
"contractKind" : "contract", "contractKind": "contract",
"documentation" : null, "documentation": null,
"fullyImplemented" : true, "fullyImplemented": true,
"linearizedBaseContracts" : "linearizedBaseContracts":
[ [
18 18
], ],
"name" : "Error1", "name": "Error1",
"scope" : 19 "scope": 19
}, },
"children" : "children":
[ [
{ {
"attributes" : "attributes":
{ {
"documentation" : null, "documentation": null,
"implemented" : true, "implemented": true,
"isConstructor" : true, "isConstructor": true,
"kind" : "constructor", "kind": "constructor",
"modifiers" : "modifiers":
[ [
null null
], ],
"name" : "", "name": "",
"overrides" : null, "overrides": null,
"scope" : 18, "scope": 18,
"stateMutability" : "nonpayable", "stateMutability": "nonpayable",
"superFunction" : null, "superFunction": null,
"visibility" : "public" "visibility": "public"
}, },
"children" : "children":
[ [
{ {
"attributes" : "attributes":
{ {
"parameters" : "parameters":
[ [
null null
] ]
}, },
"children" : [], "children": [],
"id" : 2, "id": 2,
"name" : "ParameterList", "name": "ParameterList",
"src" : "57:2:0" "src": "57:2:0"
}, },
{ {
"attributes" : "attributes":
{ {
"parameters" : "parameters":
[ [
null null
] ]
}, },
"children" : [], "children": [],
"id" : 3, "id": 3,
"name" : "ParameterList", "name": "ParameterList",
"src" : "67:0:0" "src": "67:0:0"
}, },
{ {
"attributes" : "attributes":
{ {
"statements" : "statements":
[ [
null null
] ]
}, },
"children" : [], "children": [],
"id" : 8, "id": 8,
"name" : "Block", "name": "Block",
"src" : "67:49:0" "src": "67:49:0"
} }
], ],
"id" : 9, "id": 9,
"name" : "FunctionDefinition", "name": "FunctionDefinition",
"src" : "46:70:0" "src": "46:70:0"
}, },
{ {
"attributes" : "attributes":
{ {
"documentation" : null, "documentation": null,
"implemented" : true, "implemented": true,
"isConstructor" : false, "isConstructor": false,
"kind" : "function", "kind": "function",
"modifiers" : "modifiers":
[ [
null null
], ],
"name" : "five", "name": "five",
"overrides" : null, "overrides": null,
"scope" : 18, "scope": 18,
"stateMutability" : "view", "stateMutability": "view",
"superFunction" : null, "superFunction": null,
"visibility" : "public" "visibility": "public"
}, },
"children" : "children":
[ [
{ {
"attributes" : "attributes":
{ {
"parameters" : "parameters":
[ [
null null
] ]
}, },
"children" : [], "children": [],
"id" : 10, "id": 10,
"name" : "ParameterList", "name": "ParameterList",
"src" : "382:2:0" "src": "382:2:0"
}, },
{ {
"children" : "children":
[ [
{ {
"attributes" : "attributes":
{ {
"constant" : false, "constant": false,
"name" : "", "name": "",
"overrides" : null, "overrides": null,
"scope" : 17, "scope": 17,
"stateVariable" : false, "stateVariable": false,
"storageLocation" : "default", "storageLocation": "default",
"type" : "uint256", "type": "uint256",
"value" : null, "value": null,
"visibility" : "internal" "visibility": "internal"
}, },
"children" : "children":
[ [
{ {
"attributes" : "attributes":
{ {
"name" : "uint", "name": "uint",
"type" : "uint256" "type": "uint256"
}, },
"id" : 11, "id": 11,
"name" : "ElementaryTypeName", "name": "ElementaryTypeName",
"src" : "405:4:0" "src": "405:4:0"
} }
], ],
"id" : 12, "id": 12,
"name" : "VariableDeclaration", "name": "VariableDeclaration",
"src" : "405:4:0" "src": "405:4:0"
} }
], ],
"id" : 13, "id": 13,
"name" : "ParameterList", "name": "ParameterList",
"src" : "404:6:0" "src": "404:6:0"
}, },
{ {
"children" : "children":
[ [
{ {
"attributes" : "attributes":
{ {
"functionReturnParameters" : 13 "functionReturnParameters": 13
}, },
"children" : "children":
[ [
{ {
"attributes" : "attributes":
{ {
"argumentTypes" : null, "argumentTypes": null,
"hexvalue" : "35", "hexvalue": "35",
"isConstant" : false, "isConstant": false,
"isLValue" : false, "isLValue": false,
"isPure" : true, "isPure": true,
"lValueRequested" : false, "lValueRequested": false,
"subdenomination" : null, "subdenomination": null,
"token" : "number", "token": "number",
"type" : "int_const 5", "type": "int_const 5",
"value" : "5" "value": "5"
}, },
"id" : 14, "id": 14,
"name" : "Literal", "name": "Literal",
"src" : "424:1:0" "src": "424:1:0"
} }
], ],
"id" : 15, "id": 15,
"name" : "Return", "name": "Return",
"src" : "417:8:0" "src": "417:8:0"
} }
], ],
"id" : 16, "id": 16,
"name" : "Block", "name": "Block",
"src" : "411:19:0" "src": "411:19:0"
} }
], ],
"id" : 17, "id": 17,
"name" : "FunctionDefinition", "name": "FunctionDefinition",
"src" : "369:61:0" "src": "369:61:0"
} }
], ],
"id" : 18, "id": 18,
"name" : "ContractDefinition", "name": "ContractDefinition",
"src" : "26:406:0" "src": "26:406:0"
} }
], ],
"id" : 19, "id": 19,
"name" : "SourceUnit", "name": "SourceUnit",
"src" : "0:433:0" "src": "0:433:0"
} }