Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ScalafmtRunner: always allow top-level terms #3357

Merged
merged 1 commit into from
Oct 31, 2022

Conversation

kitbellew
Copy link
Collaborator

The formatter's job is not to validate code but to format it.

@@ -64,7 +59,7 @@ case class ScalafmtRunner(
if (null != eventCallback) evts.foreach(eventCallback)

def parse(input: meta.inputs.Input): Parsed[_ <: Tree] =
getParser(input, getDialect)
getParser(input, getDialect.withAllowToplevelTerms(true))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
getParser(input, getDialect.withAllowToplevelTerms(true))
getParser(input, getDialect.withAllowToplevelStatements(true))

don't we want to be most inclusive?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah, didn't realize there were two possible options...

The formatter's job is not to validate code but to format it.
@@ -28,17 +28,17 @@ case class ScalafmtRunner(
fatalWarnings: Boolean = false
) {
@inline private[scalafmt] def getDialect = dialect.dialect
private[scalafmt] lazy val getDialectForParser: Dialect =
getDialect.withAllowToplevelTerms(true).withAllowToplevelStatements(true)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@tgodzik moved it here.

Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

LGTM!

@kitbellew kitbellew merged commit 8266921 into scalameta:master Oct 31, 2022
@kitbellew kitbellew deleted the 3357 branch October 31, 2022 17:06
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants