Partial body resolve works for local Nothing functions + does not go inside local functions and classes

This commit is contained in:
Valentin Kipyatkov
2014-11-19 20:03:31 +03:00
parent b22233d378
commit 8010c0f09d
15 changed files with 118 additions and 33 deletions
@@ -391,3 +391,6 @@ public fun Call.isSafeCall(): Boolean {
}
public fun Call.isExplicitSafeCall(): Boolean = getCallOperationNode()?.getElementType() == JetTokens.SAFE_ACCESS
public fun JetTypeReference?.isProbablyNothing(): Boolean
= (this?.getTypeElement() as? JetUserType)?.getReferencedName() == "Nothing"
@@ -24,6 +24,7 @@ import com.intellij.util.io.StringRef;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.psi.psiUtil.PsiUtilPackage;
import org.jetbrains.jet.lang.psi.stubs.KotlinFunctionStub;
import org.jetbrains.jet.lang.psi.stubs.impl.KotlinFunctionStubImpl;
import org.jetbrains.jet.lang.resolve.lazy.ResolveSessionUtils;
@@ -46,7 +47,7 @@ public class JetFunctionElementType extends JetStubElementType<KotlinFunctionStu
boolean hasBody = psi.hasBody();
return new KotlinFunctionStubImpl(parentStub, StringRef.fromString(psi.getName()), isTopLevel, fqName,
isExtension, hasBlockBody, hasBody, psi.hasTypeParameterListBeforeFunctionName(),
ElementsPackage.isProbablyNothing(psi.getTypeReference()));
PsiUtilPackage.isProbablyNothing(psi.getTypeReference()));
}
@Override
@@ -24,6 +24,7 @@ import com.intellij.util.io.StringRef;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetProperty;
import org.jetbrains.jet.lang.psi.psiUtil.PsiUtilPackage;
import org.jetbrains.jet.lang.psi.stubs.KotlinPropertyStub;
import org.jetbrains.jet.lang.psi.stubs.impl.KotlinPropertyStubImpl;
import org.jetbrains.jet.lang.resolve.lazy.ResolveSessionUtils;
@@ -47,7 +48,7 @@ public class JetPropertyElementType extends JetStubElementType<KotlinPropertyStu
psi.isVar(), psi.isTopLevel(), psi.hasDelegate(),
psi.hasDelegateExpression(), psi.hasInitializer(),
psi.getReceiverTypeReference() != null, psi.getTypeReference() != null,
ElementsPackage.isProbablyNothing(psi.getTypeReference()),
PsiUtilPackage.isProbablyNothing(psi.getTypeReference()),
ResolveSessionUtils.safeFqNameForLazyResolve(psi)
);
}
@@ -1,23 +0,0 @@
/*
* Copyright 2010-2014 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.lang.psi.stubs.elements
import org.jetbrains.jet.lang.psi.JetUserType
import org.jetbrains.jet.lang.psi.JetTypeReference
fun JetTypeReference?.isProbablyNothing()
= (this?.getTypeElement() as? JetUserType)?.getReferencedName() == "Nothing"