Skip to content

Commit e53a450

Browse files
Strum355olafurpg
andauthored
skip outputting lsif snapshot for files located outside the sourceroot (#195)
Co-authored-by: Ólafur Páll Geirsson <[email protected]>
1 parent 548e179 commit e53a450

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lsif-java/src/main/scala/com/sourcegraph/lsif_java/commands/SnapshotLsifCommand.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ case class SnapshotLsifCommand(
4949
@PositionalArguments() input: List[Path] = List(Paths.get("dump.lsif"))
5050
) extends Command {
5151

52-
private val finalOutput = AbsolutePath.of(output, sourceroot)
5352
def sourceroot: Path = AbsolutePath.of(app.env.workingDirectory)
53+
private val finalOutput = AbsolutePath.of(output, sourceroot)
5454

5555
def run(): Int = {
5656
Files.walkFileTree(finalOutput, new DeleteVisitor())
@@ -59,7 +59,12 @@ case class SnapshotLsifCommand(
5959
in = AbsolutePath.of(inputPath, sourceroot)
6060
doc <- SnapshotLsifCommand.parseTextDocument(in, sourceroot)
6161
} {
62-
SnapshotCommand.writeSnapshot(doc, finalOutput)
62+
val docPath = AbsolutePath
63+
.of(Paths.get(doc.getUri), sourceroot)
64+
.toRealPath()
65+
if (docPath.toAbsolutePath.startsWith(sourceroot)) {
66+
SnapshotCommand.writeSnapshot(doc, finalOutput)
67+
}
6368
}
6469
0
6570
}

0 commit comments

Comments
 (0)