Skip to content

output cleanup - #501

Merged
tomblind merged 14 commits into
masterfrom
output-cleanup
Apr 3, 2019
Merged

output cleanup#501
tomblind merged 14 commits into
masterfrom
output-cleanup

Conversation

@tomblind

Copy link
Copy Markdown
Collaborator

Removed wrapping all binary & unary expressions in parenthesis and fixed issues that arose. Also removed empty string literals from template strings.

I'd like to test this against some real code bases and see how fragile it is.

Comment thread src/LuaTransformer.ts
Comment thread src/LuaTransformer.ts Outdated
Comment thread test/unit/expressions.spec.ts
@tomblind
tomblind marked this pull request as ready for review April 1, 2019 19:34
tomblind added 2 commits April 2, 2019 07:29
- using `function foo()` syntax instead of `foo = function()`
  - Exception made for assigned function expressions
- inlining arrow functions with no body
- also stripping empty do...end statements
@tomblind

tomblind commented Apr 2, 2019

Copy link
Copy Markdown
Collaborator Author

Added to this PR:

  • functions are now output as function foo() instead of foo = function(), except for methods which were assigned as function expressions in the original TS
  • arrow functions with no body are inlined
  • arrow functions with no parameters don't include the dummy parameter ____, since it's not necessary
  • empty do...end statements are not generated
  • continue labels are only output if the loop actually has a continue statement

Comment thread src/LuaPrinter.ts Outdated
Comment thread src/LuaTransformer.ts
Comment thread src/LuaTransformer.ts
Comment thread src/LuaTransformer.ts
Comment thread src/LuaTransformer.ts Outdated
Comment thread src/LuaTransformer.ts Outdated
Comment thread src/LuaPrinter.ts
@tomblind

tomblind commented Apr 3, 2019

Copy link
Copy Markdown
Collaborator Author

Last addition to this PR: tables with more than one entry are now formatted into multiple lines.

@tomblind
tomblind requested a review from Perryvw April 3, 2019 13:18
Comment thread src/LuaTransformer.ts Outdated
Comment thread src/TSHelper.ts
Comment thread test/unit/loops.spec.ts Outdated
Comment thread src/LuaPrinter.ts Outdated
Comment thread src/LuaPrinter.ts Outdated
@tomblind

tomblind commented Apr 3, 2019

Copy link
Copy Markdown
Collaborator Author

Updated with fixes for feedback

Comment thread src/LuaPrinter.ts Outdated

@Perryvw Perryvw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely certain on adding the parentheses inside printFunctionParameters, I personally would have put them in the function header printing. I doubt it really matters though, so approved 👍

@tomblind
tomblind merged commit 422a36a into master Apr 3, 2019
@tomblind
tomblind deleted the output-cleanup branch April 3, 2019 21:34
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

Successfully merging this pull request may close these issues.

2 participants