ScalaMacros和Eclipse [英] ScalaMacros and Eclipse

查看:85
本文介绍了ScalaMacros和Eclipse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用适用于Scala 2.10.0-M3的Scala IDE插件在Eclipse 3.7.2中编译一个(Scala)宏,但是遇到以下错误:

I am trying to compile a (Scala) macro in Eclipse 3.7.2 with the Scala IDE Plugin available for Scala 2.10.0-M3, but I am experiencing the following error:

找不到宏实现:XXXXX(最常见的原因是,您不能在定义宏实现的同一编译运行中使用宏实现),如果您确实需要与其他宏一起定义宏实现程序,请考虑在第二阶段使用-Xmacro-fallback-classpath进行两阶段编译,指向第一阶段的输出.

我已经知道如何使用简单的编辑器和终端(仅遵循错误消息)来避免这种情况,但是有可能在Eclipse中实现双阶段任务吗?

I already know how to avoid it with a simple editor and a terminal (just following the error message), but is it possible to achieve the dual phase task in Eclipse?

推荐答案

如何创建宏项目以链接到现有项目:

How to create a macro project to link to an existing project:

  • 创建一个名为例如ProjectMacros的scala项目,并在其中放入一个包含例如宏的名为Macros.scala的文件.该项目应该编译没有问题,因为只有宏.
  • 在现有的Scala项目,然后单击属性"单击鼠标右键. 属性"窗口打开.
  • Java Build Path部分中:
    • 在的标签添加
    • 在选项卡Libraries下,单击Add Class Folder,然后选择ProjectMacros/bin目录.
    • Create a scala project named for example ProjectMacros, put a file named for example Macros.scala containing macros in it. This project should compile without problems, because there are only macros.
    • Right-click on the existing scala project, then "Properties". The Properties window opens.
    • In the Java Build Path section:
      • Under the tab Projects, add ProjectMacros.
      • Under the tab Libraries, click Add Class Folder, and select the ProjectMacros/bin directory.

      现在,在现有项目中添加import Macros._之类的导入后,您可以使用宏功能和注释.

      Now, after adding in the existing project an import like import Macros._ you can use the macros functions and annotations.

      这篇关于ScalaMacros和Eclipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆