Skip to content

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