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