Skip to content

Add Semanticdb data models generated from semanticdb.proto #12780

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 4 commits into from
Jun 14, 2021

Conversation

tanishiking
Copy link
Member

Related issues

Abstract

This PR adds Semanticdb's data models (e.g., SymbolInformation, ClassSignature, etc., see https://scalameta.org/docs/semanticdb/specification.html#data-model) generated from semanticdb.proto, and the first step to adding Signature information (and Synthetics section in the future) to SemanticDB extracted from Scala3.

How these scala codes are generated

They (in package dotty.tools.dotc.semanticdb) are generated from https://github.com/tanishiking/semanticdb-for-scala3 that

And I copy-and-pasted generated codes.

Why I decided to generate Scala code using Scalapb and Scalafix

See: scalameta/scalameta#2367

Possible alternative options

  • Add scalapb-runtime dependency to scala3
    • and generate scala code using scalapb in this (lampepfl/dotty) project.
  • If there's another possible option, let me know!

These data models are automatically generated from
https://github.com/tanishiking/semanticdb-for-scala3
tanishiking/semanticdb-for-scala3@d0d04f0

which generates Scala code from semanticdb.proto using Scalapb,
and adjust them using scalafix to remove the dependency to
`scalapb-runtime` from generated code.
// Generated by the Scala Plugin for the Protocol Buffer Compiler.
// Do not edit!
//
// Protofile syntax: PROTO3
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe I should comment it is generated from tanishiking/semanticdb-for-scala3 ?

@bishabosha
Copy link
Member

bishabosha commented Jun 10, 2021

I noticed in your generator you remove @transient and @SerialVersionUID, given that the generated code will still extend Serializable they should probably remain (it was probably a mistake to remove them before)

bytes = readRawBytesSlowPath(size);
pos = 0;
}
// TODO: should validate Utf8
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this TODO coming from? Let's remove it if it's not needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure where they (the Scala codes under semancidb.internal package) originally come from, if they are from https://android.googlesource.com/platform/external/protobuf/+/7fca48d8ce97f7ba3ab8eea5c472f1ad3711762f/java/src/main/java/com/google/protobuf , maybe we should add the copyright header

// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc.  All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//     * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

As it says,

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

Looks good from my side, we should apply @bishabosha suggestions, but otherwise it's generated code that should work ok.

Copy link
Member

@bishabosha bishabosha left a comment

Choose a reason for hiding this comment

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

LGTM, thank you. We could follow up by removing the files compiler/src/dotty/tools/dotc/semanticdb/internal/SemanticdbEnum.scala and compiler/src/dotty/tools/dotc/semanticdb/internal/SemanticdbMessage.scala

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.

3 participants