do not use BindingContext.DESCRIPTOR_TO_DECLARATION explictly
This commit is contained in:
@@ -23,6 +23,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.*;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -51,7 +52,7 @@ public abstract class AnnotationCodegen {
|
||||
if(!(annotated instanceof DeclarationDescriptor))
|
||||
return;
|
||||
|
||||
PsiElement psiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, (DeclarationDescriptor)annotated);
|
||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(bindingContext, (DeclarationDescriptor) annotated);
|
||||
|
||||
JetModifierList modifierList = null;
|
||||
if(annotated instanceof ConstructorDescriptor && psiElement instanceof JetClass) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.jet.lang.psi.JetDeclarationWithBody;
|
||||
import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
@@ -288,7 +289,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
|
||||
argTypes[i++] = type;
|
||||
}
|
||||
else if(CodegenUtil.isNamedFun(descriptor, state.getBindingContext()) && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
|
||||
final Type type = Type.getObjectType(state.getInjector().getJetTypeMapper().getClosureAnnotator().classNameForAnonymousClass((JetElement) bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor)));
|
||||
final Type type = Type.getObjectType(state.getInjector().getJetTypeMapper().getClosureAnnotator().classNameForAnonymousClass((JetElement) BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor)));
|
||||
argTypes[i++] = type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,16 +17,15 @@
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -86,7 +85,7 @@ public class CodegenUtil {
|
||||
|
||||
|
||||
public static boolean isNamedFun(DeclarationDescriptor fd, BindingContext bindingContext) {
|
||||
PsiElement psiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, fd);
|
||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(bindingContext, fd);
|
||||
if(psiElement instanceof JetNamedFunction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.*;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
@@ -1066,7 +1067,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
}
|
||||
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
PsiElement declaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor);
|
||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor);
|
||||
if(declaration instanceof JetClass) {
|
||||
final JetClassObject classObject = ((JetClass) declaration).getClassObject();
|
||||
if (classObject == null) {
|
||||
@@ -1433,7 +1434,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
public StackValue generateThisOrOuter(ClassDescriptor calleeContainingClass) {
|
||||
CodegenContext cur = context;
|
||||
|
||||
PsiElement psiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, calleeContainingClass);
|
||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(bindingContext, calleeContainingClass);
|
||||
boolean isObject = psiElement instanceof JetClassOrObject && CodegenUtil.isNonLiteralObject((JetClassOrObject)psiElement);
|
||||
|
||||
cur = context;
|
||||
@@ -2235,7 +2236,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
|
||||
private StackValue generateConstructorCall(JetCallExpression expression, JetSimpleNameExpression constructorReference, StackValue receiver) {
|
||||
DeclarationDescriptor constructorDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, constructorReference);
|
||||
final PsiElement declaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, constructorDescriptor);
|
||||
final PsiElement declaration = BindingContextUtils.descriptorToDeclaration(bindingContext, constructorDescriptor);
|
||||
Type type;
|
||||
if (declaration instanceof PsiMethod) {
|
||||
type = generateJavaConstructorCall(expression);
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.jet.codegen.signature.kotlin.JetValueParameterAnnotationWri
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
@@ -299,7 +300,7 @@ public class FunctionCodegen {
|
||||
if(kind != OwnerKind.TRAIT_IMPL) {
|
||||
// we don't generate defaults for traits but do for traitImpl
|
||||
if(contextClass instanceof ClassDescriptor) {
|
||||
PsiElement psiElement = state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, contextClass);
|
||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(state.getBindingContext(), contextClass);
|
||||
if(psiElement instanceof JetClass) {
|
||||
JetClass element = (JetClass) psiElement;
|
||||
if(element.isTrait())
|
||||
@@ -404,7 +405,7 @@ public class FunctionCodegen {
|
||||
Label loadArg = new Label();
|
||||
iv.ifeq(loadArg);
|
||||
|
||||
JetParameter jetParameter = (JetParameter) state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, parameterDescriptor);
|
||||
JetParameter jetParameter = (JetParameter) BindingContextUtils.descriptorToDeclaration(state.getBindingContext(), parameterDescriptor);
|
||||
assert jetParameter != null;
|
||||
codegen.gen(jetParameter.getDefaultValue(), t);
|
||||
|
||||
@@ -439,7 +440,7 @@ public class FunctionCodegen {
|
||||
|
||||
iv.areturn(jvmSignature.getReturnType());
|
||||
|
||||
endVisit(mv, "default method", state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, functionDescriptor));
|
||||
endVisit(mv, "default method", BindingContextUtils.descriptorToDeclaration(state.getBindingContext(), functionDescriptor));
|
||||
mv.visitEnd();
|
||||
}
|
||||
}
|
||||
@@ -499,7 +500,7 @@ public class FunctionCodegen {
|
||||
if(jvmSignature.getReturnType() == Type.VOID_TYPE)
|
||||
iv.aconst(null);
|
||||
iv.areturn(overriden.getReturnType());
|
||||
endVisit(mv, "bridge method", state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, functionDescriptor));
|
||||
endVisit(mv, "bridge method", BindingContextUtils.descriptorToDeclaration(state.getBindingContext(), functionDescriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -543,7 +544,7 @@ public class FunctionCodegen {
|
||||
else
|
||||
iv.invokevirtual(internalName, method.getName(), method.getDescriptor());
|
||||
iv.areturn(method.getReturnType());
|
||||
endVisit(mv, "delegate method", state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, functionDescriptor));
|
||||
endVisit(mv, "delegate method", BindingContextUtils.descriptorToDeclaration(state.getBindingContext(), functionDescriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.jet.codegen.signature.kotlin.JetValueParameterAnnotationWri
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.OverridingUtil;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
@@ -633,7 +634,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
StackValue field = StackValue.field(fieldType, classname, delegateField, false);
|
||||
field.store(iv);
|
||||
|
||||
JetClass superClass = (JetClass) bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, superClassDescriptor);
|
||||
JetClass superClass = (JetClass) BindingContextUtils.descriptorToDeclaration(bindingContext, superClassDescriptor);
|
||||
final CodegenContext delegateContext = context.intoClass(superClassDescriptor,
|
||||
new OwnerKind.DelegateKind(StackValue.field(fieldType, classname, delegateField, false),
|
||||
typeMapper.mapType(superClassDescriptor.getDefaultType(), MapTypeMode.IMPL).getInternalName()), state.getInjector().getJetTypeMapper());
|
||||
@@ -722,7 +723,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
DeclarationDescriptor containingDeclaration = fun.getContainingDeclaration();
|
||||
if(containingDeclaration instanceof ClassDescriptor) {
|
||||
ClassDescriptor declaration = (ClassDescriptor) containingDeclaration;
|
||||
PsiElement psiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, declaration);
|
||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(bindingContext, declaration);
|
||||
if(psiElement instanceof JetClass) {
|
||||
JetClass jetClass = (JetClass) psiElement;
|
||||
if(jetClass.isTrait()) {
|
||||
@@ -764,7 +765,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
iv.checkcast(function.getReturnType());
|
||||
}
|
||||
iv.areturn(function.getReturnType());
|
||||
FunctionCodegen.endVisit(iv, "trait method", bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, fun));
|
||||
FunctionCodegen.endVisit(iv, "trait method", BindingContextUtils.descriptorToDeclaration(bindingContext, fun));
|
||||
}
|
||||
|
||||
FunctionCodegen.generateBridgeIfNeeded(context, state, v, function, fun, kind);
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.jet.codegen.signature.JvmPropertyAccessorSignature;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.java.*;
|
||||
@@ -275,7 +276,7 @@ public class JetTypeMapper {
|
||||
DeclarationDescriptor container = descriptor.getContainingDeclaration();
|
||||
String name = descriptor.getName();
|
||||
if(JetPsiUtil.NO_NAME_PROVIDED.equals(name)) {
|
||||
return closureAnnotator.classNameForAnonymousClass((JetElement) bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor));
|
||||
return closureAnnotator.classNameForAnonymousClass((JetElement) BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor));
|
||||
}
|
||||
if(name.contains("/"))
|
||||
return name;
|
||||
@@ -924,7 +925,7 @@ public class JetTypeMapper {
|
||||
return StackValue.sharedTypeForType(mapType(((PropertyDescriptor) descriptor).getReceiverParameter().getType(), MapTypeMode.VALUE));
|
||||
}
|
||||
else if (descriptor instanceof SimpleFunctionDescriptor && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
|
||||
PsiElement psiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor);
|
||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor);
|
||||
return Type.getObjectType(closureAnnotator.classNameForAnonymousClass((JetElement) psiElement));
|
||||
}
|
||||
else if (descriptor instanceof FunctionDescriptor) {
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.jet.codegen;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.JetDelegatorToSuperCall;
|
||||
import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
@@ -82,7 +82,7 @@ public class ObjectOrClosureCodegen {
|
||||
final int idx = exprContext.lookupLocal(vd);
|
||||
if (idx < 0) return null;
|
||||
|
||||
JetElement expression = (JetElement) state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, vd);
|
||||
JetElement expression = (JetElement) BindingContextUtils.descriptorToDeclaration(state.getBindingContext(), vd);
|
||||
String cn = state.getInjector().getJetTypeMapper().getClosureAnnotator().classNameForAnonymousClass(expression);
|
||||
Type localType = Type.getObjectType(cn);
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.jet.codegen.signature.JvmPropertyAccessorSignature;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
@@ -160,7 +161,7 @@ public class PropertyCodegen {
|
||||
flags |= Opcodes.ACC_STATIC;
|
||||
}
|
||||
|
||||
PsiElement psiElement = state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, propertyDescriptor.getContainingDeclaration());
|
||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(state.getBindingContext(), propertyDescriptor.getContainingDeclaration());
|
||||
boolean isTrait = psiElement instanceof JetClass && ((JetClass) psiElement).isTrait();
|
||||
if(isTrait && !(kind instanceof OwnerKind.DelegateKind))
|
||||
flags |= Opcodes.ACC_ABSTRACT;
|
||||
@@ -245,7 +246,7 @@ public class PropertyCodegen {
|
||||
flags |= Opcodes.ACC_STATIC;
|
||||
}
|
||||
|
||||
PsiElement psiElement = state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, propertyDescriptor.getContainingDeclaration());
|
||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(state.getBindingContext(), propertyDescriptor.getContainingDeclaration());
|
||||
boolean isTrait = psiElement instanceof JetClass && ((JetClass) psiElement).isTrait();
|
||||
if(isTrait && !(kind instanceof OwnerKind.DelegateKind))
|
||||
flags |= Opcodes.ACC_ABSTRACT;
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
@@ -34,7 +35,7 @@ public class TraitImplBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
//todo not needed when frontend will be able to calculate properly
|
||||
static JetType getSuperClass(ClassDescriptor myClassDescr, BindingContext bindingContext) {
|
||||
JetClassOrObject myClass = (JetClassOrObject) bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, myClassDescr);
|
||||
JetClassOrObject myClass = (JetClassOrObject) BindingContextUtils.descriptorToDeclaration(bindingContext, myClassDescr);
|
||||
if(myClass == null)
|
||||
return JetStandardClasses.getAnyType();
|
||||
List<JetDelegationSpecifier> delegationSpecifiers = myClass.getDelegationSpecifiers();
|
||||
@@ -43,7 +44,7 @@ public class TraitImplBodyCodegen extends ClassBodyCodegen {
|
||||
if (specifier instanceof JetDelegatorToSuperClass || specifier instanceof JetDelegatorToSuperCall) {
|
||||
JetType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference());
|
||||
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
||||
final PsiElement declaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, superClassDescriptor);
|
||||
final PsiElement declaration = BindingContextUtils.descriptorToDeclaration(bindingContext, superClassDescriptor);
|
||||
if (declaration != null) {
|
||||
if (declaration instanceof PsiClass) {
|
||||
if (!((PsiClass) declaration).isInterface()) {
|
||||
|
||||
@@ -361,7 +361,7 @@ public class JetFlowInformationProvider {
|
||||
if (variableDescriptor instanceof PropertyDescriptor && !enterInitializers.isInitialized() && exitInitializers.isInitialized()) {
|
||||
if (!variableDescriptor.isVar()) return false;
|
||||
if (!trace.get(BindingContext.BACKING_FIELD_REQUIRED, (PropertyDescriptor) variableDescriptor)) return false;
|
||||
PsiElement property = trace.get(BindingContext.DESCRIPTOR_TO_DECLARATION, variableDescriptor);
|
||||
PsiElement property = BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), variableDescriptor);
|
||||
assert property instanceof JetProperty;
|
||||
if (((PropertyDescriptor) variableDescriptor).getModality() == Modality.FINAL && ((JetProperty) property).getSetter() == null) return false;
|
||||
JetExpression variable = expression;
|
||||
@@ -395,7 +395,7 @@ public class JetFlowInformationProvider {
|
||||
trace.report(Errors.NOT_PROPERTY_BACKING_FIELD.on(element));
|
||||
return true;
|
||||
}
|
||||
PsiElement property = trace.get(BindingContext.DESCRIPTOR_TO_DECLARATION, variableDescriptor);
|
||||
PsiElement property = BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), variableDescriptor);
|
||||
boolean insideSelfAccessors = PsiTreeUtil.isAncestor(property, element, false);
|
||||
if (!trace.get(BindingContext.BACKING_FIELD_REQUIRED, (PropertyDescriptor) variableDescriptor) && !insideSelfAccessors) { // not to generate error in accessors of abstract properties, there is one: declared accessor of abstract property
|
||||
if (((PropertyDescriptor) variableDescriptor).getModality() == Modality.ABSTRACT) {
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetParameter;
|
||||
import org.jetbrains.jet.lang.resolve.AbstractScopeAdapter;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.*;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver;
|
||||
@@ -91,7 +91,7 @@ public class MutableClassDescriptor extends MutableClassDescriptorLite {
|
||||
if (constructorDescriptor.isPrimary()) {
|
||||
setUpScopeForInitializers(constructorDescriptor);
|
||||
for (ValueParameterDescriptor valueParameterDescriptor : constructorDescriptor.getValueParameters()) {
|
||||
JetParameter parameter = (JetParameter) trace.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, valueParameterDescriptor);
|
||||
JetParameter parameter = (JetParameter) BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), valueParameterDescriptor);
|
||||
assert parameter != null;
|
||||
if (parameter.getValOrVarNode() == null || !constructorDescriptor.isPrimary()) {
|
||||
getWritableScopeForInitializers().addVariableDescriptor(valueParameterDescriptor);
|
||||
|
||||
+2
-1
@@ -24,6 +24,7 @@ import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedDeclaration;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -59,7 +60,7 @@ public interface RedeclarationDiagnostic extends Diagnostic {
|
||||
|
||||
private PsiElement resolve() {
|
||||
if (element == null) {
|
||||
element = contextToResolveToDeclaration.get(BindingContext.DESCRIPTOR_TO_DECLARATION, duplicatingDescriptor);
|
||||
element = BindingContextUtils.descriptorToDeclaration(contextToResolveToDeclaration, duplicatingDescriptor);
|
||||
assert element != null : "No element for descriptor: " + duplicatingDescriptor;
|
||||
}
|
||||
return element;
|
||||
|
||||
@@ -87,6 +87,7 @@ public interface BindingContext {
|
||||
}
|
||||
backingFieldRequired = valueNotFound ? false : backingFieldRequired;
|
||||
assert backingFieldRequired != null;
|
||||
// TODO: user BindingContextAccessors
|
||||
PsiElement declarationPsiElement = map.get(DESCRIPTOR_TO_DECLARATION, propertyDescriptor);
|
||||
if (declarationPsiElement instanceof JetParameter) {
|
||||
JetParameter jetParameter = (JetParameter) declarationPsiElement;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class BindingContextUtils {
|
||||
return bindingContext.get(BindingContext.LABEL_TARGET, referenceExpression);
|
||||
}
|
||||
|
||||
PsiElement element = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, declarationDescriptor);
|
||||
PsiElement element = descriptorToDeclaration(bindingContext, declarationDescriptor);
|
||||
if (element != null) {
|
||||
return element;
|
||||
}
|
||||
@@ -77,11 +77,13 @@ public class BindingContextUtils {
|
||||
|
||||
// TODO these helper methods are added as a workaround to some compiler bugs in Kotlin...
|
||||
|
||||
// NOTE this is used by KDoc
|
||||
@Nullable
|
||||
public static NamespaceDescriptor namespaceDescriptor(@NotNull BindingContext context, @NotNull JetFile source) {
|
||||
return context.get(BindingContext.FILE_TO_NAMESPACE, source);
|
||||
}
|
||||
|
||||
// NOTE this is also used by KDoc
|
||||
@Nullable
|
||||
public static PsiElement descriptorToDeclaration(@NotNull BindingContext context, @NotNull DeclarationDescriptor descriptor) {
|
||||
return context.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor);
|
||||
|
||||
@@ -291,7 +291,7 @@ public class DeclarationResolver {
|
||||
});
|
||||
}
|
||||
else {
|
||||
declarations = Collections.singletonList(trace.get(BindingContext.DESCRIPTOR_TO_DECLARATION, declarationDescriptor));
|
||||
declarations = Collections.singletonList(BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), declarationDescriptor));
|
||||
}
|
||||
return declarations;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class DeclarationsChecker {
|
||||
private void checkOpenMembers(MutableClassDescriptor classDescriptor) {
|
||||
for (CallableMemberDescriptor memberDescriptor : classDescriptor.getCallableMembers()) {
|
||||
|
||||
JetNamedDeclaration member = (JetNamedDeclaration) trace.get(BindingContext.DESCRIPTOR_TO_DECLARATION, memberDescriptor);
|
||||
JetNamedDeclaration member = (JetNamedDeclaration) BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), memberDescriptor);
|
||||
if (member != null && classDescriptor.getModality() == Modality.FINAL && member.hasModifier(JetTokens.OPEN_KEYWORD)) {
|
||||
trace.report(NON_FINAL_MEMBER_IN_FINAL_CLASS.on(member));
|
||||
}
|
||||
@@ -179,7 +179,7 @@ public class DeclarationsChecker {
|
||||
return;
|
||||
}
|
||||
if (!(classDescriptor.getModality() == Modality.ABSTRACT) && classDescriptor.getKind() != ClassKind.ENUM_CLASS) {
|
||||
PsiElement classElement = trace.get(BindingContext.DESCRIPTOR_TO_DECLARATION, classDescriptor);
|
||||
PsiElement classElement = BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), classDescriptor);
|
||||
assert classElement instanceof JetClass;
|
||||
String name = property.getName();
|
||||
trace.report(ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS.on(property, name != null ? name : "", classDescriptor, (JetClass) classElement));
|
||||
@@ -252,7 +252,7 @@ public class DeclarationsChecker {
|
||||
boolean inEnum = classDescriptor.getKind() == ClassKind.ENUM_CLASS;
|
||||
boolean inAbstractClass = classDescriptor.getModality() == Modality.ABSTRACT;
|
||||
if (hasAbstractModifier && !inAbstractClass && !inTrait && !inEnum) {
|
||||
PsiElement classElement = trace.get(BindingContext.DESCRIPTOR_TO_DECLARATION, classDescriptor);
|
||||
PsiElement classElement = BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), classDescriptor);
|
||||
assert classElement instanceof JetClass;
|
||||
trace.report(ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS.on(function, functionDescriptor.getName(), classDescriptor, (JetClass) classElement));
|
||||
}
|
||||
|
||||
@@ -194,14 +194,14 @@ public class OverloadResolver {
|
||||
|
||||
OverloadUtil.OverloadCompatibilityInfo overloadable = OverloadUtil.isOverloadable(member, member2);
|
||||
if (!overloadable.isSuccess()) {
|
||||
JetDeclaration jetDeclaration = (JetDeclaration) trace.get(BindingContext.DESCRIPTOR_TO_DECLARATION, member);
|
||||
JetDeclaration jetDeclaration = (JetDeclaration) BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), member);
|
||||
if (jetDeclaration == null) {
|
||||
assert trace.get(DELEGATED, member);
|
||||
return;
|
||||
}
|
||||
|
||||
if (member instanceof PropertyDescriptor) {
|
||||
trace.report(Errors.REDECLARATION.on(trace.get(DESCRIPTOR_TO_DECLARATION, member), member.getName()));
|
||||
trace.report(Errors.REDECLARATION.on(BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), member), member.getName()));
|
||||
}
|
||||
else {
|
||||
trace.report(Errors.CONFLICTING_OVERLOADS.on(jetDeclaration, member, functionContainer));
|
||||
|
||||
@@ -135,7 +135,7 @@ public class OverrideResolver {
|
||||
|
||||
@Override
|
||||
public void conflict(@NotNull CallableMemberDescriptor fromSuper, @NotNull CallableMemberDescriptor fromCurrent) {
|
||||
JetDeclaration jetProperty = (JetDeclaration) trace.get(BindingContext.DESCRIPTOR_TO_DECLARATION, fromCurrent);
|
||||
JetDeclaration jetProperty = (JetDeclaration) BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), fromCurrent);
|
||||
trace.report(Errors.CONFLICTING_OVERLOADS.on(jetProperty, fromCurrent, fromCurrent.getContainingDeclaration().getName()));
|
||||
}
|
||||
});
|
||||
@@ -372,7 +372,7 @@ public class OverrideResolver {
|
||||
}
|
||||
|
||||
private void checkOverride(CallableMemberDescriptor declared) {
|
||||
JetNamedDeclaration member = (JetNamedDeclaration) trace.get(BindingContext.DESCRIPTOR_TO_DECLARATION, declared);
|
||||
JetNamedDeclaration member = (JetNamedDeclaration) BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), declared);
|
||||
if (member == null) {
|
||||
assert trace.get(DELEGATED, declared);
|
||||
return;
|
||||
@@ -441,7 +441,7 @@ public class OverrideResolver {
|
||||
checkVisibilityForMember(propertyDescriptor.getVisibility(), property, propertyDescriptor.getOverriddenDescriptors());
|
||||
}
|
||||
for (PropertyDescriptor propertyDescriptor : context.getPrimaryConstructorParameterProperties()) {
|
||||
PsiElement parameter = trace.get(BindingContext.DESCRIPTOR_TO_DECLARATION, propertyDescriptor);
|
||||
PsiElement parameter = BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), propertyDescriptor);
|
||||
if (parameter instanceof JetParameter) {
|
||||
checkVisibilityForMember(propertyDescriptor.getVisibility(), (JetParameter)parameter, propertyDescriptor.getOverriddenDescriptors());
|
||||
}
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class TraceBasedRedeclarationHandler implements RedeclarationHandler {
|
||||
}
|
||||
|
||||
private void report(DeclarationDescriptor descriptor) {
|
||||
PsiElement firstElement = trace.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor);
|
||||
PsiElement firstElement = BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), descriptor);
|
||||
if (firstElement != null) {
|
||||
trace.report(REDECLARATION.on(firstElement, descriptor.getName()));
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ public class TypeHierarchyResolver {
|
||||
if (!found) continue;
|
||||
|
||||
ClassDescriptor superclass = (i < size - 1) ? currentPath.get(i + 1) : current;
|
||||
PsiElement psiElement = trace.get(DESCRIPTOR_TO_DECLARATION, classDescriptor);
|
||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), classDescriptor);
|
||||
|
||||
PsiElement elementToMark = null;
|
||||
if (psiElement instanceof JetClassOrObject) {
|
||||
@@ -410,7 +410,7 @@ public class TypeHierarchyResolver {
|
||||
if (conflictingTypes.size() > 1) {
|
||||
DeclarationDescriptor containingDeclaration = typeParameterDescriptor.getContainingDeclaration();
|
||||
assert containingDeclaration instanceof ClassDescriptor : containingDeclaration;
|
||||
PsiElement psiElement = trace.get(DESCRIPTOR_TO_DECLARATION, mutableClassDescriptor);
|
||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(trace.getBindingContext(), mutableClassDescriptor);
|
||||
assert psiElement instanceof JetClassOrObject : psiElement;
|
||||
JetClassOrObject declaration = (JetClassOrObject) psiElement;
|
||||
JetDelegationSpecifierList delegationSpecifierList = declaration.getDelegationSpecifierList();
|
||||
|
||||
+4
-3
@@ -27,6 +27,7 @@ import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTraceContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
@@ -271,7 +272,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
|
||||
VariableDescriptor olderVariable = context.scope.getLocalVariable(variableDescriptor.getName());
|
||||
if (olderVariable != null && DescriptorUtils.isLocal(context.scope.getContainingDeclaration(), olderVariable)) {
|
||||
PsiElement declaration = context.trace.get(DESCRIPTOR_TO_DECLARATION, variableDescriptor);
|
||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context.trace.getBindingContext(), variableDescriptor);
|
||||
context.trace.report(Errors.NAME_SHADOWING.on(declaration, variableDescriptor.getName()));
|
||||
}
|
||||
}
|
||||
@@ -472,12 +473,12 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
|
||||
if (expression.getTargetLabel() == null) {
|
||||
if (containingFunctionDescriptor != null) {
|
||||
PsiElement containingFunction = context.trace.get(DESCRIPTOR_TO_DECLARATION, containingFunctionDescriptor);
|
||||
PsiElement containingFunction = BindingContextUtils.descriptorToDeclaration(context.trace.getBindingContext(), containingFunctionDescriptor);
|
||||
assert containingFunction != null;
|
||||
if (containingFunction instanceof JetFunctionLiteralExpression) {
|
||||
do {
|
||||
containingFunctionDescriptor = DescriptorUtils.getParentOfType(containingFunctionDescriptor, FunctionDescriptor.class);
|
||||
containingFunction = containingFunctionDescriptor != null ? context.trace.get(DESCRIPTOR_TO_DECLARATION, containingFunctionDescriptor) : null;
|
||||
containingFunction = containingFunctionDescriptor != null ? BindingContextUtils.descriptorToDeclaration(context.trace.getBindingContext(), containingFunctionDescriptor) : null;
|
||||
} while (containingFunction instanceof JetFunctionLiteralExpression);
|
||||
context.trace.report(RETURN_NOT_ALLOWED.on(expression));
|
||||
}
|
||||
|
||||
+2
-1
@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.TemporaryBindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.TopDownAnalyzer;
|
||||
@@ -118,7 +119,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
||||
{
|
||||
VariableDescriptor olderVariable = scope.getLocalVariable(propertyDescriptor.getName());
|
||||
if (olderVariable != null && DescriptorUtils.isLocal(propertyDescriptor.getContainingDeclaration(), olderVariable)) {
|
||||
PsiElement declaration = context.trace.get(DESCRIPTOR_TO_DECLARATION, propertyDescriptor);
|
||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context.trace.getBindingContext(), propertyDescriptor);
|
||||
context.trace.report(Errors.NAME_SHADOWING.on(declaration, propertyDescriptor.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
|
||||
import java.util.*;
|
||||
@@ -79,7 +80,7 @@ public class LabelResolver {
|
||||
DeclarationDescriptor declarationDescriptor = declarationsByLabel.iterator().next();
|
||||
JetElement element;
|
||||
if (declarationDescriptor instanceof FunctionDescriptor || declarationDescriptor instanceof ClassDescriptor) {
|
||||
element = (JetElement) context.trace.get(BindingContext.DESCRIPTOR_TO_DECLARATION, declarationDescriptor);
|
||||
element = (JetElement) BindingContextUtils.descriptorToDeclaration(context.trace.getBindingContext(), declarationDescriptor);
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException(); // TODO
|
||||
@@ -139,7 +140,7 @@ public class LabelResolver {
|
||||
else {
|
||||
throw new UnsupportedOperationException(); // TODO
|
||||
}
|
||||
PsiElement element = context.trace.get(DESCRIPTOR_TO_DECLARATION, declarationDescriptor);
|
||||
PsiElement element = BindingContextUtils.descriptorToDeclaration(context.trace.getBindingContext(), declarationDescriptor);
|
||||
assert element != null;
|
||||
context.trace.record(LABEL_TARGET, targetLabel, element);
|
||||
context.trace.record(REFERENCE_TARGET, thisReference, declarationDescriptor);
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.plugin.completion.handlers.JetClassInsertHandler;
|
||||
@@ -119,7 +120,7 @@ public final class DescriptorLookupConverter {
|
||||
}
|
||||
descriptor = callableMemberDescriptor;
|
||||
}
|
||||
return createLookupElement(bindingContext, descriptor, bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor));
|
||||
return createLookupElement(bindingContext, descriptor, BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor));
|
||||
}
|
||||
|
||||
public static LookupElement[] collectLookupElements(BindingContext bindingContext, Iterable<DeclarationDescriptor> descriptors) {
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.plugin.project.WholeProjectAnalyzerFacade;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
|
||||
@@ -110,7 +111,7 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
|
||||
if (overriddenMembers.isEmpty()) return;
|
||||
final List<PsiElement> list = Lists.newArrayList();
|
||||
for (CallableMemberDescriptor overriddenMember : overriddenMembers) {
|
||||
PsiElement declarationPsiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, overriddenMember);
|
||||
PsiElement declarationPsiElement = BindingContextUtils.descriptorToDeclaration(bindingContext, overriddenMember);
|
||||
list.add(declarationPsiElement);
|
||||
}
|
||||
if (list.isEmpty()) {
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
||||
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||
@@ -176,7 +177,7 @@ class DecompiledDataFactory {
|
||||
}
|
||||
|
||||
myBuilder.append("\n");
|
||||
PsiElement clsMember = myBindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor);
|
||||
PsiElement clsMember = BindingContextUtils.descriptorToDeclaration(myBindingContext, descriptor);
|
||||
if (clsMember != null) {
|
||||
myClsMembersToRanges.put(clsMember, new TextRange(startOffset, endOffset));
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
||||
@@ -100,7 +101,8 @@ public class JetSourceNavigationHelper {
|
||||
public static JetClass getSourceClass(@NotNull JetClass decompiledClass) {
|
||||
Tuple2<BindingContext, ClassDescriptor> bindingContextAndClassDescriptor = getBindingContextAndClassDescriptor(decompiledClass);
|
||||
if (bindingContextAndClassDescriptor == null) return null;
|
||||
PsiElement declaration = bindingContextAndClassDescriptor._1.get(BindingContext.DESCRIPTOR_TO_DECLARATION, bindingContextAndClassDescriptor._2);
|
||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(
|
||||
bindingContextAndClassDescriptor._1, bindingContextAndClassDescriptor._2);
|
||||
assert declaration instanceof JetClass;
|
||||
return (JetClass) declaration;
|
||||
}
|
||||
@@ -159,7 +161,7 @@ public class JetSourceNavigationHelper {
|
||||
for (Descr candidate : matcher.getCandidatesFromScope(namespaceDescriptor.getMemberScope(), entityName)) {
|
||||
if (candidate.getReceiverParameter() == ReceiverDescriptor.NO_RECEIVER) {
|
||||
if (matcher.areSame(decompiledDeclaration, candidate)) {
|
||||
return (JetDeclaration) bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, candidate);
|
||||
return (JetDeclaration) BindingContextUtils.descriptorToDeclaration(bindingContext, candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,7 +174,7 @@ public class JetSourceNavigationHelper {
|
||||
String thisReceiverType = DescriptorRenderer.TEXT.renderType(candidate.getReceiverParameter().getType());
|
||||
if (expectedTypeString.equals(thisReceiverType)) {
|
||||
if (matcher.areSame(decompiledDeclaration, candidate)) {
|
||||
return (JetDeclaration) bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, candidate);
|
||||
return (JetDeclaration) BindingContextUtils.descriptorToDeclaration(bindingContext, candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,7 +205,7 @@ public class JetSourceNavigationHelper {
|
||||
ClassDescriptor expectedContainer = isClassObject ? classDescriptor.getClassObjectDescriptor() : classDescriptor;
|
||||
for (Descr candidate : matcher.getCandidatesFromScope(memberScope, entityName)) {
|
||||
if (candidate.getContainingDeclaration() == expectedContainer) {
|
||||
JetDeclaration property = (JetDeclaration) bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, candidate);
|
||||
JetDeclaration property = (JetDeclaration) BindingContextUtils.descriptorToDeclaration(bindingContext, candidate);
|
||||
if (property != null) {
|
||||
return property;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices;
|
||||
import org.jetbrains.jet.plugin.project.WholeProjectAnalyzerFacade;
|
||||
@@ -82,7 +83,7 @@ public abstract class BaseJetVariableMacro extends Macro {
|
||||
|
||||
List<JetNamedDeclaration> declarations = new ArrayList<JetNamedDeclaration>();
|
||||
for (DeclarationDescriptor declarationDescriptor : TipsManager.excludeNotCallableExtensions(filteredDescriptors, scope)) {
|
||||
PsiElement declaration = bc.get(BindingContext.DESCRIPTOR_TO_DECLARATION, declarationDescriptor);
|
||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(bc, declarationDescriptor);
|
||||
assert declaration == null || declaration instanceof PsiNamedElement;
|
||||
|
||||
if (declaration instanceof JetProperty || declaration instanceof JetParameter) {
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
import org.jetbrains.jet.plugin.project.WholeProjectAnalyzerFacade;
|
||||
@@ -106,7 +107,7 @@ public class JetAnonymousSuperMacro extends Macro {
|
||||
if (!classDescriptor.getModality().isOverridable()) continue;
|
||||
ClassKind kind = classDescriptor.getKind();
|
||||
if (kind == ClassKind.TRAIT || kind == ClassKind.CLASS) {
|
||||
PsiElement declaration = bc.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor);
|
||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(bc, descriptor);
|
||||
if (declaration != null) {
|
||||
result.add((PsiNamedElement) declaration);
|
||||
}
|
||||
|
||||
+2
-1
@@ -30,6 +30,7 @@ import org.jetbrains.jet.compiler.TipsManager;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.JetVisibilityChecker;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -149,7 +150,7 @@ public class JetFunctionParameterInfoHandler implements
|
||||
builder.append(descriptor.getName()).append(": ").
|
||||
append(DescriptorRenderer.TEXT.renderType(getActualParameterType(descriptor)));
|
||||
if (descriptor.hasDefaultValue()) {
|
||||
PsiElement element = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor);
|
||||
PsiElement element = BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor);
|
||||
String defaultExpression = "?";
|
||||
if (element instanceof JetParameter) {
|
||||
JetParameter parameter = (JetParameter) element;
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ChangeVariableMutabilityFix implements IntentionAction {
|
||||
BindingContext bindingContext = getContextForSingleFile(file);
|
||||
VariableDescriptor descriptor = BindingContextUtils.extractVariableDescriptorIfAny(bindingContext, simpleNameExpression, true);
|
||||
if (descriptor != null) {
|
||||
PsiElement declaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor);
|
||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor);
|
||||
if (declaration instanceof JetProperty) {
|
||||
return (JetProperty) declaration;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.usages.impl.rules.NonCodeUsageGroupingRule;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.DefaultModuleConfiguration;
|
||||
@@ -25,6 +26,7 @@ import org.jetbrains.jet.lang.psi.JetImportDirective;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaBridgeConfiguration;
|
||||
@@ -56,7 +58,7 @@ public class ImportInsertHelper {
|
||||
return;
|
||||
}
|
||||
BindingContext bindingContext = getContextForSingleFile(file);
|
||||
PsiElement element = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, type.getMemberScope().getContainingDeclaration());
|
||||
PsiElement element = BindingContextUtils.descriptorToDeclaration(bindingContext, type.getMemberScope().getContainingDeclaration());
|
||||
if (element != null && element.getContainingFile() == file) { //declaration is in the same file, so no import is needed
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.jet.lang.psi.JetArrayAccessExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetContainerNode;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ResolvedCall;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.project.WholeProjectAnalyzerFacade;
|
||||
@@ -76,9 +77,9 @@ class JetArrayAccessReference extends JetPsiReference implements MultiRangeRefer
|
||||
if (getFunction == null || setFunction == null) {
|
||||
return new ResolveResult[0];
|
||||
}
|
||||
PsiElement getFunctionElement = bindingContext.get(DESCRIPTOR_TO_DECLARATION, getFunction.getResultingDescriptor());
|
||||
PsiElement getFunctionElement = BindingContextUtils.descriptorToDeclaration(bindingContext, getFunction.getResultingDescriptor());
|
||||
assert getFunctionElement != null;
|
||||
PsiElement setFunctionElement = bindingContext.get(DESCRIPTOR_TO_DECLARATION, setFunction.getResultingDescriptor());
|
||||
PsiElement setFunctionElement = BindingContextUtils.descriptorToDeclaration(bindingContext, setFunction.getResultingDescriptor());
|
||||
assert setFunctionElement != null;
|
||||
return new ResolveResult[] {new PsiElementResolveResult(getFunctionElement, true), new PsiElementResolveResult(setFunctionElement, true)};
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public abstract class JetPsiReference implements PsiPolyVariantReference {
|
||||
ArrayList<ResolveResult> results = new ArrayList<ResolveResult>(declarationDescriptors.size());
|
||||
|
||||
for (DeclarationDescriptor descriptor : declarationDescriptors) {
|
||||
PsiElement element = bindingContext.get(DESCRIPTOR_TO_DECLARATION, descriptor);
|
||||
PsiElement element = BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor);
|
||||
if (element == null) {
|
||||
// TODO: Need a better resolution for Intrinsic function (KT-975)
|
||||
element = file;
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.refactoring.rename.RenameProcessor;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.FqName;
|
||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||
import org.jetbrains.jet.plugin.project.WholeProjectAnalyzerFacade;
|
||||
@@ -69,7 +70,7 @@ public class RenameInKotlinTest extends MultiFileTestCase {
|
||||
|
||||
assertNotNull(classDescriptor);
|
||||
|
||||
PsiElement psiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, classDescriptor);
|
||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(bindingContext, classDescriptor);
|
||||
|
||||
assertNotNull(psiElement);
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -88,7 +89,7 @@ public final class BindingUtils {
|
||||
@NotNull
|
||||
public static JetClass getClassForDescriptor(@NotNull BindingContext context,
|
||||
@NotNull ClassDescriptor descriptor) {
|
||||
PsiElement result = context.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor);
|
||||
PsiElement result = BindingContextUtils.descriptorToDeclaration(context, descriptor);
|
||||
assert result instanceof JetClass : "ClassDescriptor should have declaration of type JetClass";
|
||||
return (JetClass)result;
|
||||
}
|
||||
@@ -96,7 +97,7 @@ public final class BindingUtils {
|
||||
@NotNull
|
||||
public static JetFunction getFunctionForDescriptor(@NotNull BindingContext context,
|
||||
@NotNull SimpleFunctionDescriptor descriptor) {
|
||||
PsiElement result = context.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor);
|
||||
PsiElement result = BindingContextUtils.descriptorToDeclaration(context, descriptor);
|
||||
assert result instanceof JetFunction : "SimpleFunctionDescriptor should have declaration of type JetFunction";
|
||||
return (JetFunction)result;
|
||||
}
|
||||
@@ -120,7 +121,7 @@ public final class BindingUtils {
|
||||
@Nullable
|
||||
private static JetDeclaration getDeclarationForDescriptor(@NotNull BindingContext context,
|
||||
@NotNull DeclarationDescriptor descriptor) {
|
||||
PsiElement result = context.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor);
|
||||
PsiElement result = BindingContextUtils.descriptorToDeclaration(context, descriptor);
|
||||
if (result == null) {
|
||||
//TODO: never get there
|
||||
return null;
|
||||
@@ -132,7 +133,7 @@ public final class BindingUtils {
|
||||
@NotNull
|
||||
private static JetParameter getParameterForDescriptor(@NotNull BindingContext context,
|
||||
@NotNull ValueParameterDescriptor descriptor) {
|
||||
PsiElement result = context.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor);
|
||||
PsiElement result = BindingContextUtils.descriptorToDeclaration(context, descriptor);
|
||||
assert result instanceof JetParameter : "ValueParameterDescriptor should have corresponding JetParameter.";
|
||||
return (JetParameter)result;
|
||||
}
|
||||
@@ -172,7 +173,7 @@ public final class BindingUtils {
|
||||
@Nullable
|
||||
public static JetProperty getPropertyForDescriptor(@NotNull BindingContext context,
|
||||
@NotNull PropertyDescriptor property) {
|
||||
PsiElement result = context.get(BindingContext.DESCRIPTOR_TO_DECLARATION, property);
|
||||
PsiElement result = BindingContextUtils.descriptorToDeclaration(context, property);
|
||||
if (!(result instanceof JetProperty)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+2
-1
@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetTreeVisitor;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.k2js.translate.utils.BindingUtils;
|
||||
|
||||
/**
|
||||
@@ -53,7 +54,7 @@ public class CaptureClosureVisitor extends JetTreeVisitor<ClosureContext> {
|
||||
return null;
|
||||
}
|
||||
VariableDescriptor variableDescriptor = (VariableDescriptor) descriptor;
|
||||
PsiElement variableDeclaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor);
|
||||
PsiElement variableDeclaration = BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor);
|
||||
if (variableDeclaration == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user