Skip to content

Commit

Permalink
Merge pull request #228 from olafurpg/kind-local
Browse files Browse the repository at this point in the history
Use "local" instead of "import"  for local symbol monikers.
  • Loading branch information
olafurpg authored May 21, 2021
2 parents 32ff67b + 9326f20 commit 99b6f0b
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ case class SnapshotLsifCommand(
@PositionalArguments() input: List[Path] = List(Paths.get("dump.lsif"))
) extends Command {

def sourceroot: Path = AbsolutePath.of(app.env.workingDirectory)
private val finalOutput = AbsolutePath.of(output, sourceroot)
def sourceroot: Path = AbsolutePath.of(app.env.workingDirectory).normalize()
private val finalOutput = AbsolutePath.of(output, sourceroot).normalize()

def run(): Int = {
Files.walkFileTree(finalOutput, new DeleteVisitor())
Expand All @@ -61,7 +61,7 @@ case class SnapshotLsifCommand(
} {
val docPath = AbsolutePath
.of(Paths.get(doc.getUri), sourceroot)
.toRealPath()
.normalize()
if (docPath.toAbsolutePath.startsWith(sourceroot)) {
SnapshotCommand.writeSnapshot(doc, finalOutput)
}
Expand Down Expand Up @@ -252,7 +252,7 @@ object SnapshotLsifCommand {
.trim()
s"hoverResult(${node.getId}) ${contents}"
case ("vertex", "moniker") =>
s"moniker ${node.getIdentifier}"
s"${node.getKind} ${node.getIdentifier}"
case ("vertex", "range") =>
val i = input(node)
val p = Position.range(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.sourcegraph.lsif_protocol.LsifObject;
import com.sourcegraph.lsif_protocol.LsifPosition;
import com.sourcegraph.semanticdb_javac.Semanticdb;
import com.sourcegraph.semanticdb_javac.SemanticdbSymbols;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.nio.file.Files;
Expand Down Expand Up @@ -112,7 +113,8 @@ public void emitMonikerEdge(int outV, int inV) {
}

public int emitMonikerVertex(String symbol, boolean isExportedSymbol) {
String kind = isExportedSymbol ? "export" : "import";
String kind =
SemanticdbSymbols.isLocal(symbol) ? "local" : isExportedSymbol ? "export" : "import";
return emitObject(
lsifVertex("moniker").setKind(kind).setScheme("semanticdb").setIdentifier(symbol));
}
Expand Down
68 changes: 34 additions & 34 deletions tests/snapshots/src/main/generated/index-semanticdb/locals
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,41 @@ public class Example {
──────────────────────────────────
│ LSIF Graph for symbol 'local0' │
──────────────────────────────────
╭──────────╮
│project(2)│
╰─────┬────╯
╭──────────────
╭──────────╮
│project(2)│
╰─────┬────╯
╭──────────────╯
v
╭─────────────────────────────╮ ╭───────────────────╮
│document example/Example.java│ │referenceResult(48)│
╰─────┬────────────┬────────╯ ╰────┬─────────────╯
│^
╭────── ╭───────────────╯│ ╰───╮
│ │
v v
╭──────────────────╮
│range(56) 3:46 'n'│
╰────────────┬─────╯
╭───────────╯
v
╭─────────┴───╮
│resultSet(43)│
╰──┬─────┬───┬╯
│ │ ^│
v │ ││
╭────────────────────│ │
│definitionResult(46)│ │ │
───────────────────││
││
╰──┼┼──────────────╮
│ ╭──────────╯│
╰───────────────╮
╭────────────┼─────────────────╯
│ │ │ ╭──────────────────────┼────╯
│ │ │ │ │
v v v │ v v
╭──────────────╮ ╭───────────┴──────╮ ╭───────────────────────────────────╮
moniker local0│ │range(50) 3:34 'n'│ │hoverResult(54) ```java\nint n\n```│
╰──────────────╯ ╰──────────────────╯ ╰───────────────────────────────────╯
╰─────┬────────────┬──────────╯ ╰────┬─────────────╯
│ │ ^ │
╭──────╯ │ │ │
│ │ ╭───────────────┼─╯
v v │
╭──────────────────╮
│range(56) 3:46 'n'│
╰────────────┬─────╯ │ │
│ │ ╭──────────╯
v │
╭─────────┴───╮
│resultSet(43)│
╰──┬──┬──┬────╯
│ │ │ ^
│ ╭─────────────────────┼──╯ │ │
v │ │
────────────────────╮ │
│definitionResult(46)│ │ │
╰──────────┬─────────╯ │ │
│ ╭───────┼──╯
╰──────────────────╮
╰─┼───────────
│ │ │ │ ╭──────────────────────┼──────╯
│ │ │ │ │
v v v │ v v
╭────────────╮ ╭───────────┴──────╮ ╭───────────────────────────────────╮
local local0│ │range(50) 3:34 'n'│ │hoverResult(54) ```java\nint n\n```│
╰────────────╯ ╰──────────────────╯ ╰───────────────────────────────────╯
Loading

0 comments on commit 99b6f0b

Please sign in to comment.