Skip to content

Commit

Permalink
bug fix, import statement in the middle of an AS3 file are now put to…
Browse files Browse the repository at this point in the history
… the beginning of the HAxe file
  • Loading branch information
yanhick committed Sep 4, 2013
1 parent ef61335 commit 2b69091
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
22 changes: 21 additions & 1 deletion as3hx/as3hx/Parser.hx
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ class Parser {
var closed = false;
var inNamespace = false;
var inCondBlock = false;
var outsidePackage = false;

var pf : Bool->Void = null;
pf = function(included:Bool) {
Expand All @@ -445,6 +446,7 @@ class Parser {
}
else if( !closed ) {
closed = true;
outsidePackage = true;
continue;
}
else if (inCondBlock) {
Expand Down Expand Up @@ -473,9 +475,27 @@ class Parser {
switch( id ) {
case "import":
var impt = parseImport();

//outsidePackage = false;
//note : when parsing package, user defined imports
//are stored as meta, this way, comments can be kept
if (impt.length > 0) meta.push(EImport(impt));
if (impt.length > 0) {
if (!outsidePackage) {
meta.push(EImport(impt));
}
//coner case : import for AS3 private class, for those,
//need to add them to regular import list so that they
//get written at the top of file, as in Haxe all imports
//must be at the top of the file
//
//Tradeof is that formatting and comment is lost for
//these imports
else {
imports.push(impt);
}

}

end();
continue;
case "use":
Expand Down
1 change: 1 addition & 0 deletions as3hx/as3hx/Writer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ class Writer
var imported = []; //holds already written types to prevent duplicates
for(i in imports) {
writeImport(i);
writeNL();
}
writeNL();
}
Expand Down

0 comments on commit 2b69091

Please sign in to comment.