Skip to content

skip outputting lsif snapshot for files located outside the sourceroot#195

Merged
Strum355 merged 2 commits into
mainfrom
nsc/lsif-snapshot-skip-notinsourceroot
May 12, 2021
Merged

skip outputting lsif snapshot for files located outside the sourceroot#195
Strum355 merged 2 commits into
mainfrom
nsc/lsif-snapshot-skip-notinsourceroot

Conversation

@Strum355

Copy link
Copy Markdown
Contributor

Fixes the following exception being thrown when a document in the LSIF dump points to a file outside the source root. They get filtered out by the backend anyways so I see no reason to come up with a way to display them in the snapshot

$ lsif-java snapshot-lsif
java.nio.file.NoSuchFileException: /tmp/highlight_tool/generated/../../home/noah/.config/nvm/14.15.4/lib/node_modules/@sourcegraph/lsif-tsc/node_modules/typescript-lsif/lib/lib.es5.d.ts
	at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
	at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:218)
	at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:478)
	at java.base/java.nio.file.Files.newOutputStream(Files.java:224)
	at java.base/java.nio.file.Files.write(Files.java:3491)
	at com.sourcegraph.lsif_java.commands.SnapshotCommand$.writeSnapshot(SnapshotCommand.scala:89)
	at com.sourcegraph.lsif_java.commands.SnapshotLsifCommand.$anonfun$run$3(SnapshotLsifCommand.scala:62)
	at com.sourcegraph.lsif_java.commands.SnapshotLsifCommand.$anonfun$run$3$adapted(SnapshotLsifCommand.scala:60)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at com.sourcegraph.lsif_java.commands.SnapshotLsifCommand.$anonfun$run$2(SnapshotLsifCommand.scala:60)
	at com.sourcegraph.lsif_java.commands.SnapshotLsifCommand.$anonfun$run$2$adapted(SnapshotLsifCommand.scala:58)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at com.sourcegraph.lsif_java.commands.SnapshotLsifCommand.run(SnapshotLsifCommand.scala:58)
	at moped.cli.Command.$anonfun$runAsFuture$1(BaseCommand.scala:14)
	at scala.runtime.java8.JFunction0$mcI$sp.apply(JFunction0$mcI$sp.scala:17)
	at scala.util.Try$.apply(Try.scala:210)
	at moped.cli.Command.runAsFuture(BaseCommand.scala:14)
	at moped.cli.Application$.$anonfun$run$7(Application.scala:317)
	at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:434)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1429)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

@olafurpg olafurpg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

} {
SnapshotCommand.writeSnapshot(doc, finalOutput)
val docPath = AbsolutePath.of(Path.of(doc.getUri), sourceroot).toRealPath()
if (docPath.toAbsolutePath.startsWith(sourceroot)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, you can define variables and add if conditions inside for comprehensions. Not relevant in this diff here but could be useful if you want to continue to drill deeper into a data structure

@Strum355 Strum355 force-pushed the nsc/lsif-snapshot-skip-notinsourceroot branch from 59f5410 to 7d2382c Compare May 12, 2021 12:34
…apshotLsifCommand.scala

Co-authored-by: Ólafur Páll Geirsson <olafurpg@gmail.com>
@Strum355 Strum355 force-pushed the nsc/lsif-snapshot-skip-notinsourceroot branch from 7d2382c to ac795b3 Compare May 12, 2021 13:02
@Strum355 Strum355 merged commit e53a450 into main May 12, 2021
@Strum355 Strum355 deleted the nsc/lsif-snapshot-skip-notinsourceroot branch May 12, 2021 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants