如何让Scala编译器插件在Scala IDE中工作 [英] How to get Scala Compiler Plugin to work in Scala IDE

查看:428
本文介绍了如何让Scala编译器插件在Scala IDE中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:这是对Scala-IDE邮件列表上的同一个问题的确切转发,我在那里收到了0条回复,并在5天后放弃等待。

我在写一个Scala编译器插件。它目前调用
scalawrapper(但我可能会找到一个更好的名称)。我安装了
Typesafe Stack,我把我的插件放在下面:

I'm writing a Scala Compiler Plugin. It's currently called scalawrapper (but I might find a better name later). I have the Typesafe Stack installed, and I put my plugin in it under:

C:\Program Files\typesafe-stack\misc\scala-devel\plugins

像这样:

scalac -classpath ... -Xplugin-require:scalawrapper test\...

,它会自动找到并使用我的插件。

and it finds and uses my plugin automatically.

我只是不能得到Scala-IDE使用它。我总是得到
缺少必需的插件:scalawrapper 。在项目属性
\Scala编译器(使用项目设置)\高级选项卡中,我已经在Xplugin-require字段中输入了
scalawrapper,并且这样工作,因为我得到
错误。但是没有什么我可以输入Xpluginsdir似乎有任何
效果。

Unfortunately, I just can't get the Scala-IDE to use it. I always get Missing required plugin: scalawrapper. In the "Project Properties \Scala Compiler (Use Project Settings)\Advanced" tab, I have entered scalawrapper in the Xplugin-require field, and that works, since I get the error. But nothing I can type in Xpluginsdir seem to have any effect.

我尝试了上面给出的绝对路径,尝试了forward
,反斜杠,尝试了一个没有空格的临时目录
,已经尝试相对于项目目录,已经尝试相对
到工作区。它只是不会使用任何东西。我还应该注意,
是不是特定于我自己的插件,因为我试图使用ScalaCL
插件之前在以前的版本的Scala-IDE,失败了
的确切同样的原因。

I have tried the absolute path given above, have tried with forward and backward slashes, have tried a temporary directory without spaces in it, have tried relative to project directory, have tried relative to workspace. It just will not use anything. I should also note that is is not specific to my own plugin, as I tried to use the ScalaCL plugin before in a previous version of the Scala-IDE, and failed for the exact same reason.

我刚刚更新今天(15.10.2011),所以应该有最新的
版本(似乎我可以明确地设置缩进4,
,但也许我只是忽略了过去的设置)。

I have just updated today (15.10.2011) and so should have the latest version (it seems I can finally explicitly set the indentation to 4, but maybe I just overlooked the setting in the past).

有人可以告诉我它实际上的期望,什么是用作
默认当我不在Xpluginsdir放什么?

Can someone tell me what it actually expects, and what is uses as default when I don't put anything in Xpluginsdir?

推荐答案

Scala IDE使用演示编译器,而不是您安装的编译器。要使用插件,使用Scala IDE,您需要在Eclipse的首选项中指定它。

The Scala IDE uses the presentation compiler, not the compiler that you've installed. To use a plugin, with Scala IDE, you need to specify it in the preferences in Eclipse.

尝试 Windows-> Preferences-> Scala-> Compiler 。请参阅高级选项卡。

Try Windows->Preferences->Scala->Compiler. See the Advanced tab. The paths are relative to the workspace.

编辑:当我相对于工作空间说的时候,我的意思是存储.metadata的实际工作空间目录( $ workspace_loc )。我有一个项目,其中包括源代码的项目文件存储在一个目录,工作空间在其他地方,即 $ project_loc (c:\code\project \源)不同于 $ workspace_loc (c:\ code\project\workspace)。在编译器参数中指定的目录是相对于工作空间( $ workspace_loc )。

When I say relative to the workspace, I mean the actual workspace directory under which the .metadata is stored ($workspace_loc). I have a project where project files including the source code is stored in one directory and the workspace is elsewhere, i.e the $project_loc (c:\code\project\source) is different from the $workspace_loc (c:\code\project\workspace). The directory that you specify in the compiler parameters is relative to the workspace ($workspace_loc).

如果您有类似的设置,请转到该项目并选择 Properties-> Resource-> Linked Resources

To find out if you have a similar setup, go to the project and select Properties->Resource->Linked Resources.

我在 $ workspace_loc 下创建了一个名为plugin的目录,并将jar文件放在那里。 Windows->偏好设置 - > Scala->编译器高级选项卡

I created a directory under $workspace_loc called plugin and placed the jar file in there. Under Windows->Preferences->Scala->Compiler Advanced tab I have

Xplugin = C:\code\project\workspace\plugin\xxx-0.0.1.jar
Xplugin-require = xxx

请注意,您也可以在项目属性中指定插件,但它仍然使用 $ workspace_loc 。上述配置适用于我。

Please note that you can specify the plugin in the project properties as well, but it still uses $workspace_loc. The above configuration works for me.

这篇关于如何让Scala编译器插件在Scala IDE中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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