- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Change in the Scala compiler
Mon, 2010-04-12, 13:03
Hello,
I was trying to update a maven tool that I want to use (scala-mojo-support) but does not work with Scala 2.8.0.Beta1, most changes I made were straight forward but there is one that I do not see how to fix.
The plugin use an Annotation class from scala.tools.nsc.ast, in 2.7 there was this definition:
/** Annotation application (constructor arguments + name-value pairs) */
case class Annotation(constr: Tree, elements: List[Tree])
extends TermTree
But it is not present in 2.8 and I do not see any obvious alternative. What class should be used instead?
regards,
Oscar
Mon, 2010-04-12, 15:47
#2
Re: Change in the Scala compiler
Oscar, I'm glad someone is cleaning up my projects ;) Let me know how I can help. I'm pretty swamped right now with other higher priority items, but I'll help out as I can.
- Josh
On Mon, Apr 12, 2010 at 9:40 AM, Lukas Rytz <lukas.rytz@epfl.ch> wrote:
- Josh
On Mon, Apr 12, 2010 at 9:40 AM, Lukas Rytz <lukas.rytz@epfl.ch> wrote:
The "elements" part was removed in 2.8 because we can now represent them
with named arguments. Therefore, the "Annotation(constr: Tree)" became a no-op
and we removed it. Just put the annotation constructor call where you'd have
put the "Annotation" tree before.
Lukas
On Mon, Apr 12, 2010 at 14:03, Oscar Forero <oscar.forero@computer.org> wrote:
Hello,
I was trying to update a maven tool that I want to use (scala-mojo-support) but does not work with Scala 2.8.0.Beta1, most changes I made were straight forward but there is one that I do not see how to fix.
The plugin use an Annotation class from scala.tools.nsc.ast, in 2.7 there was this definition:
/** Annotation application (constructor arguments + name-value pairs) */
case class Annotation(constr: Tree, elements: List[Tree])
extends TermTree
But it is not present in 2.8 and I do not see any obvious alternative. What class should be used instead?
regards,
Oscar
Mon, 2010-04-12, 16:47
#3
Re: Change in the Scala compiler
Hello,
Does that also explains why a call to classDef.mods.annotations returns an empty list?
the classDef definitely has a class with annotations:
[INFO] TRACER: classDef: @org.scala_tools.maven.mojo.annotations.goal("echo") @org.scala_tools.maven.mojo.annotations.phase("process-sources") [INFO] class TestMojo extends org.apache.maven.plugin.AbstractMojo with ScalaObject {[INFO] def this(): org.scala_tools.mojo.TestMojo = {[INFO] TestMojo.super.this();[INFO] ()[INFO] };[INFO] @org.scala_tools.maven.mojo.annotations.parameter @org.scala_tools.maven.mojo.annotations.expression("${project.build.directory}") [INFO] private[this] var outputDirectory: java.io.File = _;[INFO] <accessor> def outputDirectory: java.io.File = TestMojo.this.outputDirectory;[INFO] <accessor> def outputDirectory_=(x$1: java.io.File): Unit = TestMojo.this.outputDirectory = x$1;[INFO] @org.scala_tools.maven.mojo.annotations.parameter @org.scala_tools.maven.mojo.annotations.expression("${project}") @org.scala_tools.maven.mojo.annotations.readOnly [INFO] private[this] var project: org.apache.maven.project.MavenProject = _;[INFO] <accessor> def project: org.apache.maven.project.MavenProject = TestMojo.this.project;[INFO] <accessor> def project_=(x$1: org.apache.maven.project.MavenProject): Unit = TestMojo.this.project = x$1;[INFO] @throws(classOf[org.apache.maven.plugin.MojoExecutionException]) [INFO] override def execute(): Unit = {[INFO] if (TestMojo.this.outputDirectory.exists().unary_!)[INFO] TestMojo.this.outputDirectory.mkdirs()[INFO] else[INFO] ();[INFO] val file: java.io.File = new java.io.File(TestMojo.this.outputDirectory, "echo.txt");[INFO] val output: java.io.PrintStream = new java.io.PrintStream(new java.io.FileOutputStream(file));[INFO] output.println("HAI");[INFO] output.close()[INFO] }[INFO] }
Any ideas? do the methods get populated at a different compiler phase? in the original code was apparently stopping at the "typer"
regards,
Oscar
On Apr 12, 2010, at 3:40 PM, Lukas Rytz wrote:
Does that also explains why a call to classDef.mods.annotations returns an empty list?
the classDef definitely has a class with annotations:
[INFO] TRACER: classDef: @org.scala_tools.maven.mojo.annotations.goal("echo") @org.scala_tools.maven.mojo.annotations.phase("process-sources") [INFO] class TestMojo extends org.apache.maven.plugin.AbstractMojo with ScalaObject {[INFO] def this(): org.scala_tools.mojo.TestMojo = {[INFO] TestMojo.super.this();[INFO] ()[INFO] };[INFO] @org.scala_tools.maven.mojo.annotations.parameter @org.scala_tools.maven.mojo.annotations.expression("${project.build.directory}") [INFO] private[this] var outputDirectory: java.io.File = _;[INFO] <accessor> def outputDirectory: java.io.File = TestMojo.this.outputDirectory;[INFO] <accessor> def outputDirectory_=(x$1: java.io.File): Unit = TestMojo.this.outputDirectory = x$1;[INFO] @org.scala_tools.maven.mojo.annotations.parameter @org.scala_tools.maven.mojo.annotations.expression("${project}") @org.scala_tools.maven.mojo.annotations.readOnly [INFO] private[this] var project: org.apache.maven.project.MavenProject = _;[INFO] <accessor> def project: org.apache.maven.project.MavenProject = TestMojo.this.project;[INFO] <accessor> def project_=(x$1: org.apache.maven.project.MavenProject): Unit = TestMojo.this.project = x$1;[INFO] @throws(classOf[org.apache.maven.plugin.MojoExecutionException]) [INFO] override def execute(): Unit = {[INFO] if (TestMojo.this.outputDirectory.exists().unary_!)[INFO] TestMojo.this.outputDirectory.mkdirs()[INFO] else[INFO] ();[INFO] val file: java.io.File = new java.io.File(TestMojo.this.outputDirectory, "echo.txt");[INFO] val output: java.io.PrintStream = new java.io.PrintStream(new java.io.FileOutputStream(file));[INFO] output.println("HAI");[INFO] output.close()[INFO] }[INFO] }
Any ideas? do the methods get populated at a different compiler phase? in the original code was apparently stopping at the "typer"
regards,
Oscar
On Apr 12, 2010, at 3:40 PM, Lukas Rytz wrote:
The "elements" part was removed in 2.8 because we can now represent them
with named arguments. Therefore, the "Annotation(constr: Tree)" became a no-op
and we removed it. Just put the annotation constructor call where you'd have
put the "Annotation" tree before.
Lukas
On Mon, Apr 12, 2010 at 14:03, Oscar Forero <oscar.forero@computer.org> wrote:
Hello,
I was trying to update a maven tool that I want to use (scala-mojo-support) but does not work with Scala 2.8.0.Beta1, most changes I made were straight forward but there is one that I do not see how to fix.
The plugin use an Annotation class from scala.tools.nsc.ast, in 2.7 there was this definition:
/** Annotation application (constructor arguments + name-value pairs) */
case class Annotation(constr: Tree, elements: List[Tree])
extends TermTree
But it is not present in 2.8 and I do not see any obvious alternative. What class should be used instead?
regards,
Oscar
Tue, 2010-04-13, 07:17
#4
Re: Change in the Scala compiler
Annotations are removed from the Modifiers during type-checking. Instead,
they are added to the "annotations" of the definition's Symbol.
Have a look at this document: http://www.scala-lang.org/sid/5
Lukas
On Mon, Apr 12, 2010 at 17:33, Oscar Forero <oscar.forero@computer.org> wrote:
they are added to the "annotations" of the definition's Symbol.
Have a look at this document: http://www.scala-lang.org/sid/5
Lukas
On Mon, Apr 12, 2010 at 17:33, Oscar Forero <oscar.forero@computer.org> wrote:
Hello,
Does that also explains why a call to classDef.mods.annotations returns an empty list?
the classDef definitely has a class with annotations:
[INFO] TRACER: classDef: @org.scala_tools.maven.mojo.annotations.goal("echo") @org.scala_tools.maven.mojo.annotations.phase("process-sources") [INFO] class TestMojo extends org.apache.maven.plugin.AbstractMojo with ScalaObject { [INFO] def this(): org.scala_tools.mojo.TestMojo = {[INFO] TestMojo.super.this();[INFO] ()[INFO] };[INFO] @org.scala_tools.maven.mojo.annotations.parameter @org.scala_tools.maven.mojo.annotations.expression("${project.build.directory}") [INFO] private[this] var outputDirectory: java.io.File = _;[INFO] <accessor> def outputDirectory: java.io.File = TestMojo.this.outputDirectory;[INFO] <accessor> def outputDirectory_=(x$1: java.io.File): Unit = TestMojo.this.outputDirectory = x$1; [INFO] @org.scala_tools.maven.mojo.annotations.parameter @org.scala_tools.maven.mojo.annotations.expression("${project}") @org.scala_tools.maven.mojo.annotations.readOnly [INFO] private[this] var project: org.apache.maven.project.MavenProject = _; [INFO] <accessor> def project: org.apache.maven.project.MavenProject = TestMojo.this.project;[INFO] <accessor> def project_=(x$1: org.apache.maven.project.MavenProject): Unit = TestMojo.this.project = x$1; [INFO] @throws(classOf[org.apache.maven.plugin.MojoExecutionException]) [INFO] override def execute(): Unit = {[INFO] if (TestMojo.this.outputDirectory.exists().unary_!)[INFO] TestMojo.this.outputDirectory.mkdirs() [INFO] else[INFO] ();[INFO] val file: java.io.File = new java.io.File(TestMojo.this.outputDirectory, "echo.txt");[INFO] val output: java.io.PrintStream = new java.io.PrintStream(new java.io.FileOutputStream(file)); [INFO] output.println("HAI");[INFO] output.close()[INFO] }[INFO] }
Any ideas? do the methods get populated at a different compiler phase? in the original code was apparently stopping at the "typer"
regards,
Oscar
On Apr 12, 2010, at 3:40 PM, Lukas Rytz wrote:
The "elements" part was removed in 2.8 because we can now represent them
with named arguments. Therefore, the "Annotation(constr: Tree)" became a no-op
and we removed it. Just put the annotation constructor call where you'd have
put the "Annotation" tree before.
Lukas
On Mon, Apr 12, 2010 at 14:03, Oscar Forero <oscar.forero@computer.org> wrote:
Hello,
I was trying to update a maven tool that I want to use (scala-mojo-support) but does not work with Scala 2.8.0.Beta1, most changes I made were straight forward but there is one that I do not see how to fix.
The plugin use an Annotation class from scala.tools.nsc.ast, in 2.7 there was this definition:
/** Annotation application (constructor arguments + name-value pairs) */
case class Annotation(constr: Tree, elements: List[Tree])
extends TermTree
But it is not present in 2.8 and I do not see any obvious alternative. What class should be used instead?
regards,
Oscar
Tue, 2010-04-13, 07:47
#5
Re: Change in the Scala compiler
Also take a look at how BeanProperty is implemented in the source, I often find that having a real-life example helps to make sense of things :)
On 13 April 2010 07:15, Lukas Rytz <lukas.rytz@epfl.ch> wrote:
--
Kevin Wright
mail/google talk: kev.lee.wright@googlemail.com
wave: kev.lee.wright@googlewave.com
skype: kev.lee.wright
twitter: @thecoda
On 13 April 2010 07:15, Lukas Rytz <lukas.rytz@epfl.ch> wrote:
Annotations are removed from the Modifiers during type-checking. Instead,
they are added to the "annotations" of the definition's Symbol.
Have a look at this document: http://www.scala-lang.org/sid/5
Lukas
On Mon, Apr 12, 2010 at 17:33, Oscar Forero <oscar.forero@computer.org> wrote:
Hello,
Does that also explains why a call to classDef.mods.annotations returns an empty list?
the classDef definitely has a class with annotations:
[INFO] TRACER: classDef: @org.scala_tools.maven.mojo.annotations.goal("echo") @org.scala_tools.maven.mojo.annotations.phase("process-sources") [INFO] class TestMojo extends org.apache.maven.plugin.AbstractMojo with ScalaObject { [INFO] def this(): org.scala_tools.mojo.TestMojo = {[INFO] TestMojo.super.this();[INFO] ()[INFO] };[INFO] @org.scala_tools.maven.mojo.annotations.parameter @org.scala_tools.maven.mojo.annotations.expression("${project.build.directory}") [INFO] private[this] var outputDirectory: java.io.File = _;[INFO] <accessor> def outputDirectory: java.io.File = TestMojo.this.outputDirectory;[INFO] <accessor> def outputDirectory_=(x$1: java.io.File): Unit = TestMojo.this.outputDirectory = x$1; [INFO] @org.scala_tools.maven.mojo.annotations.parameter @org.scala_tools.maven.mojo.annotations.expression("${project}") @org.scala_tools.maven.mojo.annotations.readOnly [INFO] private[this] var project: org.apache.maven.project.MavenProject = _; [INFO] <accessor> def project: org.apache.maven.project.MavenProject = TestMojo.this.project;[INFO] <accessor> def project_=(x$1: org.apache.maven.project.MavenProject): Unit = TestMojo.this.project = x$1; [INFO] @throws(classOf[org.apache.maven.plugin.MojoExecutionException]) [INFO] override def execute(): Unit = {[INFO] if (TestMojo.this.outputDirectory.exists().unary_!)[INFO] TestMojo.this.outputDirectory.mkdirs() [INFO] else[INFO] ();[INFO] val file: java.io.File = new java.io.File(TestMojo.this.outputDirectory, "echo.txt");[INFO] val output: java.io.PrintStream = new java.io.PrintStream(new java.io.FileOutputStream(file)); [INFO] output.println("HAI");[INFO] output.close()[INFO] }[INFO] }
Any ideas? do the methods get populated at a different compiler phase? in the original code was apparently stopping at the "typer"
regards,
Oscar
On Apr 12, 2010, at 3:40 PM, Lukas Rytz wrote:
The "elements" part was removed in 2.8 because we can now represent them
with named arguments. Therefore, the "Annotation(constr: Tree)" became a no-op
and we removed it. Just put the annotation constructor call where you'd have
put the "Annotation" tree before.
Lukas
On Mon, Apr 12, 2010 at 14:03, Oscar Forero <oscar.forero@computer.org> wrote:
Hello,
I was trying to update a maven tool that I want to use (scala-mojo-support) but does not work with Scala 2.8.0.Beta1, most changes I made were straight forward but there is one that I do not see how to fix.
The plugin use an Annotation class from scala.tools.nsc.ast, in 2.7 there was this definition:
/** Annotation application (constructor arguments + name-value pairs) */
case class Annotation(constr: Tree, elements: List[Tree])
extends TermTree
But it is not present in 2.8 and I do not see any obvious alternative. What class should be used instead?
regards,
Oscar
--
Kevin Wright
mail/google talk: kev.lee.wright@googlemail.com
wave: kev.lee.wright@googlewave.com
skype: kev.lee.wright
twitter: @thecoda
Sun, 2010-04-25, 20:37
#6
Re: Change in the Scala compiler
Hello Josh,
I have a working? mojo extractor, I am trying to figure out my mojo to see if it works, the IT fails for a reason that I have not worked out yet but it is probably maven related. I notice that the output quotes (") all the String values, I do not know if this is expected or not ...
For this to work it is necessary to fix a little problem with the -Ystop or if that is not accepted then use stop = superaccessors.
The code is not pretty, but I having it compiling an running in 2.8.0.RC1 is an step :-)
regards,
Oscar
On Apr 12, 2010, at 4:35 PM, Josh Suereth wrote:
I have a working? mojo extractor, I am trying to figure out my mojo to see if it works, the IT fails for a reason that I have not worked out yet but it is probably maven related. I notice that the output quotes (") all the String values, I do not know if this is expected or not ...
For this to work it is necessary to fix a little problem with the -Ystop or if that is not accepted then use stop = superaccessors.
The code is not pretty, but I having it compiling an running in 2.8.0.RC1 is an step :-)
regards,
Oscar
On Apr 12, 2010, at 4:35 PM, Josh Suereth wrote:
Oscar, I'm glad someone is cleaning up my projects ;) Let me know how I can help. I'm pretty swamped right now with other higher priority items, but I'll help out as I can.
- Josh
On Mon, Apr 12, 2010 at 9:40 AM, Lukas Rytz <lukas.rytz@epfl.ch> wrote:The "elements" part was removed in 2.8 because we can now represent them
with named arguments. Therefore, the "Annotation(constr: Tree)" became a no-op
and we removed it. Just put the annotation constructor call where you'd have
put the "Annotation" tree before.
Lukas
On Mon, Apr 12, 2010 at 14:03, Oscar Forero <oscar.forero@computer.org> wrote:
Hello,
I was trying to update a maven tool that I want to use (scala-mojo-support) but does not work with Scala 2.8.0.Beta1, most changes I made were straight forward but there is one that I do not see how to fix.
The plugin use an Annotation class from scala.tools.nsc.ast, in 2.7 there was this definition:
/** Annotation application (constructor arguments + name-value pairs) */
case class Annotation(constr: Tree, elements: List[Tree])
extends TermTree
But it is not present in 2.8 and I do not see any obvious alternative. What class should be used instead?
regards,
Oscar
Sun, 2010-04-25, 21:07
#7
Re: Change in the Scala compiler
Moving the stop for this plugin should be no issue. You just don't want it to actually compile... it's an after-compile analysis step. If you post to github, I'll take a look when i get some free moments and pull it into my branch as well.
Good work! Glad to know this stuff is useful enough for someone to work on it ;)
- Josh
On Sun, Apr 25, 2010 at 3:32 PM, Oscar Forero <oscar.forero@computer.org> wrote:
Good work! Glad to know this stuff is useful enough for someone to work on it ;)
- Josh
On Sun, Apr 25, 2010 at 3:32 PM, Oscar Forero <oscar.forero@computer.org> wrote:
Hello Josh,
I have a working? mojo extractor, I am trying to figure out my mojo to see if it works, the IT fails for a reason that I have not worked out yet but it is probably maven related. I notice that the output quotes (") all the String values, I do not know if this is expected or not ...
For this to work it is necessary to fix a little problem with the -Ystop or if that is not accepted then use stop = superaccessors.
The code is not pretty, but I having it compiling an running in 2.8.0.RC1 is an step :-)
regards,
Oscar
On Apr 12, 2010, at 4:35 PM, Josh Suereth wrote:Oscar, I'm glad someone is cleaning up my projects ;) Let me know how I can help. I'm pretty swamped right now with other higher priority items, but I'll help out as I can.
- Josh
On Mon, Apr 12, 2010 at 9:40 AM, Lukas Rytz <lukas.rytz@epfl.ch> wrote:The "elements" part was removed in 2.8 because we can now represent them
with named arguments. Therefore, the "Annotation(constr: Tree)" became a no-op
and we removed it. Just put the annotation constructor call where you'd have
put the "Annotation" tree before.
Lukas
On Mon, Apr 12, 2010 at 14:03, Oscar Forero <oscar.forero@computer.org> wrote:
Hello,
I was trying to update a maven tool that I want to use (scala-mojo-support) but does not work with Scala 2.8.0.Beta1, most changes I made were straight forward but there is one that I do not see how to fix.
The plugin use an Annotation class from scala.tools.nsc.ast, in 2.7 there was this definition:
/** Annotation application (constructor arguments + name-value pairs) */
case class Annotation(constr: Tree, elements: List[Tree])
extends TermTree
But it is not present in 2.8 and I do not see any obvious alternative. What class should be used instead?
regards,
Oscar
with named arguments. Therefore, the "Annotation(constr: Tree)" became a no-op
and we removed it. Just put the annotation constructor call where you'd have
put the "Annotation" tree before.
Lukas
On Mon, Apr 12, 2010 at 14:03, Oscar Forero <oscar.forero@computer.org> wrote: