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