Skip to content

Commit 99b6f0b

Browse files
authored
Merge pull request #228 from olafurpg/kind-local
Use "local" instead of "import" for local symbol monikers.
2 parents 32ff67b + 9326f20 commit 99b6f0b

File tree

8 files changed

+136
-134
lines changed

8 files changed

+136
-134
lines changed

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

+4-4
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-
def sourceroot: Path = AbsolutePath.of(app.env.workingDirectory)
53-
private val finalOutput = AbsolutePath.of(output, sourceroot)
52+
def sourceroot: Path = AbsolutePath.of(app.env.workingDirectory).normalize()
53+
private val finalOutput = AbsolutePath.of(output, sourceroot).normalize()
5454

5555
def run(): Int = {
5656
Files.walkFileTree(finalOutput, new DeleteVisitor())
@@ -61,7 +61,7 @@ case class SnapshotLsifCommand(
6161
} {
6262
val docPath = AbsolutePath
6363
.of(Paths.get(doc.getUri), sourceroot)
64-
.toRealPath()
64+
.normalize()
6565
if (docPath.toAbsolutePath.startsWith(sourceroot)) {
6666
SnapshotCommand.writeSnapshot(doc, finalOutput)
6767
}
@@ -252,7 +252,7 @@ object SnapshotLsifCommand {
252252
.trim()
253253
s"hoverResult(${node.getId}) ${contents}"
254254
case ("vertex", "moniker") =>
255-
s"moniker ${node.getIdentifier}"
255+
s"${node.getKind} ${node.getIdentifier}"
256256
case ("vertex", "range") =>
257257
val i = input(node)
258258
val p = Position.range(

lsif-semanticdb/src/main/java/com/sourcegraph/lsif_semanticdb/LsifWriter.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.sourcegraph.lsif_protocol.LsifObject;
66
import com.sourcegraph.lsif_protocol.LsifPosition;
77
import com.sourcegraph.semanticdb_javac.Semanticdb;
8+
import com.sourcegraph.semanticdb_javac.SemanticdbSymbols;
89
import java.io.BufferedOutputStream;
910
import java.io.IOException;
1011
import java.nio.file.Files;
@@ -112,7 +113,8 @@ public void emitMonikerEdge(int outV, int inV) {
112113
}
113114

114115
public int emitMonikerVertex(String symbol, boolean isExportedSymbol) {
115-
String kind = isExportedSymbol ? "export" : "import";
116+
String kind =
117+
SemanticdbSymbols.isLocal(symbol) ? "local" : isExportedSymbol ? "export" : "import";
116118
return emitObject(
117119
lsifVertex("moniker").setKind(kind).setScheme("semanticdb").setIdentifier(symbol));
118120
}

tests/snapshots/src/main/generated/index-semanticdb/locals

+34-34
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,41 @@ public class Example {
1717
──────────────────────────────────
1818
│ LSIF Graph for symbol 'local0' │
1919
──────────────────────────────────
20-
╭──────────╮
21-
│project(2)│
22-
╰─────┬────╯
23-
24-
╭──────────────
20+
╭──────────╮
21+
│project(2)│
22+
╰─────┬────╯
23+
24+
╭──────────────╯
2525
2626
v
2727
╭─────────────────────────────╮ ╭───────────────────╮
2828
│document example/Example.java│ │referenceResult(48)│
29-
╰─────┬────────────┬────────╯ ╰────┬─────────────╯
30-
│^
31-
╭────── ╭───────────────╯│ ╰───╮
32-
│ │
33-
v v
34-
╭──────────────────╮
35-
│range(56) 3:46 'n'│
36-
╰────────────┬─────╯
37-
╭───────────╯
38-
v
39-
╭─────────┴───╮
40-
│resultSet(43)│
41-
╰──┬─────┬───┬╯
42-
│ │ ^│
43-
v │ ││
44-
╭────────────────────│ │
45-
│definitionResult(46)│ │ │
46-
───────────────────││
47-
││
48-
╰──┼┼──────────────╮
49-
│ ╭──────────╯│
50-
╰───────────────╮
51-
╭────────────┼─────────────────╯
52-
│ │ │ ╭──────────────────────┼────╯
53-
│ │ │ │ │
54-
v v v │ v v
55-
╭──────────────╮ ╭───────────┴──────╮ ╭───────────────────────────────────╮
56-
moniker local0│ │range(50) 3:34 'n'│ │hoverResult(54) ```java\nint n\n```│
57-
╰──────────────╯ ╰──────────────────╯ ╰───────────────────────────────────╯
29+
╰─────┬────────────┬──────────╯ ╰────┬─────────────╯
30+
│ │ ^ │
31+
╭──────╯ │ │ │
32+
│ │ ╭───────────────┼─╯
33+
34+
v v │
35+
╭──────────────────╮
36+
│range(56) 3:46 'n'│
37+
╰────────────┬─────╯ │ │
38+
│ │ ╭──────────╯
39+
v │
40+
╭─────────┴───╮
41+
│resultSet(43)│
42+
╰──┬──┬──┬────╯
43+
│ │ │ ^
44+
│ ╭─────────────────────┼──╯ │ │
45+
v │ │
46+
────────────────────╮ │
47+
│definitionResult(46)│ │ │
48+
╰──────────┬─────────╯ │ │
49+
│ ╭───────┼──╯
50+
╰──────────────────╮
51+
╰─┼───────────
52+
│ │ │ │ ╭──────────────────────┼──────╯
53+
│ │ │ │ │
54+
v v v │ v v
55+
╭────────────╮ ╭───────────┴──────╮ ╭───────────────────────────────────╮
56+
local local0│ │range(50) 3:34 'n'│ │hoverResult(54) ```java\nint n\n```│
57+
╰────────────╯ ╰──────────────────╯ ╰───────────────────────────────────╯

0 commit comments

Comments
 (0)