Support/workaround for no-default Predef settings?

For a while (Lightbend) Scala supported Predef disabling flags -Yno-predef and -Yno-imports - they help get get rid of some of scala.Predef quirks by not importing it in the first place and allowing for import my.Predef._ instead. Currently this approach is not really supported, but workable. Built-in types are highlighted as normal classes, and if one forget to import it compilation will fail, while syntax highlighting shows no issue.

However there is an ongoing PR that was already merged in Typelevel Scala that adds support for -Ysysdef and -Ypredef where one can configure own import lines that should land for every compiler file (and so one doesn't have to add import my.Predef._ everywhere). However, this one is much more annoying as it results with cannot resolve symbol  for things that were not present in original scala.Predef.

I cannot expect that Intellij would add support for feature that is not (yet?) very popular, but are there some existing settings, that could help me get rid of those errors? Alternatively, if this could be resolved by e.g. writing addon or plugin where can I find some samples for Intellij Scala extension?

1 comment
Comment actions Permalink

We have a ticket for this for quite a while, but it is not implemented yet. 
https://youtrack.jetbrains.com/issue/SCL-7735

I don't know any workaround for this problem except for completely disabling error highlighting: 
https://www.jetbrains.com/help/idea/working-with-type-aware-highlighting.html#enable_disable_highlighting

You may try to make a pull request to the plugin itself:
https://github.com/jetbrains/intellij-scala

I would start with a text search of "scala.Predef" in our sources. Also to get scalac options, you'll probably need `org.jetbrains.plugins.scala.project.ProjectPsiElementExt.module` and `org.jetbrains.plugins.scala.project.ModuleExt.scalaCompilerSettings` extension methods. 

Feel free to ask more questions if you decide to do it.

0

Please sign in to leave a comment.