Merge branch 'master' into idea13
This commit is contained in:
+2
-1
@@ -9,4 +9,5 @@ out
|
||||
pluginPublisher/idea*
|
||||
pluginPublisher/plugin-verifier.jar
|
||||
tmp
|
||||
workspace.xml
|
||||
workspace.xml
|
||||
*.versionsBackup
|
||||
|
||||
Generated
+9
@@ -0,0 +1,9 @@
|
||||
<component name="libraryTable">
|
||||
<library name="java-i18n">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/java-i18n/lib/java-i18n.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
||||
Generated
+10
@@ -0,0 +1,10 @@
|
||||
<component name="libraryTable">
|
||||
<library name="properties">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/properties/lib/properties.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/properties/lib/resources_en.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
||||
Generated
+12
@@ -0,0 +1,12 @@
|
||||
<component name="libraryTable">
|
||||
<library name="testng-plugin">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/testng/lib/testng-plugin.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/testng/lib/testng.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.zip!/plugins/testng/src" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@@ -354,6 +354,8 @@
|
||||
|
||||
-dontwarn com.intellij.util.ui.IsRetina*
|
||||
-dontwarn com.intellij.util.RetinaImage*
|
||||
-dontwarn apple.awt.*
|
||||
-dontwarn dk.brics.automaton.*
|
||||
-dontwarn org.fusesource.**
|
||||
|
||||
-libraryjars '${rtjar}'
|
||||
@@ -573,4 +575,4 @@
|
||||
</zip>
|
||||
<echo message="##teamcity[publishArtifacts '${output.relative}/${output.name}.zip']"/>
|
||||
</target>
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.codegen.context.ClassContext;
|
||||
@@ -54,6 +55,9 @@ public class MemberCodegen extends GenerationStateAware {
|
||||
try {
|
||||
functionCodegen.gen((JetNamedFunction) functionOrProperty);
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (CompilationException e) {
|
||||
throw e;
|
||||
}
|
||||
@@ -65,6 +69,9 @@ public class MemberCodegen extends GenerationStateAware {
|
||||
try {
|
||||
new PropertyCodegen(context, classBuilder, functionCodegen, this).gen((JetProperty) functionOrProperty);
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (CompilationException e) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
@NotNull
|
||||
public Type mapType(@NotNull JetType jetType, @Nullable BothSignatureWriter signatureVisitor, @NotNull JetTypeMapperMode kind) {
|
||||
return mapType(jetType, signatureVisitor, kind, Variance.INVARIANT);
|
||||
return mapType(jetType, signatureVisitor, kind, Variance.INVARIANT, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -227,7 +227,17 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
@NotNull JetType jetType,
|
||||
@Nullable BothSignatureWriter signatureVisitor,
|
||||
@NotNull JetTypeMapperMode kind,
|
||||
@NotNull Variance howThisTypeIsUsed
|
||||
@NotNull Variance howThisTypeIsUsed) {
|
||||
return mapType(jetType, signatureVisitor, kind, howThisTypeIsUsed, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type mapType(
|
||||
@NotNull JetType jetType,
|
||||
@Nullable BothSignatureWriter signatureVisitor,
|
||||
@NotNull JetTypeMapperMode kind,
|
||||
@NotNull Variance howThisTypeIsUsed,
|
||||
boolean arrayParameter
|
||||
) {
|
||||
Type known = null;
|
||||
DeclarationDescriptor descriptor = jetType.getConstructor().getDeclarationDescriptor();
|
||||
@@ -243,7 +253,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
return mapKnownAsmType(jetType, known, signatureVisitor, howThisTypeIsUsed);
|
||||
}
|
||||
else if (kind == JetTypeMapperMode.TYPE_PARAMETER) {
|
||||
return mapKnownAsmType(jetType, boxType(known), signatureVisitor, howThisTypeIsUsed);
|
||||
return mapKnownAsmType(jetType, boxType(known), signatureVisitor, howThisTypeIsUsed, arrayParameter);
|
||||
}
|
||||
else if (kind == JetTypeMapperMode.TRAIT_IMPL) {
|
||||
throw new IllegalStateException("TRAIT_IMPL is not possible for " + jetType);
|
||||
@@ -291,7 +301,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
if (signatureVisitor != null) {
|
||||
signatureVisitor.writeArrayType(jetType.isNullable(), memberProjection.getProjectionKind());
|
||||
mapType(memberType, signatureVisitor, JetTypeMapperMode.TYPE_PARAMETER);
|
||||
mapType(memberType, signatureVisitor, JetTypeMapperMode.TYPE_PARAMETER, memberProjection.getProjectionKind(), true);
|
||||
signatureVisitor.writeArrayEnd();
|
||||
}
|
||||
|
||||
@@ -408,10 +418,24 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
Type asmType,
|
||||
@Nullable BothSignatureWriter signatureVisitor,
|
||||
@NotNull Variance howThisTypeIsUsed
|
||||
) {
|
||||
return mapKnownAsmType(jetType, asmType, signatureVisitor, howThisTypeIsUsed, false);
|
||||
}
|
||||
|
||||
private Type mapKnownAsmType(
|
||||
JetType jetType,
|
||||
Type asmType,
|
||||
@Nullable BothSignatureWriter signatureVisitor,
|
||||
@NotNull Variance howThisTypeIsUsed,
|
||||
boolean arrayParameter
|
||||
) {
|
||||
if (signatureVisitor != null) {
|
||||
if (jetType.getArguments().isEmpty()) {
|
||||
String kotlinTypeName = getKotlinTypeNameForSignature(jetType, asmType);
|
||||
if (arrayParameter
|
||||
&& (howThisTypeIsUsed == Variance.IN_VARIANCE)) {
|
||||
asmType = AsmTypeConstants.OBJECT_TYPE;
|
||||
}
|
||||
String kotlinTypeName = getKotlinTypeNameForSignature(jetType, asmType, arrayParameter);
|
||||
signatureVisitor.writeAsmType(asmType, jetType.isNullable(), kotlinTypeName);
|
||||
}
|
||||
else {
|
||||
@@ -424,12 +448,18 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
@Nullable
|
||||
private static String getKotlinTypeNameForSignature(@NotNull JetType jetType, @NotNull Type asmType) {
|
||||
return getKotlinTypeNameForSignature(jetType, asmType, false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getKotlinTypeNameForSignature(@NotNull JetType jetType, @NotNull Type asmType, boolean arrayParameter) {
|
||||
ClassifierDescriptor descriptor = jetType.getConstructor().getDeclarationDescriptor();
|
||||
if (descriptor == null) return null;
|
||||
if (asmType.getSort() != Type.OBJECT) return null;
|
||||
|
||||
JvmClassName jvmClassName = JvmClassName.byType(asmType);
|
||||
if (JavaToKotlinClassMap.getInstance().mapPlatformClass(jvmClassName.getFqName()).size() > 1) {
|
||||
if ((arrayParameter && JavaToKotlinClassMap.getInstance().mapPlatformClass(jvmClassName.getFqName()).size() >= 1)
|
||||
|| ((!arrayParameter) && JavaToKotlinClassMap.getInstance().mapPlatformClass(jvmClassName.getFqName()).size() > 1)) {
|
||||
return JvmClassName.byClassDescriptor(descriptor).getSignatureName();
|
||||
}
|
||||
return null;
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
org.jetbrains.jet.lang.resolve.java.sam.SamAdapterOverridabilityCondition
|
||||
+17
-12
@@ -38,6 +38,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.java.TypeUsage.*;
|
||||
import static org.jetbrains.jet.lang.types.Variance.*;
|
||||
|
||||
public class JavaTypeTransformer {
|
||||
|
||||
@@ -73,7 +74,7 @@ public class JavaTypeTransformer {
|
||||
if (!wildcardType.isBounded()) {
|
||||
return SubstitutionUtils.makeStarProjection(typeParameterDescriptor);
|
||||
}
|
||||
Variance variance = wildcardType.isExtends() ? Variance.OUT_VARIANCE : Variance.IN_VARIANCE;
|
||||
Variance variance = wildcardType.isExtends() ? OUT_VARIANCE : IN_VARIANCE;
|
||||
|
||||
PsiType bound = wildcardType.getBound();
|
||||
assert bound != null;
|
||||
@@ -165,14 +166,18 @@ public class JavaTypeTransformer {
|
||||
List<TypeParameterDescriptor> parameters = classData.getTypeConstructor().getParameters();
|
||||
if (isRaw(classType, !parameters.isEmpty())) {
|
||||
for (TypeParameterDescriptor parameter : parameters) {
|
||||
TypeProjection starProjection = SubstitutionUtils.makeStarProjection(parameter);
|
||||
if (howThisTypeIsUsed == SUPERTYPE) {
|
||||
// projections are not allowed in immediate arguments of supertypes
|
||||
arguments.add(new TypeProjection(starProjection.getType()));
|
||||
}
|
||||
else {
|
||||
arguments.add(starProjection);
|
||||
}
|
||||
// not making a star projection because of this case:
|
||||
// Java:
|
||||
// class C<T extends C> {}
|
||||
// The upper bound is raw here, and we can't compute the projection: it would be infinite:
|
||||
// C<*> = C<out C<out C<...>>>
|
||||
// this way we loose some type information, even when the case is not so bad, but it doesn't seem to matter
|
||||
|
||||
// projections are not allowed in immediate arguments of supertypes
|
||||
Variance projectionKind = parameter.getVariance() == OUT_VARIANCE || howThisTypeIsUsed == SUPERTYPE
|
||||
? INVARIANT
|
||||
: OUT_VARIANCE;
|
||||
arguments.add(new TypeProjection(projectionKind, KotlinBuiltIns.getInstance().getNullableAnyType()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -198,7 +203,7 @@ public class JavaTypeTransformer {
|
||||
|
||||
if (typeProjection.getProjectionKind() == typeParameterDescriptor.getVariance()) {
|
||||
// remove redundant 'out' and 'in'
|
||||
arguments.add(new TypeProjection(Variance.INVARIANT, typeProjection.getType()));
|
||||
arguments.add(new TypeProjection(INVARIANT, typeProjection.getType()));
|
||||
}
|
||||
else {
|
||||
arguments.add(typeProjection);
|
||||
@@ -245,10 +250,10 @@ public class JavaTypeTransformer {
|
||||
private Variance arrayElementTypeProjectionKind(boolean vararg) {
|
||||
Variance variance;
|
||||
if (howThisTypeIsUsed == MEMBER_SIGNATURE_CONTRAVARIANT && !vararg) {
|
||||
variance = Variance.OUT_VARIANCE;
|
||||
variance = OUT_VARIANCE;
|
||||
}
|
||||
else {
|
||||
variance = Variance.INVARIANT;
|
||||
variance = INVARIANT;
|
||||
}
|
||||
return variance;
|
||||
}
|
||||
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
package org.jetbrains.jet.lang.resolve.java.sam;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.resolve.ExternalOverridabilityCondition;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SamAdapterOverridabilityCondition implements ExternalOverridabilityCondition {
|
||||
@Override
|
||||
public boolean isOverridable(@NotNull CallableDescriptor superDescriptor, @NotNull CallableDescriptor subDescriptor) {
|
||||
if (subDescriptor instanceof PropertyDescriptor) {
|
||||
return true;
|
||||
}
|
||||
|
||||
SimpleFunctionDescriptor superOriginal = getOriginalOfSamAdapterFunction((SimpleFunctionDescriptor) superDescriptor);
|
||||
SimpleFunctionDescriptor subOriginal = getOriginalOfSamAdapterFunction((SimpleFunctionDescriptor) subDescriptor);
|
||||
if (superOriginal == null || subOriginal == null) { // super or sub is/overrides DECLARATION
|
||||
return subOriginal == null; // DECLARATION can override anything
|
||||
}
|
||||
|
||||
// inheritor if SYNTHESIZED can override inheritor of SYNTHESIZED if their originals have same erasure
|
||||
return equalErasure(superOriginal, subOriginal);
|
||||
}
|
||||
|
||||
private static boolean equalErasure(@NotNull FunctionDescriptor fun1, @NotNull FunctionDescriptor fun2) {
|
||||
List<ValueParameterDescriptor> parameters1 = fun1.getValueParameters();
|
||||
List<ValueParameterDescriptor> parameters2 = fun2.getValueParameters();
|
||||
|
||||
for (ValueParameterDescriptor param1 : parameters1) {
|
||||
ValueParameterDescriptor param2 = parameters2.get(param1.getIndex());
|
||||
if (!TypeUtils.equalClasses(param2.getType(), param1.getType())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// if function is or overrides declaration, returns null; otherwise, return original of sam adapter with substituted type parameters
|
||||
@Nullable
|
||||
private static SimpleFunctionDescriptor getOriginalOfSamAdapterFunction(@NotNull SimpleFunctionDescriptor callable) {
|
||||
DeclarationDescriptor containingDeclaration = callable.getContainingDeclaration();
|
||||
if (!(containingDeclaration instanceof ClassDescriptor)) {
|
||||
return null;
|
||||
}
|
||||
Pair<SimpleFunctionDescriptor, JetType> declarationOrSynthesized =
|
||||
getNearestDeclarationOrSynthesized(callable, ((ClassDescriptor) containingDeclaration).getDefaultType());
|
||||
|
||||
if (declarationOrSynthesized == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
SimpleFunctionDescriptor fun = declarationOrSynthesized.first;
|
||||
if (fun.getKind() != CallableMemberDescriptor.Kind.SYNTHESIZED) {
|
||||
return null;
|
||||
}
|
||||
|
||||
SimpleFunctionDescriptor originalOfSynthesized = ((SimpleFunctionDescriptorImpl) fun.getOriginal())
|
||||
.getOriginalOfSynthesized();
|
||||
if (originalOfSynthesized == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ((SimpleFunctionDescriptor) originalOfSynthesized.substitute(TypeSubstitutor.create(declarationOrSynthesized.second)));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Pair<SimpleFunctionDescriptor, JetType> getNearestDeclarationOrSynthesized(
|
||||
@NotNull SimpleFunctionDescriptor samAdapter,
|
||||
@NotNull JetType ownerType
|
||||
) {
|
||||
if (samAdapter.getKind() != CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
|
||||
return Pair.create(samAdapter, ownerType);
|
||||
}
|
||||
for (CallableMemberDescriptor overridden : samAdapter.getOverriddenDescriptors()) {
|
||||
ClassDescriptor containingClass = (ClassDescriptor) overridden.getContainingDeclaration();
|
||||
|
||||
for (JetType immediateSupertype : TypeUtils.getImmediateSupertypes(ownerType)) {
|
||||
if (containingClass != immediateSupertype.getConstructor().getDeclarationDescriptor()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Pair<SimpleFunctionDescriptor, JetType> found =
|
||||
getNearestDeclarationOrSynthesized((SimpleFunctionDescriptor) overridden, immediateSupertype);
|
||||
if (found != null) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+4
-5
@@ -45,9 +45,7 @@ public class SingleAbstractMethodUtils {
|
||||
public static List<CallableMemberDescriptor> getAbstractMembers(@NotNull JetType type) {
|
||||
List<CallableMemberDescriptor> abstractMembers = Lists.newArrayList();
|
||||
for (DeclarationDescriptor member : type.getMemberScope().getAllDescriptors()) {
|
||||
if (member instanceof CallableMemberDescriptor &&
|
||||
((CallableMemberDescriptor) member).getModality() == Modality.ABSTRACT &&
|
||||
!CallResolverUtil.isOrOverridesSynthesized((CallableMemberDescriptor) member)) {
|
||||
if (member instanceof CallableMemberDescriptor && ((CallableMemberDescriptor) member).getModality() == Modality.ABSTRACT) {
|
||||
abstractMembers.add((CallableMemberDescriptor) member);
|
||||
}
|
||||
}
|
||||
@@ -190,7 +188,8 @@ public class SingleAbstractMethodUtils {
|
||||
original.getContainingDeclaration(),
|
||||
original.getAnnotations(),
|
||||
original.getName(),
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
original
|
||||
);
|
||||
FunctionInitializer initializer = new FunctionInitializer() {
|
||||
@Override
|
||||
@@ -205,7 +204,7 @@ public class SingleAbstractMethodUtils {
|
||||
typeParameters,
|
||||
valueParameters,
|
||||
returnType,
|
||||
original.getModality(),
|
||||
Modality.FINAL,
|
||||
original.getVisibility(),
|
||||
false
|
||||
);
|
||||
|
||||
+25
-1
@@ -30,12 +30,29 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
||||
|
||||
private boolean isInline = false;
|
||||
|
||||
private final SimpleFunctionDescriptor originalOfSynthesized; // TODO replace with user data
|
||||
|
||||
public SimpleFunctionDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull Name name,
|
||||
@NotNull Kind kind) {
|
||||
@NotNull Kind kind
|
||||
) {
|
||||
this(containingDeclaration, annotations, name, kind, null);
|
||||
}
|
||||
|
||||
public SimpleFunctionDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull Name name,
|
||||
@NotNull Kind kind,
|
||||
@Nullable SimpleFunctionDescriptor originalOfSynthesized
|
||||
) {
|
||||
super(containingDeclaration, annotations, name, kind);
|
||||
this.originalOfSynthesized = originalOfSynthesized;
|
||||
if (originalOfSynthesized != null) {
|
||||
assert kind == Kind.SYNTHESIZED;
|
||||
}
|
||||
}
|
||||
|
||||
private SimpleFunctionDescriptorImpl(
|
||||
@@ -45,6 +62,7 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
||||
@NotNull Name name,
|
||||
@NotNull Kind kind) {
|
||||
super(containingDeclaration, original, annotations, name, kind);
|
||||
originalOfSynthesized = null;
|
||||
}
|
||||
|
||||
public SimpleFunctionDescriptorImpl initialize(
|
||||
@@ -100,4 +118,10 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
||||
public boolean isInline() {
|
||||
return isInline;
|
||||
}
|
||||
|
||||
// TODO replace with user data
|
||||
@Nullable
|
||||
public SimpleFunctionDescriptor getOriginalOfSynthesized() {
|
||||
return originalOfSynthesized;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,14 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
}
|
||||
}
|
||||
|
||||
public static final TokenSet ALLOW_NEWLINE_OPERATIONS = TokenSet.create(DOT, SAFE_ACCESS);
|
||||
public static final TokenSet ALLOW_NEWLINE_OPERATIONS = TokenSet.create(
|
||||
DOT, SAFE_ACCESS,
|
||||
COLON, AS_KEYWORD, AS_SAFE,
|
||||
ELVIS,
|
||||
// Can't allow `is` and `!is` because of when entry conditions: IS_KEYWORD, NOT_IS,
|
||||
ANDAND,
|
||||
OROR
|
||||
);
|
||||
|
||||
public static final TokenSet ALL_OPERATIONS;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.psi;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
@@ -62,6 +63,11 @@ public class JetModifierList extends JetElementImpl {
|
||||
return getModifierNode(token) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiElement getModifier(JetToken token) {
|
||||
return findChildByType(token);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ASTNode getModifierNode(JetToken token) {
|
||||
ASTNode node = getNode().getFirstChildNode();
|
||||
@@ -71,4 +77,6 @@ public class JetModifierList extends JetElementImpl {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package org.jetbrains.jet.lang.resolve;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
|
||||
public interface ExternalOverridabilityCondition {
|
||||
boolean isOverridable(@NotNull CallableDescriptor superDescriptor, @NotNull CallableDescriptor subDescriptor);
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.resolve;
|
||||
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.jet.renderer.DescriptorRendererBuilder;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@@ -25,6 +26,8 @@ import java.util.List;
|
||||
public class MemberComparator implements Comparator<DeclarationDescriptor> {
|
||||
public static final MemberComparator INSTANCE = new MemberComparator();
|
||||
|
||||
private static final DescriptorRenderer RENDERER = new DescriptorRendererBuilder().setWithDefinedIn(false).setVerbose(true).build();
|
||||
|
||||
private MemberComparator() {
|
||||
}
|
||||
|
||||
@@ -77,8 +80,8 @@ public class MemberComparator implements Comparator<DeclarationDescriptor> {
|
||||
ReceiverParameterDescriptor c2ReceiverParameter = c2.getReceiverParameter();
|
||||
assert (c1ReceiverParameter != null) == (c2ReceiverParameter != null);
|
||||
if (c1ReceiverParameter != null) {
|
||||
String r1 = DescriptorRenderer.TEXT.renderType(c1ReceiverParameter.getType());
|
||||
String r2 = DescriptorRenderer.TEXT.renderType(c2ReceiverParameter.getType());
|
||||
String r1 = RENDERER.renderType(c1ReceiverParameter.getType());
|
||||
String r2 = RENDERER.renderType(c2ReceiverParameter.getType());
|
||||
int receiversCompareTo = r1.compareTo(r2);
|
||||
if (receiversCompareTo != 0) {
|
||||
return receiversCompareTo;
|
||||
@@ -88,8 +91,8 @@ public class MemberComparator implements Comparator<DeclarationDescriptor> {
|
||||
List<ValueParameterDescriptor> c1ValueParameters = c1.getValueParameters();
|
||||
List<ValueParameterDescriptor> c2ValueParameters = c2.getValueParameters();
|
||||
for (int i = 0; i < Math.min(c1ValueParameters.size(), c2ValueParameters.size()); i++) {
|
||||
String p1 = DescriptorRenderer.TEXT.renderType(c1ValueParameters.get(i).getType());
|
||||
String p2 = DescriptorRenderer.TEXT.renderType(c2ValueParameters.get(i).getType());
|
||||
String p1 = RENDERER.renderType(c1ValueParameters.get(i).getType());
|
||||
String p2 = RENDERER.renderType(c2ValueParameters.get(i).getType());
|
||||
int parametersCompareTo = p1.compareTo(p2);
|
||||
if (parametersCompareTo != 0) {
|
||||
return parametersCompareTo;
|
||||
@@ -104,8 +107,8 @@ public class MemberComparator implements Comparator<DeclarationDescriptor> {
|
||||
List<TypeParameterDescriptor> c1TypeParameters = c1.getTypeParameters();
|
||||
List<TypeParameterDescriptor> c2TypeParameters = c2.getTypeParameters();
|
||||
for (int i = 0; i < Math.min(c1TypeParameters.size(), c2TypeParameters.size()); i++) {
|
||||
String p1 = DescriptorRenderer.TEXT.renderType(c1TypeParameters.get(i).getUpperBoundsAsType());
|
||||
String p2 = DescriptorRenderer.TEXT.renderType(c2TypeParameters.get(i).getUpperBoundsAsType());
|
||||
String p1 = RENDERER.renderType(c1TypeParameters.get(i).getUpperBoundsAsType());
|
||||
String p2 = RENDERER.renderType(c2TypeParameters.get(i).getUpperBoundsAsType());
|
||||
int parametersCompareTo = p1.compareTo(p2);
|
||||
if (parametersCompareTo != 0) {
|
||||
return parametersCompareTo;
|
||||
@@ -120,9 +123,12 @@ public class MemberComparator implements Comparator<DeclarationDescriptor> {
|
||||
if (c1 instanceof CallableMemberDescriptor && c2 instanceof CallableMemberDescriptor) {
|
||||
CallableMemberDescriptor.Kind c1Kind = ((CallableMemberDescriptor) c1).getKind();
|
||||
CallableMemberDescriptor.Kind c2Kind = ((CallableMemberDescriptor) c2).getKind();
|
||||
return c1Kind.ordinal() - c2Kind.ordinal();
|
||||
int kindsCompareTo = c1Kind.ordinal() - c2Kind.ordinal();
|
||||
if (kindsCompareTo != 0) {
|
||||
return kindsCompareTo;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return RENDERER.render(o1).compareTo(RENDERER.render(o2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import javax.inject.Inject;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
|
||||
import static org.jetbrains.jet.lang.resolve.OverridingUtil.OverrideCompatibilityInfo.Result.CONFLICT;
|
||||
import static org.jetbrains.jet.lang.resolve.OverridingUtil.OverrideCompatibilityInfo.Result.OVERRIDABLE;
|
||||
|
||||
public class OverrideResolver {
|
||||
@@ -242,13 +243,47 @@ public class OverrideResolver {
|
||||
Queue<CallableMemberDescriptor> fromSuperQueue = new LinkedList<CallableMemberDescriptor>(notOverridden);
|
||||
while (!fromSuperQueue.isEmpty()) {
|
||||
CallableMemberDescriptor notOverriddenFromSuper = VisibilityUtil.findMemberWithMaxVisibility(fromSuperQueue);
|
||||
Collection<CallableMemberDescriptor> overridables = extractMembersOverridableBy(notOverriddenFromSuper, fromSuperQueue, sink);
|
||||
createAndBindFakeOverride(notOverriddenFromSuper, overridables, current, sink);
|
||||
Collection<CallableMemberDescriptor> overridables = extractMembersOverridableInBothWays(notOverriddenFromSuper, fromSuperQueue,
|
||||
sink);
|
||||
createAndBindFakeOverride(overridables, current, sink);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isMoreSpecific(@NotNull CallableMemberDescriptor a, @NotNull CallableMemberDescriptor b) {
|
||||
if (a instanceof SimpleFunctionDescriptor) {
|
||||
assert b instanceof SimpleFunctionDescriptor : "b is " + b.getClass();
|
||||
|
||||
JetType aReturnType = a.getReturnType();
|
||||
assert aReturnType != null;
|
||||
JetType bReturnType = b.getReturnType();
|
||||
assert bReturnType != null;
|
||||
|
||||
return JetTypeChecker.INSTANCE.isSubtypeOf(aReturnType, bReturnType);
|
||||
}
|
||||
if (a instanceof PropertyDescriptor) {
|
||||
assert b instanceof PropertyDescriptor : "b is " + b.getClass();
|
||||
|
||||
if (((PropertyDescriptor) a).isVar() || ((PropertyDescriptor) b).isVar()) {
|
||||
return ((PropertyDescriptor) a).isVar();
|
||||
}
|
||||
|
||||
// both vals
|
||||
return JetTypeChecker.INSTANCE.isSubtypeOf(((PropertyDescriptor) a).getType(), ((PropertyDescriptor) b).getType());
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected callable: " + a.getClass());
|
||||
}
|
||||
|
||||
private static CallableMemberDescriptor selectMostSpecificMemberFromSuper(@NotNull Collection<CallableMemberDescriptor> overridables) {
|
||||
CallableMemberDescriptor result = null;
|
||||
for (CallableMemberDescriptor overridable : overridables) {
|
||||
if (result == null || isMoreSpecific(overridable, result)) {
|
||||
result = overridable;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void createAndBindFakeOverride(
|
||||
@NotNull CallableMemberDescriptor notOverriddenFromSuper,
|
||||
@NotNull Collection<CallableMemberDescriptor> overridables,
|
||||
@NotNull ClassDescriptor current,
|
||||
@NotNull DescriptorSink sink
|
||||
@@ -258,8 +293,9 @@ public class OverrideResolver {
|
||||
boolean allInvisible = visibleOverridables.isEmpty();
|
||||
Collection<CallableMemberDescriptor> effectiveOverridden = allInvisible ? overridables : visibleOverridables;
|
||||
Visibility visibility = allInvisible ? Visibilities.INVISIBLE_FAKE : Visibilities.INHERITED;
|
||||
CallableMemberDescriptor mostSpecific = selectMostSpecificMemberFromSuper(effectiveOverridden);
|
||||
CallableMemberDescriptor fakeOverride =
|
||||
notOverriddenFromSuper.copy(current, modality, visibility, CallableMemberDescriptor.Kind.FAKE_OVERRIDE, false);
|
||||
mostSpecific.copy(current, modality, visibility, CallableMemberDescriptor.Kind.FAKE_OVERRIDE, false);
|
||||
for (CallableMemberDescriptor descriptor : effectiveOverridden) {
|
||||
OverridingUtil.bindOverride(fakeOverride, descriptor);
|
||||
}
|
||||
@@ -292,7 +328,7 @@ public class OverrideResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Collection<CallableMemberDescriptor> extractMembersOverridableBy(
|
||||
private static Collection<CallableMemberDescriptor> extractMembersOverridableInBothWays(
|
||||
@NotNull CallableMemberDescriptor overrider,
|
||||
@NotNull Queue<CallableMemberDescriptor> extractFrom,
|
||||
@NotNull DescriptorSink sink
|
||||
@@ -306,19 +342,17 @@ public class OverrideResolver {
|
||||
continue;
|
||||
}
|
||||
|
||||
OverridingUtil.OverrideCompatibilityInfo.Result result =
|
||||
OverridingUtil.OverrideCompatibilityInfo.Result result1 =
|
||||
OverridingUtil.isOverridableBy(candidate, overrider).getResult();
|
||||
switch (result) {
|
||||
case OVERRIDABLE:
|
||||
overridable.add(candidate);
|
||||
iterator.remove();
|
||||
break;
|
||||
case CONFLICT:
|
||||
sink.conflict(overrider, candidate);
|
||||
iterator.remove();
|
||||
break;
|
||||
case INCOMPATIBLE:
|
||||
break;
|
||||
OverridingUtil.OverrideCompatibilityInfo.Result result2 =
|
||||
OverridingUtil.isOverridableBy(overrider, candidate).getResult();
|
||||
if (result1 == OVERRIDABLE && result2 == OVERRIDABLE) {
|
||||
overridable.add(candidate);
|
||||
iterator.remove();
|
||||
}
|
||||
else if (result1 == CONFLICT || result2 == CONFLICT) {
|
||||
sink.conflict(overrider, candidate);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return overridable;
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
@@ -31,6 +32,12 @@ import java.util.*;
|
||||
|
||||
public class OverridingUtil {
|
||||
|
||||
private static final List<ExternalOverridabilityCondition> EXTERNAL_CONDITIONS =
|
||||
ContainerUtil.collect(ServiceLoader.load(
|
||||
ExternalOverridabilityCondition.class,
|
||||
ExternalOverridabilityCondition.class.getClassLoader()).iterator()
|
||||
);
|
||||
|
||||
private OverridingUtil() {
|
||||
}
|
||||
|
||||
@@ -128,7 +135,7 @@ public class OverridingUtil {
|
||||
// TODO : Visibility
|
||||
|
||||
if ((superDescriptor.getReceiverParameter() == null) != (subDescriptor.getReceiverParameter() == null)) {
|
||||
return OverrideCompatibilityInfo.receiverPresenseMismatch();
|
||||
return OverrideCompatibilityInfo.receiverPresenceMismatch();
|
||||
}
|
||||
|
||||
if (superDescriptor.getValueParameters().size() != subDescriptor.getValueParameters().size()) {
|
||||
@@ -183,6 +190,11 @@ public class OverridingUtil {
|
||||
}
|
||||
}
|
||||
|
||||
for (ExternalOverridabilityCondition externalCondition : EXTERNAL_CONDITIONS) {
|
||||
if (!externalCondition.isOverridable(superDescriptor, subDescriptor)) {
|
||||
return OverrideCompatibilityInfo.externalConditionFailed(externalCondition.getClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -277,7 +289,7 @@ public class OverridingUtil {
|
||||
}
|
||||
else {
|
||||
if (descriptor.getOverriddenDescriptors().isEmpty()) {
|
||||
throw new IllegalStateException();
|
||||
throw new IllegalStateException("No overridden descriptors found for (fake override) " + descriptor);
|
||||
}
|
||||
for (CallableMemberDescriptor overridden : descriptor.getOverriddenDescriptors()) {
|
||||
getOverriddenDeclarations(overridden, r);
|
||||
@@ -322,8 +334,8 @@ public class OverridingUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static OverrideCompatibilityInfo receiverPresenseMismatch() {
|
||||
return new OverrideCompatibilityInfo(Result.INCOMPATIBLE, "receiverPresenseMismatch"); // TODO
|
||||
public static OverrideCompatibilityInfo receiverPresenceMismatch() {
|
||||
return new OverrideCompatibilityInfo(Result.INCOMPATIBLE, "receiverPresenceMismatch"); // TODO
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -356,6 +368,11 @@ public class OverridingUtil {
|
||||
return new OverrideCompatibilityInfo(Result.INCOMPATIBLE, "varOverriddenByVal"); // TODO
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static OverrideCompatibilityInfo externalConditionFailed(Class<? extends ExternalOverridabilityCondition> conditionClass) {
|
||||
return new OverrideCompatibilityInfo(Result.INCOMPATIBLE, "externalConditionFailed: " + conditionClass.getName()); // TODO
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private final Result overridable;
|
||||
|
||||
+42
-13
@@ -20,13 +20,11 @@ import gnu.trove.THashSet;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ScriptDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.OverridingUtil;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
@@ -58,21 +56,52 @@ public class OverloadingConflictResolver {
|
||||
return object == null ? 0 : object.getResultingDescriptor().hashCode();
|
||||
}
|
||||
});
|
||||
meLoop:
|
||||
for (ResolvedCallWithTrace<D> candidateCall : candidates) {
|
||||
D me = candidateCall.getResultingDescriptor();
|
||||
for (ResolvedCallWithTrace<D> otherCall : candidates) {
|
||||
D other = otherCall.getResultingDescriptor();
|
||||
if (other == me) continue;
|
||||
if (!moreSpecific(me, other, discriminateGenericDescriptors) || moreSpecific(other, me, discriminateGenericDescriptors)) {
|
||||
continue meLoop;
|
||||
}
|
||||
if (isMaximallySpecific(candidateCall, candidates, discriminateGenericDescriptors)) {
|
||||
maximallySpecific.add(candidateCall);
|
||||
}
|
||||
maximallySpecific.add(candidateCall);
|
||||
}
|
||||
return maximallySpecific.size() == 1 ? maximallySpecific.iterator().next() : null;
|
||||
}
|
||||
|
||||
private <D extends CallableDescriptor> boolean isMaximallySpecific(
|
||||
@NotNull ResolvedCallWithTrace<D> candidateCall,
|
||||
@NotNull Set<ResolvedCallWithTrace<D>> candidates,
|
||||
boolean discriminateGenericDescriptors
|
||||
) {
|
||||
D me = candidateCall.getResultingDescriptor();
|
||||
|
||||
boolean isInvoke = candidateCall instanceof VariableAsFunctionResolvedCall;
|
||||
VariableDescriptor variable;
|
||||
if (isInvoke) {
|
||||
variable = ((VariableAsFunctionResolvedCall) candidateCall).getVariableCall().getResultingDescriptor();
|
||||
}
|
||||
else {
|
||||
variable = null;
|
||||
}
|
||||
|
||||
for (ResolvedCallWithTrace<D> otherCall : candidates) {
|
||||
D other = otherCall.getResultingDescriptor();
|
||||
if (other == me) continue;
|
||||
|
||||
if (definitelyNotMaximallySpecific(me, other, discriminateGenericDescriptors)) {
|
||||
|
||||
if (!isInvoke) return false;
|
||||
|
||||
assert otherCall instanceof VariableAsFunctionResolvedCall : "'invoke' candidate goes with usual one: " + candidateCall + otherCall;
|
||||
ResolvedCallWithTrace<VariableDescriptor> otherVariableCall = ((VariableAsFunctionResolvedCall) otherCall).getVariableCall();
|
||||
if (definitelyNotMaximallySpecific(variable, otherVariableCall.getResultingDescriptor(), discriminateGenericDescriptors)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private <D extends CallableDescriptor> boolean definitelyNotMaximallySpecific(D me, D other, boolean discriminateGenericDescriptors) {
|
||||
return !moreSpecific(me, other, discriminateGenericDescriptors) || moreSpecific(other, me, discriminateGenericDescriptors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Let < mean "more specific"
|
||||
* Subtype < supertype
|
||||
|
||||
@@ -1323,7 +1323,7 @@ public trait MutableList</*0*/ E> : jet.List<E>, jet.MutableCollection<E> {
|
||||
public abstract override /*2*/ /*fake_override*/ fun hashCode(): jet.Int
|
||||
public abstract override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: jet.Any?): jet.Int
|
||||
public abstract override /*2*/ /*fake_override*/ fun isEmpty(): jet.Boolean
|
||||
public abstract override /*2*/ /*fake_override*/ fun iterator(): jet.Iterator<E>
|
||||
public abstract override /*2*/ /*fake_override*/ fun iterator(): jet.MutableIterator<E>
|
||||
public abstract override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: jet.Any?): jet.Int
|
||||
public abstract override /*1*/ fun listIterator(): jet.MutableListIterator<E>
|
||||
public abstract override /*1*/ fun listIterator(/*0*/ index: jet.Int): jet.MutableListIterator<E>
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
class Super {
|
||||
public String lastCalled = null;
|
||||
|
||||
void foo(Runnable r) {
|
||||
lastCalled = "super";
|
||||
}
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
class Sub() : Super() {
|
||||
override fun foo(r : (() -> Unit)?) {
|
||||
lastCalled = "sub"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val sub = Sub()
|
||||
|
||||
(sub : Super).foo{ }
|
||||
if (sub.lastCalled != "super") {
|
||||
return "FAIL: ${sub.lastCalled} instead of super"
|
||||
}
|
||||
|
||||
sub.foo{ }
|
||||
if (sub.lastCalled != "sub") {
|
||||
return "FAIL: ${sub.lastCalled} instead of sub"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fun fill(dest : Array<in String>, v : String) {
|
||||
dest[0] = v
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
//fun main(args : Array<String>) {
|
||||
val s : String = "bar"
|
||||
val any : Array<Any> = array(1, "foo", 1.234)
|
||||
fill(any, s)
|
||||
/* shouldn't throw
|
||||
ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
|
||||
*/
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// FILE: Super.java
|
||||
class Super {
|
||||
void foo(Runnable r) {
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Sub.kt
|
||||
class Sub1() : Super() {
|
||||
<!VIRTUAL_MEMBER_HIDDEN!>fun foo(r : (() -> Unit)?)<!> {
|
||||
}
|
||||
}
|
||||
|
||||
class Sub2() : Super() {
|
||||
<!OVERRIDING_FINAL_MEMBER!>override<!> fun foo(r : (() -> Unit)?) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// FILE: Bad.java
|
||||
|
||||
class Bad<T extends Bad> {}
|
||||
|
||||
// FILE: X.java
|
||||
|
||||
class X {
|
||||
Bad foo() {return null;}
|
||||
}
|
||||
|
||||
// FILE: Usage.kt
|
||||
|
||||
fun foo(p: X) = p.foo()
|
||||
@@ -0,0 +1,25 @@
|
||||
//KT-3772 Invoke and overload resolution ambiguity
|
||||
package bar
|
||||
|
||||
open class A {
|
||||
public fun invoke(<!UNUSED_PARAMETER!>f<!>: A.() -> Unit) {}
|
||||
}
|
||||
|
||||
class B {
|
||||
public fun invoke(<!UNUSED_PARAMETER!>f<!>: B.() -> Unit) {}
|
||||
}
|
||||
|
||||
open class C
|
||||
val C.attr = A()
|
||||
|
||||
open class D: C()
|
||||
val D.attr = B()
|
||||
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val b = D()
|
||||
b.attr {} // overload resolution ambiguity
|
||||
|
||||
val d = b.attr
|
||||
d {} // no error
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package test
|
||||
public trait SamSubinterfaceOfTwo : java.lang.Object {
|
||||
|
||||
public trait Sub : test.SamSubinterfaceOfTwo.Super1, test.SamSubinterfaceOfTwo.Super2<jet.String> {
|
||||
public abstract override /*2*/ /*fake_override*/ fun f(): jet.CharSequence?
|
||||
public abstract override /*2*/ /*fake_override*/ fun f(): jet.String?
|
||||
}
|
||||
|
||||
public trait Super1 : java.lang.Object {
|
||||
|
||||
@@ -2,8 +2,8 @@ package test
|
||||
|
||||
public open class AmbiguousAdapters : java.lang.Object {
|
||||
public constructor AmbiguousAdapters()
|
||||
public open /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public open /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public open fun foo(/*0*/ p0: java.io.Closeable?): jet.Unit
|
||||
public open fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ package test
|
||||
|
||||
public open class Basic : java.lang.Object {
|
||||
public constructor Basic()
|
||||
public open /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public open fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
package Basic {
|
||||
public open /*synthesized*/ fun bar(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public /*synthesized*/ fun bar(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public open fun bar(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ package test
|
||||
public trait DeepSamLoop : java.lang.Object {
|
||||
|
||||
public trait Bar : java.lang.Object {
|
||||
public abstract /*synthesized*/ fun foo(/*0*/ p0: ((test.DeepSamLoop.Bar?) -> jet.Unit)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: ((test.DeepSamLoop.Bar?) -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: test.DeepSamLoop.Foo?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Foo : java.lang.Object {
|
||||
public abstract /*synthesized*/ fun foo(/*0*/ p0: ((test.DeepSamLoop.Foo?) -> jet.Unit)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: ((test.DeepSamLoop.Foo?) -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: test.DeepSamLoop.Bar?): jet.Unit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ package test
|
||||
|
||||
public open class NonTrivialFunctionType : java.lang.Object {
|
||||
public constructor NonTrivialFunctionType()
|
||||
public open /*synthesized*/ fun foo(/*0*/ p0: ((java.io.File, jet.String) -> jet.Boolean)?): jet.Unit
|
||||
public open /*synthesized*/ fun foo(/*0*/ p0: ((jet.String, jet.String) -> jet.Int)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: ((java.io.File, jet.String) -> jet.Boolean)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: ((jet.String, jet.String) -> jet.Int)?): jet.Unit
|
||||
public open fun foo(/*0*/ p0: java.io.FilenameFilter?): jet.Unit
|
||||
public open fun foo(/*0*/ p0: java.util.Comparator<jet.String>?): jet.Unit
|
||||
public open /*synthesized*/ fun wildcardBound(/*0*/ p0: ((jet.CharSequence?, jet.CharSequence?) -> jet.Int)?): jet.Unit
|
||||
public final /*synthesized*/ fun wildcardBound(/*0*/ p0: ((jet.CharSequence?, jet.CharSequence?) -> jet.Int)?): jet.Unit
|
||||
public open fun wildcardBound(/*0*/ p0: java.util.Comparator<in jet.CharSequence?>?): jet.Unit
|
||||
public open fun wildcardUnbound(/*0*/ p0: java.util.Comparator<out jet.Any?>?): jet.Unit
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@ package test
|
||||
public /*synthesized*/ fun SelfAsParameter(/*0*/ function: (test.SelfAsParameter?) -> jet.Unit): test.SelfAsParameter
|
||||
|
||||
public trait SelfAsParameter : java.lang.Object {
|
||||
public abstract /*synthesized*/ fun foo(/*0*/ p0: ((test.SelfAsParameter?) -> jet.Unit)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: ((test.SelfAsParameter?) -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: test.SelfAsParameter?): jet.Unit
|
||||
}
|
||||
|
||||
@@ -5,6 +5,6 @@ public open class SeveralSamParameters : java.lang.Object {
|
||||
}
|
||||
|
||||
package SeveralSamParameters {
|
||||
public open /*synthesized*/ fun findMaxAndInvokeCallback(/*0*/ p0: ((jet.String, jet.String) -> jet.Int)?, /*1*/ p1: jet.String?, /*2*/ p2: jet.String?, /*3*/ p3: (() -> jet.Unit)?): jet.String?
|
||||
public /*synthesized*/ fun findMaxAndInvokeCallback(/*0*/ p0: ((jet.String, jet.String) -> jet.Int)?, /*1*/ p1: jet.String?, /*2*/ p2: jet.String?, /*3*/ p3: (() -> jet.Unit)?): jet.String?
|
||||
public open fun findMaxAndInvokeCallback(/*0*/ p0: java.util.Comparator<jet.String>?, /*1*/ p1: jet.String?, /*2*/ p2: jet.String?, /*3*/ p3: java.lang.Runnable?): jet.String?
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ package test
|
||||
|
||||
public open class TypeParameterOfClass</*0*/ T> : java.lang.Object {
|
||||
public constructor TypeParameterOfClass</*0*/ T>()
|
||||
public open /*synthesized*/ fun foo(/*0*/ p0: ((T, T) -> jet.Int)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: ((T, T) -> jet.Int)?): jet.Unit
|
||||
public open fun foo(/*0*/ p0: java.util.Comparator<T>?): jet.Unit
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ public open class TypeParameterOfMethod : java.lang.Object {
|
||||
}
|
||||
|
||||
package TypeParameterOfMethod {
|
||||
public open /*synthesized*/ fun </*0*/ T> max(/*0*/ p0: ((T, T) -> jet.Int)?, /*1*/ p1: T?, /*2*/ p2: T?): T?
|
||||
public /*synthesized*/ fun </*0*/ T> max(/*0*/ p0: ((T, T) -> jet.Int)?, /*1*/ p1: T?, /*2*/ p2: T?): T?
|
||||
public open fun </*0*/ T> max(/*0*/ p0: java.util.Comparator<T>?, /*1*/ p1: T?, /*2*/ p2: T?): T?
|
||||
public open /*synthesized*/ fun </*0*/ T : jet.CharSequence?> max2(/*0*/ p0: ((T, T) -> jet.Int)?, /*1*/ p1: T?, /*2*/ p2: T?): T?
|
||||
public /*synthesized*/ fun </*0*/ T : jet.CharSequence?> max2(/*0*/ p0: ((T, T) -> jet.Int)?, /*1*/ p1: T?, /*2*/ p2: T?): T?
|
||||
public open fun </*0*/ T : jet.CharSequence?> max2(/*0*/ p0: java.util.Comparator<T>?, /*1*/ p1: T?, /*2*/ p2: T?): T?
|
||||
public open /*synthesized*/ fun </*0*/ A : jet.CharSequence?, /*1*/ B : jet.List<A>?> method(/*0*/ p0: ((A, A) -> jet.Int)?, /*1*/ p1: B?): jet.Unit
|
||||
public /*synthesized*/ fun </*0*/ A : jet.CharSequence?, /*1*/ B : jet.List<A>?> method(/*0*/ p0: ((A, A) -> jet.Int)?, /*1*/ p1: B?): jet.Unit
|
||||
public open fun </*0*/ A : jet.CharSequence?, /*1*/ B : jet.List<A>?> method(/*0*/ p0: java.util.Comparator<A>?, /*1*/ p1: B?): jet.Unit
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ public open class TypeParameterOfOuterClass</*0*/ T> : java.lang.Object {
|
||||
|
||||
public open inner class Inner : java.lang.Object {
|
||||
public constructor Inner()
|
||||
public open /*synthesized*/ fun foo(/*0*/ p0: ((T, T) -> jet.Int)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: ((T, T) -> jet.Int)?): jet.Unit
|
||||
public open fun foo(/*0*/ p0: java.util.Comparator<T>?): jet.Unit
|
||||
}
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package test;
|
||||
|
||||
public interface AdapterDoesntOverrideDeclaration {
|
||||
public interface Super {
|
||||
void foo(jet.Function0<jet.Unit> r);
|
||||
}
|
||||
|
||||
public interface Sub extends Super {
|
||||
void foo(Runnable r);
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package test
|
||||
|
||||
public trait AdapterDoesntOverrideDeclaration : java.lang.Object {
|
||||
|
||||
public trait Sub : test.AdapterDoesntOverrideDeclaration.Super {
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super : java.lang.Object {
|
||||
public abstract fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
}
|
||||
}
|
||||
|
||||
package AdapterDoesntOverrideDeclaration {
|
||||
public /*synthesized*/ fun Super(/*0*/ function: ((() -> jet.Unit)?) -> jet.Unit): test.AdapterDoesntOverrideDeclaration.Super
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package test;
|
||||
|
||||
public interface InheritedAdapterAndDeclaration {
|
||||
public interface Super {
|
||||
void foo(Runnable r);
|
||||
void foo(jet.Function0<jet.Unit> r);
|
||||
}
|
||||
|
||||
public interface Sub extends Super {
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package test
|
||||
|
||||
public trait InheritedAdapterAndDeclaration : java.lang.Object {
|
||||
|
||||
public trait Sub : test.InheritedAdapterAndDeclaration.Super {
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super : java.lang.Object {
|
||||
public abstract fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package test;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
public interface InheritedAmbiguousAdapters {
|
||||
public interface Super {
|
||||
void foo(Runnable r);
|
||||
void foo(Closeable r);
|
||||
}
|
||||
|
||||
public interface Sub extends Super {
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package test
|
||||
|
||||
public trait InheritedAmbiguousAdapters : java.lang.Object {
|
||||
|
||||
public trait Sub : test.InheritedAmbiguousAdapters.Super {
|
||||
public final override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.io.Closeable?): jet.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super : java.lang.Object {
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.io.Closeable?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package test;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
public interface InheritedAndOverriddenAmbiguousAdapters {
|
||||
public interface Super {
|
||||
void foo(Runnable r);
|
||||
void foo(Closeable r);
|
||||
}
|
||||
|
||||
public interface Sub extends Super {
|
||||
void foo(Runnable r);
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package test
|
||||
|
||||
public trait InheritedAndOverriddenAmbiguousAdapters : java.lang.Object {
|
||||
|
||||
public trait Sub : test.InheritedAndOverriddenAmbiguousAdapters.Super {
|
||||
public final override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public final override /*1*/ /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.io.Closeable?): jet.Unit
|
||||
public abstract override /*1*/ fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super : java.lang.Object {
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.io.Closeable?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -4,13 +4,13 @@ public trait InheritedOverridden : java.lang.Object {
|
||||
|
||||
public open class Sub : test.InheritedOverridden.Super {
|
||||
public constructor Sub()
|
||||
public open override /*1*/ /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public final override /*1*/ /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public open override /*1*/ fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public open class Super : java.lang.Object {
|
||||
public constructor Super()
|
||||
public open /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public open fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -10,7 +10,7 @@ public trait InheritedOverriddenAdapter : java.lang.Object {
|
||||
|
||||
public open class Super : java.lang.Object {
|
||||
public constructor Super()
|
||||
public open /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public open fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package test;
|
||||
|
||||
public interface InheritedSameAdapters {
|
||||
public interface Super1 {
|
||||
void foo(Runnable r);
|
||||
}
|
||||
|
||||
public interface Super2 {
|
||||
void foo(Runnable r);
|
||||
}
|
||||
|
||||
public interface Sub extends Super1, Super2 {
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package test
|
||||
|
||||
public trait InheritedSameAdapters : java.lang.Object {
|
||||
|
||||
public trait Sub : test.InheritedSameAdapters.Super1, test.InheritedSameAdapters.Super2 {
|
||||
public final override /*2*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract override /*2*/ /*fake_override*/ fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super1 : java.lang.Object {
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super2 : java.lang.Object {
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
}
|
||||
|
||||
package InheritedSameAdapters {
|
||||
public /*synthesized*/ fun Sub(/*0*/ function: (java.lang.Runnable?) -> jet.Unit): test.InheritedSameAdapters.Sub
|
||||
public /*synthesized*/ fun Super1(/*0*/ function: (java.lang.Runnable?) -> jet.Unit): test.InheritedSameAdapters.Super1
|
||||
public /*synthesized*/ fun Super2(/*0*/ function: (java.lang.Runnable?) -> jet.Unit): test.InheritedSameAdapters.Super2
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package test;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public interface InheritedSameAdaptersWithSubstitution {
|
||||
public interface Super1 {
|
||||
void foo(Comparator<String> r);
|
||||
}
|
||||
|
||||
public interface Super2<T> {
|
||||
void foo(Comparator<T> r);
|
||||
}
|
||||
|
||||
public interface Super2Substituted extends Super2<String> {
|
||||
}
|
||||
|
||||
public interface Sub extends Super1, Super2Substituted {
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package test
|
||||
|
||||
public trait InheritedSameAdaptersWithSubstitution : java.lang.Object {
|
||||
|
||||
public trait Sub : test.InheritedSameAdaptersWithSubstitution.Super1, test.InheritedSameAdaptersWithSubstitution.Super2Substituted {
|
||||
public final override /*2*/ /*fake_override*/ fun foo(/*0*/ p0: ((jet.String, jet.String) -> jet.Int)?): jet.Unit
|
||||
public abstract override /*2*/ /*fake_override*/ fun foo(/*0*/ p0: java.util.Comparator<jet.String>?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super1 : java.lang.Object {
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: ((jet.String, jet.String) -> jet.Int)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.util.Comparator<jet.String>?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super2</*0*/ T> : java.lang.Object {
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: ((T, T) -> jet.Int)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.util.Comparator<T>?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super2Substituted : test.InheritedSameAdaptersWithSubstitution.Super2<jet.String> {
|
||||
public final override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: ((jet.String, jet.String) -> jet.Int)?): jet.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.util.Comparator<jet.String>?): jet.Unit
|
||||
}
|
||||
}
|
||||
|
||||
package InheritedSameAdaptersWithSubstitution {
|
||||
public /*synthesized*/ fun Sub(/*0*/ function: (java.util.Comparator<jet.String>?) -> jet.Unit): test.InheritedSameAdaptersWithSubstitution.Sub
|
||||
public /*synthesized*/ fun Super1(/*0*/ function: (java.util.Comparator<jet.String>?) -> jet.Unit): test.InheritedSameAdaptersWithSubstitution.Super1
|
||||
public /*synthesized*/ fun </*0*/ T> Super2(/*0*/ function: (java.util.Comparator<T>?) -> jet.Unit): test.InheritedSameAdaptersWithSubstitution.Super2<T>
|
||||
public /*synthesized*/ fun Super2Substituted(/*0*/ function: (java.util.Comparator<jet.String>?) -> jet.Unit): test.InheritedSameAdaptersWithSubstitution.Super2Substituted
|
||||
}
|
||||
+1
-1
@@ -7,4 +7,4 @@ public interface InheritedSimple {
|
||||
|
||||
public interface Sub extends Super {
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -3,12 +3,12 @@ package test
|
||||
public trait InheritedSimple : java.lang.Object {
|
||||
|
||||
public trait Sub : test.InheritedSimple.Super {
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super : java.lang.Object {
|
||||
public abstract /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package test;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
public interface OverriddenAmbiguousAdapters {
|
||||
public interface Super {
|
||||
void foo(Runnable r);
|
||||
void foo(Closeable r);
|
||||
}
|
||||
|
||||
public interface Sub extends Super {
|
||||
void foo(jet.Function0<jet.Unit> r);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package test
|
||||
|
||||
public trait OverriddenAmbiguousAdapters : java.lang.Object {
|
||||
|
||||
public trait Sub : test.OverriddenAmbiguousAdapters.Super {
|
||||
public abstract override /*2*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.io.Closeable?): jet.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super : java.lang.Object {
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ p0: (() -> jet.Unit)?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.io.Closeable?): jet.Unit
|
||||
public abstract fun foo(/*0*/ p0: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package test;
|
||||
|
||||
public final class InheritMethodsDifferentReturnTypes {
|
||||
public interface Super1 {
|
||||
CharSequence foo();
|
||||
String bar();
|
||||
}
|
||||
|
||||
public interface Super2 {
|
||||
String foo();
|
||||
CharSequence bar();
|
||||
}
|
||||
|
||||
public interface Sub extends Super1, Super2 {
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package test
|
||||
|
||||
public class InheritMethodsDifferentReturnTypes: Object() {
|
||||
public trait Super1: Object {
|
||||
public fun foo(): CharSequence?
|
||||
public fun bar(): String?
|
||||
}
|
||||
|
||||
public trait Super2: Object {
|
||||
public fun foo(): String?
|
||||
public fun bar(): CharSequence?
|
||||
}
|
||||
|
||||
public trait Sub: Super1, Super2 {
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package test
|
||||
|
||||
public final class InheritMethodsDifferentReturnTypes : java.lang.Object {
|
||||
public constructor InheritMethodsDifferentReturnTypes()
|
||||
|
||||
public trait Sub : test.InheritMethodsDifferentReturnTypes.Super1, test.InheritMethodsDifferentReturnTypes.Super2 {
|
||||
public abstract override /*2*/ /*fake_override*/ fun bar(): jet.String?
|
||||
public abstract override /*2*/ /*fake_override*/ fun foo(): jet.String?
|
||||
}
|
||||
|
||||
public trait Super1 : java.lang.Object {
|
||||
public abstract fun bar(): jet.String?
|
||||
public abstract fun foo(): jet.CharSequence?
|
||||
}
|
||||
|
||||
public trait Super2 : java.lang.Object {
|
||||
public abstract fun bar(): jet.CharSequence?
|
||||
public abstract fun foo(): jet.String?
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package test;
|
||||
|
||||
public final class InheritMethodsDifferentReturnTypesGeneric {
|
||||
public interface Super1<F, B> {
|
||||
F foo();
|
||||
B bar();
|
||||
}
|
||||
|
||||
public interface Super2<FF, BB> {
|
||||
FF foo();
|
||||
BB bar();
|
||||
}
|
||||
|
||||
public interface Sub extends Super1<String, CharSequence>, Super2<CharSequence, String> {
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package test
|
||||
|
||||
public class InheritMethodsDifferentReturnTypesGeneric: Object() {
|
||||
public trait Super1<F, B>: Object {
|
||||
public fun foo(): F?
|
||||
public fun bar(): B?
|
||||
}
|
||||
|
||||
public trait Super2<FF, BB>: Object {
|
||||
public fun foo(): FF?
|
||||
public fun bar(): BB?
|
||||
}
|
||||
|
||||
public trait Sub: Super1<String, CharSequence>, Super2<CharSequence, String> {
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package test
|
||||
|
||||
public final class InheritMethodsDifferentReturnTypesGeneric : java.lang.Object {
|
||||
public constructor InheritMethodsDifferentReturnTypesGeneric()
|
||||
|
||||
public trait Sub : test.InheritMethodsDifferentReturnTypesGeneric.Super1<jet.String, jet.CharSequence>, test.InheritMethodsDifferentReturnTypesGeneric.Super2<jet.CharSequence, jet.String> {
|
||||
public abstract override /*2*/ /*fake_override*/ fun bar(): jet.String?
|
||||
public abstract override /*2*/ /*fake_override*/ fun foo(): jet.String?
|
||||
}
|
||||
|
||||
public trait Super1</*0*/ F, /*1*/ B> : java.lang.Object {
|
||||
public abstract fun bar(): B?
|
||||
public abstract fun foo(): F?
|
||||
}
|
||||
|
||||
public trait Super2</*0*/ FF, /*1*/ BB> : java.lang.Object {
|
||||
public abstract fun bar(): BB?
|
||||
public abstract fun foo(): FF?
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -23,7 +23,7 @@ public trait HalfSubstitutedTypeParameters : java.lang.Object {
|
||||
public abstract override /*1*/ /*fake_override*/ fun get(/*0*/ index: jet.Int): E
|
||||
public abstract override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: jet.Any?): jet.Int
|
||||
public abstract override /*1*/ /*fake_override*/ fun isEmpty(): jet.Boolean
|
||||
public abstract override /*1*/ /*fake_override*/ fun iterator(): jet.Iterator<E>
|
||||
public abstract override /*1*/ /*fake_override*/ fun iterator(): jet.MutableIterator<E>
|
||||
public abstract override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: jet.Any?): jet.Int
|
||||
public abstract override /*1*/ /*fake_override*/ fun listIterator(): jet.MutableListIterator<E>
|
||||
public abstract override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: jet.Int): jet.MutableListIterator<E>
|
||||
|
||||
+6
-6
@@ -5,11 +5,11 @@ public open class ModalityOfFakeOverrides : java.util.AbstractList<jet.String> {
|
||||
protected final override /*1*/ /*fake_override*/ var modCount: jet.Int
|
||||
public open override /*1*/ /*fake_override*/ fun add(/*0*/ p0: jet.Int, /*1*/ p1: jet.String): jet.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun add(/*0*/ p0: jet.String): jet.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ p0: jet.Collection<jet.String>): jet.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: jet.Collection<jet.String>): jet.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ p0: jet.Int, /*1*/ p1: jet.Collection<jet.String>): jet.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun clear(): jet.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun contains(/*0*/ p0: jet.Any?): jet.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun containsAll(/*0*/ p0: jet.Collection<jet.Any?>): jet.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun contains(/*0*/ o: jet.Any?): jet.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun containsAll(/*0*/ c: jet.Collection<jet.Any?>): jet.Boolean
|
||||
public open override /*1*/ fun get(/*0*/ p0: jet.Int): jet.String
|
||||
public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ p0: jet.Any?): jet.Int
|
||||
public open override /*1*/ /*fake_override*/ fun isEmpty(): jet.Boolean
|
||||
@@ -17,11 +17,11 @@ public open class ModalityOfFakeOverrides : java.util.AbstractList<jet.String> {
|
||||
public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ p0: jet.Any?): jet.Int
|
||||
public open override /*1*/ /*fake_override*/ fun listIterator(): jet.MutableListIterator<jet.String>
|
||||
public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ p0: jet.Int): jet.MutableListIterator<jet.String>
|
||||
public open override /*1*/ /*fake_override*/ fun remove(/*0*/ p0: jet.Any?): jet.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: jet.Any?): jet.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun remove(/*0*/ p0: jet.Int): jet.String
|
||||
public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ p0: jet.Collection<jet.Any?>): jet.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: jet.Collection<jet.Any?>): jet.Boolean
|
||||
protected open override /*1*/ /*fake_override*/ fun removeRange(/*0*/ p0: jet.Int, /*1*/ p1: jet.Int): jet.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ p0: jet.Collection<jet.Any?>): jet.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: jet.Collection<jet.Any?>): jet.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun set(/*0*/ p0: jet.Int, /*1*/ p1: jet.String): jet.String
|
||||
public open override /*1*/ fun size(): jet.Int
|
||||
public open override /*1*/ /*fake_override*/ fun subList(/*0*/ p0: jet.Int, /*1*/ p1: jet.Int): jet.MutableList<jet.String>
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package test
|
||||
|
||||
public final class Sub : test.Super {
|
||||
public constructor Sub()
|
||||
internal final override /*1*/ /*fake_override*/ fun foo(/*0*/ r: (() -> jet.Unit)?): jet.Unit
|
||||
internal final override /*1*/ /*fake_override*/ fun foo(/*0*/ r: (() -> jet.Unit)?): jet.Unit
|
||||
internal open override /*1*/ /*fake_override*/ fun foo(/*0*/ r: java.io.Closeable?): jet.Unit
|
||||
internal open override /*1*/ /*fake_override*/ fun foo(/*0*/ r: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public open class Super : java.lang.Object {
|
||||
public constructor Super()
|
||||
public/*package*/ final /*synthesized*/ fun foo(/*0*/ r: (() -> jet.Unit)?): jet.Unit
|
||||
public/*package*/ final /*synthesized*/ fun foo(/*0*/ r: (() -> jet.Unit)?): jet.Unit
|
||||
public/*package*/ open fun foo(/*0*/ r: java.io.Closeable?): jet.Unit
|
||||
public/*package*/ open fun foo(/*0*/ r: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package test
|
||||
|
||||
public class Sub: Super() {
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
public class Super {
|
||||
void foo(Runnable r);
|
||||
void foo(Closeable r);
|
||||
}
|
||||
+2
-2
@@ -2,12 +2,12 @@ package test
|
||||
|
||||
public final class Sub : test.Super {
|
||||
public constructor Sub()
|
||||
internal open override /*1*/ /*fake_override*/ fun foo(/*0*/ r: (() -> jet.Unit)?): jet.Unit
|
||||
internal final override /*1*/ /*fake_override*/ fun foo(/*0*/ r: (() -> jet.Unit)?): jet.Unit
|
||||
internal open override /*1*/ /*fake_override*/ fun foo(/*0*/ r: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
public open class Super : java.lang.Object {
|
||||
public constructor Super()
|
||||
public/*package*/ open /*synthesized*/ fun foo(/*0*/ r: (() -> jet.Unit)?): jet.Unit
|
||||
public/*package*/ final /*synthesized*/ fun foo(/*0*/ r: (() -> jet.Unit)?): jet.Unit
|
||||
public/*package*/ open fun foo(/*0*/ r: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,6 +8,6 @@ public final class Sub : test.Super {
|
||||
|
||||
public open class Super : java.lang.Object {
|
||||
public constructor Super()
|
||||
public/*package*/ open /*synthesized*/ fun foo(/*0*/ r: (() -> jet.Unit)?): jet.Unit
|
||||
public/*package*/ final /*synthesized*/ fun foo(/*0*/ r: (() -> jet.Unit)?): jet.Unit
|
||||
public/*package*/ open fun foo(/*0*/ r: java.lang.Runnable?): jet.Unit
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package test
|
||||
|
||||
public open class Sub : test.Super {
|
||||
public constructor Sub()
|
||||
public open /*synthesized*/ fun foo(/*0*/ r: () -> jet.Unit): jet.Unit
|
||||
public final /*synthesized*/ fun foo(/*0*/ r: () -> jet.Unit): jet.Unit
|
||||
public open override /*1*/ fun foo(/*0*/ r: java.lang.Runnable): jet.Unit
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package test
|
||||
|
||||
public trait Super1 {
|
||||
public fun foo(): CharSequence
|
||||
private fun bar(): String
|
||||
}
|
||||
|
||||
public trait Super2 {
|
||||
private fun foo(): String
|
||||
public fun bar(): CharSequence
|
||||
}
|
||||
|
||||
public trait Sub: Super1, Super2 {
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package test
|
||||
|
||||
public trait Sub : test.Super1, test.Super2 {
|
||||
public abstract override /*1*/ /*fake_override*/ fun bar(): jet.CharSequence
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(): jet.CharSequence
|
||||
}
|
||||
|
||||
public trait Super1 {
|
||||
private abstract fun bar(): jet.String
|
||||
public abstract fun foo(): jet.CharSequence
|
||||
}
|
||||
|
||||
public trait Super2 {
|
||||
public abstract fun bar(): jet.CharSequence
|
||||
private abstract fun foo(): jet.String
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package test
|
||||
|
||||
public trait Super1 {
|
||||
val x: String
|
||||
var y: String
|
||||
}
|
||||
|
||||
public trait Super2 {
|
||||
var x: String
|
||||
val y: String
|
||||
}
|
||||
|
||||
public trait Sub: Super1, Super2 {
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package test
|
||||
|
||||
public trait Sub : test.Super1, test.Super2 {
|
||||
internal abstract override /*2*/ /*fake_override*/ var x: jet.String
|
||||
internal abstract override /*2*/ /*fake_override*/ fun <get-x>(): jet.String
|
||||
internal abstract override /*1*/ /*fake_override*/ fun <set-x>(/*0*/ <set-?>: jet.String): jet.Unit
|
||||
internal abstract override /*2*/ /*fake_override*/ var y: jet.String
|
||||
internal abstract override /*2*/ /*fake_override*/ fun <get-y>(): jet.String
|
||||
internal abstract override /*1*/ /*fake_override*/ fun <set-y>(/*0*/ <set-?>: jet.String): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super1 {
|
||||
internal abstract val x: jet.String
|
||||
internal abstract fun <get-x>(): jet.String
|
||||
internal abstract var y: jet.String
|
||||
internal abstract fun <get-y>(): jet.String
|
||||
internal abstract fun <set-y>(/*0*/ <set-?>: jet.String): jet.Unit
|
||||
}
|
||||
|
||||
public trait Super2 {
|
||||
internal abstract var x: jet.String
|
||||
internal abstract fun <get-x>(): jet.String
|
||||
internal abstract fun <set-x>(/*0*/ <set-?>: jet.String): jet.Unit
|
||||
internal abstract val y: jet.String
|
||||
internal abstract fun <get-y>(): jet.String
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package test
|
||||
|
||||
public trait Super1 {
|
||||
val x: String
|
||||
val y: CharSequence
|
||||
}
|
||||
|
||||
public trait Super2 {
|
||||
val x: CharSequence
|
||||
val y: String
|
||||
}
|
||||
|
||||
public trait Sub: Super1, Super2 {
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package test
|
||||
|
||||
public trait Sub : test.Super1, test.Super2 {
|
||||
internal abstract override /*2*/ /*fake_override*/ val x: jet.String
|
||||
internal abstract override /*2*/ /*fake_override*/ fun <get-x>(): jet.String
|
||||
internal abstract override /*2*/ /*fake_override*/ val y: jet.String
|
||||
internal abstract override /*2*/ /*fake_override*/ fun <get-y>(): jet.String
|
||||
}
|
||||
|
||||
public trait Super1 {
|
||||
internal abstract val x: jet.String
|
||||
internal abstract fun <get-x>(): jet.String
|
||||
internal abstract val y: jet.CharSequence
|
||||
internal abstract fun <get-y>(): jet.CharSequence
|
||||
}
|
||||
|
||||
public trait Super2 {
|
||||
internal abstract val x: jet.CharSequence
|
||||
internal abstract fun <get-x>(): jet.CharSequence
|
||||
internal abstract val y: jet.String
|
||||
internal abstract fun <get-y>(): jet.String
|
||||
}
|
||||
@@ -8,4 +8,29 @@ fun test() {
|
||||
str
|
||||
|
||||
?.length
|
||||
|
||||
str
|
||||
|
||||
: String
|
||||
|
||||
str
|
||||
|
||||
as String
|
||||
|
||||
str
|
||||
|
||||
as? String
|
||||
|
||||
str
|
||||
|
||||
?: foo
|
||||
|
||||
true
|
||||
|
||||
|| false
|
||||
|
||||
|
||||
false
|
||||
|
||||
&& true
|
||||
}
|
||||
@@ -38,5 +38,71 @@ JetFile: NewLinesValidOperations.jet
|
||||
PsiElement(SAFE_ACCESS)('?.')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('length')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
BINARY_WITH_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('str')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
OPERATION_REFERENCE
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('String')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
BINARY_WITH_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('str')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
OPERATION_REFERENCE
|
||||
PsiElement(as)('as')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('String')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
BINARY_WITH_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('str')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
OPERATION_REFERENCE
|
||||
PsiElement(AS_SAFE)('as?')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('String')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
BINARY_EXPRESSION
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('str')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
OPERATION_REFERENCE
|
||||
PsiElement(ELVIS)('?:')
|
||||
PsiWhiteSpace(' ')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
BINARY_EXPRESSION
|
||||
BOOLEAN_CONSTANT
|
||||
PsiElement(true)('true') ª
|
||||
PsiWhiteSpace('\n\n ')
|
||||
OPERATION_REFERENCE
|
||||
PsiElement(OROR)('||')
|
||||
PsiWhiteSpace(' ')
|
||||
BOOLEAN_CONSTANT
|
||||
PsiElement(false)('false')
|
||||
PsiWhiteSpace('\n\n\n ')
|
||||
BINARY_EXPRESSION
|
||||
BOOLEAN_CONSTANT
|
||||
PsiElement(false)('false')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
OPERATION_REFERENCE
|
||||
PsiElement(ANDAND)('&&')
|
||||
PsiWhiteSpace(' ')
|
||||
BOOLEAN_CONSTANT
|
||||
PsiElement(true)('true')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
@@ -3,4 +3,4 @@ fun never(): Array<Int> = throw Exception()
|
||||
// method: _DefaultPackage::never
|
||||
// jvm signature: ()[Ljava/lang/Integer;
|
||||
// generic signature: null
|
||||
// kotlin signature: ()[Ljava/lang/Integer; // TODO: need to skip kotlin signature
|
||||
// kotlin signature: ()[Ljet/Int; // TODO: need to skip kotlin signature
|
||||
|
||||
@@ -3234,6 +3234,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/j+k/ambiguousSamAdapters.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("cantDeclareIfSamAdapterIsInherited.kt")
|
||||
public void testCantDeclareIfSamAdapterIsInherited() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/j+k/cantDeclareIfSamAdapterIsInherited.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inheritAbstractSamAdapter.kt")
|
||||
public void testInheritAbstractSamAdapter() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/j+k/inheritAbstractSamAdapter.kt");
|
||||
@@ -3314,6 +3319,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/j+k/packageVisibility.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("recursiveRawUpperBound.kt")
|
||||
public void testRecursiveRawUpperBound() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/j+k/recursiveRawUpperBound.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("Simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/j+k/Simple.kt");
|
||||
@@ -4572,6 +4582,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/resolve/invoke/invokeAsMemberExtensionToExplicitReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt3772.kt")
|
||||
public void testKt3772() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/resolve/invoke/kt3772.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Test innerSuite() {
|
||||
|
||||
-5
@@ -178,11 +178,6 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege
|
||||
doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/inheritedOverriddenAdapter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inheritedOverriddenAdapterInKotlin.kt")
|
||||
public void testInheritedOverriddenAdapterInKotlin() throws Exception {
|
||||
doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/inheritedOverriddenAdapterInKotlin.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inheritedSimple.kt")
|
||||
public void testInheritedSimple() throws Exception {
|
||||
doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/inheritedSimple.kt");
|
||||
|
||||
+15
-1
@@ -31,7 +31,7 @@ import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest;
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/codegen/boxWithStdlib")
|
||||
@InnerTestClasses({BlackBoxWithStdlibCodegenTestGenerated.Annotations.class, BlackBoxWithStdlibCodegenTestGenerated.Casts.class, BlackBoxWithStdlibCodegenTestGenerated.DataClasses.class, BlackBoxWithStdlibCodegenTestGenerated.FullJdk.class, BlackBoxWithStdlibCodegenTestGenerated.JdkAnnotations.class, BlackBoxWithStdlibCodegenTestGenerated.Ranges.class, BlackBoxWithStdlibCodegenTestGenerated.Regressions.class, BlackBoxWithStdlibCodegenTestGenerated.Strings.class})
|
||||
@InnerTestClasses({BlackBoxWithStdlibCodegenTestGenerated.Annotations.class, BlackBoxWithStdlibCodegenTestGenerated.Arrays.class, BlackBoxWithStdlibCodegenTestGenerated.Casts.class, BlackBoxWithStdlibCodegenTestGenerated.DataClasses.class, BlackBoxWithStdlibCodegenTestGenerated.FullJdk.class, BlackBoxWithStdlibCodegenTestGenerated.JdkAnnotations.class, BlackBoxWithStdlibCodegenTestGenerated.Ranges.class, BlackBoxWithStdlibCodegenTestGenerated.Regressions.class, BlackBoxWithStdlibCodegenTestGenerated.Strings.class})
|
||||
public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInBoxWithStdlib() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/boxWithStdlib"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
@@ -50,6 +50,19 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxWithStdlib/arrays")
|
||||
public static class Arrays extends AbstractBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInArrays() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/boxWithStdlib/arrays"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("kt3771.kt")
|
||||
public void testKt3771() throws Exception {
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/arrays/kt3771.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxWithStdlib/casts")
|
||||
public static class Casts extends AbstractBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInCasts() throws Exception {
|
||||
@@ -896,6 +909,7 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
TestSuite suite = new TestSuite("BlackBoxWithStdlibCodegenTestGenerated");
|
||||
suite.addTestSuite(BlackBoxWithStdlibCodegenTestGenerated.class);
|
||||
suite.addTestSuite(Annotations.class);
|
||||
suite.addTestSuite(Arrays.class);
|
||||
suite.addTestSuite(Casts.class);
|
||||
suite.addTest(DataClasses.innerSuite());
|
||||
suite.addTestSuite(FullJdk.class);
|
||||
|
||||
@@ -444,6 +444,21 @@ public class LoadCompiledKotlinTestGenerated extends AbstractLoadCompiledKotlinT
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadKotlin/fun"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("InheritMethodsDifferentReturnTypesAndVisibilities.kt")
|
||||
public void testInheritMethodsDifferentReturnTypesAndVisibilities() throws Exception {
|
||||
doTestWithAccessors("compiler/testData/loadKotlin/fun/InheritMethodsDifferentReturnTypesAndVisibilities.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritValAndVar.kt")
|
||||
public void testInheritValAndVar() throws Exception {
|
||||
doTestWithAccessors("compiler/testData/loadKotlin/fun/InheritValAndVar.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritValsDifferentTypes.kt")
|
||||
public void testInheritValsDifferentTypes() throws Exception {
|
||||
doTestWithAccessors("compiler/testData/loadKotlin/fun/InheritValsDifferentTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NoSamAdapter.kt")
|
||||
public void testNoSamAdapter() throws Exception {
|
||||
doTestWithAccessors("compiler/testData/loadKotlin/fun/NoSamAdapter.kt");
|
||||
|
||||
@@ -94,6 +94,16 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
||||
doTest("compiler/testData/loadJava/compiledJavaCompareWithKotlin/FinalFieldAsVal.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritMethodsDifferentReturnTypes.java")
|
||||
public void testInheritMethodsDifferentReturnTypes() throws Exception {
|
||||
doTest("compiler/testData/loadJava/compiledJavaCompareWithKotlin/InheritMethodsDifferentReturnTypes.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritMethodsDifferentReturnTypesGeneric.java")
|
||||
public void testInheritMethodsDifferentReturnTypesGeneric() throws Exception {
|
||||
doTest("compiler/testData/loadJava/compiledJavaCompareWithKotlin/InheritMethodsDifferentReturnTypesGeneric.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InnerClass.java")
|
||||
public void testInnerClass() throws Exception {
|
||||
doTest("compiler/testData/loadJava/compiledJavaCompareWithKotlin/InnerClass.java");
|
||||
@@ -1201,6 +1211,7 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledJava/sam/adapters")
|
||||
@InnerTestClasses({Adapters.Inheritance.class})
|
||||
public static class Adapters extends AbstractLoadJavaTest {
|
||||
public void testAllFilesPresentInAdapters() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/compiledJava/sam/adapters"), Pattern.compile("^(.+)\\.java$"), true);
|
||||
@@ -1226,21 +1237,6 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/DeepSamLoop.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedOverridden.java")
|
||||
public void testInheritedOverridden() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/InheritedOverridden.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedOverriddenAdapter.java")
|
||||
public void testInheritedOverriddenAdapter() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/InheritedOverriddenAdapter.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedSimple.java")
|
||||
public void testInheritedSimple() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/InheritedSimple.java");
|
||||
}
|
||||
|
||||
@TestMetadata("NonTrivialFunctionType.java")
|
||||
public void testNonTrivialFunctionType() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/NonTrivialFunctionType.java");
|
||||
@@ -1271,12 +1267,76 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/TypeParameterOfOuterClass.java");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance")
|
||||
public static class Inheritance extends AbstractLoadJavaTest {
|
||||
@TestMetadata("AdapterDoesntOverrideDeclaration.java")
|
||||
public void testAdapterDoesntOverrideDeclaration() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/AdapterDoesntOverrideDeclaration.java");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInInheritance() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance"), Pattern.compile("^(.+)\\.java$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedAdapterAndDeclaration.java")
|
||||
public void testInheritedAdapterAndDeclaration() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedAdapterAndDeclaration.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedAmbiguousAdapters.java")
|
||||
public void testInheritedAmbiguousAdapters() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedAmbiguousAdapters.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedAndOverriddenAmbiguousAdapters.java")
|
||||
public void testInheritedAndOverriddenAmbiguousAdapters() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedAndOverriddenAmbiguousAdapters.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedOverridden.java")
|
||||
public void testInheritedOverridden() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedOverridden.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedOverriddenAdapter.java")
|
||||
public void testInheritedOverriddenAdapter() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedOverriddenAdapter.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedSameAdapters.java")
|
||||
public void testInheritedSameAdapters() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedSameAdapters.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedSameAdaptersWithSubstitution.java")
|
||||
public void testInheritedSameAdaptersWithSubstitution() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedSameAdaptersWithSubstitution.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritedSimple.java")
|
||||
public void testInheritedSimple() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedSimple.java");
|
||||
}
|
||||
|
||||
@TestMetadata("OverriddenAmbiguousAdapters.java")
|
||||
public void testOverriddenAmbiguousAdapters() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/OverriddenAmbiguousAdapters.java");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Test innerSuite() {
|
||||
TestSuite suite = new TestSuite("Adapters");
|
||||
suite.addTestSuite(Adapters.class);
|
||||
suite.addTestSuite(Inheritance.class);
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
|
||||
public static Test innerSuite() {
|
||||
TestSuite suite = new TestSuite("Sam");
|
||||
suite.addTestSuite(Sam.class);
|
||||
suite.addTestSuite(Adapters.class);
|
||||
suite.addTest(Adapters.innerSuite());
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
@@ -1422,6 +1482,11 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/javaAgainstKotlin/samAdapters"), Pattern.compile("^(.+)\\.txt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("InheritAmbguousSamAdaptersInKotlin.txt")
|
||||
public void testInheritAmbguousSamAdaptersInKotlin() throws Exception {
|
||||
doTestJavaAgainstKotlin("compiler/testData/loadJava/javaAgainstKotlin/samAdapters/InheritAmbguousSamAdaptersInKotlin.txt");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritSamAdapterInKotlin.txt")
|
||||
public void testInheritSamAdapterInKotlin() throws Exception {
|
||||
doTestJavaAgainstKotlin("compiler/testData/loadJava/javaAgainstKotlin/samAdapters/InheritSamAdapterInKotlin.txt");
|
||||
|
||||
+25
@@ -446,6 +446,21 @@ public class LazyResolveNamespaceComparingTestGenerated extends AbstractLazyReso
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadKotlin/fun"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("InheritMethodsDifferentReturnTypesAndVisibilities.kt")
|
||||
public void testInheritMethodsDifferentReturnTypesAndVisibilities() throws Exception {
|
||||
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadKotlin/fun/InheritMethodsDifferentReturnTypesAndVisibilities.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritValAndVar.kt")
|
||||
public void testInheritValAndVar() throws Exception {
|
||||
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadKotlin/fun/InheritValAndVar.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritValsDifferentTypes.kt")
|
||||
public void testInheritValsDifferentTypes() throws Exception {
|
||||
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadKotlin/fun/InheritValsDifferentTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NoSamAdapter.kt")
|
||||
public void testNoSamAdapter() throws Exception {
|
||||
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadKotlin/fun/NoSamAdapter.kt");
|
||||
@@ -1186,6 +1201,16 @@ public class LazyResolveNamespaceComparingTestGenerated extends AbstractLazyReso
|
||||
doTestNotCheckingPrimaryConstructors("compiler/testData/loadJava/compiledJavaCompareWithKotlin/FinalFieldAsVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritMethodsDifferentReturnTypes.kt")
|
||||
public void testInheritMethodsDifferentReturnTypes() throws Exception {
|
||||
doTestNotCheckingPrimaryConstructors("compiler/testData/loadJava/compiledJavaCompareWithKotlin/InheritMethodsDifferentReturnTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritMethodsDifferentReturnTypesGeneric.kt")
|
||||
public void testInheritMethodsDifferentReturnTypesGeneric() throws Exception {
|
||||
doTestNotCheckingPrimaryConstructors("compiler/testData/loadJava/compiledJavaCompareWithKotlin/InheritMethodsDifferentReturnTypesGeneric.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InnerClass.kt")
|
||||
public void testInnerClass() throws Exception {
|
||||
doTestNotCheckingPrimaryConstructors("compiler/testData/loadJava/compiledJavaCompareWithKotlin/InnerClass.kt");
|
||||
|
||||
@@ -39,9 +39,9 @@ abstract class Actor(protected val executor: Executor, val fair: Boolean = false
|
||||
}
|
||||
else {
|
||||
val removed = q.removeFirst()
|
||||
val newQueue = if(removed._2.empty) busyEmptyQueue else removed._2
|
||||
val newQueue = if(removed.second.empty) busyEmptyQueue else removed.second
|
||||
if(compareAndSet(q, newQueue)) {
|
||||
doProcess(removed._1)
|
||||
doProcess(removed.first)
|
||||
executor.execute(this)
|
||||
break
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.jetbrains.jet.plugin.quickfix.AbstractQuickFixMultiFileTest;
|
||||
import org.jetbrains.jet.plugin.quickfix.AbstractQuickFixTest;
|
||||
import org.jetbrains.jet.psi.AbstractJetPsiMatcherTest;
|
||||
import org.jetbrains.jet.resolve.AbstractResolveTest;
|
||||
import org.jetbrains.jet.safeDelete.AbstractJetSafeDeleteTest;
|
||||
import org.jetbrains.jet.test.generator.SimpleTestClassModel;
|
||||
import org.jetbrains.jet.test.generator.TestClassModel;
|
||||
import org.jetbrains.jet.test.generator.TestGenerator;
|
||||
@@ -395,6 +396,17 @@ public class GenerateTests {
|
||||
AbstractJetQuickDocProviderTest.class,
|
||||
testModel("idea/testData/editor/quickDoc", "doTest")
|
||||
);
|
||||
|
||||
generateTest(
|
||||
"idea/tests/",
|
||||
"JetSafeDeleteTestGenerated",
|
||||
AbstractJetSafeDeleteTest.class,
|
||||
testModel("idea/testData/safeDelete/deleteClass", "doClassTest"),
|
||||
testModel("idea/testData/safeDelete/deleteObject", "doObjectTest"),
|
||||
testModel("idea/testData/safeDelete/deleteFunction", "doFunctionTest"),
|
||||
testModel("idea/testData/safeDelete/deleteFunctionWithJavaUsages", "doFunctionTestWithJava"),
|
||||
testModel("idea/testData/safeDelete/deleteJavaMethod", "doJavaMethodTest")
|
||||
);
|
||||
}
|
||||
|
||||
private static SimpleTestClassModel testModel(@NotNull String rootPath) {
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
<orderEntry type="module" module-name="jet.as.java.psi" />
|
||||
<orderEntry type="library" name="idea-full" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="junit-plugin" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="testng-plugin" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="copyright-plugin" level="project" />
|
||||
<orderEntry type="module" module-name="j2k" />
|
||||
<orderEntry type="module" module-name="js.translator" />
|
||||
@@ -33,6 +34,8 @@
|
||||
<orderEntry type="module" module-name="ide-compiler-runner" />
|
||||
<orderEntry type="module" module-name="cli-common" />
|
||||
<orderEntry type="module" module-name="jps-plugin" scope="TEST" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="properties" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="java-i18n" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<idea-plugin>
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<configurationProducer implementation="org.jetbrains.jet.plugin.run.JetJUnitConfigurationProducer"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
<idea-version since-build="130.555" until-build="131.0"/>
|
||||
|
||||
<depends optional="true">JUnit</depends>
|
||||
<depends optional="true" config-file="junit.xml">JUnit</depends>
|
||||
<depends optional="true" config-file="testng-j.xml">TestNG-J</depends>
|
||||
<depends optional="true" config-file="kotlin-copyright.xml">com.intellij.copyright</depends>
|
||||
|
||||
<project-components>
|
||||
@@ -52,6 +53,7 @@
|
||||
<action id="ShowJetExpressionType" class="org.jetbrains.jet.plugin.actions.ShowExpressionTypeAction"
|
||||
text="Show Expression Type">
|
||||
<keyboard-shortcut keymap="$default" first-keystroke="control shift Q"/>
|
||||
<keyboard-shortcut keymap="Mac OS X" first-keystroke="control shift T"/>
|
||||
<add-to-group group-id="CodeMenu" anchor="last"/>
|
||||
</action>
|
||||
<action id="CopyAsDiagnosticTest" class="org.jetbrains.jet.plugin.actions.CopyAsDiagnosticTestAction"
|
||||
@@ -209,7 +211,6 @@
|
||||
<configurationType implementation="org.jetbrains.jet.plugin.k2jsrun.K2JSRunConfigurationType"/>
|
||||
<programRunner implementation="org.jetbrains.jet.plugin.k2jsrun.K2JSBrowserProgramRunner"/>
|
||||
<configurationProducer implementation="org.jetbrains.jet.plugin.run.JetRunConfigurationProducer"/>
|
||||
<configurationProducer implementation="org.jetbrains.jet.plugin.run.JetJUnitConfigurationProducer"/>
|
||||
<codeInsight.lineMarkerProvider language="jet" implementationClass="org.jetbrains.jet.plugin.highlighter.JetLineMarkerProvider"/>
|
||||
<codeInsight.lineMarkerProvider language="JAVA"
|
||||
implementationClass="org.jetbrains.jet.plugin.ktSignature.KotlinSignatureInJavaMarkerProvider"/>
|
||||
@@ -226,6 +227,11 @@
|
||||
order="first"/>
|
||||
<elementDescriptionProvider implementation="org.jetbrains.jet.plugin.findUsages.JetElementDescriptionProvider"/>
|
||||
<findUsagesHandlerFactory implementation="org.jetbrains.jet.plugin.findUsages.KotlinFindUsagesHandlerFactory"/>
|
||||
<usageTypeProvider implementation="org.jetbrains.jet.plugin.findUsages.JetUsageTypeProvider"/>
|
||||
<refactoring.safeDeleteProcessor
|
||||
id="kotlinProcessor"
|
||||
implementation="org.jetbrains.jet.plugin.refactoring.safeDelete.KotlinSafeDeleteProcessor"
|
||||
order="before javaProcessor"/>
|
||||
<debugger.positionManagerFactory implementation="org.jetbrains.jet.plugin.debugger.JetPositionManagerFactory"/>
|
||||
<codeInsight.implementMethod language="jet" implementationClass="org.jetbrains.jet.plugin.codeInsight.ImplementMethodsHandler"/>
|
||||
<codeInsight.overrideMethod language="jet" implementationClass="org.jetbrains.jet.plugin.codeInsight.OverrideMethodsHandler"/>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<idea-plugin>
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<configurationProducer implementation="org.jetbrains.jet.plugin.run.JetTestNgConfigurationProducer"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -232,4 +232,30 @@ add.function.to.type.action.type.chooser=Choose type...
|
||||
remove.expression = Remove ''{0}''
|
||||
unwrap.expression = Unwrap ''{0}''
|
||||
remove.else = Remove else in ''{0}''
|
||||
unwrap.else = Unwrap else in ''{0}''
|
||||
unwrap.else = Unwrap else in ''{0}''
|
||||
|
||||
usageType.annotation.type = Annotation
|
||||
usageType.import = Import directive
|
||||
usageType.callable.reference = Callable reference
|
||||
usageType.type.constraint = Type constraint
|
||||
usageType.type.argument = Type argument
|
||||
usageType.value.parameter.type = Parameter type
|
||||
usageType.nonLocal.property.type = Class/object property type
|
||||
usageType.local.variable.type = Local variable type
|
||||
usageType.function.return.type = Function return types
|
||||
usageType.superType = Supertype
|
||||
usageType.type.definition = Type definition
|
||||
usageType.is = Target type of 'is' operation
|
||||
usageType.as = Target type of 'as' operation
|
||||
usageType.class.object = Nested class/object
|
||||
usageType.instantiation = Instantiation
|
||||
usageType.function.call = Function call
|
||||
usageType.extension.receiver.type = Extension receiver type
|
||||
usageType.super.type.qualifier = Super type qualifier
|
||||
usageType.receiver = Receiver
|
||||
usageType.selector = Selector
|
||||
|
||||
x.in.y={0} in {1}
|
||||
x.implements.y={0} in {1} implements {2} in {3}.
|
||||
x.overrides.y.in.class.list={0} in {1} overrides functions in the following classes/traits: {2} Do you want to delete (with usage search) the base methods?
|
||||
unused.overriding.methods.title=Unused Overriding Methods
|
||||
+8
-2
@@ -47,9 +47,15 @@ public abstract class AbstractJetUpDownMover extends LineMover {
|
||||
LineRange lineRange2 = getElementSourceLineRange(combinedRange.second, editor, oldRange);
|
||||
if (lineRange2 == null) return null;
|
||||
|
||||
LineRange parentLineRange = getElementSourceLineRange(parent, editor, oldRange);
|
||||
|
||||
LineRange sourceRange = new LineRange(lineRange1.startLine, lineRange2.endLine);
|
||||
sourceRange.firstElement = combinedRange.first;
|
||||
sourceRange.lastElement = combinedRange.second;
|
||||
if (parentLineRange != null && sourceRange.contains(parentLineRange)) {
|
||||
sourceRange.firstElement = sourceRange.lastElement = parent;
|
||||
} else {
|
||||
sourceRange.firstElement = combinedRange.first;
|
||||
sourceRange.lastElement = combinedRange.second;
|
||||
}
|
||||
|
||||
return sourceRange;
|
||||
}
|
||||
|
||||
@@ -20,9 +20,10 @@ import com.intellij.psi.ElementDescriptionLocation;
|
||||
import com.intellij.psi.ElementDescriptionProvider;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiNamedElement;
|
||||
import com.intellij.refactoring.util.RefactoringDescriptionLocation;
|
||||
import com.intellij.usageView.UsageViewLongNameLocation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
|
||||
public class JetElementDescriptionProvider implements ElementDescriptionProvider {
|
||||
@Override
|
||||
@@ -32,6 +33,21 @@ public class JetElementDescriptionProvider implements ElementDescriptionProvider
|
||||
return ((PsiNamedElement)element).getName();
|
||||
}
|
||||
}
|
||||
else if (location instanceof RefactoringDescriptionLocation) {
|
||||
if (element instanceof JetClass) {
|
||||
JetClass jetClass = (JetClass) element;
|
||||
return (jetClass.isTrait() ? "Trait " : "Class ") + jetClass.getName();
|
||||
}
|
||||
if (element instanceof JetObjectDeclaration || element instanceof JetObjectDeclarationName) {
|
||||
return "Object " + ((PsiNamedElement)element).getName();
|
||||
}
|
||||
if (element instanceof JetNamedFunction) {
|
||||
return "Function " + ((PsiNamedElement)element).getName();
|
||||
}
|
||||
if (element instanceof JetProperty) {
|
||||
return "Property " + ((PsiNamedElement)element).getName();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.plugin.findUsages;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.usages.UsageTarget;
|
||||
import com.intellij.usages.impl.rules.UsageType;
|
||||
import com.intellij.usages.impl.rules.UsageTypeProviderEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
||||
|
||||
public class JetUsageTypeProvider implements UsageTypeProviderEx {
|
||||
private static final Predicate<PsiElement> IS_ASSIGNMENT = new Predicate<PsiElement>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable PsiElement input) {
|
||||
return input != null && JetPsiUtil.isAssignment(input);
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public UsageType getUsageType(PsiElement element) {
|
||||
return getUsageType(element, UsageTarget.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public UsageType getUsageType(PsiElement element, @NotNull UsageTarget[] targets) {
|
||||
if (element == null) return null;
|
||||
|
||||
UsageType usageType = getCommonUsageType(element);
|
||||
if (usageType != null) return usageType;
|
||||
|
||||
JetSimpleNameExpression reference = PsiTreeUtil.getParentOfType(element, JetSimpleNameExpression.class, false);
|
||||
if (reference == null) return null;
|
||||
|
||||
BindingContext bindingContext =
|
||||
AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) element.getContainingFile()).getBindingContext();
|
||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, reference);
|
||||
|
||||
if (descriptor instanceof ClassifierDescriptor) {
|
||||
return getClassUsageType(element);
|
||||
}
|
||||
if (descriptor instanceof VariableDescriptor) {
|
||||
return getVariableUsageType(element);
|
||||
}
|
||||
if (descriptor instanceof FunctionDescriptor) {
|
||||
return getFunctionUsageType(element, (FunctionDescriptor) descriptor);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static UsageType getCommonUsageType(@NotNull PsiElement element) {
|
||||
JetImportDirective importDirective = PsiTreeUtil.getParentOfType(element, JetImportDirective.class, false);
|
||||
if (importDirective != null) return JetUsageTypes.IMPORT_DIRECTIVE;
|
||||
|
||||
JetCallableReferenceExpression callableReference =
|
||||
PsiTreeUtil.getParentOfType(element, JetCallableReferenceExpression.class, false);
|
||||
if (callableReference != null && PsiTreeUtil.isAncestor(callableReference.getCallableReference(), element, false)) {
|
||||
return JetUsageTypes.CALLABLE_REFERENCE;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static UsageType getClassUsageType(@NotNull PsiElement element) {
|
||||
JetTypeParameter typeParameter = PsiTreeUtil.getParentOfType(element, JetTypeParameter.class, false);
|
||||
if (typeParameter != null && PsiTreeUtil.isAncestor(typeParameter.getExtendsBound(), element, false)) {
|
||||
return JetUsageTypes.TYPE_CONSTRAINT;
|
||||
}
|
||||
|
||||
JetTypeConstraint typeConstraint = PsiTreeUtil.getParentOfType(element, JetTypeConstraint.class, false);
|
||||
if (typeConstraint != null && PsiTreeUtil.isAncestor(typeConstraint.getBoundTypeReference(), element, false)) {
|
||||
return JetUsageTypes.TYPE_CONSTRAINT;
|
||||
}
|
||||
|
||||
JetDelegationSpecifier delegationSpecifier = PsiTreeUtil.getParentOfType(element, JetDelegationSpecifier.class, false);
|
||||
if (delegationSpecifier != null
|
||||
&& (delegationSpecifier == element || PsiTreeUtil.isAncestor(delegationSpecifier.getTypeReference(), element, false))) {
|
||||
return JetUsageTypes.SUPER_TYPE;
|
||||
}
|
||||
|
||||
JetTypedef typedef = PsiTreeUtil.getParentOfType(element, JetTypedef.class, false);
|
||||
if (typedef != null && PsiTreeUtil.isAncestor(typedef.getTypeReference(), element, false)) {
|
||||
return JetUsageTypes.TYPE_DEFINITION;
|
||||
}
|
||||
|
||||
JetTypeProjection typeProjection = PsiTreeUtil.getParentOfType(element, JetTypeProjection.class, false);
|
||||
if (typeProjection != null) return JetUsageTypes.TYPE_ARGUMENT;
|
||||
|
||||
JetParameter parameter = PsiTreeUtil.getParentOfType(element, JetParameter.class, false);
|
||||
if (parameter != null) {
|
||||
if (PsiTreeUtil.isAncestor(parameter.getTypeReference(), element, false)) return JetUsageTypes.VALUE_PARAMETER_TYPE;
|
||||
}
|
||||
|
||||
JetProperty property = PsiTreeUtil.getParentOfType(element, JetProperty.class, false);
|
||||
if (property != null) {
|
||||
if (PsiTreeUtil.isAncestor(property.getTypeRef(), element, false)) {
|
||||
return property.isLocal() ? JetUsageTypes.LOCAL_VARIABLE_TYPE : JetUsageTypes.NON_LOCAL_PROPERTY_TYPE;
|
||||
}
|
||||
if (PsiTreeUtil.isAncestor(property.getReceiverTypeRef(), element, false)) {
|
||||
return JetUsageTypes.EXTENSION_RECEIVER_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
JetFunction function = PsiTreeUtil.getParentOfType(element, JetFunction.class, false);
|
||||
if (function != null) {
|
||||
if (PsiTreeUtil.isAncestor(function.getReturnTypeRef(), element, false)) {
|
||||
return JetUsageTypes.FUNCTION_RETURN_TYPE;
|
||||
}
|
||||
if (PsiTreeUtil.isAncestor(function.getReceiverTypeRef(), element, false)) {
|
||||
return JetUsageTypes.EXTENSION_RECEIVER_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
JetIsExpression isExpression = PsiTreeUtil.getParentOfType(element, JetIsExpression.class, false);
|
||||
if (isExpression != null && PsiTreeUtil.isAncestor(isExpression.getTypeRef(), element, false)) {
|
||||
return JetUsageTypes.IS;
|
||||
}
|
||||
|
||||
JetBinaryExpressionWithTypeRHS typeRHSExpression =
|
||||
PsiTreeUtil.getParentOfType(element, JetBinaryExpressionWithTypeRHS.class, false);
|
||||
if (typeRHSExpression != null && PsiTreeUtil.isAncestor(typeRHSExpression.getRight(), element, false)) {
|
||||
IElementType opType = typeRHSExpression.getOperationReference().getReferencedNameElementType();
|
||||
if (opType == JetTokens.AS_KEYWORD || opType == JetTokens.AS_SAFE) return JetUsageTypes.AS;
|
||||
}
|
||||
|
||||
JetDotQualifiedExpression dotQualifiedExpression = PsiTreeUtil.getParentOfType(element, JetDotQualifiedExpression.class, false);
|
||||
if (dotQualifiedExpression != null
|
||||
&& dotQualifiedExpression.getReceiverExpression() instanceof JetSimpleNameExpression
|
||||
&& PsiTreeUtil.isAncestor(dotQualifiedExpression.getReceiverExpression(), element, false)) {
|
||||
|
||||
return JetUsageTypes.CLASS_OBJECT_ACCESS;
|
||||
}
|
||||
|
||||
JetSuperExpression superExpression = PsiTreeUtil.getParentOfType(element, JetSuperExpression.class, false);
|
||||
if (superExpression != null && PsiTreeUtil.isAncestor(superExpression.getSuperTypeQualifier(), element, false)) {
|
||||
return JetUsageTypes.SUPER_TYPE_QUALIFIER;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static UsageType getFunctionUsageType(@NotNull PsiElement element, @NotNull FunctionDescriptor descriptor) {
|
||||
if (descriptor instanceof ConstructorDescriptor) {
|
||||
JetAnnotationEntry annotation = PsiTreeUtil.getParentOfType(element, JetAnnotationEntry.class, false);
|
||||
if (annotation != null && PsiTreeUtil.isAncestor(annotation.getTypeReference(), element, false)) {
|
||||
return JetUsageTypes.ANNOTATION_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
JetCallExpression callExpression = PsiTreeUtil.getParentOfType(element, JetCallExpression.class, false);
|
||||
if (callExpression != null
|
||||
&& callExpression.getCalleeExpression() instanceof JetSimpleNameExpression
|
||||
&& PsiTreeUtil.isAncestor(callExpression.getCalleeExpression(), element, false)) {
|
||||
|
||||
return (descriptor instanceof ConstructorDescriptor) ? JetUsageTypes.INSTANTIATION : JetUsageTypes.FUNCTION_CALL;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static UsageType getVariableUsageType(@NotNull PsiElement element) {
|
||||
JetDotQualifiedExpression dotQualifiedExpression = PsiTreeUtil.getParentOfType(element, JetDotQualifiedExpression.class, false);
|
||||
if (dotQualifiedExpression != null) {
|
||||
if (PsiTreeUtil.isAncestor(dotQualifiedExpression.getReceiverExpression(), element, false)) {
|
||||
return JetUsageTypes.RECEIVER;
|
||||
}
|
||||
|
||||
PsiElement parent = dotQualifiedExpression.getParent();
|
||||
if (parent instanceof JetDotQualifiedExpression
|
||||
&& PsiTreeUtil.isAncestor(((JetDotQualifiedExpression) parent).getReceiverExpression(), element, false)) {
|
||||
return JetUsageTypes.RECEIVER;
|
||||
}
|
||||
|
||||
return JetUsageTypes.SELECTOR;
|
||||
}
|
||||
|
||||
JetBinaryExpression binaryExpression =
|
||||
(JetBinaryExpression) JetPsiUtil.getParentByTypeAndPredicate(element, JetBinaryExpression.class, IS_ASSIGNMENT, false);
|
||||
if (binaryExpression != null && PsiTreeUtil.isAncestor(binaryExpression.getLeft(), element, false)) {
|
||||
return UsageType.WRITE;
|
||||
}
|
||||
|
||||
JetSimpleNameExpression simpleNameExpression = PsiTreeUtil.getParentOfType(element, JetSimpleNameExpression.class, false);
|
||||
if (simpleNameExpression != null) {
|
||||
return UsageType.READ;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.plugin.findUsages;
|
||||
|
||||
import com.intellij.usages.impl.rules.UsageType;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
public class JetUsageTypes {
|
||||
private JetUsageTypes() {
|
||||
}
|
||||
|
||||
// Type-related usages
|
||||
public static final UsageType ANNOTATION_TYPE = new UsageType(JetBundle.message("usageType.annotation.type"));
|
||||
public static final UsageType TYPE_CONSTRAINT = new UsageType(JetBundle.message("usageType.type.constraint"));
|
||||
public static final UsageType TYPE_ARGUMENT = new UsageType(JetBundle.message("usageType.type.argument"));
|
||||
public static final UsageType VALUE_PARAMETER_TYPE = new UsageType(JetBundle.message("usageType.value.parameter.type"));
|
||||
public static final UsageType NON_LOCAL_PROPERTY_TYPE = new UsageType(JetBundle.message("usageType.nonLocal.property.type"));
|
||||
public static final UsageType LOCAL_VARIABLE_TYPE = new UsageType(JetBundle.message("usageType.local.variable.type"));
|
||||
public static final UsageType FUNCTION_RETURN_TYPE = new UsageType(JetBundle.message("usageType.function.return.type"));
|
||||
public static final UsageType SUPER_TYPE = new UsageType(JetBundle.message("usageType.superType"));
|
||||
public static final UsageType TYPE_DEFINITION = new UsageType(JetBundle.message("usageType.type.definition"));
|
||||
public static final UsageType AS = new UsageType(JetBundle.message("usageType.as"));
|
||||
public static final UsageType IS = new UsageType(JetBundle.message("usageType.is"));
|
||||
public static final UsageType CLASS_OBJECT_ACCESS = new UsageType(JetBundle.message("usageType.class.object"));
|
||||
public static final UsageType EXTENSION_RECEIVER_TYPE = new UsageType(JetBundle.message("usageType.extension.receiver.type"));
|
||||
public static final UsageType SUPER_TYPE_QUALIFIER = new UsageType(JetBundle.message("usageType.super.type.qualifier"));
|
||||
|
||||
// Function-related usages
|
||||
public static final UsageType INSTANTIATION = new UsageType(JetBundle.message("usageType.instantiation"));
|
||||
public static final UsageType FUNCTION_CALL = new UsageType(JetBundle.message("usageType.function.call"));
|
||||
|
||||
// Value-related usages
|
||||
public static final UsageType RECEIVER = new UsageType(JetBundle.message("usageType.receiver"));
|
||||
public static final UsageType SELECTOR = new UsageType(JetBundle.message("usageType.selector"));
|
||||
|
||||
// Miscellaneous usages
|
||||
public static final UsageType IMPORT_DIRECTIVE = new UsageType(JetBundle.message("usageType.import"));
|
||||
public static final UsageType CALLABLE_REFERENCE = new UsageType(JetBundle.message("usageType.callable.reference"));
|
||||
}
|
||||
@@ -21,16 +21,21 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import com.intellij.refactoring.changeSignature.ChangeSignatureHandler;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetFunction;
|
||||
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.plugin.refactoring.changeSignature.JetChangeSignatureHandler;
|
||||
import org.jetbrains.jet.plugin.refactoring.introduceVariable.JetIntroduceVariableHandler;
|
||||
import org.jetbrains.jet.plugin.refactoring.safeDelete.KotlinSafeDeleteProcessor;
|
||||
|
||||
/**
|
||||
* User: Alefas
|
||||
* Date: 25.01.12
|
||||
*/
|
||||
public class JetRefactoringSupportProvider extends RefactoringSupportProvider {
|
||||
@Override
|
||||
public boolean isSafeDeleteAvailable(PsiElement element) {
|
||||
return KotlinSafeDeleteProcessor.canDeleteElement(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefactoringActionHandler getIntroduceVariableHandler() {
|
||||
return new JetIntroduceVariableHandler();
|
||||
|
||||
+295
@@ -0,0 +1,295 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.plugin.refactoring.safeDelete;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.refactoring.HelpID;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.ui.BooleanTableCellRenderer;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usages.impl.UsagePreviewPanel;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.java.JetClsMethod;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* Mostly copied from com.intellij.refactoring.safeDelete.OverridingMethodsDialog
|
||||
* Revision: 14aa2e2
|
||||
* (replace PsiMethod formatting)
|
||||
*/
|
||||
class KotlinOverridingMethodsDialog extends DialogWrapper {
|
||||
private final List<UsageInfo> myOverridingMethods;
|
||||
private final String[] myMethodText;
|
||||
private final boolean[] myChecked;
|
||||
|
||||
private static final int CHECK_COLUMN = 0;
|
||||
private JBTable myTable;
|
||||
private final UsagePreviewPanel myUsagePreviewPanel;
|
||||
|
||||
public KotlinOverridingMethodsDialog(Project project, List<UsageInfo> overridingMethods) {
|
||||
super(project, true);
|
||||
myOverridingMethods = overridingMethods;
|
||||
myChecked = new boolean[myOverridingMethods.size()];
|
||||
for (int i = 0; i < myChecked.length; i++) {
|
||||
myChecked[i] = true;
|
||||
}
|
||||
|
||||
myMethodText = new String[myOverridingMethods.size()];
|
||||
for (int i = 0; i < myMethodText.length; i++) {
|
||||
myMethodText[i] = formatMethod(((KotlinSafeDeleteOverridingMethodUsageInfo) myOverridingMethods.get(i)).getOverridingMethod());
|
||||
}
|
||||
myUsagePreviewPanel = new UsagePreviewPanel(project);
|
||||
setTitle(JetBundle.message("unused.overriding.methods.title"));
|
||||
init();
|
||||
}
|
||||
|
||||
private static String formatMethod(PsiMethod method) {
|
||||
if (method instanceof JetClsMethod) {
|
||||
JetNamedFunction function = (JetNamedFunction) ((JetClsMethod) method).getOrigin();
|
||||
|
||||
BindingContext bindingContext =
|
||||
AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) function.getContainingFile()).getBindingContext();
|
||||
|
||||
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, function);
|
||||
if (declarationDescriptor instanceof FunctionDescriptor) {
|
||||
DeclarationDescriptor containingDescriptor = declarationDescriptor.getContainingDeclaration();
|
||||
if (containingDescriptor instanceof ClassDescriptor) {
|
||||
return JetBundle.message(
|
||||
"x.in.y",
|
||||
DescriptorRenderer.COMPACT.render(declarationDescriptor),
|
||||
DescriptorRenderer.SOURCE_CODE_SHORT_NAMES_IN_TYPES.render(containingDescriptor)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return KotlinSafeDeleteProcessor.formatPsiMethod(method, true, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDimensionServiceKey() {
|
||||
return "#org.jetbrains.jet.plugin.refactoring.safeDelete.KotlinOverridingMethodsDialog";
|
||||
}
|
||||
|
||||
public ArrayList<UsageInfo> getSelected() {
|
||||
ArrayList<UsageInfo> result = new ArrayList<UsageInfo>();
|
||||
for (int i = 0; i < myChecked.length; i++) {
|
||||
if (myChecked[i]) {
|
||||
result.add(myOverridingMethods.get(i));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Action[] createActions() {
|
||||
return new Action[] {getOKAction(), getCancelAction()};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doHelpAction() {
|
||||
HelpManager.getInstance().invokeHelp(HelpID.SAFE_DELETE_OVERRIDING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createNorthPanel() {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||
panel.add(new JLabel(RefactoringBundle.message("there.are.unused.methods.that.override.methods.you.delete")));
|
||||
panel.add(new JLabel(RefactoringBundle.message("choose.the.ones.you.want.to.be.deleted")));
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return myTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispose() {
|
||||
Disposer.dispose(myUsagePreviewPanel);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(8, 0, 4, 0));
|
||||
final MyTableModel tableModel = new MyTableModel();
|
||||
myTable = new JBTable(tableModel);
|
||||
myTable.setShowGrid(false);
|
||||
|
||||
TableColumnModel columnModel = myTable.getColumnModel();
|
||||
int checkBoxWidth = new JCheckBox().getPreferredSize().width;
|
||||
columnModel.getColumn(CHECK_COLUMN).setCellRenderer(new BooleanTableCellRenderer());
|
||||
columnModel.getColumn(CHECK_COLUMN).setMaxWidth(checkBoxWidth);
|
||||
columnModel.getColumn(CHECK_COLUMN).setMinWidth(checkBoxWidth);
|
||||
|
||||
|
||||
// make SPACE check/uncheck selected rows
|
||||
InputMap inputMap = myTable.getInputMap();
|
||||
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "enable_disable");
|
||||
ActionMap actionMap = myTable.getActionMap();
|
||||
actionMap.put("enable_disable", new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (myTable.isEditing()) return;
|
||||
int[] rows = myTable.getSelectedRows();
|
||||
if (rows.length > 0) {
|
||||
boolean valueToBeSet = false;
|
||||
for (int row : rows) {
|
||||
if (!myChecked[row]) {
|
||||
valueToBeSet = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int row : rows) {
|
||||
myChecked[row] = valueToBeSet;
|
||||
}
|
||||
|
||||
tableModel.updateData();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
panel.setLayout(new BorderLayout());
|
||||
|
||||
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable);
|
||||
|
||||
panel.add(scrollPane, BorderLayout.CENTER);
|
||||
ListSelectionListener selectionListener = new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
int index = myTable.getSelectionModel().getLeadSelectionIndex();
|
||||
if (index != -1) {
|
||||
UsageInfo usageInfo = myOverridingMethods.get(index);
|
||||
myUsagePreviewPanel.updateLayout(Collections.singletonList(usageInfo));
|
||||
}
|
||||
else {
|
||||
myUsagePreviewPanel.updateLayout(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
myTable.getSelectionModel().addListSelectionListener(selectionListener);
|
||||
|
||||
final Splitter splitter = new Splitter(true, 0.3f);
|
||||
splitter.setFirstComponent(panel);
|
||||
splitter.setSecondComponent(myUsagePreviewPanel);
|
||||
myUsagePreviewPanel.updateLayout(null);
|
||||
|
||||
Disposer.register(myDisposable, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
splitter.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
if (tableModel.getRowCount() != 0) {
|
||||
myTable.getSelectionModel().addSelectionInterval(0, 0);
|
||||
}
|
||||
return splitter;
|
||||
}
|
||||
|
||||
class MyTableModel extends AbstractTableModel {
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return myChecked.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int column) {
|
||||
switch (column) {
|
||||
case CHECK_COLUMN:
|
||||
return " ";
|
||||
default:
|
||||
return RefactoringBundle.message("method.column");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case CHECK_COLUMN:
|
||||
return Boolean.class;
|
||||
default:
|
||||
return String.class;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
if (columnIndex == CHECK_COLUMN) {
|
||||
return Boolean.valueOf(myChecked[rowIndex]);
|
||||
}
|
||||
else {
|
||||
return myMethodText[rowIndex];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
|
||||
if (columnIndex == CHECK_COLUMN) {
|
||||
myChecked[rowIndex] = ((Boolean) aValue).booleanValue();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return columnIndex == CHECK_COLUMN;
|
||||
}
|
||||
|
||||
void updateData() {
|
||||
fireTableDataChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.plugin.refactoring.safeDelete;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteCustomUsageInfo;
|
||||
import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteUsageInfo;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.jet.asJava.LightClassUtil;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||
|
||||
public class KotlinSafeDeleteOverridingMethodUsageInfo extends SafeDeleteUsageInfo implements SafeDeleteCustomUsageInfo {
|
||||
public KotlinSafeDeleteOverridingMethodUsageInfo(PsiElement overridingMethod, PsiElement method) {
|
||||
super(toPsiMethod(overridingMethod), toPsiMethod(method));
|
||||
}
|
||||
|
||||
protected static PsiMethod toPsiMethod(PsiElement element) {
|
||||
if (element instanceof JetNamedFunction) {
|
||||
element = LightClassUtil.getLightClassMethod((JetNamedFunction) element);
|
||||
}
|
||||
return element instanceof PsiMethod ? (PsiMethod) element : null;
|
||||
}
|
||||
|
||||
public PsiMethod getOverridingMethod() {
|
||||
return toPsiMethod(getElement());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performRefactoring() throws IncorrectOperationException {
|
||||
PsiElement element = getElement();
|
||||
if (element != null) {
|
||||
element.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
+586
@@ -0,0 +1,586 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.plugin.refactoring.safeDelete;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.searches.OverridingMethodsSearch;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.search.searches.SuperMethodsSearch;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.refactoring.safeDelete.JavaSafeDeleteProcessor;
|
||||
import com.intellij.refactoring.safeDelete.NonCodeUsageSearchInfo;
|
||||
import com.intellij.refactoring.safeDelete.SafeDeleteProcessor;
|
||||
import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteOverridingMethodUsageInfo;
|
||||
import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteReferenceSimpleDeleteUsageInfo;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.asJava.LightClassUtil;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.Modality;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.JetClsMethod;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class KotlinSafeDeleteProcessor extends JavaSafeDeleteProcessor {
|
||||
public static boolean canDeleteElement(PsiElement element) {
|
||||
return element instanceof JetClassOrObject
|
||||
|| element instanceof JetObjectDeclarationName
|
||||
|| element instanceof JetNamedFunction
|
||||
|| element instanceof PsiMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlesElement(PsiElement element) {
|
||||
return canDeleteElement(element);
|
||||
}
|
||||
|
||||
protected static NonCodeUsageSearchInfo getDefaultNonCodeUsageSearchInfo(
|
||||
@NotNull PsiElement element, @NotNull PsiElement[] allElementsToDelete
|
||||
) {
|
||||
return new NonCodeUsageSearchInfo(SafeDeleteProcessor.getDefaultInsideDeletedCondition(allElementsToDelete), element);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public NonCodeUsageSearchInfo findUsages(PsiElement element, PsiElement[] allElementsToDelete, List<UsageInfo> result) {
|
||||
if (element instanceof JetClassOrObject) {
|
||||
return findClassOrObjectUsages(element, (JetClassOrObject) element, allElementsToDelete, result);
|
||||
}
|
||||
if (element instanceof JetObjectDeclarationName) {
|
||||
PsiElement parent = getObjectDeclarationOrFail(element);
|
||||
return findClassOrObjectUsages(element, (JetObjectDeclaration) parent, allElementsToDelete, result);
|
||||
}
|
||||
if (element instanceof JetNamedFunction) {
|
||||
return findFunctionUsages((JetNamedFunction) element, allElementsToDelete, result);
|
||||
}
|
||||
if (element instanceof PsiMethod) {
|
||||
return findPsiMethodUsages((PsiMethod) element, allElementsToDelete, result);
|
||||
}
|
||||
return getDefaultNonCodeUsageSearchInfo(element, allElementsToDelete);
|
||||
}
|
||||
|
||||
private static PsiElement getObjectDeclarationOrFail(PsiElement element) {
|
||||
PsiElement parent = element.getParent();
|
||||
assert parent instanceof JetObjectDeclaration;
|
||||
return parent;
|
||||
}
|
||||
|
||||
@SuppressWarnings("MethodOverridesPrivateMethodOfSuperclass")
|
||||
protected static boolean isInside(PsiElement place, PsiElement[] ancestors) {
|
||||
return isInside(place, Arrays.asList(ancestors));
|
||||
}
|
||||
|
||||
@SuppressWarnings("MethodOverridesPrivateMethodOfSuperclass")
|
||||
protected static boolean isInside(PsiElement place, Collection<? extends PsiElement> ancestors) {
|
||||
for (PsiElement element : ancestors) {
|
||||
if (isInside(place, element)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("MethodOverridesStaticMethodOfSuperclass")
|
||||
public static boolean isInside(PsiElement place, PsiElement ancestor) {
|
||||
if (ancestor instanceof JetClsMethod) {
|
||||
ancestor = ((JetClsMethod) ancestor).getOrigin();
|
||||
}
|
||||
return JavaSafeDeleteProcessor.isInside(place, ancestor);
|
||||
}
|
||||
|
||||
protected static NonCodeUsageSearchInfo findClassOrObjectUsages(
|
||||
PsiElement referencedElement,
|
||||
final JetClassOrObject classOrObject,
|
||||
final PsiElement[] allElementsToDelete,
|
||||
final List<UsageInfo> result
|
||||
) {
|
||||
ReferencesSearch.search(referencedElement).forEach(new Processor<PsiReference>() {
|
||||
@Override
|
||||
public boolean process(PsiReference reference) {
|
||||
PsiElement element = reference.getElement();
|
||||
|
||||
if (!isInside(element, allElementsToDelete)) {
|
||||
JetImportDirective importDirective = PsiTreeUtil.getParentOfType(element, JetImportDirective.class, false);
|
||||
if (importDirective != null) {
|
||||
result.add(new SafeDeleteImportDirectiveUsageInfo(importDirective, classOrObject));
|
||||
return true;
|
||||
}
|
||||
|
||||
result.add(new SafeDeleteReferenceSimpleDeleteUsageInfo(element, classOrObject, false));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return getDefaultNonCodeUsageSearchInfo(referencedElement, allElementsToDelete);
|
||||
}
|
||||
|
||||
protected NonCodeUsageSearchInfo findPsiMethodUsages(
|
||||
PsiMethod method,
|
||||
PsiElement[] allElementsToDelete,
|
||||
List<UsageInfo> result
|
||||
) {
|
||||
List<UsageInfo> javaUsages = new ArrayList<UsageInfo>();
|
||||
NonCodeUsageSearchInfo searchInfo = super.findUsages(method, allElementsToDelete, javaUsages);
|
||||
|
||||
for (UsageInfo usageInfo : javaUsages) {
|
||||
if (usageInfo instanceof SafeDeleteOverridingMethodUsageInfo) {
|
||||
SafeDeleteOverridingMethodUsageInfo overrideUsageInfo = (SafeDeleteOverridingMethodUsageInfo) usageInfo;
|
||||
usageInfo = new KotlinSafeDeleteOverridingMethodUsageInfo(
|
||||
overrideUsageInfo.getSmartPointer().getElement(), overrideUsageInfo.getReferencedElement()
|
||||
);
|
||||
}
|
||||
result.add(usageInfo);
|
||||
}
|
||||
|
||||
return searchInfo;
|
||||
}
|
||||
|
||||
private static <T, C extends T> List<C> difference(Collection<C> from, T[] a) {
|
||||
List<C> list = new ArrayList<C>(from);
|
||||
list.removeAll(Arrays.asList(a));
|
||||
return list;
|
||||
}
|
||||
|
||||
protected static NonCodeUsageSearchInfo findFunctionUsages(
|
||||
JetNamedFunction function,
|
||||
final PsiElement[] allElementsToDelete,
|
||||
List<UsageInfo> result
|
||||
) {
|
||||
PsiMethod lightMethod = LightClassUtil.getLightClassMethod(function);
|
||||
if (lightMethod == null) {
|
||||
return getDefaultNonCodeUsageSearchInfo(function, allElementsToDelete);
|
||||
}
|
||||
|
||||
Collection<PsiReference> references = ReferencesSearch.search(function).findAll();
|
||||
List<PsiMethod> overridingMethods = difference(OverridingMethodsSearch.search(lightMethod, true).findAll(), allElementsToDelete);
|
||||
|
||||
for (PsiReference reference : references) {
|
||||
PsiElement element = reference.getElement();
|
||||
if (!isInside(element, allElementsToDelete) && !isInside(element, overridingMethods)) {
|
||||
JetImportDirective importDirective = PsiTreeUtil.getParentOfType(element, JetImportDirective.class, false);
|
||||
if (importDirective != null) {
|
||||
result.add(new SafeDeleteImportDirectiveUsageInfo(importDirective, function));
|
||||
}
|
||||
else {
|
||||
result.add(new SafeDeleteReferenceSimpleDeleteUsageInfo(element, function, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<PsiMethod, Collection<PsiReference>> methodToReferences = new HashMap<PsiMethod, Collection<PsiReference>>();
|
||||
for (PsiMethod overridingMethod : overridingMethods) {
|
||||
Collection<PsiReference> overridingReferences =
|
||||
ReferencesSearch.search(
|
||||
overridingMethod instanceof JetClsMethod ? ((JetClsMethod) overridingMethod).getOrigin() : overridingMethod
|
||||
).findAll();
|
||||
methodToReferences.put(overridingMethod, overridingReferences);
|
||||
}
|
||||
final Set<PsiMethod> safeOverriding =
|
||||
filterSafeOverridingMethods(lightMethod, references, overridingMethods, methodToReferences, result, allElementsToDelete);
|
||||
|
||||
return new NonCodeUsageSearchInfo(
|
||||
new Condition<PsiElement>() {
|
||||
@Override
|
||||
public boolean value(PsiElement usage) {
|
||||
if (usage instanceof JetFile) return false;
|
||||
return isInside(usage, allElementsToDelete) || isInside(usage, safeOverriding);
|
||||
}
|
||||
},
|
||||
function
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Mostly copied from JavaSafeDeleteProcessor.validateOverridingMethods
|
||||
* Revision: d4fc033
|
||||
* (simplified and implemented proper treatment of light methods)
|
||||
*/
|
||||
private static Set<PsiMethod> filterSafeOverridingMethods(
|
||||
PsiMethod originalMethod, Collection<PsiReference> originalReferences,
|
||||
Collection<PsiMethod> overridingMethods, HashMap<PsiMethod, Collection<PsiReference>> methodToReferences,
|
||||
List<UsageInfo> usages,
|
||||
PsiElement[] allElementsToDelete
|
||||
) {
|
||||
Set<PsiMethod> validOverriding = new LinkedHashSet<PsiMethod>(overridingMethods);
|
||||
boolean anyNewBadRefs;
|
||||
do {
|
||||
anyNewBadRefs = false;
|
||||
for (PsiMethod overridingMethod : overridingMethods) {
|
||||
if (validOverriding.contains(overridingMethod)) {
|
||||
Collection<PsiReference> overridingReferences = methodToReferences.get(overridingMethod);
|
||||
boolean anyOverridingRefs = false;
|
||||
for (PsiReference overridingReference : overridingReferences) {
|
||||
PsiElement element = overridingReference.getElement();
|
||||
if (!isInside(element, allElementsToDelete) && !isInside(element, validOverriding)) {
|
||||
anyOverridingRefs = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!anyOverridingRefs && isMultipleInterfacesImplementation(overridingMethod, originalMethod, allElementsToDelete)) {
|
||||
anyOverridingRefs = true;
|
||||
}
|
||||
|
||||
if (anyOverridingRefs) {
|
||||
validOverriding.remove(overridingMethod);
|
||||
anyNewBadRefs = true;
|
||||
|
||||
for (PsiReference reference : originalReferences) {
|
||||
PsiElement element = reference.getElement();
|
||||
if (!isInside(element, allElementsToDelete) && !isInside(element, overridingMethods)) {
|
||||
validOverriding.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (anyNewBadRefs && !validOverriding.isEmpty());
|
||||
|
||||
for (PsiMethod method : validOverriding) {
|
||||
if (method != originalMethod) {
|
||||
usages.add(new KotlinSafeDeleteOverridingMethodUsageInfo(method, originalMethod));
|
||||
}
|
||||
}
|
||||
|
||||
return validOverriding;
|
||||
}
|
||||
|
||||
@SuppressWarnings("MethodOverridesPrivateMethodOfSuperclass")
|
||||
private static boolean isMultipleInterfacesImplementation(PsiMethod method, PsiMethod originalMethod, PsiElement[] ignore) {
|
||||
PsiMethod[] methods = method.findSuperMethods();
|
||||
for (PsiMethod superMethod: methods) {
|
||||
PsiElement relevantElement = superMethod instanceof JetClsMethod ? ((JetClsMethod) superMethod).getOrigin() : superMethod;
|
||||
if (ArrayUtilRt.find(ignore, relevantElement) < 0 && !MethodSignatureUtil.isSuperMethod(originalMethod, superMethod)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private static String wrapOrSkip(String s, boolean inCode) {
|
||||
return inCode ? "<code>" + s + "</code>" : s;
|
||||
}
|
||||
|
||||
private static String formatClass(DeclarationDescriptor classDescriptor, BindingContext bindingContext, boolean inCode) {
|
||||
PsiElement element = BindingContextUtils.descriptorToDeclaration(bindingContext, classDescriptor);
|
||||
if (element instanceof PsiClass) {
|
||||
return formatPsiClass((PsiClass) element, false, inCode);
|
||||
}
|
||||
|
||||
return wrapOrSkip(formatClassDescriptor(classDescriptor), inCode);
|
||||
}
|
||||
|
||||
private static String formatFunction(DeclarationDescriptor functionDescriptor, BindingContext bindingContext, boolean inCode) {
|
||||
PsiElement element = BindingContextUtils.descriptorToDeclaration(bindingContext, functionDescriptor);
|
||||
if (element instanceof PsiMethod) {
|
||||
return formatPsiMethod((PsiMethod) element, false, inCode);
|
||||
}
|
||||
|
||||
return wrapOrSkip(formatFunctionDescriptor(functionDescriptor), inCode);
|
||||
}
|
||||
|
||||
private static String formatClassDescriptor(DeclarationDescriptor classDescriptor) {
|
||||
return DescriptorRenderer.SOURCE_CODE_SHORT_NAMES_IN_TYPES.render(classDescriptor);
|
||||
}
|
||||
|
||||
private static String formatFunctionDescriptor(DeclarationDescriptor functionDescriptor) {
|
||||
return DescriptorRenderer.COMPACT.render(functionDescriptor);
|
||||
}
|
||||
|
||||
public static String formatPsiClass(PsiClass psiClass, boolean markAsJava, boolean inCode) {
|
||||
String description;
|
||||
|
||||
String kind = psiClass.isInterface() ? "interface " : "class ";
|
||||
description = kind + PsiFormatUtil.formatClass(
|
||||
psiClass,
|
||||
PsiFormatUtilBase.SHOW_CONTAINING_CLASS
|
||||
| PsiFormatUtilBase.SHOW_NAME
|
||||
| PsiFormatUtilBase.SHOW_PARAMETERS
|
||||
| PsiFormatUtilBase.SHOW_TYPE
|
||||
);
|
||||
description = wrapOrSkip(description, inCode);
|
||||
|
||||
return markAsJava ? "[Java] " + description : description;
|
||||
}
|
||||
|
||||
public static String formatPsiMethod(PsiMethod psiMethod, boolean showContainingClass, boolean inCode) {
|
||||
int options = PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS | PsiFormatUtilBase.SHOW_TYPE;
|
||||
if (showContainingClass) {
|
||||
options |= PsiFormatUtilBase.SHOW_CONTAINING_CLASS;
|
||||
}
|
||||
|
||||
String description = PsiFormatUtil.formatMethod(psiMethod, PsiSubstitutor.EMPTY, options, PsiFormatUtilBase.SHOW_TYPE);
|
||||
description = wrapOrSkip(description, inCode);
|
||||
|
||||
return "[Java] " + description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> findConflicts(PsiElement element, PsiElement[] allElementsToDelete) {
|
||||
if (element instanceof JetNamedFunction) {
|
||||
JetClass jetClass = PsiTreeUtil.getParentOfType(element, JetClass.class);
|
||||
if (jetClass == null || jetClass.getBody() != element.getParent()) return null;
|
||||
|
||||
JetModifierList modifierList = jetClass.getModifierList();
|
||||
if (modifierList != null && modifierList.hasModifier(JetTokens.ABSTRACT_KEYWORD)) return null;
|
||||
|
||||
BindingContext bindingContext =
|
||||
AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) element.getContainingFile()).getBindingContext();
|
||||
|
||||
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element);
|
||||
if (!(declarationDescriptor instanceof FunctionDescriptor)) return null;
|
||||
|
||||
List<String> messages = new ArrayList<String>();
|
||||
FunctionDescriptor functionDescriptor = (FunctionDescriptor) declarationDescriptor;
|
||||
for (FunctionDescriptor overridenDescriptor : functionDescriptor.getOverriddenDescriptors()) {
|
||||
if (overridenDescriptor.getModality() == Modality.ABSTRACT) {
|
||||
String message = JetBundle.message(
|
||||
"x.implements.y",
|
||||
formatFunction(functionDescriptor, bindingContext, true),
|
||||
formatClass(functionDescriptor.getContainingDeclaration(), bindingContext, true),
|
||||
formatFunction(overridenDescriptor, bindingContext, true),
|
||||
formatClass(overridenDescriptor.getContainingDeclaration(), bindingContext, true)
|
||||
);
|
||||
messages.add(message);
|
||||
}
|
||||
}
|
||||
|
||||
if (!messages.isEmpty()) return messages;
|
||||
}
|
||||
return super.findConflicts(element, allElementsToDelete);
|
||||
}
|
||||
|
||||
/*
|
||||
* Mostly copied from JavaSafeDeleteProcessor.preprocessUsages
|
||||
* Revision: d4fc033
|
||||
* (replaced original dialog)
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public UsageInfo[] preprocessUsages(Project project, UsageInfo[] usages) {
|
||||
ArrayList<UsageInfo> result = new ArrayList<UsageInfo>();
|
||||
ArrayList<UsageInfo> overridingMethodUsages = new ArrayList<UsageInfo>();
|
||||
|
||||
for (UsageInfo usage : usages) {
|
||||
if (usage instanceof KotlinSafeDeleteOverridingMethodUsageInfo) {
|
||||
overridingMethodUsages.add(usage);
|
||||
}
|
||||
else {
|
||||
result.add(usage);
|
||||
}
|
||||
}
|
||||
|
||||
if (!overridingMethodUsages.isEmpty()) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
result.addAll(overridingMethodUsages);
|
||||
}
|
||||
else {
|
||||
KotlinOverridingMethodsDialog dialog = new KotlinOverridingMethodsDialog(project, overridingMethodUsages);
|
||||
dialog.show();
|
||||
if (!dialog.isOK()) return null;
|
||||
result.addAll(dialog.getSelected());
|
||||
}
|
||||
}
|
||||
|
||||
return result.toArray(new UsageInfo[result.size()]);
|
||||
}
|
||||
|
||||
private static void removeOverrideModifier(@NotNull PsiElement element) {
|
||||
if (element instanceof JetNamedFunction) {
|
||||
JetModifierList modifierList = ((JetNamedFunction) element).getModifierList();
|
||||
if (modifierList == null) return;
|
||||
|
||||
PsiElement overrideModifier = modifierList.getModifier(JetTokens.OVERRIDE_KEYWORD);
|
||||
if (overrideModifier != null) {
|
||||
overrideModifier.delete();
|
||||
}
|
||||
}
|
||||
else if (element instanceof PsiMethod) {
|
||||
PsiMethod method = (PsiMethod) element;
|
||||
|
||||
PsiAnnotation overrideAnnotation = null;
|
||||
for (PsiAnnotation annotation : method.getModifierList().getAnnotations()) {
|
||||
if ("java.lang.Override".equals(annotation.getQualifiedName())) {
|
||||
overrideAnnotation = annotation;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (overrideAnnotation != null) {
|
||||
overrideAnnotation.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareForDeletion(PsiElement element) throws IncorrectOperationException {
|
||||
if (element instanceof PsiMethod) {
|
||||
cleanUpOverrides((PsiMethod) element);
|
||||
}
|
||||
else if (element instanceof JetNamedFunction) {
|
||||
PsiMethod lightMethod = LightClassUtil.getLightClassMethod((JetNamedFunction) element);
|
||||
if (lightMethod == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
cleanUpOverrides(lightMethod);
|
||||
}
|
||||
}
|
||||
|
||||
private static void cleanUpOverrides(PsiMethod method) {
|
||||
Collection<MethodSignatureBackedByPsiMethod> superMethods =
|
||||
SuperMethodsSearch.search(method, null, true, false).findAll();
|
||||
Collection<PsiMethod> overridingMethods = OverridingMethodsSearch.search(method, false).findAll();
|
||||
overrideLoop: for (PsiMethod overridingMethod : overridingMethods) {
|
||||
PsiElement overridingElement = overridingMethod instanceof JetClsMethod
|
||||
? ((JetClsMethod) overridingMethod).getOrigin()
|
||||
: overridingMethod;
|
||||
Collection<MethodSignatureBackedByPsiMethod> currentSuperMethods =
|
||||
SuperMethodsSearch.search(overridingMethod, null, true, false).findAll();
|
||||
currentSuperMethods.addAll(superMethods);
|
||||
for (MethodSignatureBackedByPsiMethod superMethod: currentSuperMethods) {
|
||||
if (superMethod.getMethod() != method) continue overrideLoop;
|
||||
}
|
||||
|
||||
removeOverrideModifier(overridingElement);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Collection<? extends PsiElement> checkSuperMethods(
|
||||
@NotNull JetNamedFunction function, @Nullable Collection<PsiElement> ignore
|
||||
) {
|
||||
final BindingContext bindingContext =
|
||||
AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) function.getContainingFile()).getBindingContext();
|
||||
|
||||
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, function);
|
||||
if (!(declarationDescriptor instanceof FunctionDescriptor)) return null;
|
||||
|
||||
FunctionDescriptor functionDescriptor = (FunctionDescriptor) declarationDescriptor;
|
||||
Set<? extends FunctionDescriptor> overridenDescriptors = functionDescriptor.getOverriddenDescriptors();
|
||||
|
||||
Collection<? extends PsiElement> superMethods = ContainerUtil.map(
|
||||
overridenDescriptors,
|
||||
new Function<FunctionDescriptor, PsiElement>() {
|
||||
@Override
|
||||
public PsiElement fun(FunctionDescriptor descriptor) {
|
||||
return BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (ignore != null) {
|
||||
superMethods.removeAll(ignore);
|
||||
}
|
||||
|
||||
if (superMethods.isEmpty()) return Collections.singletonList(function);
|
||||
|
||||
List<String> superClasses = ContainerUtil.map(
|
||||
superMethods,
|
||||
new Function<PsiElement, String>() {
|
||||
@Override
|
||||
public String fun(PsiElement element) {
|
||||
String description;
|
||||
|
||||
if (element instanceof JetNamedFunction) {
|
||||
DeclarationDescriptor descriptor =
|
||||
bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element);
|
||||
assert descriptor != null;
|
||||
|
||||
DeclarationDescriptor containingDescriptor = descriptor.getContainingDeclaration();
|
||||
assert containingDescriptor != null;
|
||||
|
||||
description = formatClassDescriptor(containingDescriptor);
|
||||
}
|
||||
else {
|
||||
assert element instanceof PsiMethod;
|
||||
|
||||
PsiClass psiClass = ((PsiMethod) element).getContainingClass();
|
||||
assert psiClass != null;
|
||||
|
||||
description = formatPsiClass(psiClass, true, false);
|
||||
}
|
||||
|
||||
return " " + description + "\n";
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
String superClassesStr = "\n" + StringUtil.join(superClasses, "");
|
||||
String message = JetBundle.message(
|
||||
"x.overrides.y.in.class.list",
|
||||
DescriptorRenderer.COMPACT.render(functionDescriptor),
|
||||
DescriptorRenderer.SOURCE_CODE_SHORT_NAMES_IN_TYPES.render(functionDescriptor.getContainingDeclaration()),
|
||||
superClassesStr
|
||||
);
|
||||
|
||||
int exitCode = Messages.showYesNoCancelDialog(
|
||||
function.getProject(), message, IdeBundle.message("title.warning"), Messages.getQuestionIcon()
|
||||
);
|
||||
switch (exitCode) {
|
||||
case Messages.YES:
|
||||
return superMethods;
|
||||
case Messages.NO:
|
||||
return Collections.singletonList(function);
|
||||
default:
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Collection<? extends PsiElement> getElementsToSearch(
|
||||
PsiElement element, @Nullable Module module, Collection<PsiElement> allElementsToDelete
|
||||
) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
return Collections.singletonList(element);
|
||||
}
|
||||
|
||||
if (element instanceof JetNamedFunction) {
|
||||
return checkSuperMethods((JetNamedFunction) element, allElementsToDelete);
|
||||
}
|
||||
return super.getElementsToSearch(element, module, allElementsToDelete);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PsiElement> getAdditionalElementsToDelete(
|
||||
PsiElement element, Collection<PsiElement> allElementsToDelete, boolean askUser
|
||||
) {
|
||||
if (element instanceof JetObjectDeclarationName) {
|
||||
return Arrays.asList(getObjectDeclarationOrFail(element));
|
||||
}
|
||||
return super.getAdditionalElementsToDelete(element, allElementsToDelete, askUser);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user