Skip to content

Commit

Permalink
Automated cleanups
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=148352025
  • Loading branch information
tbreisacher committed Feb 27, 2017
1 parent eb6fbd1 commit 177fe51
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 102 deletions.
2 changes: 1 addition & 1 deletion test/com/google/debugging/sourcemap/Base64Test.java
Expand Up @@ -38,7 +38,7 @@ public void testBase64EncodeInt() {
assertThat(Base64.base64EncodeInt(0xffffffff)).isEqualTo("/////w");
}

private void testValue(int value) {
private static void testValue(int value) {
assertThat(Base64.fromBase64(Base64.toBase64(value))).isEqualTo(value);
}
}
2 changes: 1 addition & 1 deletion test/com/google/debugging/sourcemap/Base64VLQTest.java
Expand Up @@ -83,7 +83,7 @@ public char next() {
}


private void testValue(int value) {
private static void testValue(int value) {
try {
StringBuilder sb = new StringBuilder();
Base64VLQ.encode(sb, value);
Expand Down
Expand Up @@ -26,7 +26,6 @@
import com.google.gson.JsonPrimitive;
import com.google.javascript.jscomp.SourceMap;
import com.google.javascript.jscomp.SourceMap.Format;

import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
Expand Down Expand Up @@ -413,7 +412,7 @@ public void testWriteMetaMap() throws IOException {
+ "}\n");
}

private String getEmptyMapFor(String name) throws IOException {
private static String getEmptyMapFor(String name) throws IOException {
StringWriter out = new StringWriter();
SourceMapGeneratorV3 generator = new SourceMapGeneratorV3();
generator.appendTo(out, name);
Expand Down Expand Up @@ -636,7 +635,7 @@ FilePosition appendAndCount(Appendable out, String js) throws IOException {
return count(js);
}

private JsonObject parseJsonObject(String json) {
private static JsonObject parseJsonObject(String json) {
return new Gson().fromJson(json, JsonObject.class);
}
}
31 changes: 10 additions & 21 deletions test/com/google/debugging/sourcemap/SourceMapTestCase.java
Expand Up @@ -26,14 +26,12 @@
import com.google.javascript.jscomp.SourceFile;
import com.google.javascript.jscomp.SourceMap;
import com.google.javascript.jscomp.SourceMap.DetailLevel;

import junit.framework.TestCase;

import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import junit.framework.TestCase;

/**
* @author johnlenz@google.com (John Lenz)
Expand All @@ -50,8 +48,8 @@ void disableColumnValidation() {
}


static final List<SourceFile> EXTERNS = ImmutableList.of(
SourceFile.fromCode("externs", ""));
static final ImmutableList<SourceFile> EXTERNS =
ImmutableList.of(SourceFile.fromCode("externs", ""));

protected DetailLevel detailLevel = SourceMap.DetailLevel.ALL;
protected boolean sourceMapIncludeSourcesContent = false;
Expand Down Expand Up @@ -100,11 +98,8 @@ protected void checkSourceMap(String fileName, String js, String expectedMap)
assertThat(getSourceMap(result)).isEqualTo(result.sourceMapFileContent);
}

/**
* Finds the all the __XX__ tokens in the given JavaScript
* string.
*/
private Map<String, Token> findTokens(Map<String, String> inputs) {
/** Finds the all the __XX__ tokens in the given JavaScript string. */
private static Map<String, Token> findTokens(Map<String, String> inputs) {
Map<String, Token> tokens = new LinkedHashMap<>();

for (Entry<String, String> entry : inputs.entrySet()) {
Expand All @@ -114,24 +109,18 @@ private Map<String, Token> findTokens(Map<String, String> inputs) {
return tokens;
}

/**
* Finds the all the __XX__ tokens in the given JavaScript
* string.
*/
private Map<String, Token> findTokens(String src) {
/** Finds the all the __XX__ tokens in the given JavaScript string. */
private static Map<String, Token> findTokens(String src) {
Map<String, Token> tokens = new LinkedHashMap<>();

findTokens(tokens, "", src);

return tokens;
}

/**
* Finds the all the __XX__ tokens in the given JavaScript
* string.
*/
private Map<String, Token> findTokens(
Map<String, Token> tokens, String inputName, String js) {
/** Finds the all the __XX__ tokens in the given JavaScript string. */
private static Map<String, Token> findTokens(
Map<String, Token> tokens, String inputName, String js) {

int currentLine = 0;
int positionOffset = 0;
Expand Down
6 changes: 3 additions & 3 deletions test/com/google/javascript/jscomp/CommandLineRunnerTest.java
Expand Up @@ -83,10 +83,10 @@ private enum ModulePattern {
STAR
}

private List<String> args = new ArrayList<>();
private final List<String> args = new ArrayList<>();

/** Externs for the test */
private static final List<SourceFile> DEFAULT_EXTERNS = ImmutableList.of(
private static final ImmutableList<SourceFile> DEFAULT_EXTERNS = ImmutableList.of(
SourceFile.fromCode("externs", Joiner.on('\n').join(
"var arguments;",
"/**",
Expand Down Expand Up @@ -2149,7 +2149,7 @@ private static FlagEntry<JsSourceType> createZipFile(Map<String, String> entryCo
return new FlagEntry<>(JsSourceType.JS_ZIP, tempZipFile.getAbsolutePath());
}

private FlagEntry<JsSourceType> createJsFile(String filename, String fileContent)
private static FlagEntry<JsSourceType> createJsFile(String filename, String fileContent)
throws IOException {
File tempJsFile = File.createTempFile(filename, ".js",
java.nio.file.Files.createTempDirectory("jscomp").toFile());
Expand Down
4 changes: 2 additions & 2 deletions test/com/google/javascript/jscomp/CompilerTestCase.java
Expand Up @@ -1576,7 +1576,7 @@ private void test(
}
}

private void transpileToEs5(AbstractCompiler compiler, Node externsRoot, Node codeRoot) {
private static void transpileToEs5(AbstractCompiler compiler, Node externsRoot, Node codeRoot) {
List<PassFactory> factories = new ArrayList<>();
TranspilationPasses.addEs6EarlyPasses(factories);
TranspilationPasses.addEs6LatePasses(factories);
Expand All @@ -1597,7 +1597,7 @@ private void validateSourceLocation(JSError jserror) {
}
}

private void normalizeActualCode(Compiler compiler, Node externsRoot, Node mainRoot) {
private static void normalizeActualCode(Compiler compiler, Node externsRoot, Node mainRoot) {
Normalize normalize = new Normalize(compiler, false);
normalize.process(externsRoot, mainRoot);
}
Expand Down
56 changes: 25 additions & 31 deletions test/com/google/javascript/jscomp/parsing/JsDocInfoParserTest.java
Expand Up @@ -4521,11 +4521,8 @@ public void testParseCommentWithStarsOnOpenCommentLine() {
* @param endCharno The ending character of the text.
* @return The marker, for chaining purposes.
*/
private JSDocInfo.Marker assertDocumentationInMarker(JSDocInfo.Marker marker,
String description,
int startCharno,
int endLineno,
int endCharno) {
private static JSDocInfo.Marker assertDocumentationInMarker(
JSDocInfo.Marker marker, String description, int startCharno, int endLineno, int endCharno) {
assertThat(marker.getDescription()).isNotNull();
assertThat(marker.getDescription().getItem()).isEqualTo(description);

Expand All @@ -4544,13 +4541,16 @@ private JSDocInfo.Marker assertDocumentationInMarker(JSDocInfo.Marker marker,
*
* @param typeName The name of the type expected in the type field.
* @param startCharno The starting character of the type declaration.
* @param hasBrackets Whether the type in the type field is expected
* to have brackets.
* @param hasBrackets Whether the type in the type field is expected to have brackets.
* @return The marker, for chaining purposes.
*/
private JSDocInfo.Marker assertTypeInMarker(
JSDocInfo.Marker marker, String typeName,
int startLineno, int startCharno, int endLineno, int endCharno,
private static JSDocInfo.Marker assertTypeInMarker(
JSDocInfo.Marker marker,
String typeName,
int startLineno,
int startCharno,
int endLineno,
int endCharno,
boolean hasBrackets) {
assertThat(marker.getType()).isNotNull();
assertThat(marker.getType().getItem().isString()).isTrue();
Expand All @@ -4577,8 +4577,8 @@ private JSDocInfo.Marker assertTypeInMarker(
* @param startCharno The starting character of the text.
* @return The marker, for chaining purposes.
*/
private JSDocInfo.Marker assertNameInMarker(JSDocInfo.Marker marker,
String name, int startLine, int startCharno) {
private static JSDocInfo.Marker assertNameInMarker(
JSDocInfo.Marker marker, String name, int startLine, int startCharno) {
assertThat(marker.getNameNode()).isNotNull();
assertThat(marker.getNameNode().getItem().getString()).isEqualTo(name);

Expand All @@ -4592,41 +4592,35 @@ private JSDocInfo.Marker assertNameInMarker(JSDocInfo.Marker marker,
}

/**
* Asserts that an annotation marker of a given annotation name
* is found in the given JSDocInfo.
* Asserts that an annotation marker of a given annotation name is found in the given JSDocInfo.
*
* @param jsdoc The JSDocInfo in which to search for the annotation marker.
* @param annotationName The name/type of the annotation for which to
* search. Example: "author" for an "@author" annotation.
* @param annotationName The name/type of the annotation for which to search. Example: "author"
* for an "@author" annotation.
* @param startLineno The expected starting line number of the marker.
* @param startCharno The expected character on the starting line.
* @return The marker found, for further testing.
*/
private JSDocInfo.Marker assertAnnotationMarker(JSDocInfo jsdoc,
String annotationName,
int startLineno,
int startCharno) {
private static JSDocInfo.Marker assertAnnotationMarker(
JSDocInfo jsdoc, String annotationName, int startLineno, int startCharno) {
return assertAnnotationMarker(jsdoc, annotationName, startLineno,
startCharno, 0);
}

/**
* Asserts that the index-th annotation marker of a given annotation name
* is found in the given JSDocInfo.
* Asserts that the index-th annotation marker of a given annotation name is found in the given
* JSDocInfo.
*
* @param jsdoc The JSDocInfo in which to search for the annotation marker.
* @param annotationName The name/type of the annotation for which to
* search. Example: "author" for an "@author" annotation.
* @param annotationName The name/type of the annotation for which to search. Example: "author"
* for an "@author" annotation.
* @param startLineno The expected starting line number of the marker.
* @param startCharno The expected character on the starting line.
* @param index The index of the marker.
* @return The marker found, for further testing.
*/
private JSDocInfo.Marker assertAnnotationMarker(JSDocInfo jsdoc,
String annotationName,
int startLineno,
int startCharno,
int index) {
private static JSDocInfo.Marker assertAnnotationMarker(
JSDocInfo jsdoc, String annotationName, int startLineno, int startCharno, int index) {

Collection<JSDocInfo.Marker> markers = jsdoc.getMarkers();

Expand Down Expand Up @@ -4657,7 +4651,7 @@ private JSDocInfo.Marker assertAnnotationMarker(JSDocInfo jsdoc,
return null;
}

private <T> void assertContains(Collection<T> collection, T item) {
private static <T> void assertContains(Collection<T> collection, T item) {
assertThat(collection).contains(item);
}

Expand Down Expand Up @@ -4750,7 +4744,7 @@ private JSDocInfo parse(String comment, JsDocParsing parseDocumentation,
}
}

private Node parseType(String typeComment) {
private static Node parseType(String typeComment) {
return JsDocInfoParser.parseTypeString(typeComment);
}

Expand Down
Expand Up @@ -40,10 +40,8 @@
import static com.google.javascript.jscomp.parsing.JsDocToken.STRING;

import com.google.common.collect.ImmutableList;

import junit.framework.TestCase;

import java.util.List;
import junit.framework.TestCase;

/**
* Tests for {@link JsDocTokenStream}.
Expand Down Expand Up @@ -269,8 +267,8 @@ public void testJsDocTokenization21() throws Exception {
testJSDocTokenStream("@param {Object= }*/", tokens, strings);
}

private void testJSDocTokenStream(String comment, List<JsDocToken> tokens,
List<String> strings) {
private static void testJSDocTokenStream(
String comment, List<JsDocToken> tokens, List<String> strings) {
JsDocTokenStream stream = new JsDocTokenStream(comment, 0);
int stringsIndex = 0;
for (JsDocToken token : tokens) {
Expand Down
12 changes: 6 additions & 6 deletions test/com/google/javascript/jscomp/parsing/ParserTest.java
Expand Up @@ -984,7 +984,7 @@ public void testMalformedRegexp() {
parseError(js, "primary expression expected");
}

private void assertNodeEquality(Node expected, Node found) {
private static void assertNodeEquality(Node expected, Node found) {
String message = expected.checkTreeEquals(found);
if (message != null) {
fail(message);
Expand Down Expand Up @@ -1106,7 +1106,7 @@ public void testAutomaticSemicolonInsertionExamplesFromSpec() {
parse("a = b + c(d + e).print()"));
}

private Node createScript(Node n) {
private static Node createScript(Node n) {
Node script = new Node(Token.SCRIPT);
script.addChildToBack(n);
return script;
Expand Down Expand Up @@ -3490,11 +3490,11 @@ public void testParseInlineSourceMap() {
assertThat(sourceMap.getOriginalSources()).containsExactly("foo.ts");
}

private String getRequiresEs6Message(Feature feature) {
private static String getRequiresEs6Message(Feature feature) {
return requiresLanguageModeMessage(LanguageMode.ECMASCRIPT6, feature);
}

private String requiresLanguageModeMessage(LanguageMode languageMode, Feature feature) {
private static String requiresLanguageModeMessage(LanguageMode languageMode, Feature feature) {
return String.format(
"this language feature is only supported for %s mode or better: %s",
languageMode,
Expand All @@ -3506,11 +3506,11 @@ private static Node script(Node stmt) {
return n;
}

private Node expr(Node n) {
private static Node expr(Node n) {
return new Node(Token.EXPR_RESULT, n);
}

private Node regex(String regex) {
private static Node regex(String regex) {
return new Node(Token.REGEXP, Node.newString(regex));
}

Expand Down
6 changes: 3 additions & 3 deletions test/com/google/javascript/jscomp/parsing/TypeSyntaxTest.java
Expand Up @@ -39,7 +39,6 @@
import com.google.javascript.rhino.Node.TypeDeclarationNode;
import com.google.javascript.rhino.Token;
import com.google.javascript.rhino.TypeDeclarationsIR;

import junit.framework.TestCase;

/**
Expand Down Expand Up @@ -778,11 +777,12 @@ private void assertVarType(String message, TypeDeclarationNode expectedType, Str
assertDeclaredType(message, expectedType, varDecl.getFirstChild());
}

private void assertDeclaredType(String message, TypeDeclarationNode expectedType, Node typed) {
private static void assertDeclaredType(
String message, TypeDeclarationNode expectedType, Node typed) {
assertTreeEquals(message, expectedType, typed.getDeclaredTypeExpression());
}

private void assertTreeEquals(String message, Node expected, Node actual) {
private static void assertTreeEquals(String message, Node expected, Node actual) {
String treeDiff = expected.checkTreeEquals(actual);
assertNull(message + ": " + treeDiff, treeDiff);
}
Expand Down

0 comments on commit 177fe51

Please sign in to comment.