Minor: Replace a number of trivial Guava usages with constructor calls and kotlin-stdlib function calls

This commit is contained in:
Yan Zhulanow
2018-06-01 18:03:19 +03:00
parent 61ffde54fd
commit ab5614eaac
44 changed files with 100 additions and 144 deletions
@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.codegen;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import kotlin.Pair;
@@ -160,7 +159,7 @@ public abstract class AbstractLineNumberTest extends TestCaseWithTmpdir {
@NotNull
private static List<String> readTestFunLineNumbers(@NotNull ClassReader cr) {
List<Label> labels = Lists.newArrayList();
Map<Label, String> labels2LineNumbers = Maps.newHashMap();
Map<Label, String> labels2LineNumbers = new HashMap<>();
ClassVisitor visitor = new ClassVisitor(Opcodes.ASM5) {
@Override
@@ -16,8 +16,6 @@
package org.jetbrains.kotlin.resolve;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiQualifiedNamedElement;
import com.intellij.psi.util.PsiTreeUtil;
@@ -38,10 +36,7 @@ import org.jetbrains.kotlin.types.ErrorUtils;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.TypeConstructor;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -70,9 +65,9 @@ public abstract class ExpectedResolveData {
}
}
private final Map<String, Position> declarationToPosition = Maps.newHashMap();
private final Map<Position, String> positionToReference = Maps.newHashMap();
private final Map<Position, String> positionToType = Maps.newHashMap();
private final Map<String, Position> declarationToPosition = new HashMap<>();
private final Map<Position, String> positionToReference = new HashMap<>();
private final Map<Position, String> positionToType = new HashMap<>();
private final Map<String, DeclarationDescriptor> nameToDescriptor;
private final Map<String, PsiElement> nameToPsiElement;
@@ -83,9 +78,9 @@ public abstract class ExpectedResolveData {
}
public final KtFile createFileFromMarkedUpText(String fileName, String text) {
Map<String, Integer> declarationToIntPosition = Maps.newHashMap();
Map<Integer, String> intPositionToReference = Maps.newHashMap();
Map<Integer, String> intPositionToType = Maps.newHashMap();
Map<String, Integer> declarationToIntPosition = new HashMap<>();
Map<Integer, String> intPositionToReference = new HashMap<>();
Map<Integer, String> intPositionToType = new HashMap<>();
Pattern pattern = Pattern.compile("(~[^~]+~)|(`[^`]+`)");
while (true) {
@@ -141,16 +136,16 @@ public abstract class ExpectedResolveData {
}
public final void checkResult(BindingContext bindingContext) {
Set<PsiElement> unresolvedReferences = Sets.newHashSet();
Set<PsiElement> unresolvedReferences = new HashSet<>();
for (Diagnostic diagnostic : bindingContext.getDiagnostics()) {
if (Errors.UNRESOLVED_REFERENCE_DIAGNOSTICS.contains(diagnostic.getFactory())) {
unresolvedReferences.add(diagnostic.getPsiElement());
}
}
Map<String, PsiElement> nameToDeclaration = Maps.newHashMap();
Map<String, PsiElement> nameToDeclaration = new HashMap<>();
Map<PsiElement, String> declarationToName = Maps.newHashMap();
Map<PsiElement, String> declarationToName = new HashMap<>();
for (Map.Entry<String, Position> entry : declarationToPosition.entrySet()) {
String name = entry.getKey();
Position position = entry.getValue();
@@ -6,7 +6,6 @@
package org.jetbrains.kotlin.test;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ArrayUtil;
@@ -134,7 +133,7 @@ public final class InTextDirectivesUtils {
}
public static void assertHasUnknownPrefixes(String fileText, Collection<String> knownPrefixes) {
Set<String> prefixes = Sets.newHashSet();
Set<String> prefixes = new HashSet<>();
for (String line : fileNonEmptyCommentedLines(fileText)) {
String prefix = probableDirective(line);
@@ -7,8 +7,6 @@ package org.jetbrains.kotlin.test;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
@@ -848,7 +846,7 @@ public class KotlinTestUtils {
@NotNull
public static Map<String, String> parseDirectives(String expectedText) {
Map<String, String> directives = Maps.newHashMap();
Map<String, String> directives = new HashMap<>();
Matcher directiveMatcher = DIRECTIVE_PATTERN.matcher(expectedText);
int start = 0;
while (directiveMatcher.find()) {
@@ -1183,7 +1181,7 @@ public class KotlinTestUtils {
}
private static Set<String> collectMethodsMetadata(Class<?> testCaseClass) {
Set<String> filePaths = Sets.newHashSet();
Set<String> filePaths = new HashSet<>();
for (Method method : testCaseClass.getDeclaredMethods()) {
String path = getMethodMetadata(method);
if (path != null) {
@@ -7,8 +7,6 @@ package org.jetbrains.kotlin.test;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
@@ -848,7 +846,7 @@ public class KotlinTestUtils {
@NotNull
public static Map<String, String> parseDirectives(String expectedText) {
Map<String, String> directives = Maps.newHashMap();
Map<String, String> directives = new HashMap<>();
Matcher directiveMatcher = DIRECTIVE_PATTERN.matcher(expectedText);
int start = 0;
while (directiveMatcher.find()) {
@@ -1183,7 +1181,7 @@ public class KotlinTestUtils {
}
private static Set<String> collectMethodsMetadata(Class<?> testCaseClass) {
Set<String> filePaths = Sets.newHashSet();
Set<String> filePaths = new HashSet<>();
for (Method method : testCaseClass.getDeclaredMethods()) {
String path = getMethodMetadata(method);
if (path != null) {
@@ -7,8 +7,6 @@ package org.jetbrains.kotlin.test;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
@@ -848,7 +846,7 @@ public class KotlinTestUtils {
@NotNull
public static Map<String, String> parseDirectives(String expectedText) {
Map<String, String> directives = Maps.newHashMap();
Map<String, String> directives = new HashMap<>();
Matcher directiveMatcher = DIRECTIVE_PATTERN.matcher(expectedText);
int start = 0;
while (directiveMatcher.find()) {
@@ -1183,7 +1181,7 @@ public class KotlinTestUtils {
}
private static Set<String> collectMethodsMetadata(Class<?> testCaseClass) {
Set<String> filePaths = Sets.newHashSet();
Set<String> filePaths = new HashSet<>();
for (Method method : testCaseClass.getDeclaredMethods()) {
String path = getMethodMetadata(method);
if (path != null) {
@@ -7,8 +7,6 @@ package org.jetbrains.kotlin.test;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
@@ -848,7 +846,7 @@ public class KotlinTestUtils {
@NotNull
public static Map<String, String> parseDirectives(String expectedText) {
Map<String, String> directives = Maps.newHashMap();
Map<String, String> directives = new HashMap<>();
Matcher directiveMatcher = DIRECTIVE_PATTERN.matcher(expectedText);
int start = 0;
while (directiveMatcher.find()) {
@@ -1183,7 +1181,7 @@ public class KotlinTestUtils {
}
private static Set<String> collectMethodsMetadata(Class<?> testCaseClass) {
Set<String> filePaths = Sets.newHashSet();
Set<String> filePaths = new HashSet<>();
for (Method method : testCaseClass.getDeclaredMethods()) {
String path = getMethodMetadata(method);
if (path != null) {