Use Java 7+ diamond operator in compiler modules

This commit is contained in:
Alexander Udalov
2017-04-01 02:28:36 +03:00
parent 37f435da93
commit d440f07111
187 changed files with 512 additions and 533 deletions
@@ -33,7 +33,7 @@ public class ArgumentUtils {
@NotNull
public static List<String> convertArgumentsToStringList(@NotNull CommonCompilerArguments arguments)
throws InstantiationException, IllegalAccessException {
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<>();
convertArgumentsToStringList(arguments, arguments.getClass().newInstance(), arguments.getClass(), result);
result.addAll(arguments.freeArgs);
return result;
@@ -31,7 +31,7 @@ public class AntRunner {
private final List<String> listOfAntCommands;
public AntRunner(PathManager pathManager) {
listOfAntCommands = new ArrayList<String>();
listOfAntCommands = new ArrayList<>();
String antCmdName = SystemInfo.isWindows ? "ant.bat" : "ant";
listOfAntCommands.add(pathManager.getAntBinDirectory() + "/" + antCmdName);
listOfAntCommands.add("-Dsdk.dir=" + pathManager.getAndroidSdkRoot());
@@ -30,7 +30,7 @@ public class GradleRunner {
private final List<String> listOfCommands;
public GradleRunner(PathManager pathManager) {
listOfCommands = new ArrayList<String>();
listOfCommands = new ArrayList<>();
String cmdName = SystemInfo.isWindows ? "gradle.bat" : "gradle";
listOfCommands.add(pathManager.getGradleBinFolder() + "/" + cmdName);
listOfCommands.add("--build-file");
@@ -142,7 +142,7 @@ public class CodegenTestsOnAndroidGenerator extends KtUsefulTestCase {
private final boolean isFullJdkAndRuntime;
private final boolean inheritMultifileParts;
public List<KtFile> files = new ArrayList<KtFile>();
public List<KtFile> files = new ArrayList<>();
private KotlinCoreEnvironment environment;
private FilesWriter(boolean isFullJdkAndRuntime, boolean inheritMultifileParts) {
@@ -175,7 +175,7 @@ public class CodegenTestsOnAndroidGenerator extends KtUsefulTestCase {
public void writeFilesOnDisk() {
writeFiles(files);
files = new ArrayList<KtFile>();
files = new ArrayList<>();
environment = createEnvironment(isFullJdkAndRuntime);
}
@@ -37,7 +37,7 @@ public abstract class AbstractClassBuilder implements ClassBuilder {
private final JvmSerializationBindings serializationBindings = new JvmSerializationBindings();
private final List<FileMapping> fileMappings = new ArrayList<FileMapping>();
private final List<FileMapping> fileMappings = new ArrayList<>();
private String sourceName;
@@ -56,7 +56,7 @@ public class AccessorForFunctionDescriptor extends AbstractAccessorForFunctionDe
setSuspend(descriptor.isSuspend());
if (descriptor.getUserData(CoroutineCodegenUtilKt.INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) != null) {
userDataMap = new LinkedHashMap<UserDataKey<?>, Object>();
userDataMap = new LinkedHashMap<>();
userDataMap.put(
CoroutineCodegenUtilKt.INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION,
descriptor.getUserData(CoroutineCodegenUtilKt.INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)
@@ -27,9 +27,11 @@ import org.jetbrains.kotlin.load.java.JvmAnnotationNames;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.resolve.AnnotationChecker;
import org.jetbrains.kotlin.resolve.constants.*;
import org.jetbrains.kotlin.resolve.constants.StringValue;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.types.*;
import org.jetbrains.kotlin.types.FlexibleType;
import org.jetbrains.kotlin.types.FlexibleTypesKt;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.org.objectweb.asm.*;
import java.lang.annotation.*;
@@ -87,7 +89,7 @@ public abstract class AnnotationCodegen {
return;
}
Set<String> annotationDescriptorsAlreadyPresent = new HashSet<String>();
Set<String> annotationDescriptorsAlreadyPresent = new HashSet<>();
Annotations annotations = annotated.getAnnotations();
@@ -200,8 +202,7 @@ public abstract class AnnotationCodegen {
generateAnnotationIfNotPresent(annotationDescriptorsAlreadyPresent, annotationClass);
}
private static final Map<KotlinTarget, ElementType> annotationTargetMap =
new EnumMap<KotlinTarget, ElementType>(KotlinTarget.class);
private static final Map<KotlinTarget, ElementType> annotationTargetMap = new EnumMap<>(KotlinTarget.class);
static {
annotationTargetMap.put(KotlinTarget.CLASS, ElementType.TYPE);
@@ -418,8 +419,7 @@ public abstract class AnnotationCodegen {
value.accept(argumentVisitor, null);
}
private static final Map<KotlinRetention, RetentionPolicy> annotationRetentionMap =
new EnumMap<KotlinRetention, RetentionPolicy>(KotlinRetention.class);
private static final Map<KotlinRetention, RetentionPolicy> annotationRetentionMap = new EnumMap<>(KotlinRetention.class);
static {
annotationRetentionMap.put(KotlinRetention.SOURCE, RetentionPolicy.SOURCE);
@@ -445,7 +445,7 @@ public class AsmUtil {
}
public static void genClosureFields(@NotNull CalculatedClosure closure, ClassBuilder v, KotlinTypeMapper typeMapper) {
List<Pair<String, Type>> allFields = new ArrayList<Pair<String, Type>>();
List<Pair<String, Type>> allFields = new ArrayList<>();
ClassifierDescriptor captureThis = closure.getCaptureThis();
if (captureThis != null) {
@@ -54,7 +54,7 @@ public abstract class ClassBodyCodegen extends MemberCodegen<KtPureClassOrObject
@Override
protected void generateBody() {
List<KtObjectDeclaration> companions = new ArrayList<KtObjectDeclaration>();
List<KtObjectDeclaration> companions = new ArrayList<>();
if (kind != OwnerKind.DEFAULT_IMPLS) {
//generate nested classes first and only then generate class body. It necessary to access to nested CodegenContexts
for (KtDeclaration declaration : myClass.getDeclarations()) {
@@ -42,12 +42,12 @@ import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.getMappingFileName;
public class ClassFileFactory implements OutputFileCollection {
private final GenerationState state;
private final ClassBuilderFactory builderFactory;
private final Map<String, OutAndSourceFileList> generators = new LinkedHashMap<String, OutAndSourceFileList>();
private final Map<String, OutAndSourceFileList> generators = new LinkedHashMap<>();
private boolean isDone = false;
private final Set<File> packagePartSourceFiles = new HashSet<File>();
private final Map<String, PackageParts> partsGroupedByPackage = new LinkedHashMap<String, PackageParts>();
private final Set<File> packagePartSourceFiles = new HashSet<>();
private final Map<String, PackageParts> partsGroupedByPackage = new LinkedHashMap<>();
public ClassFileFactory(@NotNull GenerationState state, @NotNull ClassBuilderFactory builderFactory) {
this.state = state;
@@ -153,7 +153,7 @@ public class ClassFileFactory implements OutputFileCollection {
@NotNull
@TestOnly
public Map<String, String> createTextForEachFile() {
Map<String, String> answer = new LinkedHashMap<String, String>();
Map<String, String> answer = new LinkedHashMap<>();
for (OutputFile file : asList()) {
answer.put(file.getRelativePath(), file.asText());
}
@@ -188,7 +188,7 @@ public class ClassFileFactory implements OutputFileCollection {
@NotNull
private static List<File> toIoFilesIgnoringNonPhysical(@NotNull Collection<? extends PsiFile> psiFiles) {
List<File> result = new ArrayList<File>(psiFiles.size());
List<File> result = new ArrayList<>(psiFiles.size());
for (PsiFile psiFile : psiFiles) {
VirtualFile virtualFile = psiFile.getVirtualFile();
// We ignore non-physical files here, because this code is needed to tell the make what inputs affect which outputs
@@ -100,7 +100,7 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
this.strategy = strategy;
if (samType == null) {
this.superInterfaceTypes = new ArrayList<KotlinType>();
this.superInterfaceTypes = new ArrayList<>();
KotlinType superClassType = null;
for (KotlinType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
@@ -252,7 +252,7 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
@NotNull
private static FunctionDescriptor createFreeLambdaDescriptor(@NotNull FunctionDescriptor descriptor) {
FunctionDescriptor.CopyBuilder<? extends FunctionDescriptor> builder = descriptor.newCopyBuilder();
List<TypeParameterDescriptor> typeParameters = new ArrayList<TypeParameterDescriptor>(0);
List<TypeParameterDescriptor> typeParameters = new ArrayList<>(0);
builder.setTypeParameters(typeParameters);
DeclarationDescriptor container = descriptor.getContainingDeclaration();
@@ -130,7 +130,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
private final TailRecursionCodegen tailRecursionCodegen;
public final CallGenerator defaultCallGenerator = new CallGenerator.DefaultCallGenerator(this);
private final Stack<BlockStackElement> blockStackElements = new Stack<BlockStackElement>();
private final Stack<BlockStackElement> blockStackElements = new Stack<>();
/*
* When we create a temporary variable to hold some value not to compute it many times
@@ -189,7 +189,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
}
static class FinallyBlockStackElement extends BlockStackElement {
List<Label> gaps = new ArrayList<Label>();
List<Label> gaps = new ArrayList<>();
final KtTryExpression expression;
@@ -571,7 +571,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
// We handle this case separately because otherwise such variable will be out of the frame map after the block ends
List<KtExpression> doWhileStatements = ((KtBlockExpression) body).getStatements();
List<KtExpression> statements = new ArrayList<KtExpression>(doWhileStatements.size() + 1);
List<KtExpression> statements = new ArrayList<>(doWhileStatements.size() + 1);
statements.addAll(doWhileStatements);
statements.add(condition);
@@ -1444,7 +1444,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
}
if (!shouldInlineConstVals && !takeUpConstValsAsConst && compileTimeValue.getUsesVariableAsConstant()) {
Ref<Boolean> containsNonInlinedVals = new Ref<Boolean>(false);
Ref<Boolean> containsNonInlinedVals = new Ref<>(false);
KtVisitor constantChecker = new KtVisitor() {
@Override
public Object visitSimpleNameExpression(@NotNull KtSimpleNameExpression expression, Object data) {
@@ -1648,9 +1648,9 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
.format("Incorrect number of mapped parameters vs arguments: %d < %d for %s",
superMappedTypes.size(), params, classDescriptor);
List<ResolvedValueArgument> valueArguments = new ArrayList<ResolvedValueArgument>(params);
List<ValueParameterDescriptor> valueParameters = new ArrayList<ValueParameterDescriptor>(params);
List<Type> mappedTypes = new ArrayList<Type>(params);
List<ResolvedValueArgument> valueArguments = new ArrayList<>(params);
List<ValueParameterDescriptor> valueParameters = new ArrayList<>(params);
List<Type> mappedTypes = new ArrayList<>(params);
for (ValueParameterDescriptor parameter : superValueParameters) {
ResolvedValueArgument argument = superCall.getValueArguments().get(parameter);
if (!(argument instanceof DefaultValueArgument)) {
@@ -2810,7 +2810,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
DefaultCallArgs defaultArgs =
argumentGenerator.generate(
valueArguments,
new ArrayList<ResolvedValueArgument>(resolvedCall.getValueArguments().values()),
new ArrayList<>(resolvedCall.getValueArguments().values()),
resolvedCall.getResultingDescriptor()
);
@@ -3041,9 +3041,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
TypeParameterDescriptor parameterDescriptor = TypeUtils.getTypeParameterDescriptorOrNull(type);
if (parameterDescriptor == null) return null;
return new Pair<TypeParameterDescriptor, ReificationArgument>(
parameterDescriptor,
new ReificationArgument(parameterDescriptor.getName().asString(), isNullable, arrayDepth));
return new Pair<>(parameterDescriptor, new ReificationArgument(parameterDescriptor.getName().asString(), isNullable, arrayDepth));
}
@NotNull
@@ -4542,9 +4540,9 @@ The "returned" value of try expression with no finally is either the last expres
@NotNull Label blockEnd
) {
List<Label> gapsInBlock =
finallyBlockStackElement != null ? new ArrayList<Label>(finallyBlockStackElement.gaps) : Collections.<Label>emptyList();
finallyBlockStackElement != null ? new ArrayList<>(finallyBlockStackElement.gaps) : Collections.emptyList();
assert gapsInBlock.size() % 2 == 0;
List<Label> blockRegions = new ArrayList<Label>(gapsInBlock.size() + 2);
List<Label> blockRegions = new ArrayList<>(gapsInBlock.size() + 2);
blockRegions.add(blockStart);
blockRegions.addAll(gapsInBlock);
blockRegions.add(blockEnd);
@@ -4809,7 +4807,7 @@ The "returned" value of try expression with no finally is either the last expres
}
public Stack<BlockStackElement> getBlockStackElements() {
return new Stack<BlockStackElement>(blockStackElements);
return new Stack<>(blockStackElements);
}
public void addBlockStackElementsForNonLocalReturns(@NotNull Stack<BlockStackElement> elements, int finallyDepth) {
@@ -28,8 +28,8 @@ import java.util.Comparator;
import java.util.List;
public class FrameMap {
private final TObjectIntHashMap<DeclarationDescriptor> myVarIndex = new TObjectIntHashMap<DeclarationDescriptor>();
private final TObjectIntHashMap<DeclarationDescriptor> myVarSizes = new TObjectIntHashMap<DeclarationDescriptor>();
private final TObjectIntHashMap<DeclarationDescriptor> myVarIndex = new TObjectIntHashMap<>();
private final TObjectIntHashMap<DeclarationDescriptor> myVarSizes = new TObjectIntHashMap<>();
private int myMaxIndex = 0;
public int enter(DeclarationDescriptor descriptor, Type type) {
@@ -81,7 +81,7 @@ public class FrameMap {
}
public void dropTo() {
List<DeclarationDescriptor> descriptorsToDrop = new ArrayList<DeclarationDescriptor>();
List<DeclarationDescriptor> descriptorsToDrop = new ArrayList<>();
TObjectIntIterator<DeclarationDescriptor> iterator = myVarIndex.iterator();
while (iterator.hasNext()) {
iterator.advance();
@@ -35,7 +35,10 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import java.util.*;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isObject;
@@ -88,7 +91,7 @@ public class FunctionReferenceGenerationStrategy extends FunctionGenerationStrat
private final Map<ValueParameterDescriptor, ResolvedValueArgument> argumentMap;
{
argumentMap = new LinkedHashMap<ValueParameterDescriptor, ResolvedValueArgument>(fakeArguments.size());
argumentMap = new LinkedHashMap<>(fakeArguments.size());
int index = 0;
List<ValueParameterDescriptor> parameters = functionDescriptor.getValueParameters();
for (ValueArgument argument : fakeArguments) {
@@ -112,7 +115,7 @@ public class FunctionReferenceGenerationStrategy extends FunctionGenerationStrat
@NotNull
@Override
public List<ResolvedValueArgument> getValueArgumentsByIndex() {
return new ArrayList<ResolvedValueArgument>(argumentMap.values());
return new ArrayList<>(argumentMap.values());
}
@NotNull
@@ -100,8 +100,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private final DelegationFieldsInfo delegationFieldsInfo;
private final List<Function2<ImplementationBodyCodegen, ClassBuilder, Unit>> additionalTasks =
new ArrayList<Function2<ImplementationBodyCodegen, ClassBuilder, Unit>>();
private final List<Function2<ImplementationBodyCodegen, ClassBuilder, Unit>> additionalTasks = new ArrayList<>();
public ImplementationBodyCodegen(
@NotNull KtPureClassOrObject aClass,
@@ -255,7 +254,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
}
private static final Map<FqName, String> KOTLIN_MARKER_INTERFACES = new HashMap<FqName, String>();
private static final Map<FqName, String> KOTLIN_MARKER_INTERFACES = new HashMap<>();
static {
KOTLIN_MARKER_INTERFACES.put(FQ_NAMES.iterator, "kotlin/jvm/internal/markers/KMappedMarker");
KOTLIN_MARKER_INTERFACES.put(FQ_NAMES.iterable, "kotlin/jvm/internal/markers/KMappedMarker");
@@ -302,8 +301,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
sw.writeSuperclassEnd();
LinkedHashSet<String> superInterfaces = new LinkedHashSet<String>();
Set<String> kotlinMarkerInterfaces = new LinkedHashSet<String>();
LinkedHashSet<String> superInterfaces = new LinkedHashSet<>();
Set<String> kotlinMarkerInterfaces = new LinkedHashSet<>();
for (KotlinType supertype : descriptor.getTypeConstructor().getSupertypes()) {
if (isJvmInterface(supertype.getConstructor().getDeclarationDescriptor())) {
@@ -330,7 +329,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
superInterfaces.addAll(kotlinMarkerInterfaces);
return new JvmClassSignature(classAsmType.getInternalName(), superClassInfo.getType().getInternalName(),
new ArrayList<String>(superInterfaces), sw.makeJavaGenericSignature());
new ArrayList<>(superInterfaces), sw.makeJavaGenericSignature());
}
private void getSuperClass() {
@@ -1089,7 +1088,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
return StackValue.field(type, classAsmType, name, false, StackValue.none());
}
}
private final Map<KtDelegatedSuperTypeEntry, Field> fields = new HashMap<KtDelegatedSuperTypeEntry, Field>();
private final Map<KtDelegatedSuperTypeEntry, Field> fields = new HashMap<>();
@NotNull
public Field getInfo(KtDelegatedSuperTypeEntry specifier) {
@@ -1266,7 +1265,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private void generateTraitMethods() {
if (isAnnotationOrJvmInterfaceWithoutDefaults(descriptor, state)) return;
List<FunctionDescriptor> restrictedInheritance = new ArrayList<FunctionDescriptor>();
List<FunctionDescriptor> restrictedInheritance = new ArrayList<>();
for (Map.Entry<FunctionDescriptor, FunctionDescriptor> entry : CodegenUtil.getNonPrivateTraitMethods(descriptor).entrySet()) {
FunctionDescriptor interfaceFun = entry.getKey();
//skip java 8 default methods
@@ -1625,7 +1624,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
public void addCompanionObjectPropertyToCopy(@NotNull PropertyDescriptor descriptor, Object defaultValue) {
if (companionObjectPropertiesToCopy == null) {
companionObjectPropertiesToCopy = new ArrayList<PropertyAndDefaultValue>();
companionObjectPropertiesToCopy = new ArrayList<>();
}
companionObjectPropertiesToCopy.add(new PropertyAndDefaultValue(descriptor, defaultValue));
}
@@ -49,8 +49,8 @@ public class KotlinCodegenFacade {
@NotNull GenerationState state,
@NotNull CompilationErrorHandler errorHandler
) {
MultiMap<FqName, KtFile> filesInPackages = new MultiMap<FqName, KtFile>();
MultiMap<FqName, KtFile> filesInMultifileClasses = new MultiMap<FqName, KtFile>();
MultiMap<FqName, KtFile> filesInPackages = new MultiMap<>();
MultiMap<FqName, KtFile> filesInMultifileClasses = new MultiMap<>();
for (KtFile file : files) {
if (file == null) throw new IllegalArgumentException("A null file given for compilation");
@@ -65,13 +65,13 @@ public class KotlinCodegenFacade {
}
}
Set<FqName> obsoleteMultifileClasses = new HashSet<FqName>(state.getObsoleteMultifileClasses());
Set<FqName> obsoleteMultifileClasses = new HashSet<>(state.getObsoleteMultifileClasses());
for (FqName multifileClassFqName : Sets.union(filesInMultifileClasses.keySet(), obsoleteMultifileClasses)) {
doCheckCancelled(state);
generateMultifileClass(state, multifileClassFqName, filesInMultifileClasses.get(multifileClassFqName), errorHandler);
}
Set<FqName> packagesWithObsoleteParts = new HashSet<FqName>(state.getPackagesWithObsoleteParts());
Set<FqName> packagesWithObsoleteParts = new HashSet<>(state.getPackagesWithObsoleteParts());
for (FqName packageFqName : Sets.union(packagesWithObsoleteParts, filesInPackages.keySet())) {
doCheckCancelled(state);
generatePackage(state, packageFqName, filesInPackages.get(packageFqName), errorHandler);
@@ -92,7 +92,7 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
private final JvmFileClassesProvider fileClassesProvider;
private final MemberCodegen<?> parentCodegen;
private final ReifiedTypeParametersUsages reifiedTypeParametersUsages = new ReifiedTypeParametersUsages();
private final Collection<ClassDescriptor> innerClasses = new LinkedHashSet<ClassDescriptor>();
private final Collection<ClassDescriptor> innerClasses = new LinkedHashSet<>();
private ExpressionCodegen clInit;
private NameGenerator inlineNameGenerator;
@@ -579,7 +579,7 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
}
protected void generatePropertyMetadataArrayFieldIfNeeded(@NotNull Type thisAsmType) {
List<KtProperty> delegatedProperties = new ArrayList<KtProperty>();
List<KtProperty> delegatedProperties = new ArrayList<>();
for (KtDeclaration declaration : ((KtDeclarationContainer) element).getDeclarations()) {
if (declaration instanceof KtProperty) {
KtProperty property = (KtProperty) declaration;
@@ -99,7 +99,7 @@ public class PackageCodegenImpl implements PackageCodegen {
boolean generatePackagePart = false;
List<KtClassOrObject> classOrObjects = new ArrayList<KtClassOrObject>();
List<KtClassOrObject> classOrObjects = new ArrayList<>();
for (KtDeclaration declaration : file.getDeclarations()) {
if (declaration.hasModifier(KtTokens.HEADER_KEYWORD)) continue;
@@ -135,7 +135,7 @@ public class PackageCodegenImpl implements PackageCodegen {
@Nullable
private PackageFragmentDescriptor getOnlyPackageFragment(@NotNull FqName expectedPackageFqName) {
SmartList<PackageFragmentDescriptor> fragments = new SmartList<PackageFragmentDescriptor>();
SmartList<PackageFragmentDescriptor> fragments = new SmartList<>();
for (KtFile file : files) {
PackageFragmentDescriptor fragment = state.getBindingContext().get(BindingContext.FILE_TO_PACKAGE_FRAGMENT, file);
assert fragment != null : "package fragment is null for " + file + "\n" + file.getText();
@@ -75,7 +75,7 @@ public class PackagePartCodegen extends MemberCodegen<KtFile> {
}
private void generateAnnotationsForPartClass() {
List<AnnotationDescriptor> fileAnnotationDescriptors = new ArrayList<AnnotationDescriptor>();
List<AnnotationDescriptor> fileAnnotationDescriptors = new ArrayList<>();
for (KtAnnotationEntry annotationEntry : element.getAnnotationEntries()) {
AnnotationDescriptor annotationDescriptor = state.getBindingContext().get(BindingContext.ANNOTATION, annotationEntry);
if (annotationDescriptor != null) {
@@ -103,7 +103,7 @@ public class PackagePartCodegen extends MemberCodegen<KtFile> {
@Override
protected void generateKotlinMetadataAnnotation() {
List<DeclarationDescriptor> members = new ArrayList<DeclarationDescriptor>();
List<DeclarationDescriptor> members = new ArrayList<>();
for (KtDeclaration declaration : element.getDeclarations()) {
if (declaration instanceof KtNamedFunction) {
SimpleFunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, declaration);
@@ -45,7 +45,7 @@ public abstract class TransformationMethodVisitor extends MethodVisitor {
super(Opcodes.ASM5);
this.delegate = delegate;
this.methodNode = new MethodNode(access, name, desc, signature, exceptions);
this.methodNode.localVariables = new ArrayList<LocalVariableNode>(5);
this.methodNode.localVariables = new ArrayList<>(5);
this.mv = InlineCodegenUtil.wrapWithMaxLocalCalc(methodNode);
}
@@ -70,10 +70,10 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
TokenSet.create(PLUS, MINUS, MUL, DIV, PERC, RANGE, LT, GT, LTEQ, GTEQ, IDENTIFIER)
);
private final Map<String, Integer> anonymousSubclassesCount = new HashMap<String, Integer>();
private final Map<String, Integer> anonymousSubclassesCount = new HashMap<>();
private final Stack<ClassDescriptor> classStack = new Stack<ClassDescriptor>();
private final Stack<String> nameStack = new Stack<String>();
private final Stack<ClassDescriptor> classStack = new Stack<>();
private final Stack<String> nameStack = new Stack<>();
private final BindingTrace bindingTrace;
private final BindingContext bindingContext;
@@ -638,7 +638,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
String currentClassName = getCurrentTopLevelClassOrPackagePartInternalName(expression.getContainingKtFile());
if (bindingContext.get(MAPPINGS_FOR_WHENS_BY_ENUM_IN_CLASS_FILE, currentClassName) == null) {
bindingTrace.record(MAPPINGS_FOR_WHENS_BY_ENUM_IN_CLASS_FILE, currentClassName, new ArrayList<WhenByEnumsMapping>(1));
bindingTrace.record(MAPPINGS_FOR_WHENS_BY_ENUM_IN_CLASS_FILE, currentClassName, new ArrayList<>(1));
}
List<WhenByEnumsMapping> mappings = bindingContext.get(MAPPINGS_FOR_WHENS_BY_ENUM_IN_CLASS_FILE, currentClassName);
@@ -181,7 +181,7 @@ public class CodegenBinding {
) {
Collection<ClassDescriptor> innerClasses = bindingTrace.get(INNER_CLASSES, outer);
if (innerClasses == null) {
innerClasses = new ArrayList<ClassDescriptor>(1);
innerClasses = new ArrayList<>(1);
bindingTrace.record(INNER_CLASSES, outer, innerClasses);
}
innerClasses.add(inner);
@@ -192,14 +192,14 @@ public class CodegenBinding {
// todo: we use Set and add given files but ignoring other scripts because something non-clear kept in binding
// for scripts especially in case of REPL
Set<FqName> names = new HashSet<FqName>();
Set<FqName> names = new HashSet<>();
for (KtFile file : files) {
if (!file.isScript()) {
names.add(file.getPackageFqName());
}
}
Set<KtFile> answer = new HashSet<KtFile>();
Set<KtFile> answer = new HashSet<>();
answer.addAll(files);
for (FqName name : names) {
@@ -209,7 +209,7 @@ public class CodegenBinding {
}
}
List<KtFile> sortedAnswer = new ArrayList<KtFile>(answer);
List<KtFile> sortedAnswer = new ArrayList<>(answer);
sortedAnswer.sort(Comparator.comparing((KtFile file) -> {
VirtualFile virtualFile = file.getVirtualFile();
@@ -234,9 +234,9 @@ public class CodegenBinding {
Collection<ClassDescriptor> innerClasses = bindingContext.get(INNER_CLASSES, outermostClass);
if (innerClasses == null || innerClasses.isEmpty()) return Collections.emptySet();
Set<ClassDescriptor> allInnerClasses = new HashSet<ClassDescriptor>();
Set<ClassDescriptor> allInnerClasses = new HashSet<>();
Deque<ClassDescriptor> stack = new ArrayDeque<ClassDescriptor>(innerClasses);
Deque<ClassDescriptor> stack = new ArrayDeque<>(innerClasses);
do {
ClassDescriptor currentClass = stack.pop();
if (allInnerClasses.add(currentClass)) {
@@ -247,7 +247,8 @@ public class CodegenBinding {
}
}
}
} while (!stack.isEmpty());
}
while (!stack.isEmpty());
return allInnerClasses;
}
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.codegen.binding;
import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.StackValue;
import org.jetbrains.kotlin.codegen.context.EnclosedValueDescriptor;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.types.KotlinType;
@@ -140,23 +139,23 @@ public final class MutableClosure implements CalculatedClosure {
private void recordField(String name, Type type) {
if (recordedFields == null) {
recordedFields = new LinkedList<Pair<String, Type>>();
recordedFields = new LinkedList<>();
}
recordedFields.add(new Pair<String, Type>(name, type));
recordedFields.add(new Pair<>(name, type));
}
public void captureVariable(EnclosedValueDescriptor value) {
recordField(value.getFieldName(), value.getType());
if (captureVariables == null) {
captureVariables = new LinkedHashMap<DeclarationDescriptor, EnclosedValueDescriptor>();
captureVariables = new LinkedHashMap<>();
}
captureVariables.put(value.getDescriptor(), value);
}
public void setCapturedParameterOffsetInConstructor(DeclarationDescriptor descriptor, int offset) {
if (parameterOffsetInConstructor == null) {
parameterOffsetInConstructor = new LinkedHashMap<DeclarationDescriptor, Integer>();
parameterOffsetInConstructor = new LinkedHashMap<>();
}
parameterOffsetInConstructor.put(descriptor, offset);
}
@@ -425,10 +425,10 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
boolean setterAccessorRequired
) {
if (accessors == null) {
accessors = new LinkedHashMap<AccessorKey, AccessorForCallableDescriptor<?>>();
accessors = new LinkedHashMap<>();
}
if (propertyAccessorFactories == null) {
propertyAccessorFactories = new LinkedHashMap<AccessorKey, AccessorForPropertyDescriptorFactory>();
propertyAccessorFactories = new LinkedHashMap<>();
}
D descriptor = (D) possiblySubstitutedDescriptor.getOriginal();
@@ -661,7 +661,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
private void addChild(@NotNull CodegenContext child) {
if (shouldAddChild(child.contextDescriptor)) {
if (childContexts == null) {
childContexts = new HashMap<DeclarationDescriptor, CodegenContext>();
childContexts = new HashMap<>();
}
DeclarationDescriptor childContextDescriptor = child.getContextDescriptor();
childContexts.put(childContextDescriptor, child);
@@ -32,7 +32,7 @@ import java.util.Map;
public abstract class FieldOwnerContext<T extends DeclarationDescriptor> extends CodegenContext<T> {
//default property name -> map<property descriptor -> bytecode name>
private final Map<String, Map<PropertyDescriptor, String>> fieldNames = new HashMap<String, Map<PropertyDescriptor, String>>();
private final Map<String, Map<PropertyDescriptor, String>> fieldNames = new HashMap<>();
public FieldOwnerContext(
@NotNull T contextDescriptor,
@@ -56,8 +56,7 @@ public abstract class FieldOwnerContext<T extends DeclarationDescriptor> extends
String defaultPropertyName = KotlinTypeMapper.mapDefaultFieldName(descriptor, isDelegated);
Map<PropertyDescriptor, String> descriptor2Name =
fieldNames.computeIfAbsent(defaultPropertyName, unused -> new HashMap<PropertyDescriptor, String>());
Map<PropertyDescriptor, String> descriptor2Name = fieldNames.computeIfAbsent(defaultPropertyName, unused -> new HashMap<>());
String actualName = descriptor2Name.get(descriptor);
if (actualName != null) return actualName;
@@ -37,7 +37,7 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
private final InliningContext inliningContext;
private final Type oldObjectType;
private final boolean isSameModule;
private final Map<String, List<String>> fieldNames = new HashMap<String, List<String>>();
private final Map<String, List<String>> fieldNames = new HashMap<>();
private MethodNode constructor;
private String sourceInfo;
@@ -58,9 +58,9 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
@Override
@NotNull
public InlineResult doTransform(@NotNull FieldRemapper parentRemapper) {
List<InnerClassNode> innerClassNodes = new ArrayList<InnerClassNode>();
List<InnerClassNode> innerClassNodes = new ArrayList<>();
ClassBuilder classBuilder = createRemappingClassBuilderViaFactory(inliningContext);
List<MethodNode> methodsToTransform = new ArrayList<MethodNode>();
List<MethodNode> methodsToTransform = new ArrayList<>();
createClassReader().accept(new ClassVisitor(InlineCodegenUtil.API, classBuilder.getVisitor()) {
@Override
@@ -139,7 +139,7 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
List<CapturedParamInfo> additionalFakeParams =
extractParametersMappingAndPatchConstructor(constructor, allCapturedParamBuilder, constructorParamBuilder,
transformationInfo, parentRemapper);
List<DeferredMethodVisitor> deferringMethods = new ArrayList<DeferredMethodVisitor>();
List<DeferredMethodVisitor> deferringMethods = new ArrayList<>();
generateConstructorAndFields(classBuilder, allCapturedParamBuilder, constructorParamBuilder, parentRemapper, additionalFakeParams);
@@ -243,7 +243,7 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
@NotNull FieldRemapper parentRemapper,
@NotNull List<CapturedParamInfo> constructorAdditionalFakeParams
) {
List<Type> descTypes = new ArrayList<Type>();
List<Type> descTypes = new ArrayList<>();
Parameters constructorParams = constructorInlineBuilder.buildParameters();
int[] capturedIndexes = new int[constructorParams.getParameters().size()];
@@ -364,10 +364,10 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
@NotNull AnonymousObjectTransformationInfo transformationInfo,
@NotNull FieldRemapper parentFieldRemapper
) {
Set<LambdaInfo> capturedLambdas = new LinkedHashSet<LambdaInfo>(); //captured var of inlined parameter
List<CapturedParamInfo> constructorAdditionalFakeParams = new ArrayList<CapturedParamInfo>();
Set<LambdaInfo> capturedLambdas = new LinkedHashSet<>(); //captured var of inlined parameter
List<CapturedParamInfo> constructorAdditionalFakeParams = new ArrayList<>();
Map<Integer, LambdaInfo> indexToLambda = transformationInfo.getLambdasToInline();
Set<Integer> capturedParams = new HashSet<Integer>();
Set<Integer> capturedParams = new HashSet<>();
//load captured parameters and patch instruction list (NB: there is also could be object fields)
AbstractInsnNode cur = constructor.instructions.getFirst();
@@ -436,12 +436,12 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
//For all inlined lambdas add their captured parameters
//TODO: some of such parameters could be skipped - we should perform additional analysis
Map<String, LambdaInfo> capturedLambdasToInline = new HashMap<String, LambdaInfo>(); //captured var of inlined parameter
List<CapturedParamDesc> allRecapturedParameters = new ArrayList<CapturedParamDesc>();
Map<String, LambdaInfo> capturedLambdasToInline = new HashMap<>(); //captured var of inlined parameter
List<CapturedParamDesc> allRecapturedParameters = new ArrayList<>();
boolean addCapturedNotAddOuter =
parentFieldRemapper.isRoot() ||
(parentFieldRemapper instanceof InlinedLambdaRemapper && parentFieldRemapper.getParent().isRoot());
Map<String, CapturedParamInfo> alreadyAdded = new HashMap<String, CapturedParamInfo>();
Map<String, CapturedParamInfo> alreadyAdded = new HashMap<>();
for (LambdaInfo info : capturedLambdas) {
if (addCapturedNotAddOuter) {
for (CapturedParamDesc desc : info.getCapturedVars()) {
@@ -524,7 +524,7 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
@NotNull
private String addUniqueField(@NotNull String name) {
List<String> existNames = fieldNames.computeIfAbsent(name, unused -> new LinkedList<String>());
List<String> existNames = fieldNames.computeIfAbsent(name, unused -> new LinkedList<>());
String suffix = existNames.isEmpty() ? "" : "$" + existNames.size();
String newName = name + suffix;
existNames.add(newName);
@@ -29,7 +29,7 @@ import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil.getLoadStore
public class InlineAdapter extends InstructionAdapter {
private final SourceMapper sourceMapper;
private final List<CatchBlock> blocks = new ArrayList<CatchBlock>();
private final List<CatchBlock> blocks = new ArrayList<>();
private boolean isLambdaInlining = false;
private int nextLocalIndex = 0;
@@ -88,7 +88,7 @@ public class InlineCodegen extends CallGenerator {
private final boolean isSameModule;
private final ParametersBuilder invocationParamBuilder = ParametersBuilder.newBuilder();
private final Map<Integer, LambdaInfo> expressionMap = new HashMap<Integer, LambdaInfo>();
private final Map<Integer, LambdaInfo> expressionMap = new HashMap<>();
private final ReifiedTypeInliner reifiedTypeInliner;
@@ -819,7 +819,7 @@ public class InlineCodegen extends CallGenerator {
@NotNull
public static Set<String> getDeclarationLabels(@Nullable PsiElement lambdaOrFun, @NotNull DeclarationDescriptor descriptor) {
Set<String> result = new HashSet<String>();
Set<String> result = new HashSet<>();
if (lambdaOrFun != null) {
Name label = LabelResolver.INSTANCE.getLabelNameIfAny(lambdaOrFun);
@@ -944,8 +944,7 @@ public class InlineCodegen extends CallGenerator {
) {
if (!codegen.hasFinallyBlocks()) return;
Map<AbstractInsnNode, MethodInliner.PointForExternalFinallyBlocks> extensionPoints =
new HashMap<AbstractInsnNode, MethodInliner.PointForExternalFinallyBlocks>();
Map<AbstractInsnNode, MethodInliner.PointForExternalFinallyBlocks> extensionPoints = new HashMap<>();
for (MethodInliner.PointForExternalFinallyBlocks insertPoint : insertPoints) {
extensionPoints.put(insertPoint.beforeIns, insertPoint);
}
@@ -35,8 +35,7 @@ public class InliningContext {
public final ReifiedTypeInliner reifiedTypeInliner;
public final boolean isInliningLambda;
public final boolean classRegeneration;
public final Map<String, AnonymousObjectTransformationInfo> internalNameToAnonymousObjectTransformationInfo =
new HashMap<String, AnonymousObjectTransformationInfo>();
public final Map<String, AnonymousObjectTransformationInfo> internalNameToAnonymousObjectTransformationInfo = new HashMap<>();
private boolean isContinuation;
@@ -67,7 +66,7 @@ public class InliningContext {
@NotNull
public InliningContext subInlineLambda(@NotNull LambdaInfo lambdaInfo) {
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
map.put(lambdaInfo.getLambdaClassType().getInternalName(), null); //mark lambda inlined
return subInline(nameGenerator.subGenerator("lambda"), map, true);
}
@@ -67,12 +67,12 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
public static void processInlineFunFinallyBlocks(@NotNull MethodNode inlineFun, int lambdaTryCatchBlockNodes, int finallyParamOffset) {
int index = 0;
List<TryCatchBlockNodeInfo> inlineFunTryBlockInfo = new ArrayList<TryCatchBlockNodeInfo>();
List<TryCatchBlockNodeInfo> inlineFunTryBlockInfo = new ArrayList<>();
for (TryCatchBlockNode block : inlineFun.tryCatchBlocks) {
inlineFunTryBlockInfo.add(new TryCatchBlockNodeInfo(block, index++ < lambdaTryCatchBlockNodes));
}
List<LocalVarNodeWrapper> localVars = new ArrayList<LocalVarNodeWrapper>();
List<LocalVarNodeWrapper> localVars = new ArrayList<>();
for (LocalVariableNode var : inlineFun.localVariables) {
localVars.add(new LocalVarNodeWrapper(var));
}
@@ -132,7 +132,7 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
}
List<TryCatchBlockNodeInfo> currentCoveringNodesFromInnermost =
sortTryCatchBlocks(new ArrayList<TryCatchBlockNodeInfo>(getTryBlocksMetaInfo().getCurrentIntervals()));
sortTryCatchBlocks(new ArrayList<>(getTryBlocksMetaInfo().getCurrentIntervals()));
checkCoveringBlocksInvariant(Lists.reverse(currentCoveringNodesFromInnermost));
if (currentCoveringNodesFromInnermost.isEmpty() ||
@@ -285,7 +285,7 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
@NotNull
private static Set<LabelNode> rememberOriginalLabelNodes(@NotNull FinallyBlockInfo finallyInfo) {
Set<LabelNode> labelsInsideFinally = new HashSet<LabelNode>();
Set<LabelNode> labelsInsideFinally = new HashSet<>();
for (AbstractInsnNode currentIns = finallyInfo.startIns; currentIns != finallyInfo.endInsExclusive; currentIns = currentIns.getNext()) {
if (currentIns instanceof LabelNode) {
labelsInsideFinally.add((LabelNode) currentIns);
@@ -305,7 +305,7 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
//copy tryCatchFinallies that totally in finally block
List<TryBlockCluster<TryCatchBlockNodePosition>> clusters = TryBlockClusteringKt.doClustering(tryCatchBlockPresentInFinally);
Map<LabelNode, TryBlockCluster<TryCatchBlockNodePosition>> handler2Cluster = new HashMap<LabelNode, TryBlockCluster<TryCatchBlockNodePosition>>();
Map<LabelNode, TryBlockCluster<TryCatchBlockNodePosition>> handler2Cluster = new HashMap<>();
IntervalMetaInfo<TryCatchBlockNodeInfo> tryBlocksMetaInfo = getTryBlocksMetaInfo();
for (TryBlockCluster<TryCatchBlockNodePosition> cluster : clusters) {
@@ -418,7 +418,7 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
@NotNull TryCatchBlockNodeInfo tryCatchBlock,
@ReadOnly @NotNull List<TryCatchBlockNodeInfo> tryCatchBlocks
) {
List<TryCatchBlockNodeInfo> sameDefaultHandler = new ArrayList<TryCatchBlockNodeInfo>();
List<TryCatchBlockNodeInfo> sameDefaultHandler = new ArrayList<>();
LabelNode defaultHandler = null;
boolean afterStartBlock = false;
for (TryCatchBlockNodeInfo block : tryCatchBlocks) {
@@ -486,8 +486,8 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
@NotNull
private List<TryCatchBlockNodePosition> findTryCatchBlocksInlinedInFinally(@NotNull FinallyBlockInfo finallyInfo) {
List<TryCatchBlockNodePosition> result = new ArrayList<TryCatchBlockNodePosition>();
Map<TryCatchBlockNodeInfo, TryCatchBlockNodePosition> processedBlocks = new HashMap<TryCatchBlockNodeInfo, TryCatchBlockNodePosition>();
List<TryCatchBlockNodePosition> result = new ArrayList<>();
Map<TryCatchBlockNodeInfo, TryCatchBlockNodePosition> processedBlocks = new HashMap<>();
for (AbstractInsnNode curInstr = finallyInfo.startIns; curInstr != finallyInfo.endInsExclusive; curInstr = curInstr.getNext()) {
if (!(curInstr instanceof LabelNode)) continue;
@@ -128,7 +128,7 @@ public class LambdaInfo implements LabelOwner {
public List<CapturedParamDesc> getCapturedVars() {
//lazy initialization cause it would be calculated after object creation
if (capturedVars == null) {
capturedVars = new ArrayList<CapturedParamDesc>();
capturedVars = new ArrayList<>();
if (closure.getCaptureThis() != null) {
Type type = typeMapper.mapType(closure.getCaptureThis());
@@ -104,9 +104,8 @@ public class MaxStackFrameSizeAndLocalsCalculator extends MaxLocalsCalculator {
*/
private int maxStack;
private final Collection<ExceptionHandler> exceptionHandlers = new LinkedList<ExceptionHandler>();
private final Map<Label, LabelWrapper> labelWrappersMap = new HashMap<Label, LabelWrapper>();
private final Collection<ExceptionHandler> exceptionHandlers = new LinkedList<>();
private final Map<Label, LabelWrapper> labelWrappersMap = new HashMap<>();
public MaxStackFrameSizeAndLocalsCalculator(int api, int access, String descriptor, MethodVisitor mv) {
super(api, access, descriptor, mv);
@@ -331,8 +330,8 @@ public class MaxStackFrameSizeAndLocalsCalculator extends MaxLocalsCalculator {
* stack sizes of these blocks.
*/
int max = 0;
Stack<LabelWrapper> stack = new Stack<LabelWrapper>();
Set<LabelWrapper> pushed = new HashSet<LabelWrapper>();
Stack<LabelWrapper> stack = new Stack<>();
Set<LabelWrapper> pushed = new HashSet<>();
stack.push(firstLabel);
pushed.add(firstLabel);
@@ -411,7 +410,7 @@ public class MaxStackFrameSizeAndLocalsCalculator extends MaxLocalsCalculator {
private static class LabelWrapper {
private final Label label;
private LabelWrapper nextLabel = null;
private final Collection<ControlFlowEdge> successors = new LinkedList<ControlFlowEdge>();
private final Collection<ControlFlowEdge> successors = new LinkedList<>();
private int outputStackMax = 0;
private int inputStackSize = 0;
@@ -29,7 +29,7 @@ public class NameGenerator {
private int nextLambdaIndex = 1;
private int nextWhenIndex = 1;
private final Map<String, NameGenerator> subGenerators = new HashMap<String, NameGenerator>();
private final Map<String, NameGenerator> subGenerators = new HashMap<>();
public NameGenerator(String generatorClass) {
this.generatorClass = generatorClass;
@@ -23,7 +23,7 @@ import java.util.Iterator;
import java.util.Set;
public class RedundantBoxedValuesCollection implements Iterable<BoxedValueDescriptor> {
private final Set<BoxedValueDescriptor> safeToDeleteValues = new HashSet<BoxedValueDescriptor>();
private final Set<BoxedValueDescriptor> safeToDeleteValues = new HashSet<>();
public void add(@NotNull BoxedValueDescriptor descriptor) {
safeToDeleteValues.add(descriptor);
@@ -153,7 +153,7 @@ public class RedundantBoxingMethodTransformer extends MethodTransformer {
@NotNull MethodNode node,
@NotNull Frame<BasicValue>[] frames
) {
List<BasicValue> values = new ArrayList<BasicValue>();
List<BasicValue> values = new ArrayList<>();
InsnList insnList = node.instructions;
int from = insnList.indexOf(localVariableNode.start) + 1;
int to = insnList.indexOf(localVariableNode.end) - 1;
@@ -192,7 +192,7 @@ public class RedundantBoxingMethodTransformer extends MethodTransformer {
@NotNull
private static int[] buildVariablesRemapping(@NotNull RedundantBoxedValuesCollection values, @NotNull MethodNode node) {
Set<Integer> doubleSizedVars = new HashSet<Integer>();
Set<Integer> doubleSizedVars = new HashSet<>();
for (BoxedValueDescriptor valueDescriptor : values) {
if (valueDescriptor.isDoubleSize()) {
doubleSizedVars.addAll(valueDescriptor.getVariablesIndexes());
@@ -41,7 +41,7 @@ public abstract class MethodTransformer {
@NotNull MethodNode node,
@NotNull Interpreter<V> interpreter
) {
return runAnalyzer(new Analyzer<V>(interpreter), internalClassName, node);
return runAnalyzer(new Analyzer<>(interpreter), internalClassName, node);
}
public abstract void transform(@NotNull String internalClassName, @NotNull MethodNode methodNode);
@@ -40,7 +40,7 @@ public final class JvmSerializationBindings {
@NotNull
public static <K, V> SerializationMappingSlice<K, V> create() {
return new SerializationMappingSlice<K, V>();
return new SerializationMappingSlice<>();
}
}
@@ -51,7 +51,7 @@ public final class JvmSerializationBindings {
@NotNull
public static <K> SerializationMappingSetSlice<K> create() {
return new SerializationMappingSetSlice<K>();
return new SerializationMappingSetSlice<>();
}
}
@@ -49,7 +49,7 @@ public class BothSignatureWriter extends JvmSignatureWriter {
this.signatureVisitor = new CheckSignatureAdapter(mode.asmType, signatureWriter);
}
private final Stack<SignatureVisitor> visitors = new Stack<SignatureVisitor>();
private final Stack<SignatureVisitor> visitors = new Stack<>();
private void push(SignatureVisitor visitor) {
visitors.push(visitor);
@@ -32,7 +32,7 @@ import java.util.List;
public class JvmSignatureWriter extends JvmDescriptorTypeWriter<Type> {
private final List<JvmMethodParameterSignature> kotlinParameterTypes = new ArrayList<JvmMethodParameterSignature>();
private final List<JvmMethodParameterSignature> kotlinParameterTypes = new ArrayList<>();
private Type jvmReturnType;
@@ -149,7 +149,7 @@ public class JvmSignatureWriter extends JvmDescriptorTypeWriter<Type> {
@NotNull
public JvmMethodGenericSignature makeJvmMethodSignature(@NotNull String name) {
List<Type> types = new ArrayList<Type>(kotlinParameterTypes.size());
List<Type> types = new ArrayList<>(kotlinParameterTypes.size());
for (JvmMethodParameterSignature parameter : kotlinParameterTypes) {
types.add(parameter.getAsmType());
}
@@ -28,7 +28,7 @@ import java.util.Set;
public class MappingsClassesForWhenByEnum {
private final GenerationState state;
private final Set<String> generatedMappingClasses = new HashSet<String>();
private final Set<String> generatedMappingClasses = new HashSet<>();
private final MappingClassesForWhenByEnumCodegen mappingsCodegen;
public MappingsClassesForWhenByEnum(@NotNull GenerationState state) {
@@ -55,12 +55,10 @@ public class StringSwitchCodegen extends SwitchCodegen {
if (!transitionsTable.containsKey(hashCode)) {
transitionsTable.put(hashCode, new Label());
hashCodesToStringAndEntryLabel.put(hashCode, new ArrayList<Pair<String, Label>>());
hashCodesToStringAndEntryLabel.put(hashCode, new ArrayList<>());
}
hashCodesToStringAndEntryLabel.get(hashCode).add(
new Pair<String, Label>(((StringValue) constant).getValue(), entryLabel)
);
hashCodesToStringAndEntryLabel.get(hashCode).add(new Pair<>(((StringValue) constant).getValue(), entryLabel));
}
@Override
@@ -43,8 +43,8 @@ abstract public class SwitchCodegen {
protected final Type resultType;
protected final InstructionAdapter v;
protected final NavigableMap<Integer, Label> transitionsTable = new TreeMap<Integer, Label>();
protected final List<Label> entryLabels = new ArrayList<Label>();
protected final NavigableMap<Integer, Label> transitionsTable = new TreeMap<>();
protected final List<Label> entryLabels = new ArrayList<>();
protected Label elseLabel = new Label();
protected Label endLabel = new Label();
protected Label defaultLabel;
@@ -66,7 +66,7 @@ public class SwitchCodegenUtil {
@NotNull BindingContext bindingContext,
boolean shouldInlineConstVals
) {
List<ConstantValue<?>> result = new ArrayList<ConstantValue<?>>();
List<ConstantValue<?>> result = new ArrayList<>();
for (KtWhenEntry entry : expression.getEntries()) {
addConstantsFromEntry(result, entry, bindingContext, shouldInlineConstVals);
@@ -97,7 +97,7 @@ public class SwitchCodegenUtil {
@NotNull BindingContext bindingContext,
boolean shouldInlineConstVals
) {
List<ConstantValue<?>> result = new ArrayList<ConstantValue<?>>();
List<ConstantValue<?>> result = new ArrayList<>();
addConstantsFromEntry(result, entry, bindingContext, shouldInlineConstVals);
return result;
}
@@ -27,7 +27,7 @@ public class WhenByEnumsMapping {
public static final String MAPPING_ARRAY_FIELD_PREFIX = "$EnumSwitchMapping$";
public static final String MAPPINGS_CLASS_NAME_POSTFIX = "$WhenMappings";
private final Map<EnumValue, Integer> map = new LinkedHashMap<EnumValue, Integer>();
private final Map<EnumValue, Integer> map = new LinkedHashMap<>();
private final ClassDescriptor enumClassDescriptor;
private final String outerClassInternalNameForExpression;
private final String mappingsClassInternalName;
@@ -95,9 +95,9 @@ public abstract class CommonCompilerArguments implements Serializable {
@ValueDescription(PLUGIN_OPTION_FORMAT)
public String[] pluginOptions;
public List<String> freeArgs = new SmartList<String>();
public List<String> freeArgs = new SmartList<>();
public List<String> unknownExtraFlags = new SmartList<String>();
public List<String> unknownExtraFlags = new SmartList<>();
@NotNull
public static CommonCompilerArguments createDefaultInstance() {
@@ -82,7 +82,7 @@ public class GroupingMessageCollector implements MessageCollector {
@NotNull
private Collection<String> sortedKeys() {
List<String> sortedKeys = new ArrayList<String>(groupedMessages.keySet());
List<String> sortedKeys = new ArrayList<>(groupedMessages.keySet());
// ensure that messages with no location i.e. perf, incomplete hierarchy are always reported first
sortedKeys.sort((o1, o2) -> {
if (o1 == o2) return 0;
@@ -75,7 +75,7 @@ public class ModuleXmlParser {
}
private final MessageCollector messageCollector;
private final List<Module> modules = new SmartList<Module>();
private final List<Module> modules = new SmartList<>();
private DefaultHandler currentState;
private ModuleXmlParser(@NotNull MessageCollector messageCollector) {
@@ -261,7 +261,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
);
}
Map<LanguageFeature, LanguageFeature.State> extraLanguageFeatures = new HashMap<LanguageFeature, LanguageFeature.State>(0);
Map<LanguageFeature, LanguageFeature.State> extraLanguageFeatures = new HashMap<>(0);
if (arguments.multiPlatform) {
extraLanguageFeatures.put(LanguageFeature.MultiPlatformProjects, LanguageFeature.State.ENABLED);
}
@@ -69,7 +69,7 @@ import static org.jetbrains.kotlin.cli.common.UtilsKt.checkKotlinPackageUsage;
import static org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation.NO_LOCATION;
public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
private static final Map<String, ModuleKind> moduleKindMap = new HashMap<String, ModuleKind>();
private static final Map<String, ModuleKind> moduleKindMap = new HashMap<>();
static {
moduleKindMap.put(K2JsArgumentConstants.MODULE_PLAIN, ModuleKind.PLAIN);
@@ -273,7 +273,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
configuration.put(JSConfigurationKeys.META_INFO, true);
}
List<String> libraries = new SmartList<String>();
List<String> libraries = new SmartList<>();
if (!arguments.noStdlib) {
libraries.add(0, PathUtil.getKotlinPathsForCompiler().getJsStdLibJarPath().getAbsolutePath());
}
@@ -45,7 +45,7 @@ public class SingleAbstractMethodUtils {
@NotNull
public static List<CallableMemberDescriptor> getAbstractMembers(@NotNull KotlinType type) {
List<CallableMemberDescriptor> abstractMembers = new ArrayList<CallableMemberDescriptor>();
List<CallableMemberDescriptor> abstractMembers = new ArrayList<>();
for (DeclarationDescriptor member : DescriptorUtils.getAllDescriptors(type.getMemberScope())) {
if (member instanceof CallableMemberDescriptor && ((CallableMemberDescriptor) member).getModality() == Modality.ABSTRACT) {
abstractMembers.add((CallableMemberDescriptor) member);
@@ -104,8 +104,8 @@ public class SingleAbstractMethodUtils {
KotlinType returnType = function.getReturnType();
assert returnType != null : "function is not initialized: " + function;
List<ValueParameterDescriptor> valueParameters = function.getValueParameters();
List<KotlinType> parameterTypes = new ArrayList<KotlinType>(valueParameters.size());
List<Name> parameterNames = new ArrayList<Name>(valueParameters.size());
List<KotlinType> parameterTypes = new ArrayList<>(valueParameters.size());
List<Name> parameterNames = new ArrayList<>(valueParameters.size());
int startIndex = 0;
KotlinType receiverType = null;
@@ -297,7 +297,7 @@ public class SingleAbstractMethodUtils {
@NotNull TypeSubstitutor substitutor
) {
List<ValueParameterDescriptor> originalValueParameters = original.getValueParameters();
List<ValueParameterDescriptor> valueParameters = new ArrayList<ValueParameterDescriptor>(originalValueParameters.size());
List<ValueParameterDescriptor> valueParameters = new ArrayList<>(originalValueParameters.size());
for (ValueParameterDescriptor originalParam : originalValueParameters) {
KotlinType originalType = originalParam.getType();
KotlinType functionType = getFunctionTypeForSamType(originalType);
@@ -343,7 +343,7 @@ public class SingleAbstractMethodUtils {
funTypeParameter.setInitialized();
}
List<TypeParameterDescriptor> typeParameters = new ArrayList<TypeParameterDescriptor>(traitToFunTypeParameters.values());
List<TypeParameterDescriptor> typeParameters = new ArrayList<>(traitToFunTypeParameters.values());
return new TypeParameters(typeParameters, typeParametersSubstitutor);
}
@@ -98,7 +98,7 @@ public class JavaClassifierTypeImpl extends JavaTypeImpl<PsiClassType> implement
PsiSubstitutor substitutor = getSubstitutor();
List<JavaType> result = new ArrayList<JavaType>(parameters.size());
List<JavaType> result = new ArrayList<>(parameters.size());
for (PsiTypeParameter typeParameter : parameters) {
PsiType substitutedType = substitutor.substitute(typeParameter);
result.add(substitutedType == null ? null : JavaTypeImpl.create(substitutedType));
@@ -124,7 +124,7 @@ public class JavaClassifierTypeImpl extends JavaTypeImpl<PsiClassType> implement
while (currentOwner != null) {
PsiTypeParameter[] typeParameters = currentOwner.getTypeParameters();
if (typeParameters.length > 0) {
if (result == null) result = new ArrayList<PsiTypeParameter>(typeParameters.length);
if (result == null) result = new ArrayList<>(typeParameters.length);
Collections.addAll(result, typeParameters);
}
@@ -69,7 +69,7 @@ public abstract class FileBasedKotlinClass implements KotlinJvmBinaryClass {
public void add(@NotNull String name, @Nullable String outerName, @Nullable String innerName) {
if (map == null) {
map = new HashMap<String, OuterAndInnerName>();
map = new HashMap<>();
}
map.put(name, new OuterAndInnerName(outerName, innerName));
}
@@ -276,7 +276,7 @@ public abstract class FileBasedKotlinClass implements KotlinJvmBinaryClass {
return ClassId.topLevel(new FqName(name.replace('/', '.')));
}
List<String> classes = new ArrayList<String>(1);
List<String> classes = new ArrayList<>(1);
boolean local = false;
while (true) {
@@ -24,7 +24,7 @@ import java.util.HashMap;
import java.util.Map;
public class AsmTypes {
private static final Map<Class<?>, Type> TYPES_MAP = new HashMap<Class<?>, Type>();
private static final Map<Class<?>, Type> TYPES_MAP = new HashMap<>();
public static final Type OBJECT_TYPE = getType(Object.class);
public static final Type JAVA_STRING_TYPE = getType(String.class);
@@ -22,13 +22,15 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
import org.jetbrains.kotlin.descriptors.SourceElement;
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl;
import org.jetbrains.kotlin.load.java.structure.*;
import org.jetbrains.kotlin.types.TypeConstructor;
import org.jetbrains.kotlin.types.TypeProjection;
import org.jetbrains.kotlin.types.TypeProjectionImpl;
import org.jetbrains.kotlin.types.TypeSubstitutor;
import java.util.*;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class JavaResolverUtils {
private JavaResolverUtils() {
@@ -39,8 +41,7 @@ public class JavaResolverUtils {
@Nullable DeclarationDescriptor newOwner
) {
// LinkedHashMap to save the order of type parameters
Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> result =
new LinkedHashMap<TypeParameterDescriptor, TypeParameterDescriptorImpl>();
Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> result = new LinkedHashMap<>();
for (TypeParameterDescriptor typeParameter : originalParameters) {
result.put(typeParameter,
TypeParameterDescriptorImpl.createForFurtherModification(
@@ -61,7 +62,7 @@ public class JavaResolverUtils {
public static TypeSubstitutor createSubstitutorForTypeParameters(
@NotNull Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters
) {
Map<TypeConstructor, TypeProjection> typeSubstitutionContext = new HashMap<TypeConstructor, TypeProjection>();
Map<TypeConstructor, TypeProjection> typeSubstitutionContext = new HashMap<>();
for (Map.Entry<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameter : originalToAltTypeParameters.entrySet()) {
typeSubstitutionContext.put(originalToAltTypeParameter.getKey().getTypeConstructor(),
new TypeProjectionImpl(originalToAltTypeParameter.getValue().getDefaultType()));
@@ -197,7 +197,7 @@ public class KotlinJavaPsiFacade {
@NotNull
private KotlinPsiElementFinderWrapper[] calcFinders() {
List<KotlinPsiElementFinderWrapper> elementFinders = new ArrayList<KotlinPsiElementFinderWrapper>();
List<KotlinPsiElementFinderWrapper> elementFinders = new ArrayList<>();
JavaFileManager javaFileManager = findJavaFileManager(project);
elementFinders.add(
javaFileManager instanceof KotlinCliJavaFileManager
@@ -230,10 +230,10 @@ public class KotlinJavaPsiFacade {
public PsiPackage findPackage(@NotNull String qualifiedName, GlobalSearchScope searchScope) {
PackageCache cache = SoftReference.dereference(packageCache);
if (cache == null) {
packageCache = new SoftReference<PackageCache>(cache = new PackageCache());
packageCache = new SoftReference<>(cache = new PackageCache());
}
Pair<String, GlobalSearchScope> key = new Pair<String, GlobalSearchScope>(qualifiedName, searchScope);
Pair<String, GlobalSearchScope> key = new Pair<>(qualifiedName, searchScope);
PsiPackage aPackage = cache.packageInScopeCache.get(key);
if (aPackage != null) {
return aPackage;
@@ -28,7 +28,7 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
private static final DiagnosticParameterRenderer<ConflictingJvmDeclarationsData> CONFLICTING_JVM_DECLARATIONS_DATA =
(data, context) -> {
List<DeclarationDescriptor> renderedDescriptors = new ArrayList<DeclarationDescriptor>();
List<DeclarationDescriptor> renderedDescriptors = new ArrayList<>();
for (JvmDeclarationOrigin origin : data.getSignatureOrigins()) {
DeclarationDescriptor descriptor = origin.getDescriptor();
if (descriptor != null) {
@@ -48,7 +48,7 @@ public class SignaturesPropagationData {
).iterator().next();
private final ValueParameters modifiedValueParameters;
private final List<String> signatureErrors = new ArrayList<String>(0);
private final List<String> signatureErrors = new ArrayList<>(0);
private final List<FunctionDescriptor> superFunctions;
public SignaturesPropagationData(
@@ -120,7 +120,7 @@ public class SignaturesPropagationData {
private ValueParameters modifyValueParametersAccordingToSuperMethods(@NotNull List<ValueParameterDescriptor> parameters) {
KotlinType resultReceiverType = null;
List<ValueParameterDescriptor> resultParameters = new ArrayList<ValueParameterDescriptor>(parameters.size());
List<ValueParameterDescriptor> resultParameters = new ArrayList<>(parameters.size());
boolean shouldBeExtension = checkIfShouldBeExtension();
@@ -124,7 +124,7 @@ public class CheckerTestUtil {
@Nullable List<DeclarationDescriptor> dynamicCallDescriptors,
@Nullable String platform
) {
List<ActualDiagnostic> diagnostics = new ArrayList<ActualDiagnostic>();
List<ActualDiagnostic> diagnostics = new ArrayList<>();
for (Diagnostic diagnostic : bindingContext.getDiagnostics().all()) {
if (PsiTreeUtil.isAncestor(root, diagnostic.getPsiElement(), false)) {
diagnostics.add(new ActualDiagnostic(diagnostic, platform));
@@ -148,7 +148,7 @@ public class CheckerTestUtil {
@Nullable List<DeclarationDescriptor> dynamicCallDescriptors,
@Nullable String platform
) {
List<ActualDiagnostic> debugAnnotations = new ArrayList<ActualDiagnostic>();
List<ActualDiagnostic> debugAnnotations = new ArrayList<>();
DebugInfoUtil.markDebugAnnotations(root, bindingContext, new DebugInfoUtil.DebugInfoReporter() {
@Override
@@ -214,7 +214,7 @@ public class CheckerTestUtil {
Collection<ActualDiagnostic> actual,
DiagnosticDiffCallbacks callbacks
) {
Map<ActualDiagnostic, TextDiagnostic> diagnosticToExpectedDiagnostic = new HashMap<ActualDiagnostic, TextDiagnostic>();
Map<ActualDiagnostic, TextDiagnostic> diagnosticToExpectedDiagnostic = new HashMap<>();
assertSameFile(actual);
@@ -358,7 +358,7 @@ public class CheckerTestUtil {
public static String parseDiagnosedRanges(String text, List<DiagnosedRange> result) {
Matcher matcher = RANGE_START_OR_END_PATTERN.matcher(text);
Stack<DiagnosedRange> opened = new Stack<DiagnosedRange>();
Stack<DiagnosedRange> opened = new Stack<>();
int offsetCompensation = 0;
@@ -405,7 +405,7 @@ public class CheckerTestUtil {
if (!diagnostics.isEmpty()) {
List<DiagnosticDescriptor> diagnosticDescriptors = getSortedDiagnosticDescriptors(diagnostics);
Stack<DiagnosticDescriptor> opened = new Stack<DiagnosticDescriptor>();
Stack<DiagnosticDescriptor> opened = new Stack<>();
ListIterator<DiagnosticDescriptor> iterator = diagnosticDescriptors.listIterator();
DiagnosticDescriptor currentDescriptor = iterator.next();
@@ -623,7 +623,7 @@ public class CheckerTestUtil {
}
public Map<ActualDiagnostic, TextDiagnostic> getTextDiagnosticsMap() {
Map<ActualDiagnostic, TextDiagnostic> diagnosticMap = new HashMap<ActualDiagnostic, TextDiagnostic>();
Map<ActualDiagnostic, TextDiagnostic> diagnosticMap = new HashMap<>();
for (ActualDiagnostic diagnostic : diagnostics) {
diagnosticMap.put(diagnostic, TextDiagnostic.asTextDiagnostic(diagnostic));
}
@@ -700,7 +700,7 @@ public class CheckerTestUtil {
return new TextDiagnostic(name, platform, null);
}
List<String> parsedParameters = new SmartList<String>();
List<String> parsedParameters = new SmartList<>();
Matcher parametersMatcher = INDIVIDUAL_PARAMETER_PATTERN.matcher(parameters);
while (parametersMatcher.find())
parsedParameters.add(unescape(parametersMatcher.group().trim()));
@@ -26,7 +26,7 @@ import java.util.*;
public class CompilerConfiguration {
public static CompilerConfiguration EMPTY = new CompilerConfiguration();
private final Map<Key, Object> map = new HashMap<Key, Object>();
private final Map<Key, Object> map = new HashMap<>();
private boolean readOnly = false;
static {
@@ -29,7 +29,7 @@ public class CompilerConfigurationKey<T> {
@NotNull
public static <T> CompilerConfigurationKey<T> create(@NotNull @NonNls String name) {
return new CompilerConfigurationKey<T>(name);
return new CompilerConfigurationKey<>(name);
}
@Override
@@ -30,11 +30,11 @@ public class DiagnosticFactory0<E extends PsiElement> extends DiagnosticFactoryW
}
public static <T extends PsiElement> DiagnosticFactory0<T> create(Severity severity, PositioningStrategy<? super T> positioningStrategy) {
return new DiagnosticFactory0<T>(severity, positioningStrategy);
return new DiagnosticFactory0<>(severity, positioningStrategy);
}
@NotNull
public SimpleDiagnostic<E> on(@NotNull E element) {
return new SimpleDiagnostic<E>(element, this, getSeverity());
return new SimpleDiagnostic<>(element, this, getSeverity());
}
}
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
public class DiagnosticFactory1<E extends PsiElement, A> extends DiagnosticFactoryWithPsiElement<E, DiagnosticWithParameters1<E, A>> {
@NotNull
public ParametrizedDiagnostic<E> on(@NotNull E element, @NotNull A argument) {
return new DiagnosticWithParameters1<E, A>(element, argument, this, getSeverity());
return new DiagnosticWithParameters1<>(element, argument, this, getSeverity());
}
protected DiagnosticFactory1(Severity severity, PositioningStrategy<? super E> positioningStrategy) {
@@ -30,7 +30,7 @@ public class DiagnosticFactory1<E extends PsiElement, A> extends DiagnosticFacto
}
public static <T extends PsiElement, A> DiagnosticFactory1<T, A> create(Severity severity, PositioningStrategy<? super T> positioningStrategy) {
return new DiagnosticFactory1<T, A>(severity, positioningStrategy);
return new DiagnosticFactory1<>(severity, positioningStrategy);
}
public static <T extends PsiElement, A> DiagnosticFactory1<T, A> create(Severity severity) {
@@ -23,7 +23,7 @@ public class DiagnosticFactory2<E extends PsiElement, A, B> extends DiagnosticFa
@NotNull
public ParametrizedDiagnostic<E> on(@NotNull E element, @NotNull A a, @NotNull B b) {
return new DiagnosticWithParameters2<E, A, B>(element, a, b, this, getSeverity());
return new DiagnosticWithParameters2<>(element, a, b, this, getSeverity());
}
private DiagnosticFactory2(Severity severity, PositioningStrategy<? super E> positioningStrategy) {
@@ -31,11 +31,11 @@ public class DiagnosticFactory2<E extends PsiElement, A, B> extends DiagnosticFa
}
public static <T extends PsiElement, A, B> DiagnosticFactory2<T, A, B> create(Severity severity, PositioningStrategy<? super T> positioningStrategy) {
return new DiagnosticFactory2<T, A, B>(severity, positioningStrategy);
return new DiagnosticFactory2<>(severity, positioningStrategy);
}
public static <T extends PsiElement, A, B> DiagnosticFactory2<T, A, B> create(Severity severity) {
return new DiagnosticFactory2<T, A, B>(severity, PositioningStrategies.DEFAULT);
return new DiagnosticFactory2<>(severity, PositioningStrategies.DEFAULT);
}
}
@@ -30,11 +30,11 @@ public class DiagnosticFactory3<E extends PsiElement, A, B, C> extends Diagnosti
}
public static <T extends PsiElement, A, B, C> DiagnosticFactory3<T, A, B, C> create(Severity severity, PositioningStrategy<? super T> positioningStrategy) {
return new DiagnosticFactory3<T, A, B, C>(severity, positioningStrategy);
return new DiagnosticFactory3<>(severity, positioningStrategy);
}
@NotNull
public ParametrizedDiagnostic<E> on(@NotNull E element, @NotNull A a, @NotNull B b, @NotNull C c) {
return new DiagnosticWithParameters3<E, A, B, C>(element, a, b, c, this, getSeverity());
return new DiagnosticWithParameters3<>(element, a, b, c, this, getSeverity());
}
}
@@ -53,7 +53,7 @@ public class DefaultErrorMessages {
private static final MappedExtensionProvider<Extension, List<DiagnosticFactoryToRendererMap>> RENDERER_MAPS = MappedExtensionProvider.create(
Extension.EP_NAME,
extensions -> {
List<DiagnosticFactoryToRendererMap> result = new ArrayList<DiagnosticFactoryToRendererMap>(extensions.size() + 1);
List<DiagnosticFactoryToRendererMap> result = new ArrayList<>(extensions.size() + 1);
for (Extension extension : extensions) {
result.add(extension.getMap());
}
@@ -25,7 +25,7 @@ import java.util.HashMap;
import java.util.Map;
public final class DiagnosticFactoryToRendererMap {
private final Map<DiagnosticFactory<?>, DiagnosticRenderer<?>> map = new HashMap<DiagnosticFactory<?>, DiagnosticRenderer<?>>();
private final Map<DiagnosticFactory<?>, DiagnosticRenderer<?>> map = new HashMap<>();
private boolean immutable = false;
// TO catch EA-75872
@@ -225,7 +225,7 @@ public class TabledDescriptorRenderer {
@NotNull
protected static RenderingContext computeRenderingContext(@NotNull TableRenderer table) {
ArrayList<Object> toRender = new ArrayList<Object>();
ArrayList<Object> toRender = new ArrayList<>();
for (TableRow row : table.rows) {
if (row instanceof DescriptorRow) {
toRender.add(((DescriptorRow) row).descriptor);
@@ -18,13 +18,10 @@
package org.jetbrains.kotlin.lexer;
import java.util.*;
import com.intellij.lexer.*;
import com.intellij.psi.*;
import com.intellij.lexer.FlexLexer;
import com.intellij.psi.TokenType;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.containers.Stack;
import org.jetbrains.kotlin.lexer.KotlinLexerException;
import org.jetbrains.kotlin.lexer.KtTokens;
/**
@@ -649,7 +646,7 @@ class _JetLexer implements FlexLexer {
}
}
private final Stack<State> states = new Stack<State>();
private final Stack<State> states = new Stack<>();
private int lBraceCount;
private int commentStart;
@@ -33,7 +33,7 @@ import java.util.Map;
import static org.jetbrains.kotlin.lexer.KtTokens.*;
/*package*/ abstract class AbstractKotlinParsing {
private static final Map<String, KtKeywordToken> SOFT_KEYWORD_TEXTS = new HashMap<String, KtKeywordToken>();
private static final Map<String, KtKeywordToken> SOFT_KEYWORD_TEXTS = new HashMap<>();
static {
for (IElementType type : KtTokens.SOFT_KEYWORDS.getTypes()) {
@@ -302,7 +302,7 @@ import static org.jetbrains.kotlin.lexer.KtTokens.*;
protected int matchTokenStreamPredicate(TokenStreamPattern pattern) {
PsiBuilder.Marker currentPosition = mark();
Stack<IElementType> opens = new Stack<IElementType>();
Stack<IElementType> opens = new Stack<>();
int openAngleBrackets = 0;
int openBraces = 0;
int openParentheses = 0;
@@ -237,7 +237,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
public static final TokenSet ALL_OPERATIONS;
static {
Set<IElementType> operations = new HashSet<IElementType>();
Set<IElementType> operations = new HashSet<>();
Precedence[] values = Precedence.values();
for (Precedence precedence : values) {
operations.addAll(Arrays.asList(precedence.getOperations().getTypes()));
@@ -247,9 +247,9 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
static {
IElementType[] operations = OPERATIONS.getTypes();
Set<IElementType> opSet = new HashSet<IElementType>(Arrays.asList(operations));
Set<IElementType> opSet = new HashSet<>(Arrays.asList(operations));
IElementType[] usedOperations = ALL_OPERATIONS.getTypes();
Set<IElementType> usedSet = new HashSet<IElementType>(Arrays.asList(usedOperations));
Set<IElementType> usedSet = new HashSet<>(Arrays.asList(usedOperations));
if (opSet.size() > usedSet.size()) {
opSet.removeAll(usedSet);
@@ -31,9 +31,9 @@ import static org.jetbrains.kotlin.lexer.KtTokens.*;
public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter implements SemanticWhitespaceAwarePsiBuilder {
private final TokenSet complexTokens = TokenSet.create(SAFE_ACCESS, ELVIS, EXCLEXCL);
private final Stack<Boolean> joinComplexTokens = new Stack<Boolean>();
private final Stack<Boolean> joinComplexTokens = new Stack<>();
private final Stack<Boolean> newlinesEnabled = new Stack<Boolean>();
private final Stack<Boolean> newlinesEnabled = new Stack<>();
private final PsiBuilderImpl delegateImpl;
@@ -108,8 +108,8 @@ public class KtPsiUtil {
@NotNull
public static Set<KtElement> findRootExpressions(@NotNull Collection<KtElement> unreachableElements) {
Set<KtElement> rootElements = new HashSet<KtElement>();
Set<KtElement> shadowedElements = new HashSet<KtElement>();
Set<KtElement> rootElements = new HashSet<>();
Set<KtElement> shadowedElements = new HashSet<>();
KtVisitorVoid shadowAllChildren = new KtVisitorVoid() {
@Override
public void visitKtElement(@NotNull KtElement element) {
@@ -29,14 +29,13 @@ import java.io.IOException;
public class KtPlaceHolderStubElementType<T extends KtElementImplStub<? extends StubElement<?>>> extends
KtStubElementType<KotlinPlaceHolderStub<T>, T> {
public KtPlaceHolderStubElementType(@NotNull @NonNls String debugName, @NotNull Class<T> psiClass) {
super(debugName, psiClass, KotlinPlaceHolderStub.class);
}
@Override
public KotlinPlaceHolderStub<T> createStub(@NotNull T psi, StubElement parentStub) {
return new KotlinPlaceHolderStubImpl<T>(parentStub, this);
return new KotlinPlaceHolderStubImpl<>(parentStub, this);
}
@Override
@@ -47,6 +46,6 @@ public class KtPlaceHolderStubElementType<T extends KtElementImplStub<? extends
@NotNull
@Override
public KotlinPlaceHolderStub<T> deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
return new KotlinPlaceHolderStubImpl<T>(parentStub, this);
return new KotlinPlaceHolderStubImpl<>(parentStub, this);
}
}
@@ -31,89 +31,89 @@ public interface KtStubElementTypes {
KtClassElementType ENUM_ENTRY = new KtClassElementType("ENUM_ENTRY");
KtObjectElementType OBJECT_DECLARATION = new KtObjectElementType("OBJECT_DECLARATION");
KtPlaceHolderStubElementType<KtClassInitializer> CLASS_INITIALIZER =
new KtPlaceHolderStubElementType<KtClassInitializer>("CLASS_INITIALIZER", KtClassInitializer.class);
new KtPlaceHolderStubElementType<>("CLASS_INITIALIZER", KtClassInitializer.class);
KtPlaceHolderStubElementType<KtSecondaryConstructor> SECONDARY_CONSTRUCTOR =
new KtPlaceHolderStubElementType<KtSecondaryConstructor>("SECONDARY_CONSTRUCTOR", KtSecondaryConstructor.class);
new KtPlaceHolderStubElementType<>("SECONDARY_CONSTRUCTOR", KtSecondaryConstructor.class);
KtPlaceHolderStubElementType<KtPrimaryConstructor> PRIMARY_CONSTRUCTOR =
new KtPlaceHolderStubElementType<KtPrimaryConstructor>("PRIMARY_CONSTRUCTOR", KtPrimaryConstructor.class);
new KtPlaceHolderStubElementType<>("PRIMARY_CONSTRUCTOR", KtPrimaryConstructor.class);
KtParameterElementType VALUE_PARAMETER = new KtParameterElementType("VALUE_PARAMETER");
KtPlaceHolderStubElementType<KtParameterList> VALUE_PARAMETER_LIST =
new KtPlaceHolderStubElementType<KtParameterList>("VALUE_PARAMETER_LIST", KtParameterList.class);
new KtPlaceHolderStubElementType<>("VALUE_PARAMETER_LIST", KtParameterList.class);
KtTypeParameterElementType TYPE_PARAMETER = new KtTypeParameterElementType("TYPE_PARAMETER");
KtPlaceHolderStubElementType<KtTypeParameterList> TYPE_PARAMETER_LIST =
new KtPlaceHolderStubElementType<KtTypeParameterList>("TYPE_PARAMETER_LIST", KtTypeParameterList.class);
new KtPlaceHolderStubElementType<>("TYPE_PARAMETER_LIST", KtTypeParameterList.class);
KtAnnotationEntryElementType ANNOTATION_ENTRY = new KtAnnotationEntryElementType("ANNOTATION_ENTRY");
KtPlaceHolderStubElementType<KtAnnotation> ANNOTATION =
new KtPlaceHolderStubElementType<KtAnnotation>("ANNOTATION", KtAnnotation.class);
new KtPlaceHolderStubElementType<>("ANNOTATION", KtAnnotation.class);
KtAnnotationUseSiteTargetElementType ANNOTATION_TARGET = new KtAnnotationUseSiteTargetElementType("ANNOTATION_TARGET");
KtPlaceHolderStubElementType<KtClassBody> CLASS_BODY =
new KtPlaceHolderStubElementType<KtClassBody>("CLASS_BODY", KtClassBody.class);
new KtPlaceHolderStubElementType<>("CLASS_BODY", KtClassBody.class);
KtPlaceHolderStubElementType<KtImportList> IMPORT_LIST =
new KtPlaceHolderStubElementType<KtImportList>("IMPORT_LIST", KtImportList.class);
new KtPlaceHolderStubElementType<>("IMPORT_LIST", KtImportList.class);
KtPlaceHolderStubElementType<KtFileAnnotationList> FILE_ANNOTATION_LIST =
new KtPlaceHolderStubElementType<KtFileAnnotationList>("FILE_ANNOTATION_LIST", KtFileAnnotationList.class);
new KtPlaceHolderStubElementType<>("FILE_ANNOTATION_LIST", KtFileAnnotationList.class);
KtImportDirectiveElementType IMPORT_DIRECTIVE = new KtImportDirectiveElementType("IMPORT_DIRECTIVE");
KtPlaceHolderStubElementType<KtPackageDirective> PACKAGE_DIRECTIVE =
new KtPlaceHolderStubElementType<KtPackageDirective>("PACKAGE_DIRECTIVE", KtPackageDirective.class);
new KtPlaceHolderStubElementType<>("PACKAGE_DIRECTIVE", KtPackageDirective.class);
KtModifierListElementType<KtDeclarationModifierList> MODIFIER_LIST =
new KtModifierListElementType<KtDeclarationModifierList>("MODIFIER_LIST", KtDeclarationModifierList.class);
new KtModifierListElementType<>("MODIFIER_LIST", KtDeclarationModifierList.class);
KtPlaceHolderStubElementType<KtTypeConstraintList> TYPE_CONSTRAINT_LIST =
new KtPlaceHolderStubElementType<KtTypeConstraintList>("TYPE_CONSTRAINT_LIST", KtTypeConstraintList.class);
new KtPlaceHolderStubElementType<>("TYPE_CONSTRAINT_LIST", KtTypeConstraintList.class);
KtPlaceHolderStubElementType<KtTypeConstraint> TYPE_CONSTRAINT =
new KtPlaceHolderStubElementType<KtTypeConstraint>("TYPE_CONSTRAINT", KtTypeConstraint.class);
new KtPlaceHolderStubElementType<>("TYPE_CONSTRAINT", KtTypeConstraint.class);
KtPlaceHolderStubElementType<KtNullableType> NULLABLE_TYPE =
new KtPlaceHolderStubElementType<KtNullableType>("NULLABLE_TYPE", KtNullableType.class);
new KtPlaceHolderStubElementType<>("NULLABLE_TYPE", KtNullableType.class);
KtPlaceHolderStubElementType<KtTypeReference> TYPE_REFERENCE =
new KtPlaceHolderStubElementType<KtTypeReference>("TYPE_REFERENCE", KtTypeReference.class);
new KtPlaceHolderStubElementType<>("TYPE_REFERENCE", KtTypeReference.class);
KtUserTypeElementType USER_TYPE = new KtUserTypeElementType("USER_TYPE");
KtPlaceHolderStubElementType<KtDynamicType> DYNAMIC_TYPE =
new KtPlaceHolderStubElementType<KtDynamicType>("DYNAMIC_TYPE", KtDynamicType.class);
new KtPlaceHolderStubElementType<>("DYNAMIC_TYPE", KtDynamicType.class);
KtPlaceHolderStubElementType<KtFunctionType> FUNCTION_TYPE =
new KtPlaceHolderStubElementType<KtFunctionType>("FUNCTION_TYPE", KtFunctionType.class);
new KtPlaceHolderStubElementType<>("FUNCTION_TYPE", KtFunctionType.class);
KtTypeProjectionElementType TYPE_PROJECTION = new KtTypeProjectionElementType("TYPE_PROJECTION");
KtPlaceHolderStubElementType<KtFunctionTypeReceiver> FUNCTION_TYPE_RECEIVER =
new KtPlaceHolderStubElementType<KtFunctionTypeReceiver>("FUNCTION_TYPE_RECEIVER", KtFunctionTypeReceiver.class);
new KtPlaceHolderStubElementType<>("FUNCTION_TYPE_RECEIVER", KtFunctionTypeReceiver.class);
KtNameReferenceExpressionElementType REFERENCE_EXPRESSION = new KtNameReferenceExpressionElementType("REFERENCE_EXPRESSION");
KtDotQualifiedExpressionElementType DOT_QUALIFIED_EXPRESSION = new KtDotQualifiedExpressionElementType("DOT_QUALIFIED_EXPRESSION");
KtEnumEntrySuperClassReferenceExpressionElementType
ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION = new KtEnumEntrySuperClassReferenceExpressionElementType("ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION");
KtPlaceHolderStubElementType<KtTypeArgumentList> TYPE_ARGUMENT_LIST =
new KtPlaceHolderStubElementType<KtTypeArgumentList>("TYPE_ARGUMENT_LIST", KtTypeArgumentList.class);
new KtPlaceHolderStubElementType<>("TYPE_ARGUMENT_LIST", KtTypeArgumentList.class);
KtPlaceHolderStubElementType<KtSuperTypeList> SUPER_TYPE_LIST =
new KtPlaceHolderStubElementType<KtSuperTypeList>("SUPER_TYPE_LIST", KtSuperTypeList.class);
new KtPlaceHolderStubElementType<>("SUPER_TYPE_LIST", KtSuperTypeList.class);
KtPlaceHolderStubElementType<KtInitializerList> INITIALIZER_LIST =
new KtPlaceHolderStubElementType<KtInitializerList>("INITIALIZER_LIST", KtInitializerList.class);
new KtPlaceHolderStubElementType<>("INITIALIZER_LIST", KtInitializerList.class);
KtPlaceHolderStubElementType<KtDelegatedSuperTypeEntry> DELEGATED_SUPER_TYPE_ENTRY =
new KtPlaceHolderStubElementType<KtDelegatedSuperTypeEntry>("DELEGATED_SUPER_TYPE_ENTRY", KtDelegatedSuperTypeEntry.class);
new KtPlaceHolderStubElementType<>("DELEGATED_SUPER_TYPE_ENTRY", KtDelegatedSuperTypeEntry.class);
KtPlaceHolderStubElementType<KtSuperTypeCallEntry> SUPER_TYPE_CALL_ENTRY =
new KtPlaceHolderStubElementType<KtSuperTypeCallEntry>("SUPER_TYPE_CALL_ENTRY", KtSuperTypeCallEntry.class);
new KtPlaceHolderStubElementType<>("SUPER_TYPE_CALL_ENTRY", KtSuperTypeCallEntry.class);
KtPlaceHolderStubElementType<KtSuperTypeEntry> SUPER_TYPE_ENTRY =
new KtPlaceHolderStubElementType<KtSuperTypeEntry>("SUPER_TYPE_ENTRY", KtSuperTypeEntry.class);
new KtPlaceHolderStubElementType<>("SUPER_TYPE_ENTRY", KtSuperTypeEntry.class);
KtPlaceHolderStubElementType<KtConstructorCalleeExpression> CONSTRUCTOR_CALLEE =
new KtPlaceHolderStubElementType<KtConstructorCalleeExpression>("CONSTRUCTOR_CALLEE", KtConstructorCalleeExpression.class);
new KtPlaceHolderStubElementType<>("CONSTRUCTOR_CALLEE", KtConstructorCalleeExpression.class);
KtScriptElementType SCRIPT = new KtScriptElementType("SCRIPT");
@@ -51,7 +51,7 @@ public class AnalyzingUtils {
}
public static List<PsiErrorElement> getSyntaxErrorRanges(@NotNull PsiElement root) {
List<PsiErrorElement> r = new ArrayList<PsiErrorElement>();
List<PsiErrorElement> r = new ArrayList<>();
root.acceptChildren(new PsiErrorElementVisitor() {
@Override
public void visitErrorElement(@NotNull PsiErrorElement element) {
@@ -79,7 +79,7 @@ public class AnnotationResolverImpl extends AnnotationResolver {
boolean shouldResolveArguments
) {
if (annotationEntryElements.isEmpty()) return Annotations.Companion.getEMPTY();
List<AnnotationWithTarget> result = new ArrayList<AnnotationWithTarget>(0);
List<AnnotationWithTarget> result = new ArrayList<>(0);
for (KtAnnotationEntry entryElement : annotationEntryElements) {
AnnotationDescriptor descriptor = trace.get(BindingContext.ANNOTATION, entryElement);
@@ -97,10 +97,10 @@ public interface BindingContext {
WritableSlice<KtTypeReference, KotlinType> TYPE = Slices.createSimpleSlice();
WritableSlice<KtTypeReference, KotlinType> ABBREVIATED_TYPE = Slices.createSimpleSlice();
WritableSlice<KtExpression, KotlinTypeInfo> EXPRESSION_TYPE_INFO = new BasicWritableSlice<KtExpression, KotlinTypeInfo>(DO_NOTHING);
WritableSlice<KtExpression, DataFlowInfo> DATA_FLOW_INFO_BEFORE = new BasicWritableSlice<KtExpression, DataFlowInfo>(DO_NOTHING);
WritableSlice<KtExpression, KotlinType> EXPECTED_EXPRESSION_TYPE = new BasicWritableSlice<KtExpression, KotlinType>(DO_NOTHING);
WritableSlice<KtFunction, KotlinType> EXPECTED_RETURN_TYPE = new BasicWritableSlice<KtFunction, KotlinType>(DO_NOTHING);
WritableSlice<KtExpression, KotlinTypeInfo> EXPRESSION_TYPE_INFO = new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<KtExpression, DataFlowInfo> DATA_FLOW_INFO_BEFORE = new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<KtExpression, KotlinType> EXPECTED_EXPRESSION_TYPE = new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<KtFunction, KotlinType> EXPECTED_RETURN_TYPE = new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<KtExpression, DataFlowInfo> DATAFLOW_INFO_AFTER_CONDITION = Slices.createSimpleSlice();
WritableSlice<VariableDescriptor, DataFlowValue> BOUND_INITIALIZER_VALUE = Slices.createSimpleSlice();
WritableSlice<KtExpression, LeakingThisDescriptor> LEAKING_THIS = Slices.createSimpleSlice();
@@ -108,26 +108,24 @@ public interface BindingContext {
/**
* A qualifier corresponds to a receiver expression (if any). For 'A.B' qualifier is recorded for 'A'.
*/
WritableSlice<KtExpression, Qualifier> QUALIFIER = new BasicWritableSlice<KtExpression, Qualifier>(DO_NOTHING);
WritableSlice<KtExpression, Qualifier> QUALIFIER = new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<KtExpression, DoubleColonLHS> DOUBLE_COLON_LHS = new BasicWritableSlice<KtExpression, DoubleColonLHS>(DO_NOTHING);
WritableSlice<KtExpression, DoubleColonLHS> DOUBLE_COLON_LHS = new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<KtSuperExpression, KotlinType> THIS_TYPE_FOR_SUPER_EXPRESSION =
new BasicWritableSlice<KtSuperExpression, KotlinType>(DO_NOTHING);
WritableSlice<KtSuperExpression, KotlinType> THIS_TYPE_FOR_SUPER_EXPRESSION = new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<KtReferenceExpression, DeclarationDescriptor> REFERENCE_TARGET =
new BasicWritableSlice<KtReferenceExpression, DeclarationDescriptor>(DO_NOTHING);
WritableSlice<KtReferenceExpression, DeclarationDescriptor> REFERENCE_TARGET = new BasicWritableSlice<>(DO_NOTHING);
// if 'A' really means 'A.Companion' then this slice stores class descriptor for A, REFERENCE_TARGET stores descriptor Companion in this case
WritableSlice<KtReferenceExpression, ClassifierDescriptorWithTypeParameters> SHORT_REFERENCE_TO_COMPANION_OBJECT =
new BasicWritableSlice<KtReferenceExpression, ClassifierDescriptorWithTypeParameters>(DO_NOTHING);
new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<Call, ResolvedCall<?>> RESOLVED_CALL = new BasicWritableSlice<Call, ResolvedCall<?>>(DO_NOTHING);
WritableSlice<Call, ResolvedCall<?>> RESOLVED_CALL = new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<Call, TailRecursionKind> TAIL_RECURSION_CALL = Slices.createSimpleSlice();
WritableSlice<KtElement, ConstraintSystemCompleter> CONSTRAINT_SYSTEM_COMPLETER = new BasicWritableSlice<KtElement, ConstraintSystemCompleter>(DO_NOTHING);
WritableSlice<KtElement, Call> CALL = new BasicWritableSlice<KtElement, Call>(DO_NOTHING);
WritableSlice<KtElement, ConstraintSystemCompleter> CONSTRAINT_SYSTEM_COMPLETER = new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<KtElement, Call> CALL = new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<KtExpression, Collection<? extends DeclarationDescriptor>> AMBIGUOUS_REFERENCE_TARGET =
new BasicWritableSlice<KtExpression, Collection<? extends DeclarationDescriptor>>(DO_NOTHING);
new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<KtExpression, ResolvedCall<FunctionDescriptor>> LOOP_RANGE_ITERATOR_RESOLVED_CALL = Slices.createSimpleSlice();
@@ -151,9 +149,9 @@ public interface BindingContext {
WritableSlice<KtCollectionLiteralExpression, ResolvedCall<FunctionDescriptor>> COLLECTION_LITERAL_CALL = Slices.createSimpleSlice();
WritableSlice<KtExpression, ExplicitSmartCasts> SMARTCAST = new BasicWritableSlice<KtExpression, ExplicitSmartCasts>(DO_NOTHING);
WritableSlice<KtExpression, ExplicitSmartCasts> SMARTCAST = new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<KtExpression, Boolean> SMARTCAST_NULL = Slices.createSimpleSlice();
WritableSlice<KtExpression, ImplicitSmartCasts> IMPLICIT_RECEIVER_SMARTCAST = new BasicWritableSlice<KtExpression, ImplicitSmartCasts>(DO_NOTHING);
WritableSlice<KtExpression, ImplicitSmartCasts> IMPLICIT_RECEIVER_SMARTCAST = new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<KtWhenExpression, Boolean> EXHAUSTIVE_WHEN = Slices.createSimpleSlice();
WritableSlice<KtWhenExpression, Boolean> IMPLICIT_EXHAUSTIVE_WHEN = Slices.createSimpleSlice();
@@ -173,8 +171,8 @@ public interface BindingContext {
WritableSlice<KtElement, Boolean> USED_AS_RESULT_OF_LAMBDA = Slices.createSimpleSetSlice();
WritableSlice<KtElement, Boolean> UNREACHABLE_CODE = Slices.createSimpleSetSlice();
WritableSlice<VariableDescriptor, CaptureKind> CAPTURED_IN_CLOSURE = new BasicWritableSlice<VariableDescriptor, CaptureKind>(DO_NOTHING);
WritableSlice<KtDeclaration, PreliminaryDeclarationVisitor> PRELIMINARY_VISITOR = new BasicWritableSlice<KtDeclaration, PreliminaryDeclarationVisitor>(DO_NOTHING);
WritableSlice<VariableDescriptor, CaptureKind> CAPTURED_IN_CLOSURE = new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<KtDeclaration, PreliminaryDeclarationVisitor> PRELIMINARY_VISITOR = new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<Box<DeferredType>, Boolean> DEFERRED_TYPE = Slices.createCollectiveSetSlice();
@@ -255,8 +253,7 @@ public interface BindingContext {
WritableSlice<ValueParameterDescriptor, FunctionDescriptor> DATA_CLASS_COMPONENT_FUNCTION = Slices.createSimpleSlice();
WritableSlice<ClassDescriptor, FunctionDescriptor> DATA_CLASS_COPY_FUNCTION = Slices.createSimpleSlice();
WritableSlice<FqNameUnsafe, ClassDescriptor> FQNAME_TO_CLASS_DESCRIPTOR =
new BasicWritableSlice<FqNameUnsafe, ClassDescriptor>(DO_NOTHING, true);
WritableSlice<FqNameUnsafe, ClassDescriptor> FQNAME_TO_CLASS_DESCRIPTOR = new BasicWritableSlice<>(DO_NOTHING, true);
WritableSlice<KtFile, PackageFragmentDescriptor> FILE_TO_PACKAGE_FRAGMENT = Slices.createSimpleSlice();
WritableSlice<FqName, Collection<KtFile>> PACKAGE_TO_FILES = Slices.createSimpleSlice();
@@ -218,7 +218,7 @@ public class BindingContextUtils {
.getSourceFromDescriptor(containingFunctionDescriptor) : null;
}
return new Pair<FunctionDescriptor, PsiElement>(containingFunctionDescriptor, containingFunction);
return new Pair<>(containingFunctionDescriptor, containingFunction);
}
@Nullable
@@ -447,7 +447,7 @@ public class BodyResolver {
currentDescriptor = (ClassDescriptor) currentDescriptor.getContainingDeclaration();
if (DescriptorUtils.isSealedClass(currentDescriptor)) {
if (parentEnumOrSealed.isEmpty()) {
parentEnumOrSealed = new HashSet<TypeConstructor>();
parentEnumOrSealed = new HashSet<>();
}
parentEnumOrSealed.add(currentDescriptor.getTypeConstructor());
}
@@ -891,7 +891,7 @@ public class BodyResolver {
return;
}
// +1 is a work around against new Queue(0).addLast(...) bug // stepan.koltsov@ 2011-11-21
Queue<DeferredType> queue = new Queue<DeferredType>(deferredTypes.size() + 1);
Queue<DeferredType> queue = new Queue<>(deferredTypes.size() + 1);
trace.addHandler(DEFERRED_TYPE, (deferredTypeKeyDeferredTypeWritableSlice, key, value) -> queue.addLast(key.getData()));
for (Box<DeferredType> deferredType : deferredTypes) {
queue.addLast(deferredType.getData());
@@ -425,7 +425,7 @@ public class DescriptorResolver {
containingDescriptor instanceof TypeAliasDescriptor
: "This method should be called for functions, properties, or type aliases, got " + containingDescriptor;
List<TypeParameterDescriptorImpl> result = new ArrayList<TypeParameterDescriptorImpl>();
List<TypeParameterDescriptorImpl> result = new ArrayList<>();
for (int i = 0, typeParametersSize = typeParameters.size(); i < typeParametersSize; i++) {
KtTypeParameter typeParameter = typeParameters.get(i);
result.add(resolveTypeParameterForDescriptor(containingDescriptor, scopeForAnnotationsResolve, typeParameter, i, trace));
@@ -558,8 +558,8 @@ public class DescriptorResolver {
public static void checkUpperBoundTypes(@NotNull BindingTrace trace, @NotNull List<UpperBoundCheckRequest> requests) {
if (requests.isEmpty()) return;
Set<Name> classBoundEncountered = new HashSet<Name>();
Set<Pair<Name, TypeConstructor>> allBounds = new HashSet<Pair<Name, TypeConstructor>>();
Set<Name> classBoundEncountered = new HashSet<>();
Set<Pair<Name, TypeConstructor>> allBounds = new HashSet<>();
for (UpperBoundCheckRequest request : requests) {
Name typeParameterName = request.typeParameterName;
@@ -567,7 +567,7 @@ public class DescriptorResolver {
KtTypeReference upperBoundElement = request.upperBound;
if (!upperBound.isError()) {
if (!allBounds.add(new Pair<Name, TypeConstructor>(typeParameterName, upperBound.getConstructor()))) {
if (!allBounds.add(new Pair<>(typeParameterName, upperBound.getConstructor()))) {
trace.report(REPEATED_BOUND.on(upperBoundElement));
}
else {
@@ -39,7 +39,7 @@ public class TopDownAnalysisContext implements BodiesResolveContext {
private final Map<KtClassOrObject, ClassDescriptorWithResolutionScopes> classes = Maps.newLinkedHashMap();
private final Map<KtAnonymousInitializer, ClassDescriptorWithResolutionScopes> anonymousInitializers = Maps.newLinkedHashMap();
private final Set<KtFile> files = new LinkedHashSet<KtFile>();
private final Set<KtFile> files = new LinkedHashSet<>();
private final Map<KtSecondaryConstructor, ClassConstructorDescriptor> secondaryConstructors = Maps.newLinkedHashMap();
private final Map<KtNamedFunction, SimpleFunctionDescriptor> functions = Maps.newLinkedHashMap();
@@ -317,8 +317,8 @@ public class ArgumentTypeResolver {
List<KtParameter> valueParameters = function.getValueParameters();
TemporaryBindingTrace temporaryTrace = TemporaryBindingTrace.create(
trace, "trace to resolve function literal parameter types");
List<KotlinType> parameterTypes = new ArrayList<KotlinType>(valueParameters.size());
List<Name> parameterNames = new ArrayList<Name>(valueParameters.size());
List<KotlinType> parameterTypes = new ArrayList<>(valueParameters.size());
List<Name> parameterNames = new ArrayList<>(valueParameters.size());
for (KtParameter parameter : valueParameters) {
parameterTypes.add(resolveTypeRefWithDefault(parameter.getTypeReference(), scope, temporaryTrace, DONT_CARE));
Name name = parameter.getNameAsName();
@@ -295,7 +295,7 @@ public class CallResolver {
KotlinType expectedType = NO_EXPECTED_TYPE;
if (calleeExpression instanceof KtLambdaExpression) {
int parameterNumber = ((KtLambdaExpression) calleeExpression).getValueParameters().size();
List<KotlinType> parameterTypes = new ArrayList<KotlinType>(parameterNumber);
List<KotlinType> parameterTypes = new ArrayList<>(parameterNumber);
for (int i = 0; i < parameterNumber; i++) {
parameterTypes.add(NO_EXPECTED_TYPE);
}
@@ -452,8 +452,7 @@ public class CallResolver {
@NotNull BasicCallResolutionContext context
) {
if (!(superType.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor)) {
return new Pair<Collection<ResolutionCandidate<ConstructorDescriptor>>, BasicCallResolutionContext>(
Collections.<ResolutionCandidate<ConstructorDescriptor>>emptyList(), context);
return new Pair<>(Collections.<ResolutionCandidate<ConstructorDescriptor>>emptyList(), context);
}
// If any constructor has type parameter (currently it only can be true for ones from Java), try to infer arguments for them
@@ -470,7 +469,7 @@ public class CallResolver {
context.scope, context.call, superType, !anyConstructorHasDeclaredTypeParameters
);
return new Pair<Collection<ResolutionCandidate<ConstructorDescriptor>>, BasicCallResolutionContext>(candidates, context);
return new Pair<>(candidates, context);
}
private static boolean anyConstructorHasDeclaredTypeParameters(@Nullable ClassifierDescriptor classDescriptor) {
@@ -495,10 +494,9 @@ public class CallResolver {
Set<ResolutionCandidate<FunctionDescriptor>> candidates = Collections.singleton(candidate);
ResolutionTask<FunctionDescriptor> resolutionTask =
new ResolutionTask<FunctionDescriptor>(
new NewResolutionOldInference.ResolutionKind.GivenCandidates<FunctionDescriptor>(), null, candidates
);
ResolutionTask<FunctionDescriptor> resolutionTask = new ResolutionTask<>(
new NewResolutionOldInference.ResolutionKind.GivenCandidates<>(), null, candidates
);
return doResolveCallOrGetCachedResults(basicCallResolutionContext, resolutionTask, tracing);
});
@@ -73,7 +73,7 @@ public class ValueArgumentsToParametersMapper {
@NotNull MutableResolvedCall<D> candidateCall
) {
//return new ValueArgumentsToParametersMapper().process(call, tracing, candidateCall, unmappedArguments);
Processor<D> processor = new Processor<D>(call, candidateCall, tracing);
Processor<D> processor = new Processor<>(call, candidateCall, tracing);
processor.process();
return processor.status;
}
@@ -49,7 +49,7 @@ import static org.jetbrains.kotlin.resolve.inline.InlineUtil.checkNonLocalReturn
class InlineChecker implements CallChecker {
private final FunctionDescriptor descriptor;
private final Set<CallableDescriptor> inlinableParameters = new LinkedHashSet<CallableDescriptor>();
private final Set<CallableDescriptor> inlinableParameters = new LinkedHashSet<>();
private final EffectiveVisibility inlineFunEffectiveVisibility;
private final boolean isEffectivelyPrivateApiFunction;
@@ -72,7 +72,7 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
@NotNull TracingStrategy tracing, @NotNull Call call,
@NotNull CandidateResolveMode candidateResolveMode
) {
return new CallCandidateResolutionContext<D>(
return new CallCandidateResolutionContext<>(
candidateCall, tracing, trace, context.scope, call, context.expectedType,
context.dataFlowInfo, context.contextDependency, context.checkArguments,
context.resolutionResultsCache, context.dataFlowInfoForArguments,
@@ -85,7 +85,7 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
public static <D extends CallableDescriptor> CallCandidateResolutionContext<D> createForCallBeingAnalyzed(
@NotNull MutableResolvedCall<D> candidateCall, @NotNull BasicCallResolutionContext context, @NotNull TracingStrategy tracing
) {
return new CallCandidateResolutionContext<D>(
return new CallCandidateResolutionContext<>(
candidateCall, tracing, context.trace, context.scope, context.call, context.expectedType,
context.dataFlowInfo, context.contextDependency, context.checkArguments, context.resolutionResultsCache,
context.dataFlowInfoForArguments, context.statementFilter,
@@ -106,7 +106,7 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
@NotNull CallPosition callPosition,
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider
) {
return new CallCandidateResolutionContext<D>(
return new CallCandidateResolutionContext<>(
candidateCall, tracing, trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments,
resolutionResultsCache, dataFlowInfoForArguments, statementFilter,
candidateResolveMode, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition, expressionContextProvider);
@@ -66,7 +66,7 @@ public class ConstraintsUtil {
context.put(typeVariable.getOriginalTypeParameter().getTypeConstructor(), typeProjection);
}
}
Collection<TypeSubstitutor> typeSubstitutors = new ArrayList<TypeSubstitutor>(substitutionContexts.size());
Collection<TypeSubstitutor> typeSubstitutors = new ArrayList<>(substitutionContexts.size());
for (Map<TypeConstructor, TypeProjection> context : substitutionContexts) {
typeSubstitutors.add(TypeSubstitutor.create(context));
}
@@ -44,7 +44,7 @@ public class DataFlowInfoForArgumentsImpl extends MutableDataFlowInfoForArgument
ValueArgument argument = iterator.next();
if (prev != null) {
if (nextArgument == null) {
nextArgument = new HashMap<ValueArgument, ValueArgument>();
nextArgument = new HashMap<>();
}
nextArgument.put(prev, argument);
}
@@ -67,7 +67,7 @@ public class DataFlowInfoForArgumentsImpl extends MutableDataFlowInfoForArgument
ValueArgument next = nextArgument == null ? null : nextArgument.get(valueArgument);
if (next != null) {
if (infoMap == null) {
infoMap = new HashMap<ValueArgument, DataFlowInfo>();
infoMap = new HashMap<>();
}
infoMap.put(next, dataFlowInfo);
return;
@@ -53,7 +53,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
@NotNull TracingStrategy tracing,
@NotNull MutableDataFlowInfoForArguments dataFlowInfoForArguments
) {
return new ResolvedCallImpl<D>(candidate, trace, tracing, dataFlowInfoForArguments);
return new ResolvedCallImpl<>(candidate, trace, tracing, dataFlowInfoForArguments);
}
private final Call call;
@@ -212,7 +212,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
List<ValueParameterDescriptor> substitutedParameters = resultingDescriptor.getValueParameters();
Collection<Map.Entry<ValueParameterDescriptor, ResolvedValueArgument>> valueArgumentsBeforeSubstitution =
new SmartList<Map.Entry<ValueParameterDescriptor, ResolvedValueArgument>>(valueArguments.entrySet());
new SmartList<>(valueArguments.entrySet());
valueArguments.clear();
@@ -223,7 +223,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
}
Collection<Map.Entry<ValueArgument, ArgumentMatchImpl>> unsubstitutedArgumentMappings =
new SmartList<Map.Entry<ValueArgument, ArgumentMatchImpl>>(argumentToParameterMap.entrySet());
new SmartList<>(argumentToParameterMap.entrySet());
argumentToParameterMap.clear();
for (Map.Entry<ValueArgument, ArgumentMatchImpl> entry : unsubstitutedArgumentMappings) {
@@ -283,7 +283,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
@Nullable
@Override
public List<ResolvedValueArgument> getValueArgumentsByIndex() {
List<ResolvedValueArgument> arguments = new ArrayList<ResolvedValueArgument>(candidateDescriptor.getValueParameters().size());
List<ResolvedValueArgument> arguments = new ArrayList<>(candidateDescriptor.getValueParameters().size());
for (int i = 0; i < candidateDescriptor.getValueParameters().size(); ++i) {
arguments.add(null);
}
@@ -29,33 +29,33 @@ import java.util.Collections;
public class OverloadResolutionResultsImpl<D extends CallableDescriptor> implements OverloadResolutionResults<D> {
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> success(@NotNull MutableResolvedCall<D> candidate) {
return new OverloadResolutionResultsImpl<D>(Code.SUCCESS, Collections.singleton(candidate));
return new OverloadResolutionResultsImpl<>(Code.SUCCESS, Collections.singleton(candidate));
}
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> nameNotFound() {
OverloadResolutionResultsImpl<D> results = new OverloadResolutionResultsImpl<D>(
OverloadResolutionResultsImpl<D> results = new OverloadResolutionResultsImpl<>(
Code.NAME_NOT_FOUND, Collections.<MutableResolvedCall<D>>emptyList());
results.setAllCandidates(Collections.<ResolvedCall<D>>emptyList());
return results;
}
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> singleFailedCandidate(MutableResolvedCall<D> candidate) {
return new OverloadResolutionResultsImpl<D>(Code.SINGLE_CANDIDATE_ARGUMENT_MISMATCH, Collections.singleton(candidate));
return new OverloadResolutionResultsImpl<>(Code.SINGLE_CANDIDATE_ARGUMENT_MISMATCH, Collections.singleton(candidate));
}
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> manyFailedCandidates(Collection<MutableResolvedCall<D>> failedCandidates) {
return new OverloadResolutionResultsImpl<D>(Code.MANY_FAILED_CANDIDATES, failedCandidates);
return new OverloadResolutionResultsImpl<>(Code.MANY_FAILED_CANDIDATES, failedCandidates);
}
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> candidatesWithWrongReceiver(Collection<MutableResolvedCall<D>> failedCandidates) {
return new OverloadResolutionResultsImpl<D>(Code.CANDIDATES_WITH_WRONG_RECEIVER, failedCandidates);
return new OverloadResolutionResultsImpl<>(Code.CANDIDATES_WITH_WRONG_RECEIVER, failedCandidates);
}
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> ambiguity(Collection<MutableResolvedCall<D>> candidates) {
return new OverloadResolutionResultsImpl<D>(Code.AMBIGUITY, candidates);
return new OverloadResolutionResultsImpl<>(Code.AMBIGUITY, candidates);
}
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> incompleteTypeInference(Collection<MutableResolvedCall<D>> candidates) {
return new OverloadResolutionResultsImpl<D>(Code.INCOMPLETE_TYPE_INFERENCE, candidates);
return new OverloadResolutionResultsImpl<>(Code.INCOMPLETE_TYPE_INFERENCE, candidates);
}
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> incompleteTypeInference(MutableResolvedCall<D> candidate) {
@@ -148,7 +148,7 @@ public class OverloadResolutionResultsImpl<D extends CallableDescriptor> impleme
assert isSingleResult() && getResultCode() == Code.INCOMPLETE_TYPE_INFERENCE :
"Only incomplete type inference status with one candidate can be changed to success: " +
getResultCode() + "\n" + getResultingCalls();
OverloadResolutionResultsImpl<D> newResults = new OverloadResolutionResultsImpl<D>(Code.SUCCESS, getResultingCalls());
OverloadResolutionResultsImpl<D> newResults = new OverloadResolutionResultsImpl<>(Code.SUCCESS, getResultingCalls());
newResults.setAllCandidates(getAllCandidates());
return newResults;
}
@@ -154,7 +154,7 @@ public class ResolutionResultsHandler {
if (severityLevel.contains(ARGUMENTS_MAPPING_ERROR)) {
@SuppressWarnings("unchecked")
OverloadingConflictResolver<MutableResolvedCall<D>> myResolver = (OverloadingConflictResolver) overloadingConflictResolver;
return recordFailedInfo(tracing, trace, myResolver.filterOutEquivalentCalls(new LinkedHashSet<MutableResolvedCall<D>>(thisLevel)));
return recordFailedInfo(tracing, trace, myResolver.filterOutEquivalentCalls(new LinkedHashSet<>(thisLevel)));
}
OverloadResolutionResultsImpl<D> results = chooseAndReportMaximallySpecific(
thisLevel, false, false, checkArgumentsMode, languageVersionSettings);
@@ -200,7 +200,7 @@ public class ResolutionResultsHandler {
Set<MutableResolvedCall<D>> refinedCandidates = candidates;
if (!languageVersionSettings.supportsFeature(LanguageFeature.RefinedSamAdaptersPriority)) {
Set<MutableResolvedCall<D>> nonSynthesized = new HashSet<MutableResolvedCall<D>>();
Set<MutableResolvedCall<D>> nonSynthesized = new HashSet<>();
for (MutableResolvedCall<D> candidate : candidates) {
if (!TowerUtilsKt.isSynthesized(candidate.getCandidateDescriptor())) {
nonSynthesized.add(candidate);
@@ -45,15 +45,14 @@ public class ResolutionCandidate<D extends CallableDescriptor> {
public static <D extends CallableDescriptor> ResolutionCandidate<D> create(
@NotNull Call call, @NotNull D descriptor
) {
return new ResolutionCandidate<D>(call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null);
return new ResolutionCandidate<>(call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null);
}
public static <D extends CallableDescriptor> ResolutionCandidate<D> create(
@NotNull Call call, @NotNull D descriptor, @Nullable TypeSubstitutor knownTypeParametersResultingSubstitutor
) {
return new ResolutionCandidate<D>(call, descriptor,
null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER,
knownTypeParametersResultingSubstitutor);
return new ResolutionCandidate<>(call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER,
knownTypeParametersResultingSubstitutor);
}
public static <D extends CallableDescriptor> ResolutionCandidate<D> create(
@@ -61,8 +60,7 @@ public class ResolutionCandidate<D extends CallableDescriptor> {
@NotNull ExplicitReceiverKind explicitReceiverKind,
@Nullable TypeSubstitutor knownTypeParametersResultingSubstitutor
) {
return new ResolutionCandidate<D>(call, descriptor, dispatchReceiver, explicitReceiverKind,
knownTypeParametersResultingSubstitutor);
return new ResolutionCandidate<>(call, descriptor, dispatchReceiver, explicitReceiverKind, knownTypeParametersResultingSubstitutor);
}
public void setDispatchReceiver(@Nullable ReceiverValue dispatchReceiver) {
@@ -206,7 +206,7 @@ public class CallMaker {
arguments = Collections.emptyList();
}
else {
arguments = new ArrayList<ValueArgument>(argumentExpressions.size());
arguments = new ArrayList<>(argumentExpressions.size());
for (KtExpression argumentExpression : argumentExpressions) {
arguments.add(makeValueArgument(argumentExpression, calleeExpression));
}
@@ -49,7 +49,7 @@ public class DiagnosticsElementsCache {
}
private static MultiMap<PsiElement, Diagnostic> buildElementToDiagnosticCache(Diagnostics diagnostics, Function1<Diagnostic, Boolean> filter) {
MultiMap<PsiElement, Diagnostic> elementToDiagnostic = new ConcurrentMultiMap<PsiElement, Diagnostic>();
MultiMap<PsiElement, Diagnostic> elementToDiagnostic = new ConcurrentMultiMap<>();
for (Diagnostic diagnostic : diagnostics) {
if (filter.invoke(diagnostic)) {
elementToDiagnostic.putValue(diagnostic.getPsiElement(), diagnostic);
@@ -48,8 +48,7 @@ public class DiagnosticsWithSuppression implements Diagnostics {
@NotNull
@Override
public Iterator<Diagnostic> iterator() {
return new FilteringIterator<Diagnostic, Diagnostic>(diagnostics.iterator(),
diagnostic -> kotlinSuppressCache.getFilter().invoke(diagnostic));
return new FilteringIterator<>(diagnostics.iterator(), kotlinSuppressCache.getFilter()::invoke);
}
@NotNull
@@ -248,7 +248,7 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
PackageMemberDeclarationProvider provider = declarationProviderFactory.getPackageMemberDeclarationProvider(fqName.parent());
if (provider == null) return Collections.emptyList();
Collection<ClassifierDescriptor> result = new SmartList<ClassifierDescriptor>();
Collection<ClassifierDescriptor> result = new SmartList<>();
result.addAll(ContainerUtil.mapNotNull(
provider.getClassOrObjectDeclarations(fqName.shortName()),
@@ -54,7 +54,7 @@ public class ResolveSessionUtils {
) {
if (fqName.isRoot()) return Collections.emptyList();
Collection<ClassDescriptor> result = new ArrayList<ClassDescriptor>(1);
Collection<ClassDescriptor> result = new ArrayList<>(1);
FqName packageFqName = fqName.parent();
while (true) {
@@ -166,7 +166,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
this.isImpl = modifierList != null && modifierList.hasModifier(KtTokens.IMPL_KEYWORD);
// Annotation entries are taken from both own annotations (if any) and object literal annotations (if any)
List<KtAnnotationEntry> annotationEntries = new ArrayList<KtAnnotationEntry>();
List<KtAnnotationEntry> annotationEntries = new ArrayList<>();
if (classOrObject != null && classOrObject.getParent() instanceof KtObjectLiteralExpression) {
// TODO: it would be better to have separate ObjectLiteralDescriptor without so much magic
annotationEntries.addAll(KtPsiUtilKt.getAnnotationEntries((KtObjectLiteralExpression) classOrObject.getParent()));
@@ -241,7 +241,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
List<KtTypeParameter> typeParameters = typeParameterList.getParameters();
if (typeParameters.isEmpty()) return Collections.emptyList();
List<TypeParameterDescriptor> parameters = new ArrayList<TypeParameterDescriptor>(typeParameters.size());
List<TypeParameterDescriptor> parameters = new ArrayList<>(typeParameters.size());
for (int i = 0; i < typeParameters.size(); i++) {
parameters.add(new LazyTypeParameterDescriptor(c, this, typeParameters.get(i), i));
@@ -73,7 +73,7 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
@NotNull
@Override
protected List<KotlinType> resolveUpperBounds() {
List<KotlinType> upperBounds = new ArrayList<KotlinType>(1);
List<KotlinType> upperBounds = new ArrayList<>(1);
for (KtTypeReference typeReference : getAllUpperBounds()) {
KotlinType resolvedType = resolveBoundType(typeReference);
@@ -99,7 +99,7 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
}
private Collection<KtTypeReference> getUpperBoundsFromWhereClause() {
Collection<KtTypeReference> result = new ArrayList<KtTypeReference>();
Collection<KtTypeReference> result = new ArrayList<>();
KtClassOrObject classOrObject = KtStubbedPsiUtil.getPsiOrStubParent(typeParameter, KtClassOrObject.class, true);
if (classOrObject instanceof KtClass) {
@@ -52,7 +52,7 @@ public class BoundsSubstitutor {
@NotNull
private static TypeSubstitutor createUpperBoundsSubstitutor(@NotNull List<TypeParameterDescriptor> typeParameters) {
Map<TypeConstructor, TypeProjection> mutableSubstitution = new HashMap<TypeConstructor, TypeProjection>();
Map<TypeConstructor, TypeProjection> mutableSubstitution = new HashMap<>();
TypeSubstitutor substitutor = TypeSubstitutor.create(mutableSubstitution);
// todo assert: no loops

Some files were not shown because too many files have changed in this diff Show More