@@ -32,10 +32,23 @@ import dotty.tools.dotc.semanticdb.DiagnosticOps.*
3232/** Extract symbol references and uses to semanticdb files.
3333 * See https://scalameta.org/docs/semanticdb/specification.html#symbol-1
3434 * for a description of the format.
35+ *
36+ * Here, we define two phases for "ExtractSemanticDB", "PostTyper" and "PostInlining".
37+ *
38+ * The "PostTyper" phase extracts SemanticDB information such as symbol
39+ * definitions, symbol occurrences, type information, and synthetics.
40+ * This phase does not write the information to a .semanticdb file;
41+ * instead, it attaches the SemanticDB information to the top-level tree.
42+ *
43+ * The "PostInlining" phase extracts diagnostics from "ctx.reporter" and
44+ * attaches them to the SemanticDB information extracted in the "PostTyper" phase.
45+ * Afterwards, it writes the SemanticDB to a ".semanticdb" file.
46+ * We need to run this phase after the "CheckUnused.PostInlining" phase
47+ * so that we can extract the warnings generated by "-Wunused".
3548 */
3649class ExtractSemanticDB private (phaseMode : ExtractSemanticDB .PhaseMode , suffix : String , _key : Property .Key [TextDocument ]) extends Phase :
3750
38- override def phaseName : String = ExtractSemanticDB .phaseNamePrefix + suffix
51+ override val phaseName : String = ExtractSemanticDB .phaseNamePrefix + suffix
3952
4053 override val description : String = ExtractSemanticDB .description
4154
@@ -55,7 +68,7 @@ class ExtractSemanticDB private (phaseMode: ExtractSemanticDB.PhaseMode, suffix:
5568 unit.tpdTree.putAttachment(_key, extractor.toTextDocument(unit.source))
5669 else
5770 unit.tpdTree.getAttachment(_key) match
58- case None => ???
71+ case None =>
5972 case Some (doc) =>
6073 val warnings = ctx.reporter.allWarnings.collect {
6174 case w if w.pos.source == ctx.source => w.toSemanticDiagnostic
0 commit comments