Skip to content

Commit e1d0ec9

Browse files
committed
Add some comments
1 parent c5a80c4 commit e1d0ec9

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Compiler {
3838
List(new CheckUnused.PostTyper) :: // Check for unused elements
3939
List(new YCheckPositions) :: // YCheck positions
4040
List(new sbt.ExtractDependencies) :: // Sends information on classes' dependencies to sbt via callbacks
41-
List(new semanticdb.ExtractSemanticDB.PostTyper) :: // Extract info into .semanticdb files
41+
List(new semanticdb.ExtractSemanticDB.PostTyper) :: // Extract info and attach to the tree of the unit file
4242
List(new PostTyper) :: // Additional checks and cleanups after type checking
4343
List(new sjs.PrepJSInterop) :: // Additional checks and transformations for Scala.js (Scala.js only)
4444
List(new sbt.ExtractAPI) :: // Sends a representation of the API of classes to sbt via callbacks
@@ -51,7 +51,7 @@ class Compiler {
5151
List(new Inlining) :: // Inline and execute macros
5252
List(new PostInlining) :: // Add mirror support for inlined code
5353
List(new CheckUnused.PostInlining) :: // Check for unused elements
54-
List(new semanticdb.ExtractSemanticDB.PostInlining) :: // Extract info into .semanticdb files
54+
List(new semanticdb.ExtractSemanticDB.PostInlining) :: // Attach warnings to extracted SemanticDB and write to .semanticdb file
5555
List(new Staging) :: // Check staging levels and heal staged types
5656
List(new Splicing) :: // Replace level 1 splices with holes
5757
List(new PickleQuotes) :: // Turn quoted trees into explicit run-time data structures

compiler/src/dotty/tools/dotc/reporting/Reporter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ abstract class Reporter extends interfaces.ReporterResult {
114114
/** All errors reported by this reporter (ignoring outer reporters) */
115115
def allErrors: List[Error] = errors
116116

117-
/** All errors reported by this reporter (ignoring outer reporters) */
117+
/** All warnings reported by this reporter (ignoring outer reporters) */
118118
def allWarnings: List[Warning] = warnings
119119

120120
/** Were sticky errors reported? Overridden in StoreReporter. */

compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
3649
class 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

Comments
 (0)