Skip to content
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

Add Signature information for Semanticdb #12766

Open
2 of 3 tasks
tanishiking opened this issue Jun 9, 2021 · 1 comment
Open
2 of 3 tasks

Add Signature information for Semanticdb #12766

tanishiking opened this issue Jun 9, 2021 · 1 comment

Comments

@tanishiking
Copy link
Member

tanishiking commented Jun 9, 2021

Background

Current SemanticdbExtractor in Scala3 doesn't extract `` Signature information, which represents the type information for class, method, type, and local value.

Actually, from the following scala code,

class Simple {
  val a = 123
  a + a
}

symbols section will look like:

Scala 2

 Vector(
        SymbolInformation(
          "_empty_/Simple#",
          SCALA,
          CLASS,
          0,
          "Simple",
          ClassSignature(
            Some(Scope(Vector(), Vector())),
            Vector(TypeRef(Empty, "scala/AnyRef#", Vector())),
            Empty,
            Some(Scope(Vector("_empty_/Simple#`<init>`().", "_empty_/Simple#a."), Vector()))
          ),
          Vector(),
          PublicAccess()
        ),
        SymbolInformation(
          "_empty_/Simple#`<init>`().",
          SCALA,
          CONSTRUCTOR,
          8192,
          "<init>",
          MethodSignature(Some(Scope(Vector(), Vector())), Vector(Scope(Vector(), Vector())), Empty),
          Vector(),
          PublicAccess()
        ),
        SymbolInformation(
          "_empty_/Simple#a.",
          SCALA,
          METHOD,
          1024,
          "a",
          MethodSignature(
            Some(Scope(Vector(), Vector())),
            Vector(),
            TypeRef(Empty, "scala/Int#", Vector())
          ),
          Vector(),
          PublicAccess()
        )
      ),

compared to Scala 3 which is missing all information about signatures.

Scala 3

      Vector(
        SymbolInformation("_empty_/Simple#", SCALA, CLASS, 0, "Simple", Empty, Vector(), Empty),
        SymbolInformation(
          "_empty_/Simple#`<init>`().",
          SCALA,
          CONSTRUCTOR,
          8192,
          "<init>",
          Empty,
          Vector(),
          Empty
        ),
        SymbolInformation("_empty_/Simple#a.", SCALA, METHOD, 1024, "a", Empty, Vector(), Empty)
      ),

(copied from scalameta/metals#2593 (reply in thread))

Without Signature information in extracted SemanticDB, devtools based on Semanticdb lacks some functionalities for Scala3.
For example, metals can't provide textDocument/implementation and type decorations features for scala3 project, we can't implement scalafix rules that depends on Signature information.


TODOs

(details) Generate Semanticdb's data structures

As discussed here scalameta/scalameta#2367 , it would be a good first step to keep copy-and-paste and adjust the generated scala codes.
However, hand-crafting all those data-structure (because there's a lot of data structures that related to Signature) is tedious and it makes harder to catch-up new version of scalapb or new scalameta.proto.

Therefore, we'll create a project that generate the Scala code from scalameta.proto using Scalapb, and adjust them using scalafix (so that Scala3 compiler doesn't need to have dependency on scalapb-runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants