[jira] [Commented] (SCB-948) convert proto model to string
[ https://issues.apache.org/jira/browse/SCB-948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16650075#comment-16650075 ] ASF GitHub Bot commented on SCB-948: liubao68 closed pull request #946: [SCB-948] Convert proto model to string URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/946 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/common/common-protobuf/pom.xml b/common/common-protobuf/pom.xml index fa999abee..aa7036462 100644 --- a/common/common-protobuf/pom.xml +++ b/common/common-protobuf/pom.xml @@ -31,24 +31,16 @@ org.apache.servicecomb java-chassis-core - - io.protostuff - protostuff-core - - - io.protostuff - protostuff-runtime - org.apache.servicecomb common-javassist + - com.google.protobuf - protobuf-java - 3.3.0 - test + org.apache.servicecomb + foundation-protobuf + org.slf4j slf4j-log4j12 diff --git a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/internal/converter/ProtoToStringGenerator.java b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/internal/converter/ProtoToStringGenerator.java new file mode 100644 index 0..4e1b9edb2 --- /dev/null +++ b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/internal/converter/ProtoToStringGenerator.java @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.servicecomb.codec.protobuf.internal.converter; + +import static org.apache.servicecomb.foundation.common.utils.StringBuilderUtils.appendLine; + +import io.protostuff.compiler.model.Enum; +import io.protostuff.compiler.model.EnumConstant; +import io.protostuff.compiler.model.Field; +import io.protostuff.compiler.model.Import; +import io.protostuff.compiler.model.Message; +import io.protostuff.compiler.model.Proto; +import io.protostuff.compiler.model.Service; +import io.protostuff.compiler.model.ServiceMethod; + +public class ProtoToStringGenerator { + private final Proto proto; + + public ProtoToStringGenerator(Proto proto) { +this.proto = proto; + } + + public String protoToString() { +StringBuilder sb = new StringBuilder(); +appendLine(sb, "syntax = \"%s\";", proto.getSyntax()); +for (Import importValue : proto.getImports()) { + appendLine(sb, "import \"%s\";", importValue.getValue()); +} +appendLine(sb, "package %s;\n", proto.getPackage().getValue()); + +for (Message message : proto.getMessages()) { + messageToString(message, sb); +} + +for (Enum enumValue : proto.getEnums()) { + enumToString(enumValue, sb); +} + +for (Service service : proto.getServices()) { + serviceToString(service, sb); +} +return sb.toString(); + } + + private void serviceToString(Service service, StringBuilder sb) { +appendLine(sb, "service %s {", service.getName()); +for (ServiceMethod serviceMethod : service.getMethods()) { + if (!serviceMethod.getCommentLines().isEmpty()) { +appendLine(sb, " //" + serviceMethod.getComments()); + } + appendLine(sb, " rpc %s (%s) returns (%s);\n", serviceMethod.getName(), serviceMethod.getArgTypeName(), + serviceMethod.getReturnTypeName()); +} +if (!service.getMethods().isEmpty()) { + sb.setLength(sb.length() - 1); +} +appendLine(sb, "}"); + } + + protected void enumToString(Enum enumValue, StringBuilder sb) { +appendLine(sb, "enum %s {", enumValue.getName()); +for (EnumConstant enumConstant : enumValue.getConstants()) { + appendLine(sb, " %s = %s;", enumConstant.getName(), enumConstant.getValue()); +} +sb.append("}\n\n"); + } + + private void messageToString(Message message, StringBuilder sb) { +appendLine(sb, "message %s {", message.getName()); +for (Field field :
[jira] [Commented] (SCB-948) convert proto model to string
[ https://issues.apache.org/jira/browse/SCB-948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16649662#comment-16649662 ] ASF GitHub Bot commented on SCB-948: coveralls edited a comment on issue #946: [SCB-948] Convert proto model to string URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/946#issuecomment-428485743 [![Coverage Status](https://coveralls.io/builds/19517070/badge)](https://coveralls.io/builds/19517070) Coverage increased (+0.04%) to 86.269% when pulling **55451c1b5ca77e97912fd0536c6f5d03dee572c5 on wujimin:convert-proto-model-to-string** into **ddd17bf55c139189b9f2d635c137c99f940d6a26 on apache:master**. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > convert proto model to string > - > > Key: SCB-948 > URL: https://issues.apache.org/jira/browse/SCB-948 > Project: Apache ServiceComb > Issue Type: Sub-task > Components: Java-Chassis >Reporter: wujimin >Assignee: wujimin >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-948) convert proto model to string
[ https://issues.apache.org/jira/browse/SCB-948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16647556#comment-16647556 ] ASF GitHub Bot commented on SCB-948: coveralls edited a comment on issue #946: [SCB-948] Convert proto model to string URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/946#issuecomment-428485743 [![Coverage Status](https://coveralls.io/builds/19484786/badge)](https://coveralls.io/builds/19484786) Coverage increased (+0.02%) to 86.245% when pulling **32a1eb5b79ed46ff1e8f6283af7e7aa3d33507b2 on wujimin:convert-proto-model-to-string** into **ddd17bf55c139189b9f2d635c137c99f940d6a26 on apache:master**. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > convert proto model to string > - > > Key: SCB-948 > URL: https://issues.apache.org/jira/browse/SCB-948 > Project: Apache ServiceComb > Issue Type: Sub-task > Components: Java-Chassis >Reporter: wujimin >Assignee: wujimin >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-948) convert proto model to string
[ https://issues.apache.org/jira/browse/SCB-948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16647545#comment-16647545 ] ASF GitHub Bot commented on SCB-948: wujimin commented on a change in pull request #946: [SCB-948] Convert proto model to string URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/946#discussion_r224684675 ## File path: java-chassis-distribution/src/release/LICENSE ## @@ -461,3 +461,4 @@ Zipkin Sender: OkHttp 3 (https://github.com/openzipkin/zipkin-reporter-java/zipk Zipkin v1 (https://github.com/openzipkin/zipkin/) io.zipkin.java:zipkin:jar:2.4.2 Zipkin v2 (https://github.com/openzipkin/zipkin/) io.zipkin.zipkin2:zipkin:jar:2.4.2 zuul-core (https://github.com/Netflix/zuul) com.netflix.zuul:zuul-core:jar:1.3.0 +protobuf-java (https://github.com/protocolbuffers/protobuf/tree/master/java) com.google.protobuf:protobuf-java:jar:3.6.1 Review comment: it's 3-Clause BSD license fixed This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > convert proto model to string > - > > Key: SCB-948 > URL: https://issues.apache.org/jira/browse/SCB-948 > Project: Apache ServiceComb > Issue Type: Sub-task > Components: Java-Chassis >Reporter: wujimin >Assignee: wujimin >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-948) convert proto model to string
[ https://issues.apache.org/jira/browse/SCB-948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16646277#comment-16646277 ] ASF GitHub Bot commented on SCB-948: liubao68 commented on a change in pull request #946: [SCB-948] Convert proto model to string URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/946#discussion_r224404316 ## File path: java-chassis-distribution/src/release/LICENSE ## @@ -461,3 +461,4 @@ Zipkin Sender: OkHttp 3 (https://github.com/openzipkin/zipkin-reporter-java/zipk Zipkin v1 (https://github.com/openzipkin/zipkin/) io.zipkin.java:zipkin:jar:2.4.2 Zipkin v2 (https://github.com/openzipkin/zipkin/) io.zipkin.zipkin2:zipkin:jar:2.4.2 zuul-core (https://github.com/Netflix/zuul) com.netflix.zuul:zuul-core:jar:1.3.0 +protobuf-java (https://github.com/protocolbuffers/protobuf/tree/master/java) com.google.protobuf:protobuf-java:jar:3.6.1 Review comment: This project does not using Apache License v2 This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > convert proto model to string > - > > Key: SCB-948 > URL: https://issues.apache.org/jira/browse/SCB-948 > Project: Apache ServiceComb > Issue Type: Sub-task > Components: Java-Chassis >Reporter: wujimin >Assignee: wujimin >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-948) convert proto model to string
[ https://issues.apache.org/jira/browse/SCB-948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16644624#comment-16644624 ] ASF GitHub Bot commented on SCB-948: coveralls commented on issue #946: [SCB-948] Convert proto model to string URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/946#issuecomment-428485743 [![Coverage Status](https://coveralls.io/builds/19441741/badge)](https://coveralls.io/builds/19441741) Coverage increased (+0.03%) to 86.246% when pulling **138940c0a31eccd8cd8fd42cfe8cdea1a93ec26e on wujimin:convert-proto-model-to-string** into **c3f1d662cd5b41b17b58e553a45b144c8101e8ad on apache:master**. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > convert proto model to string > - > > Key: SCB-948 > URL: https://issues.apache.org/jira/browse/SCB-948 > Project: Apache ServiceComb > Issue Type: Sub-task > Components: Java-Chassis >Reporter: wujimin >Assignee: wujimin >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-948) convert proto model to string
[ https://issues.apache.org/jira/browse/SCB-948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16644609#comment-16644609 ] ASF GitHub Bot commented on SCB-948: wujimin opened a new pull request #946: [SCB-948] Convert proto model to string URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/946 This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > convert proto model to string > - > > Key: SCB-948 > URL: https://issues.apache.org/jira/browse/SCB-948 > Project: Apache ServiceComb > Issue Type: Sub-task > Components: Java-Chassis >Reporter: wujimin >Assignee: wujimin >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)