Skip to content
This repository has been archived by the owner. It is now read-only.

[Sponsored] Analyzer per Project #1807

Merged
merged 14 commits into from Jun 22, 2017
Next

Analyser per Module : Stage 1

  • Loading branch information...
VC1995 committed Jun 10, 2017
commit 408c58d2620ab3936c49d3d3a5df98c014d6a472
@@ -14,10 +14,10 @@ trait AnalyzerFixture {
}

object AnalyzerFixture {
private[fixture] def create(search: SearchService)(implicit system: ActorSystem, config: EnsimeConfig, vfs: EnsimeVFS): TestActorRef[Analyzer] = {
private[fixture] def create(search: SearchService, id: EnsimeProjectId)(implicit system: ActorSystem, config: EnsimeConfig, vfs: EnsimeVFS): TestActorRef[Analyzer] = {
val indexer = TestProbe()
val projectActor = TestProbe()
TestActorRef(Analyzer(projectActor.ref, indexer.ref, search))
TestActorRef(Analyzer(projectActor.ref, indexer.ref, search, config.modules(id)))
}
}

@@ -45,6 +45,7 @@ class BasicWorkflow extends EnsimeSpec

project ! UnloadAllReq
expectMsg(VoidResponse)

all(asyncHelper.receiveN(2)) should matchPattern {
case CompilerRestartedEvent =>
case FullTypeCheckCompleteEvent =>
@@ -120,11 +121,10 @@ class BasicWorkflow extends EnsimeSpec
ERangePosition(`packageFilePath`, 94, 80, 104)
)

asyncHelper.fishForMessage() {
case FullTypeCheckCompleteEvent => true
case _ => false
all(asyncHelper.receiveN(2)) should matchPattern {
case note: NewScalaNotesEvent =>
case FullTypeCheckCompleteEvent =>
}

// note that the line numbers appear to have been stripped from the
// scala library classfiles, so offset/line comes out as zero unless
// loaded by the pres compiler
@@ -209,7 +209,7 @@ class BasicWorkflow extends EnsimeSpec
)
) =>
}

// expand selection around "seven" in `foo.testMethod` call
project ! ExpandSelectionReq(fooFile, 215, 215)
val expandRange1 = expectMsgType[FileRange]
@@ -303,7 +303,8 @@ class BasicWorkflow extends EnsimeSpec

project ! TypecheckFilesReq(List(Left(bazFile), Right(toBeUnloaded)))
expectMsg(VoidResponse)
all(asyncHelper.receiveN(2)) should matchPattern {

all(asyncHelper.receiveN(3)) should matchPattern {
case note: NewScalaNotesEvent =>
case FullTypeCheckCompleteEvent =>
}
@@ -88,7 +88,7 @@ class MissingJarTargetTest extends EnsimeSpec
mainTarget should be a 'file

// means the file addition was detected
asyncHelper.expectMsg(10 seconds, CompilerRestartedEvent)
asyncHelper.expectMsg(10 seconds, AnalyzerReadyEvent)

eventually(timeout(scaled(10 seconds)), interval(scaled(1 second))) {
project ! PublicSymbolSearchReq(List("Foo"), 5)
@@ -51,6 +51,7 @@ class Analyzer(
broadcaster: ActorRef,
indexer: ActorRef,
search: SearchService,
scoped: List[EnsimeProjectId],
implicit val config: EnsimeConfig,
implicit val vfs: EnsimeVFS
) extends Actor with Stash with ActorLogging with RefactoringHandler {
@@ -59,7 +60,6 @@ class Analyzer(
import FileUtils._

private var allFilesMode = false

private var settings: Settings = _
private var reporter: PresentationReporter = _

@@ -77,8 +77,19 @@ class Analyzer(
case Some(scalaLib) => settings.bootclasspath.value = scalaLib.getAbsolutePath
case None => log.warning("scala-library.jar not present, enabling Odersky mode")
}
settings.classpath.value = config.classpath.mkString(JFile.pathSeparator)
settings.processArguments(config.compilerArgs, processAll = false)

val projects = scoped.map(config.modules)

settings.classpath.value = {
for {
project <- projects
entry <- project.classpath
} yield entry
}.distinct.mkString(JFile.pathSeparator)

// arbitrarily pick the first project when there are multiple
settings.processArguments(projects.head.scalacOptions, processAll = false)

presCompLog.debug("Presentation Compiler settings:\n" + settings)

reporter = new PresentationReporter(new ReportHandler {
@@ -95,7 +106,6 @@ class Analyzer(
reporter.disable() // until we start up

scalaCompiler = makeScalaCompiler()

broadcaster ! SendBackgroundMessageEvent("Initializing Analyzer. Please wait...")

scalaCompiler.askNotifyWhenReady()
@@ -105,6 +115,7 @@ class Analyzer(
config, settings, reporter, self, indexer, search
)

// FIXME: use the scoped list that the actor is constructed with
protected def restartCompiler(
strategy: ReloadStrategy,
scoped: Option[EnsimeProjectId]
@@ -145,10 +156,12 @@ class Analyzer(
def startup: Receive = withLabel("startup") {
case FullTypeCheckCompleteEvent =>
reporter.enable()

// FIXME: think about this
// legacy clients expect to see AnalyzerReady and a
// FullTypeCheckCompleteEvent on connection.
broadcaster ! Broadcaster.Persist(AnalyzerReadyEvent)
broadcaster ! Broadcaster.Persist(FullTypeCheckCompleteEvent)
// broadcaster ! Broadcaster.Persist(AnalyzerReadyEvent)
// broadcaster ! Broadcaster.Persist(FullTypeCheckCompleteEvent)
context.become(ready)
unstashAll()

@@ -159,6 +172,8 @@ class Analyzer(
def ready: Receive = withLabel("ready") {
case FullTypeCheckCompleteEvent =>
broadcaster ! FullTypeCheckCompleteEvent
// FIXME: why do we need to tell the parent?
context.parent ! FullTypeCheckCompleteEvent

case RestartScalaCompilerReq(id, strategy) =>
restartCompiler(strategy, id)
@@ -204,7 +219,6 @@ class Analyzer(
reporter.disable()
scalaCompiler.askCompletionsAt(pos(fileInfo, point), maxResults, caseSens)
} pipeTo sender

case UsesOfSymbolAtPointReq(file, point) =>
import context.dispatcher
val response = if (toSourceFileInfo(file).exists()) {
@@ -293,10 +307,11 @@ object Analyzer {
def apply(
broadcaster: ActorRef,
indexer: ActorRef,
search: SearchService
search: SearchService,
scoped: List[EnsimeProjectId]
)(
implicit
config: EnsimeConfig,
vfs: EnsimeVFS
) = Props(new Analyzer(broadcaster, indexer, search, config, vfs))
) = Props(new Analyzer(broadcaster, indexer, search, scoped, config, vfs))
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.