cheeseng/scala-ide — comment on commit 2c7150b4d1c2437deeb9d4b02066ce6274040024
File: org.scala-ide.sdt.core/src/scala/tools/eclipse/launching/ScalaTestLaunchShortcut.scala line 74
By dragos:

Hi Chee Seng,

I have looked again, and indeed you are using the 'wrong' Symbols and
Types. The compiler types are a bit special: they use the so-called
dependent types, meaning that they are members of the compiler object.
Therefore, once you have an instance of the compiler, you can access them
like compiler.Tree, compiler.Symbol and compiler.Type. You can even import
all members of the compiler object, whenever the compiler is in scope:
`import compiler._`.

In your case, one way to make it work is to make the TestLauncher take a
compiler instance as a constructor parameter and import it immediately
afterwards:

ScalaTestLaunchShortcut(compiler: ScalaPresentationCompiler) ... {
import compiler._

def getParent(t: Tree) ...

Later, you can instantiate this class at the point where you obtained an
instance of 'compiler', and call methods on the object you instantiated.

Let me know if this helps.

iulian

On Mon, Feb 6, 2012 at 3:36 AM, Chua Chee Seng <
reply@reply.github.com
> wrote:

> Hi Iulian,
>
> Thanks for reviewing the code! I have rewritten the getParent method using
> the method 'includes' that you mentioned, but I have strange compilation
> problem (see line 79 of
>
> https://github.com/cheeseng/scala-ide/blob/master/org.scala-ide.sdt.core/src/scala/tools/eclipse/launching/ScalaTestLaunchShortcut.scala
> ),
> I am not sure about the cause, may be the compiler is confused about the
> type?
>
> Thanks!
>
> Best Regards,
> Chee Seng
>
>
> On Mon, Feb 6, 2012 at 3:46 AM, Iulian Dragos <
> reply@reply.github.com
> > wrote:
>
> > This could be done much more efficiently if you used the position
> > information of the tree you're looking for. Positions have a method
> > `includes` to test if a position is fully included inside another. That
> > would guide your search in this case. Otherwise, you are blindly
> traversing
> > the whole AST. Have a look at class `Locator`, as I mentioned by email on
> > scala-ide-dev.
> >
> > ---
> > Reply to this email directly or view it on GitHub:
> >
> >
> https://github.com/cheeseng/scala-ide/commit/2c7150b4d1c2437deeb9d4b02066ce6274040024#commitcomment-934642
> >
>
> ---
> Reply to this email directly or view it on GitHub:
>
> https://github.com/cheeseng/scala-ide/commit/2c7150b4d1c2437deeb9d4b02066ce6274040024#commitcomment-935106
>

--
Je dteste la montagne, a cache le paysage
Alphonse Allais