Skip to content

Commit

Permalink
[ggj][engx] fix: use imperative method names in Escapers (#446)
Browse files Browse the repository at this point in the history
* fix: support non-name fields with res-refs in resname def parsing

* fix: add workaround for missing default_host and oauth_scopes annotation

* fix: clarify LRO parsing error messages

* feat: support deeply-nested types in AST and proto message parsing

* fix: prevent resname tokens from matching subcomponents

* fix: use TypeParser for proto message parsing

* fix: use generic types in field instantiation in ServiceClientTest

* fix: prevent descension into map types in nested message parsing

* fix: merge master

* fix: use both map generics in ServiceClientTest codegen

* fix: dir structure of generated files

* test: add asset API gradle pkg rules

* fix: remove unused dep

* test: add logging integration target and goldens, consolidate rules

* fix: fix asset_java_gapic build

* fix: fix test src packaging, update integration goldens

* fix: pass all tokens to instansiate in resname 1-pattern case

* fix: update goldens

* fix: update goldens

* build: add all integration tests to pre-commit hook

* build: run pre-commit when goldens have changed

* build: add integration golden tests to CircleCI

* fix: preserve newlines and parse itemized lists in protobuf comments

* fix: remove extraneous escaper

* fix: update integration goldens for ServiceClient comment names

* fix: use serviceClient varname in ServiceClient codegen comments

* fix: use imperative method names in Escapers
  • Loading branch information
miraleung authored Oct 31, 2020
1 parent 3f959df commit c52432e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
15 changes: 15 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,21 @@ then
fi
fi

# Check integration tests.
if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] \
|| [ $NUM_INTEGRATION_GOLDEN_FILES_CHANGED -gt 0 ] \
|| [ $NUM_INTEGRATION_BAZEL_FILES_CHANGED -gt 0 ]
then
echo_status "Checking integration tests..."
bazel --batch test --disk_cache="$BAZEL_CACHE_DIR" //test/integration/...
TEST_STATUS=$?
if [ $TEST_STATUS != 0 ]
then
echo_error "Tests failed." "Please fix them and try again."
exit 1
fi
fi

# Check and fix Bazel format.
if [ $NUM_BAZEL_FILES_CHANGED -gt 0 ]
then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public Builder addUnescapedComment(String comment) {
}

public Builder addComment(String comment) {
componentsList.add(HtmlEscaper.escaper(comment));
componentsList.add(HtmlEscaper.process(comment));
return this;
}

Expand All @@ -86,7 +86,7 @@ public Builder addSampleCode(String sampleCode) {
Arrays.stream(sampleCode.split("\\r?\\n"))
.forEach(
line -> {
componentsList.add(HtmlEscaper.escaper(line));
componentsList.add(HtmlEscaper.process(line));
});
componentsList.add("</code></pre>");
return this;
Expand Down Expand Up @@ -131,7 +131,7 @@ public JavaDocComment build() {
// Escape component in list one by one, because we will join the components by `\n`
// `\n` will be taken as escape character by the comment escaper.
componentsList =
componentsList.stream().map(c -> MetacharEscaper.escaper(c)).collect(Collectors.toList());
componentsList.stream().map(c -> MetacharEscaper.process(c)).collect(Collectors.toList());
setComment(String.join("\n", componentsList));
return autoBuild();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public abstract static class Builder {
public abstract LineComment autoBuild();

public LineComment build() {
setComment(MetacharEscaper.escaper(comment()));
setComment(MetacharEscaper.process(comment()));
return autoBuild();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public String escape(String sourceString) {
return charEscaper.escape(sourceString);
}

public static String escaper(String source) {
public static String process(String source) {
return SINGLETON.escape(source);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public String escape(String sourceString) {
return charEscaper.escape(sourceString);
}

public static String escaper(String source) {
public static String process(String source) {
return SINGLETON.escape(source);
}
}

0 comments on commit c52432e

Please sign in to comment.