Skip to content

Functional visitor, Java 8, comments#84

Open
nightscape wants to merge 12 commits intotimowest:masterfrom
nightscape:functional_visitor
Open

Functional visitor, Java 8, comments#84
nightscape wants to merge 12 commits intotimowest:masterfrom
nightscape:functional_visitor

Conversation

@nightscape
Copy link
Copy Markdown

Hi @timowest,

I've dug much deeper than I initially planned and made quite some changes to scalagen, but I hope they pay off:

  • I replaced the Maven build by an SBT one which gives much nicer compilation speed and other goodies and is the de facto standard for most Scala projects.
  • I transformed the statefull ScalaDumpVisitor into a stateless ScalaStringVisitor which instead of modifying a local SourcePrinter returns Strings in all visit methods.
  • Formatting is now handled by Scalafmt which gives much more flexibility on how to format code and reduces the complexity of scalagen a little.
  • The Java parser library is updated to a version that supports Java 8 and the corresponding visit methods implemented, so we should be able to transform Java 8 code (most likely there's some bugs in there, which we can fix as we discover them)
  • Comments are copied as good as possible. There's still some edge cases where they can get lost, especially when multiple comments occur in a row.

It would be great if you could have a look at this so we can start discussing on how to integrate and release this. If I have time, I'll publish a build on Bintray so that people can already start trying this out and finding bugs 😉

Phew, that was a journey! 😄

This gets rid of the shared mutable printer instance and its requirement to call
methods in exactly the right order
Super calls in auxiliary constructors are not allowed in Scala.
Replace them with a call this(???) which should either fail to
compile or throw an exception when used.
Also add a big fat note on what to do.
* Run compilations in parallel
* Allow filtering the files to compile by specifying a system property
  (e.g. in SBT via `sys.props += ("test-compile-filter" -> "Java8")`)
* Print the generated Scala code in case of compilation errors
using JUnit's Parameterized runner.
@matozoid
Copy link
Copy Markdown

matozoid commented Sep 6, 2017

As the maintainer of JavaParser I would say: PLEASE merge this because your dependency is way out of date!

* Maven: add scalafmt dependency [fix]

* Maven: make the build more robust (removes some build warnings)

* Maven: compile as Java 8 sources (was Java 7) [fix]

* Maven: indents cleanup

* Maven: update to latest scala 2.11.x (2.11.6 -> 2.11.8)

* Maven plugin: cleanup (just moving things around)

* Maven plugin: modernize a lot & updates & fixes

* Maven plugin: make the build more robust (gets rid of some warnings)

* README: update to latest version

* README: add maven dev instructions

* Fix small typo
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