Got rid of isProbablyNothing in stubs + fixed exception on some files on indexing stubs

This commit is contained in:
Valentin Kipyatkov
2015-03-31 17:50:26 +03:00
parent 0243280668
commit 6a2cc66eb1
52 changed files with 230 additions and 213 deletions
@@ -439,14 +439,6 @@ public fun Call.isSafeCall(): Boolean {
public fun Call.isExplicitSafeCall(): Boolean = getCallOperationNode()?.getElementType() == JetTokens.SAFE_ACCESS
public fun JetTypeReference?.isProbablyNothing(): Boolean {
val userType = this?.getTypeElement() as? JetUserType ?: return false
return userType.isProbablyNothing()
}
public fun JetUserType?.isProbablyNothing(): Boolean
= this?.getReferencedName() == "Nothing"
public fun JetStringTemplateExpression.getContentRange(): TextRange {
val start = getNode().getFirstChildNode().getTextLength()
val lastChild = getNode().getLastChildNode()
@@ -100,7 +100,6 @@ public trait KotlinPropertyStub : KotlinCallableStubBase<JetProperty> {
public trait KotlinCallableStubBase<TDeclaration: JetCallableDeclaration> : KotlinStubWithFqName<TDeclaration> {
public fun isTopLevel(): Boolean
public fun isExtension(): Boolean
public fun isProbablyNothingType(): Boolean
}
public trait KotlinTypeParameterStub : KotlinStubWithFqName<JetTypeParameter> {
@@ -115,3 +114,10 @@ public trait KotlinTypeProjectionStub : StubElement<JetTypeProjection> {
public trait KotlinUserTypeStub : StubElement<JetUserType> {
public fun isAbsoluteInRootPackage(): Boolean
}
public fun StubElement<*>.getContainingFileStub(): PsiFileStub<*> {
return if (this is PsiFileStub)
this
else
getParentStub().getContainingFileStub()
}
@@ -26,7 +26,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.JetNamedFunction;
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
import org.jetbrains.kotlin.psi.stubs.KotlinFunctionStub;
import org.jetbrains.kotlin.psi.stubs.impl.KotlinFunctionStubImpl;
import org.jetbrains.kotlin.resolve.lazy.ResolveSessionUtils;
@@ -47,8 +46,7 @@ public class JetFunctionElementType extends JetStubElementType<KotlinFunctionStu
boolean hasBlockBody = psi.hasBlockBody();
boolean hasBody = psi.hasBody();
return new KotlinFunctionStubImpl(parentStub, StringRef.fromString(psi.getName()), isTopLevel, fqName,
isExtension, hasBlockBody, hasBody, psi.hasTypeParameterListBeforeFunctionName(),
PsiUtilPackage.isProbablyNothing(psi.getTypeReference()));
isExtension, hasBlockBody, hasBody, psi.hasTypeParameterListBeforeFunctionName());
}
@Override
@@ -63,7 +61,6 @@ public class JetFunctionElementType extends JetStubElementType<KotlinFunctionStu
dataStream.writeBoolean(stub.hasBlockBody());
dataStream.writeBoolean(stub.hasBody());
dataStream.writeBoolean(stub.hasTypeParameterListBeforeFunctionName());
dataStream.writeBoolean(stub.isProbablyNothingType());
}
@NotNull
@@ -79,10 +76,9 @@ public class JetFunctionElementType extends JetStubElementType<KotlinFunctionStu
boolean hasBlockBody = dataStream.readBoolean();
boolean hasBody = dataStream.readBoolean();
boolean hasTypeParameterListBeforeFunctionName = dataStream.readBoolean();
boolean probablyNothingType = dataStream.readBoolean();
return new KotlinFunctionStubImpl(parentStub, name, isTopLevel, fqName, isExtension, hasBlockBody, hasBody,
hasTypeParameterListBeforeFunctionName, probablyNothingType);
hasTypeParameterListBeforeFunctionName);
}
@Override
@@ -48,7 +48,6 @@ public class JetPropertyElementType extends JetStubElementType<KotlinPropertyStu
psi.isVar(), psi.isTopLevel(), psi.hasDelegate(),
psi.hasDelegateExpression(), psi.hasInitializer(),
psi.getReceiverTypeReference() != null, psi.getTypeReference() != null,
PsiUtilPackage.isProbablyNothing(psi.getTypeReference()),
ResolveSessionUtils.safeFqNameForLazyResolve(psi)
);
}
@@ -63,7 +62,6 @@ public class JetPropertyElementType extends JetStubElementType<KotlinPropertyStu
dataStream.writeBoolean(stub.hasInitializer());
dataStream.writeBoolean(stub.isExtension());
dataStream.writeBoolean(stub.hasReturnTypeRef());
dataStream.writeBoolean(stub.isProbablyNothingType());
FqName fqName = stub.getFqName();
dataStream.writeName(fqName != null ? fqName.asString() : null);
@@ -80,13 +78,12 @@ public class JetPropertyElementType extends JetStubElementType<KotlinPropertyStu
boolean hasInitializer = dataStream.readBoolean();
boolean hasReceiverTypeRef = dataStream.readBoolean();
boolean hasReturnTypeRef = dataStream.readBoolean();
boolean probablyNothing = dataStream.readBoolean();
StringRef fqNameAsString = dataStream.readName();
FqName fqName = fqNameAsString != null ? new FqName(fqNameAsString.toString()) : null;
return new KotlinPropertyStubImpl(parentStub, name, isVar, isTopLevel, hasDelegate,
hasDelegateExpression, hasInitializer, hasReceiverTypeRef, hasReturnTypeRef, probablyNothing,
hasDelegateExpression, hasInitializer, hasReceiverTypeRef, hasReturnTypeRef,
fqName);
}
@@ -32,8 +32,7 @@ public class KotlinFunctionStubImpl(
private val isExtension: Boolean,
private val hasBlockBody: Boolean,
private val hasBody: Boolean,
private val hasTypeParameterListBeforeFunctionName: Boolean,
private val isProbablyNothingType: Boolean
private val hasTypeParameterListBeforeFunctionName: Boolean
) : KotlinStubBaseImpl<JetNamedFunction>(parent, JetStubElementTypes.FUNCTION), KotlinFunctionStub {
init {
if (isTopLevel && fqName == null) {
@@ -48,5 +47,4 @@ public class KotlinFunctionStubImpl(
override fun hasBlockBody() = hasBlockBody
override fun hasBody() = hasBody
override fun hasTypeParameterListBeforeFunctionName() = hasTypeParameterListBeforeFunctionName
override fun isProbablyNothingType() = isProbablyNothingType
}
@@ -34,7 +34,6 @@ public class KotlinPropertyStubImpl(
private val hasInitializer: Boolean,
private val isExtension: Boolean,
private val hasReturnTypeRef: Boolean,
private val isProbablyNothingType: Boolean,
private val fqName: FqName?
) : KotlinStubBaseImpl<JetProperty>(parent, JetStubElementTypes.PROPERTY), KotlinPropertyStub {
@@ -56,5 +55,4 @@ public class KotlinPropertyStubImpl(
override fun isExtension() = isExtension
override fun hasReturnTypeRef() = hasReturnTypeRef
override fun getName() = StringRef.toString(name)
override fun isProbablyNothingType() = isProbablyNothingType
}