File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
src/dotty/tools/dotc/semanticdb
test/dotty/tools/dotc/core/tasty Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import Names.Name
1212import StdNames .nme
1313import util .Spans .Span
1414import util .{SourceFile , SourcePosition }
15+ import scala .jdk .CollectionConverters ._
1516import collection .mutable
1617import java .nio .file .Paths
1718
@@ -594,8 +595,20 @@ object ExtractSemanticDB:
594595
595596 def write (source : SourceFile , occurrences : List [SymbolOccurrence ], symbolInfos : List [SymbolInformation ])(using Context ): Unit =
596597 def absolutePath (path : Path ): Path = path.toAbsolutePath.normalize
598+ def common (root : Path , i1 : java.util.Iterator [Path ], i2 : java.util.Iterator [Path ]) =
599+ require(root != null )
600+ var res : Path = root
601+ var next : Path = null
602+ while
603+ i1.hasNext && i2.hasNext
604+ && { next = i1.next; next } == i2.next
605+ do res = res.resolve(next)
606+ res
607+ end common
597608 val sourcePath = absolutePath(source.file.jpath)
598- val sourceRoot = absolutePath(Paths .get(ctx.settings.sourceroot.value))
609+ val sourceRoot =
610+ val sourceRoot0 = absolutePath(Paths .get(ctx.settings.sourceroot.value))
611+ common(sourcePath.getRoot, sourcePath.iterator, sourceRoot0.iterator)
599612 val semanticdbTarget =
600613 val semanticdbTargetSetting = ctx.settings.semanticdbTarget.value
601614 absolutePath(
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ class CommentPicklingTest {
8282 Directory .inTempDirectory { tmp =>
8383 val sourceFiles = sources.zipWithIndex.map {
8484 case (src, id) =>
85- val path = tmp./ (File (" Src$id.scala" )).toAbsolute
85+ val path = tmp./ (File (s " Src $id.scala " )).toAbsolute
8686 path.writeAll(src)
8787 path.toString
8888 }
You can’t perform that action at this time.
0 commit comments