Skip to content
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

New lines are not created where expected #10

Closed
AdamHarte opened this issue May 1, 2014 · 3 comments
Closed

New lines are not created where expected #10

AdamHarte opened this issue May 1, 2014 · 3 comments

Comments

@AdamHarte
Copy link
Contributor

When I run as3hx on the test folder, a lot of the output is strung together on the same line. I am using the following windows command line:

neko as3hx.n -vector2array -uint2int test\ out\

For example, the contents of the outputted Ifs.hx is:

  /**

 * Tests of assertions in if statements

 **/  import Sprite;
class Ifs
{public function single(a : Sprite){if (a != null) {a.x = 15;
        }
    }public function singleInv(a : Sprite){if (a == null) {a = new Sprite();
        }
    }public function binops(a : Sprite, b : Sprite){if (a != null && b != null)             trace("We have two sprites");if (a != null || b != null)            trace("We have at least one sprite");if (a != null && b == null)            trace("a is ok, b is null");if (a == null && b != null)             trace("a is null, b is ok");
    }public function aBool(b : Bool){  // should parse to if(b)  if (b)             { }  // should parse to if(!b)  if (!b)             { }  // should be left alone as if(b == null)  if (b == null)           { }
    }public function maths(a : Int){  // should parse to if(a++ != 0)  if (a++ != 0)            { }  // should parse to if(a++ == 0)  if (a++ == 0)             { }  // should parse to if(++a++ != 0)  if (++a++ != 0)             { }  // should parse to if(++a++ == 0)  if (++a++ == 0)             { }
    }

    public function new()
    {
    }
}

It seems that some newlines are missing

I am running:
Windows 7
Haxe 3.1.3
as3hx rev: ab16d76

@yanhick
Copy link
Contributor

yanhick commented May 1, 2014

Thanks,
I've pushed a fix in master to support Windows new lines.
This should work but I only tested on linux with Windows formatted files.

@AdamHarte
Copy link
Contributor Author

That is looking great! I am getting valid output on windows now. However there are still a few strange things happening.

In my outputted Ifs.hx I get:

public function aBool(b : Bool){
    // should parse to if(b)
    if (b) {

    }  // should parse to if(!b)  

    if (!b) {

    }  // should be left alone as if(b == null)  

    if (b == null) {

    }
}

I think the comments should be on the line above each if statement, not on the same line of the previous closing brace.

Also in Ifs.hx and Loops.hx, It looks like most blocks do not adhere to my bracesOnNewline flag being set to true.

for (i in 0..._numButtons){
    var btn : ArcButton = new ArcButton();
    btn.id = i;
    if (btn.name != null)               {i++;continue;
    };
    trace(i);
}

That nested if also seems to have no line spaces at all.

Thanks for the fixes so far.

@yanhick
Copy link
Contributor

yanhick commented May 2, 2014

I'm glad it worked !
Could you log a new issue for the bracesOnNewline flag ? Thanks.

For all the small innacuracies, such as the position of the comments, I'm
refactoring
the code so that I'll be able to write unit-test.
Currently, it's hard to fix bugs without introducing regressions so it
should help for the
last details.

2014-05-02 2:26 GMT+02:00 Adam Harte notifications@github.com:

That is looking great! I am getting valid output on windows now. However
there are still a few strange things happening.

In my outputted Ifs.hx I get:

public function aBool(b : Bool){
// should parse to if(b)
if (b) {

}  // should parse to if(!b)

if (!b) {

}  // should be left alone as if(b == null)

if (b == null) {

}

}

I think the comments should be on the line above each if statement, not on
the same line of the previous closing brace.

Also in Ifs.hx and Loops.hx, It looks like most blocks do not adhere to
my bracesOnNewline flag being set to true.

for (i in 0..._numButtons){
var btn : ArcButton = new ArcButton();
btn.id = i;
if (btn.name != null) {i++;continue;
};
trace(i);
}

That nested if also seems to have no line spaces at all.

Thanks for the fixes so far.


Reply to this email directly or view it on GitHubhttps://github.com//issues/10#issuecomment-41972087
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants