Skip to content

Inline first call in chain depending on heuristics#476

Merged
JohnnyMorganz merged 2 commits intohang-chained-static-funcsfrom
hang-chains-inline-first
Jun 27, 2022
Merged

Inline first call in chain depending on heuristics#476
JohnnyMorganz merged 2 commits intohang-chained-static-funcsfrom
hang-chains-inline-first

Conversation

@JohnnyMorganz
Copy link
Owner

@JohnnyMorganz JohnnyMorganz commented Jun 26, 2022

Heuristics are same as prettier:

  • Prefix begins with uppercase letter, OR
  • Prefix is smaller in length than the indent with

AND inlining doesn't go over width

@github-actions
Copy link
Contributor

Repo Comparison Test

No diff produced

@JohnnyMorganz
Copy link
Owner Author

JohnnyMorganz commented Jun 26, 2022

In conversation - this diff is not necessary and shouldn't reformat:
image

local function interpolateVariables(title: string, template: Template, index: number): string
    return Array.reduce(
        Array.reduce(Object.keys(template), getMatchingKeyPaths(title), {}), -- aka flatMap
        replaceKeyPathWithValue(template),
        title
    ):gsub(
        "%$#", -- ROBLOX deviation: escaped string
        tostring(index),
        1
    )
end

image

@github-actions
Copy link
Contributor

Repo Comparison Test

No diff produced

@JohnnyMorganz JohnnyMorganz merged commit 589498a into hang-chained-static-funcs Jun 27, 2022
@JohnnyMorganz JohnnyMorganz deleted the hang-chains-inline-first branch June 27, 2022 13:16
JohnnyMorganz added a commit that referenced this pull request Jul 5, 2022
* Hang static chained function calls

* Inline first call in chain depending on heuristics (#476)

* Inline first chain call using heuristics

* Keep chain inlined if the first call is inlined and there is only 2 indexes

* Expand call chain if inlined version goes over width
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.

1 participant