Skip to content

updated call & table expression formatting - #639

Merged
Perryvw merged 3 commits into
masterfrom
feature/expression-list-formatting
Jun 29, 2019
Merged

updated call & table expression formatting#639
Perryvw merged 3 commits into
masterfrom
feature/expression-list-formatting

Conversation

@tomblind

Copy link
Copy Markdown
Collaborator

Arguments/fields will now only be split into multiple lines if one or more has evaluation side-effects that would be beneficial for a debugger to step on.

Examples:

func("foo", "bar");
func("foo", "bar")

func(func("foo"), obj.method());
func(
    func("foo"),
    obj:method()
)

func({foo: "bar"});
func({foo = "bar"})

func("foo", () => "bar");
func(
    "foo",
    function() return "bar" end
)

const arr = [1, 2, 4 - 1];
local arr = {1, 2, 4 - 1}

const arr = [func(), obj.method()];
local arr = {
    func(),
    obj:method()
}

const tbl = {foo: "foo"};
local tbl = {foo = "foo"}

const tbl = {foo: func("foo"), bar: obj.method({foo: "foo", bar: () => { console.log("bar"); } })};
local tbl = {
    foo = func("foo"),
    bar = obj:method(
        {
            foo = "foo",
            bar = function()
                print("bar")
            end
        }
    )
}

Arguments/fields will now only be split into multiple lines if one or more has evaluation side-effects that would be beneficial for a debugger to step on.

@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.

I'm okay with this, taking into consideration my one comment.

Comment thread src/LuaPrinter.ts Outdated
return result;
}

protected isSimpleExpression(expression: tstl.Expression): boolean {

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.

Is this maybe a tsHelper function?

@Perryvw
Perryvw merged commit 51a125e into master Jun 29, 2019
@Perryvw
Perryvw deleted the feature/expression-list-formatting branch June 29, 2019 14:09
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