creativescala / doodle

Compositional vector graphics in Scala / Scala.JS
https://creativescala.org/doodle/
Apache License 2.0
327 stars 75 forks source link

IntelliJ showing errors when playing around with Examples #98

Closed clemniem closed 2 years ago

clemniem commented 3 years ago

Hello,

I am not sure if this is the right place to ask about this, but the Gitter looked not really used anymore.

Just found this awesome lib and wanted to try it out a little bit, but IntelliJ was showing me always some missing implicits when doing very simple stuff like:

import doodle.core._
import doodle.image._
import doodle.image.syntax._

// those two imports are not mentioned in doc, Edit: this is actually mentioned, don't know where I was looking...
// but I figured out somehow that they should be needed
import doodle.java2d._  
import doodle.java2d.effect._

object SimpleCircle extends App {
  val circle = Image.circle(10).fillColor(Color.red)

  circle.draw() // IntelliJ shows Error --> No implicits found for parameter renderer: DefaultRenderer[Alg_, F_, Frame_, Canvas_]

}

After some time googling I found that this is something from Cats, where Intellij cannot infer the Type, so this fixed the issue:

  circle.draw[Algebra, Drawing, Frame, Canvas]() // No error

Guess this is a no-brainer, when already used to the Cats Lib but since I never really used it this was quite unknown to me. So probably a good Idea to mention this in the First-Steps, to not have newbies blocked at the first very simple example. I can also do a PR but maybe this is already planned for somewhere, so I thought asking first about this would make sense.

Have a great Day and thanks for the cool Library! clem

noelwelsh commented 3 years ago

Can you tell me where in the docs you would expect to see the imports mentioned, so I can add them? I see them on, for example, the Doodle home page so I want to know where you were looking.

You shouldn't need to write

 circle.draw[Algebra, Drawing, Frame, Canvas]()

That's surprising to me. I don't use IntelliJ, though.

Jaxii commented 3 years ago
 circle.draw[Algebra, Drawing, Frame, Canvas]()

IntelliJ throws errors for me as well and won't compile without .draw[Algebra, Drawing, Frame, Canvas]() as opposed to .draw() if that's of any help.

clemniem commented 3 years ago

I was reading:

So I was mixing a little bit, and used the simple code from the "getting-started-from-sbt" but also imported the necessary imports to draw from the Quick Example

I probably would expect this note in the Quick Example, since there it is shown as code being written and not from sbt, so I would assume people pasting this into IntelliJ. Which I also did, but since it was red, I went for an easier one line of simply drawing a circle.

EDIT: concerning the Imports not being mentioned I must have been confused, since they are clearly stated in the quick example, also edited on the first comment.

noelwelsh commented 3 years ago

Ok, thanks. I will update the docs to try to make the imports more explicit.

I have to admit I don't have much energy for fighting IntelliJ issues. I don't know where to even start with that one.

clemniem commented 3 years ago

I have to admit I don't have much energy for fighting IntelliJ issues. I don't know where to even start with that one.

Totally understandable! I will try to find out the issue, as there is a bug for that on the intellij side. Will post it here later. As a simple hint that there is an issue with intellij and not the Doodle Lib would have already helped me a lot, since I thought I am using Doodle wrong.

clemniem commented 3 years ago

I found now on which documentation page I was on, without the imports to draw: https://www.creativescala.org/doodle/image/index.html

And here is the StackOverflow Answer that helped me figure out what is wrong: https://stackoverflow.com/questions/34695616/false-errors-when-using-cats-library-in-intellij

My proposal would be to just include a small warning:

Attention IntelliJ Users The Scala Plugin of IntelliJ still has an open Bug which cannot resolve implicits correctly. Therefore the above example might give you an Error warning in Line XX. To fix it in this small example use circle.draw[Algebra, Drawing, Frame, Canvas](). Please use any Text Editor and sbt directly to get a better experience using this Library.

This is just a proposal, but something along those lines should get Beginners on board and more experienced Devs will know what to do with it. Maybe there is also a way to disable this Error Warning in the Scala Plugin, but I would have to double check.

noelwelsh commented 2 years ago

Finally fixed this. Thanks for reporting!