Skip to content

Conversation

@olafurpg
Copy link
Contributor

@olafurpg olafurpg commented Mar 24, 2021

Previously, we shelled out to lsif-semanticdb to convert SemanticDB
files into LSIF. This commit ports the original Go implemementation to
Java so that we can call a normal method instead of shelling out to a
separate process.

The biggest problem with the previous solution is that it complicated
installation for users. As we evolve lsif-java, the conversion logic
will also evolve and we want to avoid the situation where users have
an outdated version of lsif-semanticdb installed. With this commit,
users only need to install lsif-java and everything should work
correctly.

This PR also adds a new snapshot-lsif command to pretty-print an
LSIF index, similar to how we pretty-print SemanticDB payloads. This
command is mostly useful for testing purposes, but could be helpful
to troubleshoot user issues.

LSIF snapshot generated for lsif-go

CleanShot 2021-03-24 at 11 48 33@2x

LSIF snapshot generated for lsif-node

CleanShot 2021-03-24 at 11 48 53@2x

.zipWithIndex
.foreach { case (line, i) =>
out.append(line)
out.append(line.replace("\t", ""))
Copy link
Contributor

Choose a reason for hiding this comment

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

Im curious if theres a reason we cant do replace("\t", " ") instead here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I we can do that but it removes the fact that there's a tab character, which may be helpful to debug an issue.

writer.emitItem(ids.referenceResult, rangeId, doc.id);

// Definition
if (occ.getRole() == SymbolOccurrence.Role.DEFINITION && ids.isDefinitionDefined()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

in what case is ids.isDefinitionDefined() == true aka when would we have two identical definitions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The definition ID should always be available in this case, it's a bug if it's not. I updated the code to report an error message in this case instead of silently ignoring it.

Previously, we shelled out to `lsif-semanticdb` to convert SemanticDB
files into LSIF. This commit ports the original Go implemementation to
Java so that we can call a normal method instead of shelling out to a
separate process.

The biggest problem with the previous solution is that it complicated
installation for users. As we evolve lsif-java, the conversion logic
will also evolve and we want to avoid the situation where users have
an outdated version of lsif-semanticdb installed. With this commit,
users only need to install `lsif-java` and everything should work
correctly.

This commit also adds a new `snapshot-lsif` command to pretty-print an
LSIF index, similar to how we pretty-print SemanticDB payloads. This
command is mostly useful for testing purposes, but could be helpful
to troubleshoot user issues.
@olafurpg olafurpg merged commit 8bf82e4 into sourcegraph:main Mar 24, 2021
@olafurpg olafurpg deleted the lsif-emitter branch March 24, 2021 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants