Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Use scalacOptions to configure ch.epfl.lamp.sdt.core.prefs #40

Closed
ijuma opened this Issue · 17 comments

5 participants

@ijuma

This should probably be optional, but it would be nice to configure scalac options in Eclipse from scalacOptions in SBT.

@gkossakowski

Upvote this one. It's really tiresome to configure Eclipse again once sbt has been configured.

@hseeberger
Owner

This one mandates an Eclipse expert. I have been one, but that was in another age. So please feel free to jump in: Fork, change, test and send a pull request. Looking forward to your contributions!

@gkossakowski

I don't think Eclipse expert is needed here. All those settings are stored in simple property file. See:

$ cat .settings/org.scala-ide.sdt.core.prefs
#Wed Sep 21 12:29:20 CEST 2011
P=continuations\:enable
Xcheck-null=false
Xcheckinit=false
Xdisable-assertions=false
Xelide-below=-2147483648
Xexperimental=false
Xfatal-warnings=false
Xfuture=false
Xlog-implicits=false
Xmigration=false
Xno-uescape=false
Xplugin=/Users/grek/scalagwt/scalagwt-sample/lib/scala/factorymanifests.jar
Xpluginsdir=
Ybuild-manager-debug=false
[..]

All it takes is to map Sbt settings to values in this property file. I don't have any free cycles left to spend on it, though.

@hseeberger
Owner

Thanks for your hint.

Nevertheless it does not look that trivial. In a test project I enabled "Use Project Settings" for the Scala Compiler and I got a whole lot more, e.g. settings for coloring, formatting, although I did not touch the check boxes for these. Looks like a can of worms ...

@viktorklang
Owner

I opened #53 because that limited subset is clearly not a can of worms.

@gkossakowski

I believe that there's no can of worms here. Just generate org.scala-ide.sdt.core.prefs and ignore the rest. If you don't generate other files Eclipse should fallback on defaults.

@skyluc or @dragos should give us confirmation that it's safe thing to do.

@dragos
Owner

AFAIK it's correct. Here's a sample of that file:

https://gist.github.com/1339152

The important thing is to add 'scala.compiler.useProjectSettings=true' so that Eclipse does not use the default, per-workspace, settings.

@hseeberger
Owner

And the file name is org.scala-ide.sdt.core.prefs?

@dragos
Owner

yes, and it lives inside your project, under .settings/.

@hseeberger
Owner

Now the can of worms is opening ...

sbt gives me scalacOptions like this:
-unchecked
-deprecation

First, I have to get rid of the leading "-". No problem.
But how should I know what value to use? E.g.
unchecked=false

@dragos
Owner

What does SBT give you? The compiler Setting object, or its own class that wraps a setting? If it's the compiler setting, you can use 'value' to retrieve the current value for that setting.

@hseeberger
Owner

From sbt I get scalacOptions which is just a Seq[String], e.g. Seq("-unchecked", "-deperecation"). It looks like in Eclipse I need to provide values, e.g. unchecked=false etc.

@hseeberger hseeberger closed this
@viktorklang
Owner
@dragos
Owner

It's a bit more complicated, because there are options that aren't boolean, such as phase names or strings (say -g:vars, -P:continuation:enable, etc). A more general scheme would be:

  • strip the leading '-', and parse until the first separator (should be only ':'). This is the name of the option
  • if the remainder is empty, it's a boolean. Otherwise try to use it as a number (for elide-below). If it fails, it's a string.
  • you probably need some escaping as well.

All types of settings are 'documented' here: https://github.com/scala/scala/blob/master/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala

@hseeberger hseeberger reopened this
@hseeberger
Owner

Looks like I have found the proper regex: """-?([^:]):?(.)"""
Will publish a snapshot today. Please test then.

@viktorklang
Owner

Yo da man

@gkossakowski

Wanted build this locally and try it out but run into #60.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.