Skip to content
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

Move turbine's fork of SourceCodeEscapers to a new package #335

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
* limitations under the License.
*/

package com.google.common.escape;
package com.google.turbine.escape;

import com.google.common.escape.ArrayBasedCharEscaper;
import com.google.common.escape.CharEscaper;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -39,7 +41,7 @@ private SourceCodeEscapers() {}
private static final char[] HEX_DIGITS = "0123456789abcdef".toCharArray();

/**
* Returns an {@link Escaper} instance that escapes special characters in a string so it can
* Returns an {@link CharEscaper} instance that escapes special characters in a string so it can
* safely be included in either a Java character literal or string literal. This is the preferred
* way to escape Java characters for use in String or character literals.
*
Expand Down Expand Up @@ -83,16 +85,16 @@ protected char[] escapeUnsafe(char c) {

// Helper for common case of escaping a single char.
private static char[] asUnicodeHexEscape(char c) {
// Equivalent to String.format("\\u%04x", (int)c);
// Equivalent to String.format("\\u%04x", (int) c);
char[] r = new char[6];
r[0] = '\\';
r[1] = 'u';
r[5] = HEX_DIGITS[c & 0xF];
c >>>= 4;
c = (char) (c >>> 4);
r[4] = HEX_DIGITS[c & 0xF];
c >>>= 4;
c = (char) (c >>> 4);
r[3] = HEX_DIGITS[c & 0xF];
c >>>= 4;
c = (char) (c >>> 4);
r[2] = HEX_DIGITS[c & 0xF];
return r;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

@com.google.errorprone.annotations.CheckReturnValue
@org.jspecify.annotations.NullMarked
package com.google.common.escape;
package com.google.turbine.escape;
2 changes: 1 addition & 1 deletion java/com/google/turbine/model/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.escape.SourceCodeEscapers;
import com.google.turbine.escape.SourceCodeEscapers;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.AnnotationValueVisitor;
import org.jspecify.annotations.Nullable;
Expand Down
2 changes: 1 addition & 1 deletion javatests/com/google/turbine/parse/JavacLexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.google.common.escape.SourceCodeEscapers;
import com.google.turbine.escape.SourceCodeEscapers;
import com.sun.tools.javac.parser.Scanner;
import com.sun.tools.javac.parser.ScannerFactory;
import com.sun.tools.javac.parser.Tokens;
Expand Down
2 changes: 1 addition & 1 deletion javatests/com/google/turbine/parse/LexerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assume.assumeTrue;

import com.google.common.escape.SourceCodeEscapers;
import com.google.common.truth.Expect;
import com.google.turbine.diag.SourceFile;
import com.google.turbine.escape.SourceCodeEscapers;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
Expand Down
Loading