sbt-eclipse icon indicating copy to clipboard operation
sbt-eclipse copied to clipboard

`def setting` is in a private object on master, how to access?

Open godenji opened this issue 10 years ago • 8 comments

Must be missing something: https://github.com/typesafehub/sbteclipse/blob/master/src/main/scala/com/typesafe/sbteclipse/core/Eclipse.scala

What is the point? Looks the above will compile and that's about it, every top level object/class is private o_O

EclipseTransformerFactory rewrites all break in attempted move to 4.0 RC2. Thanks for clues.

godenji avatar May 23 '15 17:05 godenji

I'm not sure I understand the problem that you're having. Can you post the code for what you're trying to do, what you expect to happen, and what actually happens?

benmccann avatar May 24 '15 02:05 benmccann

@benmccann hey, the problem is that previously, on <= 3.0.0, def setting(...) was publicly available in core.package.scala but is now in core.Eclipse which is a private object.

Again, I must be missing something, but AFAICT core.Eclipse.scala is there to generate heat. What do you guys do with a source file where all top level class/object are private?

Basically I just need to access at least def setting(...) again as my rewrites fail without it:

new EclipseTransformerFactory[RewriteRule] {
  override def createTransformer(ref: ProjectRef, state: State): Validation[RewriteRule] = {
    setting(crossTarget in ref, state).map{ct=>
      ....
    }
  }
}

godenji avatar May 24 '15 05:05 godenji

What do you mean by "generate heat"? Are you asking where the class is used? Here's one place

You're welcome to submit a PR to make that class public if it helps you.

benmccann avatar May 24 '15 16:05 benmccann

I mean that I didn't think one could access an object outside of the source file in which it is defined if marked as private -- therefore, generate heat in the Haskell sense of doing nothing ;-) Apparently not the case, must be package private by default.

Can issue a pull request, but presumably there's a reason it's private (as in there are things that need to be hidden from the user). If not, and it should be public, let me know, I'll do the necessary.

godenji avatar May 24 '15 17:05 godenji

You could also move the setting method back to package.scala. Or you could simply define your own in your code since it's only a few lines to copy

benmccann avatar May 24 '15 17:05 benmccann

Those options work. I know you guys are trying to get 4.0 released, but it would be nice to do the "right" thing in terms of exposing (or not) the contents of the Eclipse object.

Maybe @jsuereth or @eed3si9n will have some feedback here re: what course to take if any. Not in a huge rush on my end, was just hoping to try the 4.0 RC with recently released Scala IDE 4.1

godenji avatar May 24 '15 17:05 godenji

I just simplified the method, so it's only a few lines if you want to copy it into your own project:

def setting[A](key: SettingKey[A], state: State): A = key.get(structure(state).data).getOrElse {
  throw new IllegalStateException("Undefined setting '%s in %s'!".format(key.key, key.scope))
 }

benmccann avatar May 27 '15 18:05 benmccann

@benmccann thanks, I'll give the RC a spin again ;-)

godenji avatar May 28 '15 16:05 godenji