Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

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

Closed
ijuma opened this Issue Oct 3, 2011 · 17 comments

Comments

Projects
None yet
5 participants

ijuma commented Oct 3, 2011

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

Contributor

gkossakowski commented Oct 17, 2011

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

Contributor

hseeberger commented Oct 20, 2011

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!

Contributor

gkossakowski commented Oct 26, 2011

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.

Contributor

hseeberger commented Oct 28, 2011

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 ...

Owner

viktorklang commented Nov 3, 2011

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

Contributor

gkossakowski commented Nov 3, 2011

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.

Contributor

dragos commented Nov 4, 2011

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.

Contributor

hseeberger commented Nov 4, 2011

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

Contributor

dragos commented Nov 4, 2011

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

Contributor

hseeberger commented Nov 11, 2011

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

Contributor

dragos commented Nov 15, 2011

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.

Contributor

hseeberger commented Nov 16, 2011

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 Nov 16, 2011

Owner

viktorklang commented Nov 16, 2011

output.write("unchecked=" + scalacOptions.contains("-unchecked"))

Contributor

dragos commented Nov 16, 2011

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 Nov 21, 2011

Contributor

hseeberger commented Nov 21, 2011

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

Owner

viktorklang commented Nov 21, 2011

Yo da man

Contributor

gkossakowski commented Nov 22, 2011

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