-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
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 |
There was a problem hiding this comment.
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
?
I noticed in your generator you remove |
bytes = readRawBytesSlowPath(size); | ||
pos = 0; | ||
} | ||
// TODO: should validate Utf8 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed!
Actually this method come from https://android.googlesource.com/platform/external/protobuf/+/7fca48d8ce97f7ba3ab8eea5c472f1ad3711762f/java/src/main/java/com/google/protobuf/CodedInputStream.java#408 and cemented out the validation part, because the callees of readStringRequireUtf8
is only from test https://github.com/tanishiking/dotty/blob/6a534f298b4c3b85af4bd19dc039a36473f0382b/compiler/src/dotty/tools/dotc/semanticdb/Tools.scala#L47 and we can safely parse Semanticdb without validation.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
Because those classes still extends Serializable
There was a problem hiding this 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
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 addingSignature
information (andSynthetics
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 thatscalapb-runtime
andcom.google.protobuf
derives CanEqual
to generated class and traitsAnd I copy-and-pasted generated codes.
Why I decided to generate Scala code using Scalapb and Scalafix
See: scalameta/scalameta#2367
Possible alternative options
scalapb-runtime
dependency toscala3