-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Decompile while loops and remove empty packages #4250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decompile while loops and remove empty packages #4250
Conversation
0f8fe6f
to
2d862bc
Compare
2d862bc
to
af822e1
Compare
@@ -40,6 +49,12 @@ class DecompilerPrinter(_ctx: Context) extends RefinedPrinter(_ctx) { | |||
decl ~~ typeText(nameIdText(tree)) ~ withEnclosingDef(tree) { toTextTemplate(impl) } ~ "" | |||
} | |||
|
|||
override protected def toTextTemplate(impl: Template, ofNew: Boolean = false): Text = { | |||
val Template(constr, parents, self, preBody) = impl | |||
val impl1 = Template(constr, parents.filterNot(_.symbol.maybeOwner == defn.ObjectClass), self, preBody) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val impl1 = impl.copy(parents = impl1.parents.filterNot(_.symbol.maybeOwner == defn.ObjectClass))
@@ -29,8 +36,10 @@ class DecompilerPrinter(_ctx: Context) extends RefinedPrinter(_ctx) { | |||
case _ => toTextGlobal(stats, "\n") | |||
} | |||
val bodyText = | |||
if (currentPrecedence == TopLevelPrec) "\n" ~ statsText else " {" ~ statsText ~ "}" | |||
keywordStr("package ") ~ toTextPackageId(tree.pid) ~ bodyText | |||
if (tree.pid.symbol.isEmptyPackage) statsText |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this case redundant since you discard it on line 42 if tree.pid.symbol.isEmptyPackage
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The body is the only part that is not discarded
if (tree.pid.symbol.isEmptyPackage) statsText | ||
else if (currentPrecedence == TopLevelPrec) "\n" ~ statsText | ||
else " {" ~ statsText ~ "}" | ||
(keywordStr("package ") ~ toTextPackageId(tree.pid)).provided(!tree.pid.symbol.isEmptyPackage) ~ bodyText |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tree.pid.symbol
same as tree.symbol
?
No description provided.