Skip to content

Commit

Permalink
Avoid duplicated blank lines (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
Franco Victorio authored and mattiaerre committed Jan 8, 2019
1 parent ec6e9ea commit 5206691
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 37 deletions.
6 changes: 4 additions & 2 deletions src/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ function genericPrint(path, options, print) {
let doc;
switch (node.type) {
case 'SourceUnit':
return printPreservingEmptyLines(path, 'children', options, print);
return concat([
printPreservingEmptyLines(path, 'children', options, print),
line
]);
case 'PragmaDirective':
return concat(['pragma ', node.name, ' ', node.value, ';']);
case 'ImportDirective':
Expand Down Expand Up @@ -73,7 +76,6 @@ function genericPrint(path, options, print) {
]);
}
parts.push('}');
parts.push(line);

return concat(parts);
}
Expand Down
34 changes: 0 additions & 34 deletions tests/AllSolidityFeatures/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ interface i {
function f();
}
contract c {
function c() {
val1 = 1 wei; // 1
Expand All @@ -444,7 +443,6 @@ contract c {
uint256 val4;
}
contract test {
enum ActionChoices {GoLeft, GoRight, GoStraight, SitStill}
Expand All @@ -457,19 +455,16 @@ contract test {
ActionChoices choices;
}
contract Base {
function Base(uint i) {
m_i = i;
}
uint public m_i;
}
contract Derived is Base(0) {
function Derived(uint i) Base(i) {}
}
contract C {
uint248 x; // 31 bytes: slot 0, offset 0
uint16 y; // 2 bytes: slot 1, offset 0 (does not fit in slot 0)
Expand All @@ -485,7 +480,6 @@ contract C {
uint8 gamma; // 1 byte, slot 7 (start new slot after array)
}
contract test {
function f(uint x, uint y) returns (uint z) {
var c = x + 3;
Expand All @@ -494,14 +488,12 @@ contract test {
}
}
contract test {
function f(uint x, uint y) returns (uint z) {
return 10;
}
}
contract c {
function() returns (uint) {
return g(8);
Expand All @@ -519,15 +511,13 @@ contract c {
mapping(uint => uint) data;
}
contract Sharer {
function sendHalf(address addr) returns (uint balance) {
if (!addr.send(msg.value / 2)) throw; // also reverts the transfer to Sharer
return address(this).balance;
}
}
/// @dev Models a modifiable and iterable set of uint values.
library IntegerSet {
struct data {
Expand Down Expand Up @@ -581,7 +571,6 @@ library IntegerSet {
}
}
/// How to use it:
contract User {
/// Just a struct holding our data.
Expand All @@ -605,7 +594,6 @@ contract User {
}
}
// This broke it at one point (namely the modifiers).
contract DualIndex {
mapping(uint => mapping(uint => uint)) data;
Expand Down Expand Up @@ -633,26 +621,20 @@ contract DualIndex {
}
}
contract A {}
contract B {}
contract C is A, B {}
contract TestPrivate {
uint private value;
}
contract TestInternal {
uint internal value;
}
contract FromSolparse is A, B, TestPrivate, TestInternal {
function() {
uint a = 6 ** 9;
Expand All @@ -661,7 +643,6 @@ contract FromSolparse is A, B, TestPrivate, TestInternal {
}
}
contract CommentedOutFunction {
// FYI: This empty function, as well as the commented
// out function below (bad code) is important to this test.
Expand All @@ -673,25 +654,21 @@ contract CommentedOutFunction {
}
library VarHasBrackets {
string constant specialRight = "}";
//string storage specialLeft = "{";
}
library UsingExampleLibrary {
function sum(uint[] storage self) returns (uint s) {
for (uint i = 0; i < self.length; i++) s += self[i];
}
}
contract UsingExampleContract {
using UsingExampleLibrary for uint[];
}
contract NewStuff {
uint[] b;
Expand All @@ -701,13 +678,11 @@ contract NewStuff {
}
}
// modifier with expression
contract MyContract {
function fun() mymodifier(foo.bar()) {}
}
library GetCode {
function at(address _addr) returns (bytes o_code) {
assembly {
Expand All @@ -726,7 +701,6 @@ library GetCode {
}
}
contract assemblyLocalBinding {
function test() {
assembly {
Expand All @@ -738,7 +712,6 @@ contract assemblyLocalBinding {
}
}
contract assemblyReturn {
uint a = 10;
Expand All @@ -752,12 +725,10 @@ contract assemblyReturn {
}
}
contract usesConst {
uint const = 0;
}
contract memoryArrays {
uint seven = 7;
Expand All @@ -771,7 +742,6 @@ contract memoryArrays {
}
}
contract DeclarativeExpressions {
uint a;
uint b = 7;
Expand All @@ -793,7 +763,6 @@ contract DeclarativeExpressions {
}
}
contract VariableDeclarationTuple {
function getMyTuple() returns (bool, bool) {
return (true, false);
Expand All @@ -810,13 +779,11 @@ contract VariableDeclarationTuple {
}
}
contract TypeIndexSpacing {
uint[7] x;
uint[] y;
}
contract Ballot {
struct Voter {
uint weight;
Expand Down Expand Up @@ -844,7 +811,6 @@ contract Ballot {
Voter airbnb = Voter({weight: 2, voted: true});
}
contract multilineReturn {
function a() returns (uint x) {
return 5;
Expand Down
1 change: 0 additions & 1 deletion tests/SampleCrowdsale/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ contract SampleCrowdsaleToken is MintableToken {
}
/**
* @title SampleCrowdsale
* @dev This is an example of a fully fledged crowdsale.
Expand Down

0 comments on commit 5206691

Please sign in to comment.