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