Skip to content

Commit 5206691

Browse files
Franco Victoriomattiaerre
authored andcommitted
Avoid duplicated blank lines (#103)
1 parent ec6e9ea commit 5206691

3 files changed

Lines changed: 4 additions & 37 deletions

File tree

src/printer.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ function genericPrint(path, options, print) {
3333
let doc;
3434
switch (node.type) {
3535
case 'SourceUnit':
36-
return printPreservingEmptyLines(path, 'children', options, print);
36+
return concat([
37+
printPreservingEmptyLines(path, 'children', options, print),
38+
line
39+
]);
3740
case 'PragmaDirective':
3841
return concat(['pragma ', node.name, ' ', node.value, ';']);
3942
case 'ImportDirective':
@@ -73,7 +76,6 @@ function genericPrint(path, options, print) {
7376
]);
7477
}
7578
parts.push('}');
76-
parts.push(line);
7779

7880
return concat(parts);
7981
}

tests/AllSolidityFeatures/__snapshots__/jsfmt.spec.js.snap

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ interface i {
430430
function f();
431431
}
432432
433-
434433
contract c {
435434
function c() {
436435
val1 = 1 wei; // 1
@@ -444,7 +443,6 @@ contract c {
444443
uint256 val4;
445444
}
446445
447-
448446
contract test {
449447
enum ActionChoices {GoLeft, GoRight, GoStraight, SitStill}
450448
@@ -457,19 +455,16 @@ contract test {
457455
ActionChoices choices;
458456
}
459457
460-
461458
contract Base {
462459
function Base(uint i) {
463460
m_i = i;
464461
}
465462
uint public m_i;
466463
}
467-
468464
contract Derived is Base(0) {
469465
function Derived(uint i) Base(i) {}
470466
}
471467
472-
473468
contract C {
474469
uint248 x; // 31 bytes: slot 0, offset 0
475470
uint16 y; // 2 bytes: slot 1, offset 0 (does not fit in slot 0)
@@ -485,7 +480,6 @@ contract C {
485480
uint8 gamma; // 1 byte, slot 7 (start new slot after array)
486481
}
487482
488-
489483
contract test {
490484
function f(uint x, uint y) returns (uint z) {
491485
var c = x + 3;
@@ -494,14 +488,12 @@ contract test {
494488
}
495489
}
496490
497-
498491
contract test {
499492
function f(uint x, uint y) returns (uint z) {
500493
return 10;
501494
}
502495
}
503496
504-
505497
contract c {
506498
function() returns (uint) {
507499
return g(8);
@@ -519,15 +511,13 @@ contract c {
519511
mapping(uint => uint) data;
520512
}
521513
522-
523514
contract Sharer {
524515
function sendHalf(address addr) returns (uint balance) {
525516
if (!addr.send(msg.value / 2)) throw; // also reverts the transfer to Sharer
526517
return address(this).balance;
527518
}
528519
}
529520
530-
531521
/// @dev Models a modifiable and iterable set of uint values.
532522
library IntegerSet {
533523
struct data {
@@ -581,7 +571,6 @@ library IntegerSet {
581571
}
582572
}
583573
584-
585574
/// How to use it:
586575
contract User {
587576
/// Just a struct holding our data.
@@ -605,7 +594,6 @@ contract User {
605594
}
606595
}
607596
608-
609597
// This broke it at one point (namely the modifiers).
610598
contract DualIndex {
611599
mapping(uint => mapping(uint => uint)) data;
@@ -633,26 +621,20 @@ contract DualIndex {
633621
}
634622
}
635623
636-
637624
contract A {}
638625
639-
640626
contract B {}
641627
642-
643628
contract C is A, B {}
644629
645-
646630
contract TestPrivate {
647631
uint private value;
648632
}
649633
650-
651634
contract TestInternal {
652635
uint internal value;
653636
}
654637
655-
656638
contract FromSolparse is A, B, TestPrivate, TestInternal {
657639
function() {
658640
uint a = 6 ** 9;
@@ -661,7 +643,6 @@ contract FromSolparse is A, B, TestPrivate, TestInternal {
661643
}
662644
}
663645
664-
665646
contract CommentedOutFunction {
666647
// FYI: This empty function, as well as the commented
667648
// out function below (bad code) is important to this test.
@@ -673,25 +654,21 @@ contract CommentedOutFunction {
673654
674655
}
675656
676-
677657
library VarHasBrackets {
678658
string constant specialRight = "}";
679659
//string storage specialLeft = "{";
680660
}
681661
682-
683662
library UsingExampleLibrary {
684663
function sum(uint[] storage self) returns (uint s) {
685664
for (uint i = 0; i < self.length; i++) s += self[i];
686665
}
687666
}
688667
689-
690668
contract UsingExampleContract {
691669
using UsingExampleLibrary for uint[];
692670
}
693671
694-
695672
contract NewStuff {
696673
uint[] b;
697674
@@ -701,13 +678,11 @@ contract NewStuff {
701678
}
702679
}
703680
704-
705681
// modifier with expression
706682
contract MyContract {
707683
function fun() mymodifier(foo.bar()) {}
708684
}
709685
710-
711686
library GetCode {
712687
function at(address _addr) returns (bytes o_code) {
713688
assembly {
@@ -726,7 +701,6 @@ library GetCode {
726701
}
727702
}
728703
729-
730704
contract assemblyLocalBinding {
731705
function test() {
732706
assembly {
@@ -738,7 +712,6 @@ contract assemblyLocalBinding {
738712
}
739713
}
740714
741-
742715
contract assemblyReturn {
743716
uint a = 10;
744717
@@ -752,12 +725,10 @@ contract assemblyReturn {
752725
}
753726
}
754727
755-
756728
contract usesConst {
757729
uint const = 0;
758730
}
759731
760-
761732
contract memoryArrays {
762733
uint seven = 7;
763734
@@ -771,7 +742,6 @@ contract memoryArrays {
771742
}
772743
}
773744
774-
775745
contract DeclarativeExpressions {
776746
uint a;
777747
uint b = 7;
@@ -793,7 +763,6 @@ contract DeclarativeExpressions {
793763
}
794764
}
795765
796-
797766
contract VariableDeclarationTuple {
798767
function getMyTuple() returns (bool, bool) {
799768
return (true, false);
@@ -810,13 +779,11 @@ contract VariableDeclarationTuple {
810779
}
811780
}
812781
813-
814782
contract TypeIndexSpacing {
815783
uint[7] x;
816784
uint[] y;
817785
}
818786
819-
820787
contract Ballot {
821788
struct Voter {
822789
uint weight;
@@ -844,7 +811,6 @@ contract Ballot {
844811
Voter airbnb = Voter({weight: 2, voted: true});
845812
}
846813
847-
848814
contract multilineReturn {
849815
function a() returns (uint x) {
850816
return 5;

tests/SampleCrowdsale/__snapshots__/jsfmt.spec.js.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ contract SampleCrowdsaleToken is MintableToken {
6868
6969
}
7070
71-
7271
/**
7372
* @title SampleCrowdsale
7473
* @dev This is an example of a fully fledged crowdsale.

0 commit comments

Comments
 (0)