Skip to content

Add readme for SemanticDB directory #5268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions semanticdb/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# SemanticDB

To run the tests use two terminals. In the first terminal compile the
`semanticdb/input` project whenever sources change in
`semanticdb/input/src/main/scala/**.scala`.

```
cd semanticdb/input
sbt
> compile
```

In the second terminal, run `sbt dotty-semanticdb/test` from the main dotty
build

```
sbt
> dotty-semanticdb/test
```

The tests assert that the TASTy to SemanticDB converter produces the same output
as the semanticdb-scalac compiler plugin. Test failures result in diffs like
this

```diff
Test dotty.semanticdb.Tests.testExample failed: java.lang.AssertionError:
--- tasty
+++ scala2
-class Example {
- val a: String = "1"
+class Example /*example/Example#*/ {
+ val a /*example/Example#a.*/ : String /*scala/Predef.String#*/ = "1"
```

The lines starting with `-` are the output from the TASTy converter and the
lines starting with `+` are the output from the semanticdb-scalac compiler
plugin.

Once the TASTy converter is updated to emit correct `SymbolOccurrence`
(https://scalameta.org/docs/semanticdb/specification.html#symboloccurrence) then
the "tasty" output should become identical to "scala2" and include inline
comments `class Example /* pkg/Example# */`. The inline comments are read as:
"the symbol `pkg/Example#` was resolved next to the class name `Example`".

The spec for SemanticDB symbols can be found here:

- Scala symbols:
https://scalameta.org/docs/semanticdb/specification.html#scala-symbol
- Java symbols:
https://scalameta.org/docs/semanticdb/specification.html#java-symbol