Skip to content

Commit

Permalink
By popular demand Contracts, Libraries, and Interfaces will have 1 li…
Browse files Browse the repository at this point in the history
…ne of separation (#283)
  • Loading branch information
Janther authored May 29, 2020
1 parent 0db9c14 commit 5b043cd
Show file tree
Hide file tree
Showing 29 changed files with 1 addition and 110 deletions.
9 changes: 1 addition & 8 deletions src/nodes/print-preserving-empty-lines.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,8 @@ function printPreservingEmptyLines(path, key, options, print) {
}

if (childPath.getName() > 0) {
if (nodeType === 'ContractDefinition') {
if (parts[parts.length - 2] !== hardline) {
parts.push(hardline);
}
parts.push(hardline);
}

if (
nodeType === 'FunctionDefinition' &&
['ContractDefinition', 'FunctionDefinition'].includes(nodeType) &&
parts[parts.length - 2] !== hardline
) {
parts.push(hardline);
Expand Down
1 change: 0 additions & 1 deletion tests/AddressPayable/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ contract AddressPayable {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pragma solidity ^0.5.2;
contract AddressPayable {
using Address for address payable;
address payable[] hello;
Expand Down
39 changes: 0 additions & 39 deletions tests/AllSolidityFeatures/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -480,12 +480,10 @@ import "SomeFile.sol" as SomeOtherFile;
import "AnotherFile.sol" as SomeSymbol;
import {symbol1 as alias, symbol2} from "File.sol";
interface i {
function f();
}
contract c {
function c() {
val1 = 1 wei; // 1
Expand All @@ -500,7 +498,6 @@ contract c {
uint256 val4;
}
contract test {
enum ActionChoices {GoLeft, GoRight, GoStraight, SitStill}
Expand All @@ -515,7 +512,6 @@ contract test {
ActionChoices choices;
}
contract Base {
function Base(uint256 i) {
m_i = i;
Expand All @@ -524,12 +520,10 @@ contract Base {
uint256 public m_i;
}
contract Derived is Base(0) {
function Derived(uint256 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 @@ -545,7 +539,6 @@ contract C {
uint8 gamma; // 1 byte, slot 7 (start new slot after array)
}
contract test {
function f(uint256 x, uint256 y) returns (uint256 z) {
var c = x + 3;
Expand All @@ -554,14 +547,12 @@ contract test {
}
}
contract test {
function f(uint256 x, uint256 y) returns (uint256 z) {
return 10;
}
}
contract c {
function() returns (uint256) {
return g(8);
Expand All @@ -583,15 +574,13 @@ contract c {
mapping(uint256 => uint256) data;
}
contract Sharer {
function sendHalf(address addr) returns (uint256 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 @@ -655,7 +644,6 @@ library IntegerSet {
}
}
/// How to use it:
contract User {
/// Just a struct holding our data.
Expand All @@ -679,7 +667,6 @@ contract User {
}
}
// This broke it at one point (namely the modifiers).
contract DualIndex {
mapping(uint256 => mapping(uint256 => uint256)) data;
Expand Down Expand Up @@ -711,26 +698,20 @@ contract DualIndex {
}
}
contract A {}
contract B {}
contract C is A, B {}
contract TestPrivate {
uint256 private value;
}
contract TestInternal {
uint256 internal value;
}
contract FromSolparse is A, B, TestPrivate, TestInternal {
function() {
uint256 a = 6**9;
Expand All @@ -739,7 +720,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 @@ -750,26 +730,22 @@ contract CommentedOutFunction {
// }
}
library VarHasBrackets {
string constant specialRight = "}";
//string storage specialLeft = "{";
}
library UsingExampleLibrary {
function sum(uint256[] storage self) returns (uint256 s) {
for (uint256 i = 0; i < self.length; i++) s += self[i];
}
}
contract UsingExampleContract {
using UsingExampleLibrary for *;
using UsingExampleLibrary for uint256[];
}
contract NewStuff {
uint256[] b;
Expand All @@ -779,13 +755,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 @@ -807,7 +781,6 @@ library GetCode {
}
}
contract assemblyLocalBinding {
function test() {
assembly {
Expand All @@ -819,7 +792,6 @@ contract assemblyLocalBinding {
}
}
contract assemblyReturn {
uint256 a = 10;
Expand All @@ -833,12 +805,10 @@ contract assemblyReturn {
}
}
contract usesConst {
uint256 const = 0;
}
contract memoryArrays {
uint256 seven = 7;
Expand All @@ -852,7 +822,6 @@ contract memoryArrays {
}
}
contract DeclarativeExpressions {
uint256 a;
uint256 b = 7;
Expand All @@ -874,7 +843,6 @@ contract DeclarativeExpressions {
}
}
contract VariableDeclarationTuple {
function getMyTuple() returns (bool, bool) {
return (true, false);
Expand All @@ -891,13 +859,11 @@ contract VariableDeclarationTuple {
}
}
contract TypeIndexSpacing {
uint256[7] x;
uint256[] y;
}
contract Ballot {
struct Voter {
uint256 weight;
Expand Down Expand Up @@ -934,14 +900,12 @@ contract Ballot {
Voter airbnb = Voter({weight: 2, voted: true});
}
contract multilineReturn {
function a() returns (uint256 x) {
return 5;
}
}
contract continueStatement {
function a() {
while (true) {
Expand All @@ -950,10 +914,8 @@ contract continueStatement {
}
}
abstract contract AbstractContract {}
contract ContractWithVirtual {
function foo() public virtual returns (uint256) {}
}
Expand All @@ -976,7 +938,6 @@ contract B is A {
function doStuff() public override {}
}
contract Overrides {
mapping(address => bool) public override varName;
Expand Down
1 change: 0 additions & 1 deletion tests/Arrays/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ contract Arrays {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pragma solidity ^0.5.2;
contract Arrays {
bytes32[] public permissions = [
bytes32("addPartner"),
Expand Down
7 changes: 0 additions & 7 deletions tests/BinaryOperators/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ contract ArithmeticOperators {
}
}
contract ArithmeticOperators {
// ['**']
function someFunction() {
Expand Down Expand Up @@ -358,7 +357,6 @@ contract ArithmeticOperators {
}
}
contract ShiftOperators {
// ['<<', '>>']
function someFunction() {
Expand Down Expand Up @@ -391,7 +389,6 @@ contract ShiftOperators {
}
}
contract BitOperators {
// ['&', '|', '^']
function someFunction() {
Expand Down Expand Up @@ -427,7 +424,6 @@ contract BitOperators {
}
}
contract ComparisonOperators {
// ['<', '>', '<=', '>=', '==', '!=']
function someFunction() {
Expand Down Expand Up @@ -517,7 +513,6 @@ contract ComparisonOperators {
}
}
contract AssignmentOperators {
// ['=', '|=', '^=', '&=', '<<=', '>>=', '+=', '-=', '*=', '/=', '%=']
function someFunction() {
Expand Down Expand Up @@ -568,7 +563,6 @@ contract AssignmentOperators {
}
}
contract LogicalOperators {
// ['&&', '||']
function someFunction() {
Expand Down Expand Up @@ -811,7 +805,6 @@ contract Parentheses {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pragma solidity 0.5.8;
contract Parentheses {
function() {
a + b + c;
Expand Down
Loading

0 comments on commit 5b043cd

Please sign in to comment.