Skip to content

Remove printers abstractions from library #10162

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

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Nov 3, 2020

  • Remove printer abstractions (SourceCodePrinter, ExtractorPrinter, SyntaxHighlight)
  • Replaced show(SyntaxHighlighting) with showAnsiColored (kept normal B/W show as is)

@nicolasstucki nicolasstucki force-pushed the make-tasty-printer-work-with-quote-context branch 3 times, most recently from 4449a1a to 0403880 Compare November 4, 2020 08:46
@nicolasstucki nicolasstucki self-assigned this Nov 4, 2020
@nicolasstucki nicolasstucki force-pushed the make-tasty-printer-work-with-quote-context branch 2 times, most recently from 41c514f to 195a996 Compare November 4, 2020 09:47
@nicolasstucki nicolasstucki marked this pull request as ready for review November 4, 2020 13:39
liufengyun
liufengyun previously approved these changes Nov 4, 2020
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

Otherwise, LGTM

package scala.tasty
package reflect
package scala.quoted
package reflection.printers
Copy link
Contributor

Choose a reason for hiding this comment

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

reflection -> reflect?

If we have both names, it's easy to get confused and make mistakes. It would be nice to just use the same name through out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They have a different name to avoid confusion. I tried that but noticed that using reflect is more confusing because you would have qctx.reflect and scala.quoted.reflect in the same scope. It also clashes with scala.reflect which is annoying. scala.quoted.reflection is the one that will be used the less often hence the longer name.

Copy link
Contributor

Choose a reason for hiding this comment

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

If it has to be different, what about choosing a name that does not contain reflect*?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What name could be used? It should be clear that it is about reflection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also wanted to distance the name from tasty to avoid confusion with the file format

Copy link
Contributor

Choose a reason for hiding this comment

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

Can it be just scala.quoted.printers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will also need to move scala.tasty.Reflection and scala.tasty.reflect.* into this package.

scala.quoted
  - Expr, Type, ...
  - reflection (needs better name)
    - Reflection (or rename to Reflect to align with qctx.reflect)
    - printers
      - SourceCode, Extractors and SyntaxHighlighting
    - reflect (needs new name)
      - TreeMap, TreeAcumulator, TreeTraverser

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, naming is always hard. What about scala.quoted.trees or scala.quoted.ast?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like ast, but now I realize that we may no even need to keep this logic in the library.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now I moved to printers out of the library. We never used them in the library anyway, only in the implementation of the QuoteContext. This will also allow us to rewrite them using the compiler trees directly for efficiency if we need it in the future.

@nicolasstucki nicolasstucki force-pushed the make-tasty-printer-work-with-quote-context branch from 195a996 to 0805d53 Compare November 4, 2020 16:51
@nicolasstucki
Copy link
Contributor Author

Rebased

@nicolasstucki nicolasstucki dismissed liufengyun’s stale review November 5, 2020 06:52

Changes will happen

@nicolasstucki nicolasstucki force-pushed the make-tasty-printer-work-with-quote-context branch from ca90ff7 to 96bd7d0 Compare November 5, 2020 08:41
@nicolasstucki nicolasstucki changed the title Make reflect printers depend on quote context Remove printers abstractions from library Nov 5, 2020
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

Otherwise, LGTM

if ctx.settings.color.value == "always" then
qctx.reflect.TreeMethodsImpl.extension_showAnsiColored(tree)
else
qctx.reflect.TreeMethodsImpl.extension_show(tree)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the name change showTree -> showDecompiledTree suggest that the method only works for decompiled trees?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method is only used internally for decompilation. I renamed it to make it clear what it should do to avoid using it somewhere else afterward and changing something inside to adapt to the new use. It also differentiates it from the other general-purpose showTree methods.

@nicolasstucki nicolasstucki force-pushed the make-tasty-printer-work-with-quote-context branch from 65b8689 to da8f531 Compare November 5, 2020 10:27
@nicolasstucki
Copy link
Contributor Author

Rebased

@nicolasstucki nicolasstucki added this to the 3.0.0 milestone Nov 5, 2020
@nicolasstucki nicolasstucki merged commit 3214be3 into scala:master Nov 5, 2020
@nicolasstucki nicolasstucki deleted the make-tasty-printer-work-with-quote-context branch November 5, 2020 12:29
@Kordyjan Kordyjan modified the milestones: 3.0.0-M3, 3.0.0 Aug 2, 2023
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.

3 participants