@@ -209,7 +209,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
209
209
/** A map that associates with each abstract file the set of responses that ware waiting
210
210
* (via build) for the unit associated with the abstract file to be parsed and entered
211
211
*/
212
- protected var getParsedEnteredResponses = newResponseMap
212
+ protected val getParsedEnteredResponses = newResponseMap
213
213
214
214
private def cleanResponses (rmap : ResponseMap ): Unit = {
215
215
for ((source, rs) <- rmap.toList) {
@@ -301,6 +301,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
301
301
def isOutOfDate : Boolean = outOfDate
302
302
303
303
def demandNewCompilerRun () = {
304
+ if (! lastWasReload) allSources.foreach(getUnit(_).foreach(reset(_)))
304
305
if (outOfDate) throw new FreshRunReq // cancel background compile
305
306
else outOfDate = true // proceed normally and enable new background compile
306
307
}
@@ -429,13 +430,14 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
429
430
* @param pos The position of the tree if polling while typechecking, NoPosition otherwise
430
431
*
431
432
*/
433
+ @ nowarn(" cat=lint-nonlocal-return" )
432
434
private [interactive] def pollForWork (pos : Position ): Unit = {
433
435
var loop : Boolean = true
434
436
while (loop) {
435
- breakable{
437
+ breakable {
436
438
loop = false
437
439
// TODO refactor to eliminate breakable/break/return?
438
- ( if (! interruptsEnabled) return ) : @ nowarn( " cat=lint-nonlocal-return " )
440
+ if (! interruptsEnabled) return
439
441
if (pos == NoPosition || nodesSeen % yieldPeriod == 0 )
440
442
Thread .`yield`()
441
443
@@ -448,7 +450,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
448
450
case Some (WorkEvent (id, _)) =>
449
451
debugLog(" some work at node " + id+ " current = " + nodesSeen)
450
452
// assert(id >= nodesSeen)
451
- moreWorkAtNode = id
453
+ moreWorkAtNode = id
452
454
case None =>
453
455
}
454
456
@@ -464,7 +466,8 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
464
466
debugLog(" ask finished" + timeStep)
465
467
interruptsEnabled = true
466
468
}
467
- loop = true ; break()
469
+ loop = true
470
+ break()
468
471
case _ =>
469
472
}
470
473
@@ -475,8 +478,8 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
475
478
logreplay(" exception thrown" , scheduler.pollThrowable()) match {
476
479
case Some (ex : FreshRunReq ) =>
477
480
newTyperRun()
478
- minRunId = currentRunId
479
- demandNewCompilerRun()
481
+ minRunId = currentRunId
482
+ demandNewCompilerRun()
480
483
481
484
case Some (ShutdownReq ) =>
482
485
scheduler.synchronized { // lock the work queue so no more items are posted while we clean it up
@@ -498,7 +501,9 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
498
501
throw ShutdownReq
499
502
}
500
503
501
- case Some (ex : Throwable ) => log.flush(); throw ex
504
+ case Some (ex : Throwable ) =>
505
+ log.flush()
506
+ throw ex
502
507
case _ =>
503
508
}
504
509
@@ -563,7 +568,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
563
568
reporter.reset()
564
569
565
570
// remove any files in first that are no longer maintained by presentation compiler (i.e. closed)
566
- allSources = allSources filter (s => unitOfFile contains (s.file))
571
+ allSources = allSources. filter(s => unitOfFile. contains(s.file))
567
572
568
573
// ensure all loaded units are parsed
569
574
for (s <- allSources; unit <- getUnit(s)) {
@@ -583,7 +588,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
583
588
}
584
589
585
590
// ensure all loaded units are typechecked
586
- for (s <- allSources; if ! ignoredFiles(s.file); unit <- getUnit(s)) {
591
+ for (s <- allSources if ! ignoredFiles(s.file); unit <- getUnit(s))
587
592
try {
588
593
if (! unit.isUpToDate)
589
594
if (unit.problems.isEmpty || ! settings.YpresentationStrict .value)
@@ -611,7 +616,6 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
611
616
612
617
reporter.error(unit.body.pos, " Presentation compiler crashed while type checking this file: %s" .format(ex.toString()))
613
618
}
614
- }
615
619
616
620
// move units removable after this run to the "to-be-removed" buffer
617
621
toBeRemoved.synchronized {
@@ -720,9 +724,12 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
720
724
val result = results.head
721
725
results = results.tail
722
726
if (results.isEmpty) {
723
- response set result
727
+ response. set( result)
724
728
debugLog(" responded" + timeStep)
725
- } else response setProvisionally result
729
+ }
730
+ else {
731
+ response.setProvisionally(result)
732
+ }
726
733
}
727
734
}
728
735
} catch {
@@ -860,15 +867,13 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
860
867
861
868
private def withTempUnits [T ](sources : List [SourceFile ])(f : (SourceFile => RichCompilationUnit ) => T ): T = {
862
869
val unitOfSrc : SourceFile => RichCompilationUnit = src => unitOfFile(src.file)
863
- sources filterNot (getUnit(_).isDefined) match {
870
+ sources. filterNot(getUnit(_).isDefined) match {
864
871
case Nil =>
865
872
f(unitOfSrc)
866
873
case unknown =>
867
874
reloadSources(unknown)
868
- try {
869
- f(unitOfSrc)
870
- } finally
871
- afterRunRemoveUnitsOf(unknown)
875
+ try f(unitOfSrc)
876
+ finally afterRunRemoveUnitsOf(unknown)
872
877
}
873
878
}
874
879
@@ -949,21 +954,21 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
949
954
}
950
955
951
956
/** Implements CompilerControl.askDocComment */
952
- private [interactive] def getDocComment (sym : Symbol , source : SourceFile , site : Symbol , fragments : List [(Symbol ,SourceFile )],
957
+ private [interactive] def getDocComment (sym : Symbol , source : SourceFile , site : Symbol ,
958
+ fragments : List [(Symbol , SourceFile )],
953
959
response : Response [(String , String , Position )]): Unit = {
954
960
informIDE(s " getDocComment $sym at $source, site $site" )
955
961
respond(response) {
956
- withTempUnits(fragments.unzip._2){ units =>
957
- for ((sym, src) <- fragments) {
958
- val mirror = findMirrorSymbol(sym, units (src))
959
- if (mirror ne NoSymbol ) forceDocComment(mirror, units (src))
962
+ withTempUnits(fragments.unzip._2) { unitForSrc =>
963
+ for ((sym, src) <- fragments) {
964
+ val mirror = findMirrorSymbol(sym, unitForSrc (src))
965
+ if (mirror ne NoSymbol ) forceDocComment(mirror, unitForSrc (src))
960
966
}
961
- val mirror = findMirrorSymbol(sym, units (source))
967
+ val mirror = findMirrorSymbol(sym, unitForSrc (source))
962
968
if (mirror eq NoSymbol )
963
969
(" " , " " , NoPosition )
964
- else {
970
+ else
965
971
(expandedDocComment(mirror, site), rawDocComment(mirror), docCommentPos(mirror))
966
- }
967
972
}
968
973
}
969
974
// New typer run to remove temp units and drop per-run caches that might refer to symbols entered from temp units.
0 commit comments