-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement: clear diagnostics in downstream targets (#6604)
* improvement: clear diagnostics in downstream targets, when compilation failed * add build target mapping * don't remove downstream diagnostics for best effort compilation * clean up * rename things * use `enableBestEffort` setting
- Loading branch information
1 parent
d4f0e1e
commit 074cf7a
Showing
6 changed files
with
197 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
metals/src/main/scala/scala/meta/internal/metals/PreviouslyCompiledDownsteamTargets.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package scala.meta.internal.metals | ||
|
||
import scala.collection.concurrent.TrieMap | ||
import scala.collection.mutable | ||
|
||
import ch.epfl.scala.bsp4j.BuildTargetIdentifier | ||
|
||
/** | ||
* When there are some upstream compile errors we remove diagnostics from downstream targets, | ||
* since those can be stale. Not to give a false impression, that the project compiles | ||
* when upstream errors get fixed, we map compilation of upstream targets to | ||
* appropriate downstream targets. This class holds this mapping. | ||
*/ | ||
class PreviouslyCompiledDownsteamTargets { | ||
private val map = | ||
TrieMap.empty[BuildTargetIdentifier, Set[BuildTargetIdentifier]] | ||
|
||
def transitiveTargetsOf( | ||
targets: Seq[BuildTargetIdentifier] | ||
): Seq[BuildTargetIdentifier] = { | ||
if (map.isEmpty) targets | ||
else { | ||
val finalSet = mutable.Set[BuildTargetIdentifier]() | ||
for (key <- targets) | ||
map.get(key) match { | ||
case Some(set) if set.nonEmpty => finalSet ++= set | ||
case _ => finalSet += key | ||
} | ||
finalSet.toSeq | ||
} | ||
} | ||
|
||
def addMapping( | ||
id: BuildTargetIdentifier, | ||
to: Set[BuildTargetIdentifier], | ||
): Option[Set[BuildTargetIdentifier]] = synchronized { | ||
val newValue = map.get(id).map(to ++ _).getOrElse(to) | ||
map.put(id, newValue) | ||
} | ||
|
||
def remove(id: BuildTargetIdentifier): Unit = synchronized { | ||
for (key <- map.keySet) { | ||
for { | ||
oldSet <- map.get(key) | ||
if (oldSet.contains(id)) | ||
} map.put(id, oldSet - id) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters