inlined method 'referenceToDescriptor'

This commit is contained in:
Svetlana Isakova
2012-06-08 15:28:11 +04:00
parent e05c310cdb
commit 18e45f3c27
2 changed files with 4 additions and 16 deletions
@@ -22,8 +22,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.calls.ResolvedCall;
import org.jetbrains.jet.lang.resolve.calls.VariableAsFunctionResolvedCall;
import org.jetbrains.jet.util.slicedmap.ReadOnlySlice; import org.jetbrains.jet.util.slicedmap.ReadOnlySlice;
import org.jetbrains.jet.util.slicedmap.Slices; import org.jetbrains.jet.util.slicedmap.Slices;
@@ -63,7 +61,7 @@ public class BindingContextUtils {
@Nullable @Nullable
public static PsiElement resolveToDeclarationPsiElement(@NotNull BindingContext bindingContext, @Nullable JetReferenceExpression referenceExpression) { public static PsiElement resolveToDeclarationPsiElement(@NotNull BindingContext bindingContext, @Nullable JetReferenceExpression referenceExpression) {
DeclarationDescriptor declarationDescriptor = referenceToDescriptor(bindingContext, referenceExpression); DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, referenceExpression);
if (declarationDescriptor == null) { if (declarationDescriptor == null) {
return bindingContext.get(BindingContext.LABEL_TARGET, referenceExpression); return bindingContext.get(BindingContext.LABEL_TARGET, referenceExpression);
} }
@@ -78,7 +76,7 @@ public class BindingContextUtils {
@NotNull @NotNull
public static List<PsiElement> resolveToDeclarationPsiElements(@NotNull BindingContext bindingContext, @Nullable JetReferenceExpression referenceExpression) { public static List<PsiElement> resolveToDeclarationPsiElements(@NotNull BindingContext bindingContext, @Nullable JetReferenceExpression referenceExpression) {
DeclarationDescriptor declarationDescriptor = referenceToDescriptor(bindingContext, referenceExpression); DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, referenceExpression);
if (declarationDescriptor == null) { if (declarationDescriptor == null) {
return Lists.newArrayList(bindingContext.get(BindingContext.LABEL_TARGET, referenceExpression)); return Lists.newArrayList(bindingContext.get(BindingContext.LABEL_TARGET, referenceExpression));
} }
@@ -99,7 +97,7 @@ public class BindingContextUtils {
descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element); descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element);
} }
else if (element instanceof JetSimpleNameExpression) { else if (element instanceof JetSimpleNameExpression) {
descriptor = referenceToDescriptor(bindingContext, (JetSimpleNameExpression) element); descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, (JetSimpleNameExpression) element);
} }
else if (element instanceof JetQualifiedExpression) { else if (element instanceof JetQualifiedExpression) {
descriptor = extractVariableDescriptorIfAny(bindingContext, ((JetQualifiedExpression) element).getSelectorExpression(), onlyReference); descriptor = extractVariableDescriptorIfAny(bindingContext, ((JetQualifiedExpression) element).getSelectorExpression(), onlyReference);
@@ -110,16 +108,6 @@ public class BindingContextUtils {
return null; return null;
} }
@Nullable
public static DeclarationDescriptor referenceToDescriptor(@NotNull BindingContext bindingContext, @Nullable JetReferenceExpression element) {
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, element);
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, element);
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
descriptor = ((VariableAsFunctionResolvedCall) resolvedCall).getVariableCall().getResultingDescriptor();
}
return descriptor;
}
// TODO these helper methods are added as a workaround to some compiler bugs in Kotlin... // TODO these helper methods are added as a workaround to some compiler bugs in Kotlin...
// NOTE this is used by KDoc // NOTE this is used by KDoc
@@ -149,7 +149,7 @@ public class StandardLibraryReferenceResolver extends AbstractProjectComponent {
@Nullable @Nullable
public PsiElement resolveStandardLibrarySymbol(@NotNull BindingContext originalContext, @Nullable JetReferenceExpression referenceExpression) { public PsiElement resolveStandardLibrarySymbol(@NotNull BindingContext originalContext, @Nullable JetReferenceExpression referenceExpression) {
ensureInitialized(); ensureInitialized();
DeclarationDescriptor declarationDescriptor = BindingContextUtils.referenceToDescriptor(originalContext, referenceExpression); DeclarationDescriptor declarationDescriptor = originalContext.get(BindingContext.REFERENCE_TARGET, referenceExpression);
return declarationDescriptor != null ? resolveStandardLibrarySymbol(declarationDescriptor) : null; return declarationDescriptor != null ? resolveStandardLibrarySymbol(declarationDescriptor) : null;
} }