-
Notifications
You must be signed in to change notification settings - Fork 70
[ggj][codegen][ast] fix: solidify codegen method order with AST Comparables #311
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fd218de
feat: add protobuf comment parser util
miraleung 8c792e3
fix: add basic proto build rules
miraleung d6ee068
feat: add header comments to ServiceClient
miraleung 82aa0b6
fix: build protoc at test time
miraleung c8f2233
Merge branch 'gp/g0' of github.com:googleapis/gapic-generator-java in…
miraleung 2405b1a
fix!: wrap protobuf location and process comments
miraleung 5acc151
fix: solidify codegen method order with TypeNode/MethodArg and Compar…
miraleung 97e780a
fix: clean up tests
miraleung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/main/java/com/google/api/generator/gapic/model/SourceCodeInfoLocation.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // Copyright 2020 Google LLC | ||
| // | ||
| // Licensed 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 com.google.api.generator.gapic.model; | ||
|
|
||
| import com.google.common.escape.Escaper; | ||
| import com.google.common.escape.Escapers; | ||
| import com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location; | ||
| import javax.annotation.Nonnull; | ||
|
|
||
| /** | ||
| * A light wrapper around SourceCodeInfo.Location to provide cleaner protobuf comments. Please see | ||
| * additional documentation on descriptor.proto. | ||
| */ | ||
| public class SourceCodeInfoLocation { | ||
| // Not a singleton because of nested-class instantiation mechanics. | ||
| private final NewlineEscaper ESCAPER = new NewlineEscaper(); | ||
|
|
||
| @Nonnull private final Location location; | ||
|
|
||
| private SourceCodeInfoLocation(Location location) { | ||
| this.location = location; | ||
| } | ||
|
|
||
| public static SourceCodeInfoLocation create(@Nonnull Location location) { | ||
| return new SourceCodeInfoLocation(location); | ||
| } | ||
|
|
||
| public String getLeadingComments() { | ||
| return processProtobufComment(location.getLeadingComments()); | ||
| } | ||
|
|
||
| public String getTrailingComments() { | ||
| return processProtobufComment(location.getTrailingComments()); | ||
| } | ||
|
|
||
| public String getLeadingDetachedComments(int index) { | ||
| return processProtobufComment(location.getLeadingDetachedComments(index)); | ||
| } | ||
|
|
||
| private String processProtobufComment(String s) { | ||
| return ESCAPER.escape(s).trim(); | ||
| } | ||
|
|
||
| private class NewlineEscaper extends Escaper { | ||
| private final Escaper charEscaper = Escapers.builder().addEscape('\n', "").build(); | ||
|
|
||
| @Override | ||
| public String escape(String sourceString) { | ||
| return charEscaper.escape(sourceString); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.