Skip to content

Commit cbd4b39

Browse files
swachterKordyjan
authored andcommitted
Add -semanticdb-text compiler option to enable text output into semantic db
[Cherry-picked 24694e8]
1 parent f3e984d commit cbd4b39

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Diff for: compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ trait AllScalaSettings extends CommonScalaSettings, PluginSettings, VerboseSetti
5454

5555
/* Path related settings */
5656
val semanticdbTarget: Setting[String] = PathSetting("-semanticdb-target", "Specify an alternative output directory for SemanticDB files.", "")
57+
val semanticdbText: Setting[Boolean] = BooleanSetting("-semanticdb-text", "Specifies whether to include source code in SemanticDB files or not.")
5758

5859
val source: Setting[String] = ChoiceSetting("-source", "source version", "source version", ScalaSettings.supportedSourceVersions, SourceVersion.defaultSourceVersion.toString, aliases = List("--source"))
5960
val uniqid: Setting[Boolean] = BooleanSetting("-uniqid", "Uniquely tag all identifiers in debugging output.", aliases = List("--unique-id"))

Diff for: compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala

+4-1
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,9 @@ object ExtractSemanticDB:
483483
.filterNot(_.isEmpty)
484484
.map(Paths.get(_))
485485

486+
private def semanticdbText(using Context): Boolean =
487+
ctx.settings.semanticdbText.value
488+
486489
private def outputDirectory(using Context): AbstractFile = ctx.settings.outputDir.value
487490

488491
def write(
@@ -503,7 +506,7 @@ object ExtractSemanticDB:
503506
schema = Schema.SEMANTICDB4,
504507
language = Language.SCALA,
505508
uri = Tools.mkURIstring(Paths.get(relPath)),
506-
text = "",
509+
text = if semanticdbText then String(source.content) else "",
507510
md5 = internal.MD5.compute(String(source.content)),
508511
symbols = symbolInfos,
509512
occurrences = occurrences,

0 commit comments

Comments
 (0)