scala-ide / scala-search

Next Scala Search Engine
6 stars 10 forks source link

create Call Hierarchy View. #111

Open andrey-ilinykh opened 8 years ago

andrey-ilinykh commented 8 years ago

It is written o the top of Find Occurrences API. One field (caller offset) is added to lucent index. This field is used to build the hierarchy.

Fix #1000872

ghprb-bot commented 8 years ago

Refer to this link for build results (access rights to CI server needed):

https://jenkins.scala-ide.org:8496/jenkins/job/ghprb-scala-search-validator/59/ https://jenkins.scala-ide.org:8496/jenkins/job/ghprb-scala-search-for-ide-master-2.11.x/61/

kiritsuku commented 8 years ago

The code mostly looks good. I still have to check it for its functionality but probably can't due this before tomorrow. A note for future: It would be nice if you could split up formatting changes in their own commit. This makes review a lot easier. Also you shouldn't just format the existing code but also format your own. There are a few inconsistencies in the new Scala files - it doesn't look like you invoked auto formatting there.

ghprb-bot commented 8 years ago

Refer to this link for build results (access rights to CI server needed):

https://jenkins.scala-ide.org:8496/jenkins/job/ghprb-scala-search-validator/60/ https://jenkins.scala-ide.org:8496/jenkins/job/ghprb-scala-search-for-ide-master-2.11.x/62/

andrey-ilinykh commented 8 years ago

This plugin doesn't use scalastyle plugin, so formatting is inconsistent. Should I add it?

kiritsuku commented 8 years ago

On 12/17/2015 07:45 AM, Andrey Ilinykh wrote:

This plugin doesn't use scalastyle plugin, so formatting is inconsistent. Should I add it?

You can but beside from trailing whitespace we don't even check anything in the scala-ide main repo. In general I think most style rules are not useful.

kiritsuku commented 8 years ago

In the caller column, there are arrows shown, even when they can't be expanded. They should not be shown in this case.

kiritsuku commented 8 years ago

I don't think it is necessary to show the "content" column in the call hierarchy, one can click on the line to get to the code directly.

kiritsuku commented 8 years ago

When I have

  def foo: Int = {
    def x = {
      bar
    }
    x
  }
  def goo = bar
  def bar = 0

inside of x, foo is shown twice. Not sure where the second entry is coming from.

EDIT: Ok, I get it now. One is coming from the call of x and the other is the declaration of x. If both are shown, then the declaration of x should be shown nested in the call of x, WDYT?

kiritsuku commented 8 years ago

I got the following NPE:

2015-12-18 12:48:48,179 DEBUG [main] - System.out - java.lang.NullPointerException
    at org.scala.tools.eclipse.search.Util$.scalaSourceFileFromIFile(Util.scala:32)
    at org.scala.tools.eclipse.search.Util$$anonfun$scalaSourceFileFromAbstractFile$2$$anonfun$apply$4.apply(Util.scala:26)
    at org.scala.tools.eclipse.search.Util$$anonfun$scalaSourceFileFromAbstractFile$2$$anonfun$apply$4.apply(Util.scala:21)
    at scala.Option.flatMap(Option.scala:171)
    at org.scala.tools.eclipse.search.Util$$anonfun$scalaSourceFileFromAbstractFile$2.apply(Util.scala:21)
    at org.scala.tools.eclipse.search.Util$$anonfun$scalaSourceFileFromAbstractFile$2.apply(Util.scala:19)
    at scala.Option.flatMap(Option.scala:171)
    at org.scala.tools.eclipse.search.Util$.scalaSourceFileFromAbstractFile(Util.scala:19)
    at org.scala.tools.eclipse.search.searching.SearchPresentationCompiler.org$scala$tools$eclipse$search$searching$SearchPresentationCompiler$$symbolToEntity(SearchPresentationCompiler.scala:78)
    at org.scala.tools.eclipse.search.searching.SearchPresentationCompiler$$anonfun$entityAt$1$$anonfun$4.apply(SearchPresentationCompiler.scala:56)
    at org.scala.tools.eclipse.search.searching.SearchPresentationCompiler$$anonfun$entityAt$1$$anonfun$4.apply(SearchPresentationCompiler.scala:56)
    at scala.tools.nsc.util.InterruptReq.execute(InterruptReq.scala:26)
    at scala.tools.nsc.interactive.Global$$anonfun$pollForWork$1.apply$mcV$sp(Global.scala:457)
    at scala.util.control.Breaks.breakable(Breaks.scala:38)
    at scala.tools.nsc.interactive.Global.pollForWork(Global.scala:431)
    at scala.tools.nsc.interactive.PresentationCompilerThread.run(PresentationCompilerThread.scala:22)
2015-12-18 12:48:48,179 ERROR [main] - org.scala-ide.sdt.core - org.scala-ide.sdt.core - org.scala-ide.sdt.core - 0 - Throwable during asyncExec
java.lang.NullPointerException
    at org.scala.tools.eclipse.search.Util$.scalaSourceFileFromIFile(Util.scala:32)
    at org.scala.tools.eclipse.search.Util$$anonfun$scalaSourceFileFromAbstractFile$2$$anonfun$apply$4.apply(Util.scala:26)
    at org.scala.tools.eclipse.search.Util$$anonfun$scalaSourceFileFromAbstractFile$2$$anonfun$apply$4.apply(Util.scala:21)
    at scala.Option.flatMap(Option.scala:171)
    at org.scala.tools.eclipse.search.Util$$anonfun$scalaSourceFileFromAbstractFile$2.apply(Util.scala:21)
    at org.scala.tools.eclipse.search.Util$$anonfun$scalaSourceFileFromAbstractFile$2.apply(Util.scala:19)
    at scala.Option.flatMap(Option.scala:171)
    at org.scala.tools.eclipse.search.Util$.scalaSourceFileFromAbstractFile(Util.scala:19)
    at org.scala.tools.eclipse.search.searching.SearchPresentationCompiler.org$scala$tools$eclipse$search$searching$SearchPresentationCompiler$$symbolToEntity(SearchPresentationCompiler.scala:78)
    at org.scala.tools.eclipse.search.searching.SearchPresentationCompiler$$anonfun$entityAt$1$$anonfun$4.apply(SearchPresentationCompiler.scala:56)
    at org.scala.tools.eclipse.search.searching.SearchPresentationCompiler$$anonfun$entityAt$1$$anonfun$4.apply(SearchPresentationCompiler.scala:56)
    at scala.tools.nsc.util.InterruptReq.execute(InterruptReq.scala:26)
    at scala.tools.nsc.interactive.Global$$anonfun$pollForWork$1.apply$mcV$sp(Global.scala:457)
    at scala.util.control.Breaks.breakable(Breaks.scala:38)
    at scala.tools.nsc.interactive.Global.pollForWork(Global.scala:431)
    at scala.tools.nsc.interactive.PresentationCompilerThread.run(PresentationCompilerThread.scala:22)
kiritsuku commented 8 years ago

I just checked the feature on the following example but it didn't work for a single case:

package test

import akka.actor._

case object PingMessage
case object PongMessage
case object StartMessage
case object StopMessage

class Ping(pong: ActorRef) extends Actor {
  var count: Int = 0
  def incrementAndPrint(): Unit = { count += 1; println("ping") }
  override def receive: PartialFunction[Any, Unit] = {
    case StartMessage ⇒
      incrementAndPrint
      pong ! PingMessage
    case PongMessage ⇒
      incrementAndPrint
      if (count > 10) {
        sender ! StopMessage
        println("ping stopped")
        context.stop(self)
      } else {
        sender ! PingMessage
      }
  }
}

class Pong extends Actor {
  override def receive: PartialFunction[Any, Unit] = {
    case PingMessage ⇒
      println("  pong")
//      sender ! PoisonPill
      sender ! PongMessage
    case StopMessage ⇒
      println("pong stopped")
      context.stop(self)
  }
}

object PingPongTest extends App {
  val system: akka.actor.ActorSystem = ActorSystem("PingPongSystem")
  val pong: akka.actor.ActorRef = system.actorOf(Props[Pong], name = "pong")
  val ping: akka.actor.ActorRef = system.actorOf(Props(new Ping(pong)), name = "ping")
  // start them going
  ping ! StartMessage

  //  Thread.sleep(10000)
  //  system.shutdown()
}

On other examples it worked better. Not sure what the problem here is.

kiritsuku commented 8 years ago

Another example where nothing is shown:

class SomeTestClass {
  def foo(silent: Boolean) = {
    (new Inner1).inner.foo()
  }
  private class Inner1 {
    def inner = Inner

    object Inner {
      def foo(silent: Boolean = false): String =
        "trala".nonEmpty.toString() // <- BREAKPOINT HERE
    }
  }
}

Not sure if inner or foo are already supposed to work. In general it would be nice if you could add tests for the cases that are supposed to work.