This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Browsing the Scala compiler sources... what's the best tool?

3 replies
Peter C. Chapin 2
Joined: 2011-01-07,
User offline. Last seen 42 years 45 weeks ago.

I'm studying the Scala compiler itself. I have a copy of its source code
from Subversion and I can build it successfully. I can use a simple text
editor to browse around in the code but navigation from file to file is
awkward. I'm looking for something better but I'm having trouble getting set
up.

I've tried adding the sources to a NetBeans project using a "free form"
project based on the master Ant build file. This works as far as it goes,
but NetBeans doesn't provide any useful syntax highlighting or navigation
support. I assume this is because either

a) I haven't configured my free form project right (although I've tried a
couple of permutations).

b) The NetBeans Scala plugin isn't up to the task.

I do understand that in this case I need to manually tell NetBeans about the
various class paths it should use. Perhaps I'm using the wrong paths.

I then tried ENSIME. The ENSIME project generator detected the project type
as "custom", which is fine. It then asked me about various paths, which I
might be confused about. In the end it doesn't work for me either. In
particular when I load the project I get a message about the "Analyzer"
initializing. This step never appears to end. If I try to look up a
definition with M-. I am told, "Synchronous RPC Aborted: Analyzer not
ready!" I notice that the Analyzer consumes a lot of CPU time for a few
seconds when I first load the project but then the CPU usage drops to zero
and nothing seems to be happening (that I can tell). Yet the analyzer
appears to never be ready.

It occurs to me that browsing the compiler sources might present a special
problem for tools like this. The compiler jar file used to build the sources
contains classes like scala.tool.nsc.XYZZY and yet the generated code
contains classes with the same names that might not be identical. I'm
wondering if this is confusing the tools. Maybe it's just confusing me.

I'm hoping I can get a few hints about how to make this work.

Thanks!

Peter

Seth Tisue
Joined: 2008-12-16,
User offline. Last seen 34 weeks 3 days ago.
Re: Browsing the Scala compiler sources... what's the best tool

>>>>> "Peter" == Peter C Chapin writes:

Peter> I then tried ENSIME. The ENSIME project generator detected the
Peter> project type as "custom", which is fine. It then asked me about
Peter> various paths, which I might be confused about. In the end it
Peter> doesn't work for me either. In particular when I load the
Peter> project I get a message about the "Analyzer" initializing. This
Peter> step never appears to end. If I try to look up a definition with
Peter> M-. I am told, "Synchronous RPC Aborted: Analyzer not ready!" I
Peter> notice that the Analyzer consumes a lot of CPU time for a few
Peter> seconds when I first load the project but then the CPU usage
Peter> drops to zero and nothing seems to be happening (that I can
Peter> tell). Yet the analyzer appears to never be ready.

You can look in the *ensime-events* and *inferior-ensime-server* buffers
for error messages and clues.

Aemon Cannon
Joined: 2010-03-21,
User offline. Last seen 1 year 24 weeks ago.
Re: Browsing the Scala compiler sources... what's the best tool
The pres-compiler crashes when I try to run ENSIME on the github scala mirror - but I'm having some luck with the 2.8.1 distribution, just unpack the source jars (library & compiler) in place, and use this .ensime file: (:project-name "scala":project-package "scala":sources ("./src/"):compile-jars ("./lib/"))
Don't use ensime-typecheck-all, though. For me, it craps out with:
java.lang.Error: CC[A] in class SortedSetFactory cannot be instantiated from object scala.collection.SortedSet at scala.tools.nsc.symtab.SymbolTable.abort(SymbolTable.scala:33) at scala.tools.nsc.symtab.Types$AsSeenFromMap.throwError$1(Types.scala:3281) at scala.tools.nsc.symtab.Types$AsSeenFromMap.instParam$1(Types.scala:3284) at scala.tools.nsc.symtab.Types$AsSeenFromMap.toInstance$1(Types.scala:3295) at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply(Types.scala:3311) at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply(Types.scala:3189) at scala.tools.nsc.symtab.Types$TypeMap$$anonfun$mapOverArgs$1.apply(Types.scala:3023) at scala.tools.nsc.symtab.Types$TypeMap$$anonfun$mapOverArgs$1.apply(Types.scala:3019) at scala.tools.nsc.symtab.Types$class.map2Conserve(Types.scala:4723) at scala.tools.nsc.symtab.SymbolTable.map2Conserve(SymbolTable.scala:13) at scala.tools.nsc.symtab.Types$class.map2Conserve(Types.scala:4724) at scala.tools.nsc.symtab.SymbolTable.map2Conserve(SymbolTable.scala:13) at scala.tools.nsc.symtab.Types$class.map2Conserve(Types.scala:4724) at scala.tools.nsc.symtab.SymbolTable.map2Conserve(SymbolTable.scala:13) at scala.tools.nsc.symtab.Types$TypeMap.mapOverArgs(Types.scala:3019) at scala.tools.nsc.symtab.Types$TypeMap.mapOver(Types.scala:2929) at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply(Types.scala:3313) at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply(Types.scala:3189) at scala.tools.nsc.symtab.Types$TypeMap.mapOver(Types.scala:2945) at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply(Types.scala:3313) at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply(Types.scala:3189) at scala.tools.nsc.symtab.Types$TypeMap.mapOver(Types.scala:2953) at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply(Types.scala:3313) at scala.tools.nsc.symtab.Types$Type.asSeenFrom(Types.scala:516) at scala.tools.nsc.symtab.Types$Type.computeMemberType(Types.scala:540) at scala.tools.nsc.symtab.Symbols$MethodSymbol.typeAsMemberOf(Symbols.scala:1780) at scala.tools.nsc.symtab.Types$Type.memberType(Types.scala:531) at scala.tools.nsc.typechecker.Implicits$ImplicitInfo.tpe(Implicits.scala:102) at scala.tools.nsc.typechecker.Implicits$ImplicitInfo.isCyclicOrErroneous(Implicits.scala:120) at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.tryImplicit$1(Implicits.scala:615) at scala.tools.nsc.typechecker.Implicits$ImplicitSearch$$anonfun$addAppInfos$1$1.apply(Implicits.scala:631) at scala.tools.nsc.typechecker.Implicits$ImplicitSearch$$anonfun$addAppInfos$1$1.apply(Implicits.scala:628) at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61) at scala.collection.immutable.List.foreach(List.scala:45) at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.addAppInfos$1(Implicits.scala:628) at scala.tools.nsc.typechecker.Implicits$ImplicitSearch$$anonfun$applicableInfos$1.apply(Implicits.scala:645) at scala.tools.nsc.typechecker.Implicits$ImplicitSearch$$anonfun$applicableInfos$1.apply(Implicits.scala:645) at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61) at scala.collection.immutable.List.foreach(List.scala:45) at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.applicableInfos(Implicits.scala:645) at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.searchImplicit(Implicits.scala:669) at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.implicitManifestOrOfExpectedType(Implicits.scala:889) at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.bestImplicit(Implicits.scala:914) at scala.tools.nsc.typechecker.Implicits$class.inferImplicit(Implicits.scala:54) at scala.tools.nsc.Global$analyzer$.inferImplicit(Global.scala:301) at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$applyImplicitArgs$1.apply(Typers.scala:206) at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$applyImplicitArgs$1.apply(Typers.scala:201) at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61) at scala.collection.immutable.List.foreach(List.scala:45) at scala.tools.nsc.typechecker.Typers$Typer.applyImplicitArgs(Typers.scala:201) at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:853) at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4208) at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4265) at scala.tools.nsc.typechecker.Typers$Typer.typedCase(Typers.scala:1973) at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$typedCases$1.apply(Typers.scala:1993) at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$typedCases$1.apply(Typers.scala:1991) at scala.collection.immutable.List.loop$1(List.scala:115) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.tools.nsc.typechecker.Typers$Typer.typedCases(Typers.scala:1991) at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3946) at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4203) at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4265) at scala.tools.nsc.typechecker.Typers$Typer.computeType(Typers.scala:4341) at scala.tools.nsc.typechecker.Namers$Namer.methodSig(Namers.scala:901) at scala.tools.nsc.typechecker.Namers$Namer.typeSig(Namers.scala:1134) at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$typeCompleter$1.apply(Namers.scala:523) at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$typeCompleter$1.apply(Namers.scala:521) at scala.tools.nsc.typechecker.Namers$$anon$1.complete(Namers.scala:1309) at scala.tools.nsc.typechecker.Namers$$anon$1.complete(Namers.scala:1307) at scala.tools.nsc.symtab.Symbols$Symbol.info(Symbols.scala:735) at scala.tools.nsc.symtab.Symbols$Symbol.initialize(Symbols.scala:848) at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3840) at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4203) at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2128) at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$20.apply(Typers.scala:2196) at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$20.apply(Typers.scala:2196) at scala.collection.immutable.List.loop$1(List.scala:115) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2196) at scala.tools.nsc.typechecker.Typers$Typer.typedBlock(Typers.scala:1948) at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3894) at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4203) at scala.tools.nsc.typechecker.Typers$Typer.transformedOrTyped(Typers.scala:4348) at scala.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:1789) at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3862) at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4203) at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3887) at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4203) at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2128) at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$20.apply(Typers.scala:2196) at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$20.apply(Typers.scala:2196) at scala.collection.immutable.List.loop$1(List.scala:115) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.collection.immutable.List.loop$1(List.scala:119) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2196) at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1549) at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1348) at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3856) at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4203) at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2128) at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$20.apply(Typers.scala:2196) at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$20.apply(Typers.scala:2196) at scala.collection.immutable.List.loop$1(List.scala:115) at scala.collection.immutable.List.mapConserve(List.scala:132) at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2196) at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3849) at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4203) at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4252) at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:85) at scala.tools.nsc.Global$GlobalPhase$$anonfun$applyPhase$1.apply(Global.scala:282) at scala.tools.nsc.Global$GlobalPhase$$anonfun$applyPhase$1.apply(Global.scala:282) at scala.tools.nsc.reporters.Reporter.withSource(Reporter.scala:48) at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:282) at scala.tools.nsc.interactive.Global$TyperRun$$anonfun$applyPhase$1$$anonfun$apply$mcV$sp$1.apply(Global.scala:614) at scala.tools.nsc.interactive.Global$TyperRun$$anonfun$applyPhase$1$$anonfun$apply$mcV$sp$1.apply(Global.scala:614) at scala.tools.nsc.symtab.SymbolTable.atPhase(SymbolTable.scala:103) at scala.tools.nsc.interactive.Global$TyperRun$$anonfun$applyPhase$1.apply(Global.scala:614) at scala.tools.nsc.interactive.Global$TyperRun$$anonfun$applyPhase$1.apply(Global.scala:614) at scala.tools.nsc.reporters.Reporter.withSource(Reporter.scala:48) at scala.tools.nsc.interactive.Global$TyperRun.applyPhase(Global.scala:613) at scala.tools.nsc.interactive.Global$TyperRun.typeCheck(Global.scala:567) at scala.tools.nsc.interactive.Global$$anonfun$recompile$2.apply(Global.scala:299) at scala.tools.nsc.interactive.Global$$anonfun$recompile$2.apply(Global.scala:296 at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61) at scala.collection.immutable.List.foreach(List.scala:45) at scala.tools.nsc.interactive.Global.recompile(Global.scala:296) at org.ensime.server.RichPresentationCompiler.recompile(RichPresentationCompiler.scala:506) at scala.tools.nsc.interactive.Global.scala$tools$nsc$interactive$Global$$backgroundCompile(Global.scala:262) at scala.tools.nsc.interactive.Global$$anon$3.run(Global.scala:225)INFO: Fatal Error: java.lang.Error: CC[A] in class SortedSetFactory cannot be instantiated from object scala.collection.SortedSet

On Thu, Mar 10, 2011 at 12:37 PM, Seth Tisue <seth [at] tisue [dot] net> wrote:
>>>>> "Peter" == Peter C Chapin <PChapin [at] vtc [dot] vsc [dot] edu> writes:

 Peter> I then tried ENSIME. The ENSIME project generator detected the
 Peter> project type as "custom", which is fine. It then asked me about
 Peter> various paths, which I might be confused about. In the end it
 Peter> doesn't work for me either. In particular when I load the
 Peter> project I get a message about the "Analyzer" initializing. This
 Peter> step never appears to end. If I try to look up a definition with
 Peter> M-. I am told, "Synchronous RPC Aborted: Analyzer not ready!" I
 Peter> notice that the Analyzer consumes a lot of CPU time for a few
 Peter> seconds when I first load the project but then the CPU usage
 Peter> drops to zero and nothing seems to be happening (that I can
 Peter> tell). Yet the analyzer appears to never be ready.

You can look in the *ensime-events* and *inferior-ensime-server* buffers
for error messages and clues.

--
Seth Tisue @ Northwestern University | http://tisue.net
lead developer, NetLogo: http://ccl.northwestern.edu/netlogo/

Peter C. Chapin 2
Joined: 2011-01-07,
User offline. Last seen 42 years 45 weeks ago.
Re: [BULK] Re: Browsing the Scala compiler sources... what's t

On Thu, 10 Mar 2011, Aemon Cannon wrote:

> The pres-compiler crashes when I try to run ENSIME on the github scala
> mirror - but I'm having some luck with the 2.8.1 distribution, just unpack
> the source jars (library & compiler) in place, and use this .ensime file:
> (
> :project-name "scala"
> :project-package "scala"
> :sources ("./src/")
> :compile-jars ("./lib/")
> )

Sorry about the delay getting back to people on this. For the sake of the
list archive...

I got it working fine when using the 2.8.1 sources instead of the current
SVN snapshot. I'm not sure if that's an issue with the (ENSIME 0.4.4, Scala
2.9) pair or if I had something wrong with my configuration. The sources are
organized differently in SVN.

Anyway looking at the 2.8.1 sources will satisfy my current need so I'm up
and running. I haven't used ENSIME before. It looks pretty nifty.

Thanks for the help.

Peter

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland