2

I am repeatedly run into a similar problem with Scala IDE. Thanks to tab completion Scala IDE proposes several methods. However, always when I choose a method it complains that it cannot resolve it. In the screenshot, I select the method findByEan from models.Product. After selecting the proposed method I get an error message:

Multiple markers at this line
    - Line breakpoint:Products [line: 16] - show
    - value findByEan is not a member of object models.Product

choosing a method from models.Product

It complains that .findByEan() is not part of models.Product. As you can see from the listing above - the Product object has this method. Of course, it even proposed it to me several seconds ago!

package models

case class Product(ean:Long, name:String, description:String)


object Product{

   var products = Set() // some products ...

   def find_all = products.toList.sortBy(_.ean)
   def findByEan(ean:Long) = products.find(_.ean == ean)

A similar issue happens when I add template views to the controllers.

  • Why Scala IDE cannot compile the proposed methods?

Scala IDE Version: 3.0.2-vfinal-20131028-1923-Typesafe

Jon
  • 11,356
  • 5
  • 40
  • 74
  • 1
    I can't reproduce it with your source code (I had to move `package models` at the top of the Product.scala file, otherwise it's an error in that file). Is there anything else I could try? – Iulian Dragos Nov 25 '13 at 10:25
  • sorry- that happened when I copied the code to stackoverflow. – Jon Nov 25 '13 at 10:37
  • I restarted Scala IDE now several times. The error above disappeared, but now it can't find `details` in `Ok(views.html.products.details(product))`. – Jon Nov 25 '13 at 10:38

1 Answers1

1

About not being able to find details. From its fully qualified name, it seems be a Play template.

The Play templates are compiled by Play itself, they are only typed checked inside the template editor. For them to be listed in completion, they have to be compiled (done by refreshing the app in the web browser), and visible by Scala IDE (done by refreshing the project in the IDE).

It is also possible to setup an environment in a way that the compile+refresh is done automatically. The steps are described in this tutorial.

skyluc
  • 640
  • 4
  • 6