Remove various getDefaultObject() methods
This commit is contained in:
@@ -69,6 +69,7 @@ import org.jetbrains.org.objectweb.asm.commons.Method;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static kotlin.KotlinPackage.firstOrNull;
|
||||
import static org.jetbrains.kotlin.codegen.AsmUtil.*;
|
||||
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.*;
|
||||
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.enumEntryNeedSubclass;
|
||||
@@ -993,7 +994,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
return;
|
||||
}
|
||||
|
||||
JetObjectDeclaration defaultObject = ((JetClass) myClass).getDefaultObject();
|
||||
JetObjectDeclaration defaultObject = firstOrNull(((JetClass) myClass).getDefaultObjects());
|
||||
assert defaultObject != null : "Default object not found: " + myClass.getText();
|
||||
|
||||
StackValue.Field field = StackValue.singleton(defaultObjectDescriptor, typeMapper);
|
||||
|
||||
@@ -141,13 +141,6 @@ public class JetClass extends JetTypeParameterListOwnerStub<KotlinClassStub> imp
|
||||
return getStubOrPsiChild(JetStubElementTypes.CLASS_BODY);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetObjectDeclaration getDefaultObject() {
|
||||
JetClassBody body = getBody();
|
||||
if (body == null) return null;
|
||||
return body.getDefaultObject();
|
||||
}
|
||||
|
||||
public List<JetProperty> getProperties() {
|
||||
JetClassBody body = getBody();
|
||||
if (body == null) return Collections.emptyList();
|
||||
@@ -236,4 +229,13 @@ public class JetClass extends JetTypeParameterListOwnerStub<KotlinClassStub> imp
|
||||
}
|
||||
return JetPsiUtil.isLocal(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<JetObjectDeclaration> getDefaultObjects() {
|
||||
JetClassBody body = getBody();
|
||||
if (body == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return body.getAllDefaultObjects();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,11 +66,6 @@ public class JetClassBody extends JetElementImplStub<KotlinPlaceHolderStub<JetCl
|
||||
return getStubOrPsiChildrenAsList(JetStubElementTypes.PROPERTY);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetObjectDeclaration getDefaultObject() {
|
||||
return firstOrNull(getAllDefaultObjects());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<JetObjectDeclaration> getAllDefaultObjects() {
|
||||
List<JetObjectDeclaration> result = Lists.newArrayList();
|
||||
|
||||
@@ -45,11 +45,6 @@ public class JetClassInfo extends JetClassOrObjectInfo<JetClass> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObjectDeclaration getDefaultObject() {
|
||||
return element.getDefaultObject();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JetTypeParameterList getTypeParameterList() {
|
||||
|
||||
@@ -33,9 +33,6 @@ public interface JetClassLikeInfo extends JetDeclarationContainer {
|
||||
@Nullable
|
||||
JetModifierList getModifierList();
|
||||
|
||||
@Nullable
|
||||
JetObjectDeclaration getDefaultObject();
|
||||
|
||||
@NotNull
|
||||
@ReadOnly
|
||||
List<JetObjectDeclaration> getDefaultObjects();
|
||||
|
||||
@@ -35,11 +35,6 @@ public class JetObjectInfo extends JetClassOrObjectInfo<JetObjectDeclaration> {
|
||||
this.kind = element.isObjectLiteral() ? ClassKind.CLASS : ClassKind.OBJECT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetObjectDeclaration getDefaultObject() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JetTypeParameterList getTypeParameterList() {
|
||||
|
||||
@@ -27,7 +27,6 @@ public class JetScriptInfo(
|
||||
public val fqName: FqName = ScriptNameUtil.classNameForScript(script)
|
||||
override fun getContainingPackageFqName() = fqName.parent()
|
||||
override fun getModifierList() = null
|
||||
override fun getDefaultObject() = null
|
||||
override fun getDefaultObjects() = listOf<JetObjectDeclaration>()
|
||||
override fun getScopeAnchor() = script
|
||||
override fun getCorrespondingClassOrObject() = null
|
||||
|
||||
+2
-1
@@ -56,6 +56,7 @@ import org.jetbrains.kotlin.types.TypeUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static kotlin.KotlinPackage.firstOrNull;
|
||||
import static org.jetbrains.kotlin.diagnostics.Errors.*;
|
||||
import static org.jetbrains.kotlin.resolve.BindingContext.TYPE;
|
||||
import static org.jetbrains.kotlin.resolve.ModifiersChecker.*;
|
||||
@@ -411,7 +412,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
|
||||
@Nullable
|
||||
private JetObjectDeclaration getDefaultObjectIfAllowed() {
|
||||
JetObjectDeclaration defaultObject = declarationProvider.getOwnerInfo().getDefaultObject();
|
||||
JetObjectDeclaration defaultObject = firstOrNull(declarationProvider.getOwnerInfo().getDefaultObjects());
|
||||
return (defaultObject != null && isDefaultObjectAllowed()) ? defaultObject : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import kotlin.KotlinPackage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
|
||||
@@ -42,6 +43,8 @@ import org.jetbrains.kotlin.psi.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static kotlin.KotlinPackage.singleOrNull;
|
||||
|
||||
public class JetRunConfigurationProducer extends RuntimeConfigurationProducer implements Cloneable {
|
||||
@Nullable
|
||||
private PsiElement mySourceElement;
|
||||
@@ -117,7 +120,7 @@ public class JetRunConfigurationProducer extends RuntimeConfigurationProducer im
|
||||
currentElement = PsiTreeUtil.getParentOfType((PsiElement) currentElement, JetClassOrObject.class, JetFile.class)) {
|
||||
JetDeclarationContainer entryPointContainer = currentElement;
|
||||
if (entryPointContainer instanceof JetClass) {
|
||||
entryPointContainer = ((JetClass) currentElement).getDefaultObject();
|
||||
entryPointContainer = singleOrNull(((JetClass) currentElement).getDefaultObjects());
|
||||
}
|
||||
if (entryPointContainer != null && mainFunctionDetector.hasMain(entryPointContainer.getDeclarations())) return entryPointContainer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user