Refactor: introduce JetReference, rename: JetPsiReference -> AbstractJetReference
Add resolveToDescriptors() to JetReference trait Rewrite JetPsiReference to kotlin
This commit is contained in:
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.resolve;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import jet.runtime.typeinfo.KotlinSignature;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
@@ -92,6 +93,7 @@ public interface BindingContext {
|
||||
WritableSlice<JetElement, ConstraintSystemCompleter> CONSTRAINT_SYSTEM_COMPLETER = new BasicWritableSlice<JetElement, ConstraintSystemCompleter>(DO_NOTHING);
|
||||
WritableSlice<JetElement, Call> CALL = new BasicWritableSlice<JetElement, Call>(DO_NOTHING);
|
||||
|
||||
@KotlinSignature("val AMBIGUOUS_REFERENCE_TARGET: WritableSlice<JetReferenceExpression, Collection<DeclarationDescriptor>>")
|
||||
WritableSlice<JetReferenceExpression, Collection<? extends DeclarationDescriptor>> AMBIGUOUS_REFERENCE_TARGET =
|
||||
new BasicWritableSlice<JetReferenceExpression, Collection<? extends DeclarationDescriptor>>(DO_NOTHING);
|
||||
|
||||
@@ -235,6 +237,7 @@ public interface BindingContext {
|
||||
.setFurtherLookupSlices(DECLARATIONS_TO_DESCRIPTORS).build();
|
||||
|
||||
WritableSlice<JetReferenceExpression, PsiElement> LABEL_TARGET = Slices.<JetReferenceExpression, PsiElement>sliceBuilder().build();
|
||||
@KotlinSignature("val AMBIGUOUS_LABEL_TARGET: WritableSlice<JetReferenceExpression, Collection<PsiElement>>")
|
||||
WritableSlice<JetReferenceExpression, Collection<? extends PsiElement>> AMBIGUOUS_LABEL_TARGET =
|
||||
Slices.<JetReferenceExpression, Collection<? extends PsiElement>>sliceBuilder().build();
|
||||
WritableSlice<ValueParameterDescriptor, PropertyDescriptor> VALUE_PARAMETER_AS_PROPERTY =
|
||||
|
||||
@@ -43,7 +43,7 @@ import com.intellij.psi.PsiClass
|
||||
|
||||
fun JetClassOrObject.toLightClass(): PsiClass? = LightClassUtil.getPsiClass(this)
|
||||
|
||||
fun JetDeclaration.toLightElements(): List<PsiElement> =
|
||||
public fun JetDeclaration.toLightElements(): List<PsiElement> =
|
||||
when (this) {
|
||||
is JetClassOrObject -> Collections.singletonList(LightClassUtil.getPsiClass(this))
|
||||
is JetNamedFunction -> Collections.singletonList(LightClassUtil.getLightClassMethod(this))
|
||||
@@ -59,7 +59,7 @@ fun JetDeclaration.toLightElements(): List<PsiElement> =
|
||||
else -> Collections.emptyList()
|
||||
}
|
||||
|
||||
fun PsiElement.toLightMethods(): List<PsiMethod> =
|
||||
public fun PsiElement.toLightMethods(): List<PsiMethod> =
|
||||
when (this) {
|
||||
is JetNamedFunction -> Collections.singletonList(LightClassUtil.getLightClassMethod(this))
|
||||
is JetProperty -> LightClassUtil.getLightClassPropertyMethods(this).toList()
|
||||
@@ -69,7 +69,7 @@ fun PsiElement.toLightMethods(): List<PsiMethod> =
|
||||
else -> Collections.emptyList()
|
||||
}
|
||||
|
||||
fun PsiElement.getRepresentativeLightMethod(): PsiMethod? =
|
||||
public fun PsiElement.getRepresentativeLightMethod(): PsiMethod? =
|
||||
when (this) {
|
||||
is JetNamedFunction -> LightClassUtil.getLightClassMethod(this)
|
||||
is JetProperty -> LightClassUtil.getLightClassPropertyMethods(this).getGetter()
|
||||
@@ -79,7 +79,7 @@ fun PsiElement.getRepresentativeLightMethod(): PsiMethod? =
|
||||
else -> null
|
||||
}
|
||||
|
||||
fun JetParameter.toPsiParameter(): PsiParameter? {
|
||||
public fun JetParameter.toPsiParameter(): PsiParameter? {
|
||||
val paramList = getParentByType(javaClass<JetParameterList>())
|
||||
if (paramList == null) return null
|
||||
|
||||
@@ -100,7 +100,7 @@ fun JetParameter.toPsiParameter(): PsiParameter? {
|
||||
return method.getParameterList().getParameters()[lightParamIndex]
|
||||
}
|
||||
|
||||
fun JetTypeParameter.toPsiTypeParameters(): List<PsiTypeParameter> {
|
||||
public fun JetTypeParameter.toPsiTypeParameters(): List<PsiTypeParameter> {
|
||||
val paramList = getParentByType(javaClass<JetTypeParameterList>())
|
||||
if (paramList == null) return Collections.emptyList()
|
||||
|
||||
@@ -112,8 +112,8 @@ fun JetTypeParameter.toPsiTypeParameters(): List<PsiTypeParameter> {
|
||||
}
|
||||
|
||||
// Returns original declaration if given PsiElement is a Kotlin light element, and element itself otherwise
|
||||
val PsiElement.unwrapped: PsiElement?
|
||||
public val PsiElement.unwrapped: PsiElement?
|
||||
get() = if (this is KotlinLightElement<*, *>) origin else this
|
||||
|
||||
val PsiElement.namedUnwrappedElement: PsiNamedElement?
|
||||
public val PsiElement.namedUnwrappedElement: PsiNamedElement?
|
||||
get() = unwrapped?.getParentByType(javaClass<PsiNamedElement>())
|
||||
Reference in New Issue
Block a user