Another small code simplification to make it easier to enable nullness checks.
Also add a couple annotations.
@@ -44,6 +44,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
+import javax.annotation.Nullable;
/**
* A simple {@link ErrorReporter} that collects warnings and errors and makes
@@ -51,7 +52,9 @@ import java.util.ResourceBundle;
*
*/
public class SimpleErrorReporter implements ErrorReporter {
+ @Nullable
private List<String> warnings = null;
+ @Nullable
private List<String> errors = null;
@Override
@@ -92,17 +95,15 @@ public class SimpleErrorReporter implements ErrorReporter {
}
public static String getMessage0(String messageId) {
- return getMessage(messageId, null);
+ return getMessage(messageId);
}
public static String getMessage1(String messageId, Object arg1) {
- Object[] arguments = {arg1};
- return getMessage(messageId, arguments);
+ return getMessage(messageId, arg1);
}
- static String getMessage(String messageId, Object[] arguments) {
- final String defaultResource
- = "com.google.javascript.rhino.Messages";
+ private static String getMessage(String messageId, Object... arguments) {
+ final String defaultResource = "com.google.javascript.rhino.Messages";
Locale locale = Locale.getDefault();
@@ -118,7 +119,7 @@ public class SimpleErrorReporter implements ErrorReporter {
}
/*
- * It's OK to format the string, even if 'arguments' is null;
+ * It's OK to format the string, even if 'arguments' is empty;
* we need to format it anyway, to make double ''s collapse to
* single 's.
*/
