Move descriptorToDeclaration utilities family to a separate util class DescriptorToSourceUtils
This commit is contained in:
@@ -45,7 +45,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor.Kind.DELEGATION;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.descriptorToDeclaration;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
|
||||
import static org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage.getResolvedCall;
|
||||
|
||||
public abstract class AnnotationCodegen {
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetParameter;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.descriptorToDeclaration;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
|
||||
|
||||
public interface DefaultParameterValueLoader {
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.jetbrains.jet.lang.evaluate.EvaluatePackage;
|
||||
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.DescriptorToSourceUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker;
|
||||
@@ -1620,7 +1621,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
|
||||
PsiElement element = bindingContext.get(LABEL_TARGET, expression.getTargetLabel());
|
||||
if (element != callableDescriptorToDeclaration(context.getContextDescriptor())) {
|
||||
if (element != DescriptorToSourceUtils.callableDescriptorToDeclaration(context.getContextDescriptor())) {
|
||||
DeclarationDescriptor elementDescriptor = typeMapper.getBindingContext().get(DECLARATION_TO_DESCRIPTOR, element);
|
||||
assert element != null : "Expression should be not null " + expression.getText();
|
||||
assert elementDescriptor != null : "Descriptor should be not null: " + element.getText();
|
||||
|
||||
@@ -67,7 +67,7 @@ import static org.jetbrains.jet.codegen.AsmUtil.*;
|
||||
import static org.jetbrains.jet.codegen.JvmSerializationBindings.*;
|
||||
import static org.jetbrains.jet.codegen.binding.CodegenBinding.isLocalNamedFun;
|
||||
import static org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor.Kind.DECLARATION;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.callableDescriptorToDeclaration;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils.callableDescriptorToDeclaration;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isFunctionLiteral;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isTrait;
|
||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE;
|
||||
|
||||
@@ -71,7 +71,7 @@ import static org.jetbrains.jet.codegen.AsmUtil.*;
|
||||
import static org.jetbrains.jet.codegen.JvmCodegenUtil.*;
|
||||
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
||||
import static org.jetbrains.jet.descriptors.serialization.NameSerializationUtil.createNameResolver;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.descriptorToDeclaration;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.*;
|
||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.*;
|
||||
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass;
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.jetbrains.org.objectweb.asm.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.descriptorToDeclaration;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
|
||||
|
||||
public final class PsiCodegenPredictor {
|
||||
private PsiCodegenPredictor() {
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor;
|
||||
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.DescriptorToSourceUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
|
||||
@@ -126,7 +126,7 @@ public class InlineCodegen implements CallGenerator {
|
||||
}
|
||||
catch (Exception e) {
|
||||
boolean generateNodeText = !(e instanceof InlineException);
|
||||
PsiElement element = BindingContextUtils.descriptorToDeclaration(this.codegen.getContext().getContextDescriptor());
|
||||
PsiElement element = DescriptorToSourceUtils.descriptorToDeclaration(this.codegen.getContext().getContextDescriptor());
|
||||
throw new CompilationException("Couldn't inline method call '" +
|
||||
functionDescriptor.getName() +
|
||||
"' into \n" + (element != null ? element.getText() : "null psi element " + this.codegen.getContext().getContextDescriptor()) +
|
||||
@@ -165,7 +165,7 @@ public class InlineCodegen implements CallGenerator {
|
||||
}
|
||||
}
|
||||
else {
|
||||
PsiElement element = BindingContextUtils.descriptorToDeclaration(functionDescriptor);
|
||||
PsiElement element = DescriptorToSourceUtils.descriptorToDeclaration(functionDescriptor);
|
||||
|
||||
if (element == null) {
|
||||
throw new RuntimeException("Couldn't find declaration for function " + descriptorName(functionDescriptor));
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.jetbrains.jet.descriptors.serialization.ProtoBuf;
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedSimpleFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
@@ -247,7 +247,7 @@ public class InlineCodegenUtil {
|
||||
@Nullable
|
||||
public static PsiFile getContainingFile(CodegenContext codegenContext) {
|
||||
DeclarationDescriptor contextDescriptor = codegenContext.getContextDescriptor();
|
||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(contextDescriptor);
|
||||
PsiElement psiElement = DescriptorToSourceUtils.descriptorToDeclaration(contextDescriptor);
|
||||
if (psiElement != null) {
|
||||
return psiElement.getContainingFile();
|
||||
}
|
||||
|
||||
+3
-2
@@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor.Kind.FAKE_OVE
|
||||
import org.jetbrains.jet.utils.addIfNotNull
|
||||
import org.jetbrains.jet.codegen.ClassBuilderMode
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.SamAdapterDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
|
||||
class BuilderFactoryForDuplicateSignatureDiagnostics(
|
||||
builderFactory: ClassBuilderFactory,
|
||||
@@ -79,9 +80,9 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
|
||||
|
||||
if (member.getKind() != DELEGATION) {
|
||||
// Delegates don't have declarations in the code
|
||||
memberElement = BindingContextUtils.callableDescriptorToDeclaration(member)
|
||||
memberElement = DescriptorToSourceUtils.callableDescriptorToDeclaration(member)
|
||||
if (memberElement == null && member is PropertyAccessorDescriptor) {
|
||||
memberElement = BindingContextUtils.callableDescriptorToDeclaration(member.getCorrespondingProperty())
|
||||
memberElement = DescriptorToSourceUtils.callableDescriptorToDeclaration(member.getCorrespondingProperty())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.jetbrains.jet.codegen.binding.CalculatedClosure;
|
||||
import org.jetbrains.jet.codegen.binding.CodegenBinding;
|
||||
import org.jetbrains.jet.codegen.context.CodegenContext;
|
||||
import org.jetbrains.jet.codegen.signature.BothSignatureWriter;
|
||||
import org.jetbrains.jet.config.IncrementalCompilation;
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedCallableMemberDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
|
||||
@@ -32,10 +31,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetDelegatorToSuperCall;
|
||||
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.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.OverrideResolver;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.constants.StringValue;
|
||||
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
|
||||
@@ -310,12 +306,12 @@ public class JetTypeMapper {
|
||||
|
||||
@NotNull
|
||||
private String generateErrorMessageForErrorType(@NotNull JetType type, @NotNull DeclarationDescriptor descriptor) {
|
||||
PsiElement declarationElement = BindingContextUtils.descriptorToDeclaration(descriptor);
|
||||
PsiElement declarationElement = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
|
||||
PsiElement parentDeclarationElement = null;
|
||||
if (declarationElement != null) {
|
||||
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
||||
if (containingDeclaration != null) {
|
||||
parentDeclarationElement = BindingContextUtils.descriptorToDeclaration(containingDeclaration);
|
||||
parentDeclarationElement = DescriptorToSourceUtils.descriptorToDeclaration(containingDeclaration);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ public final class AnalyzerWithCompilerReport {
|
||||
if (!descriptorsWithErrors.isEmpty()) {
|
||||
StringBuilder message = new StringBuilder("The following Java entities have annotations with wrong Kotlin signatures:\n");
|
||||
for (DeclarationDescriptor descriptor : descriptorsWithErrors) {
|
||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(descriptor);
|
||||
PsiElement declaration = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
|
||||
assert declaration instanceof PsiModifierListOwner;
|
||||
|
||||
List<String> errors = bc.get(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor);
|
||||
|
||||
+2
-5
@@ -38,10 +38,7 @@ import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PackageViewDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.ModuleDescriptorImpl;
|
||||
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.*;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
@@ -125,7 +122,7 @@ public class CliLightClassGenerationSupport extends LightClassGenerationSupport
|
||||
public Collection<JetClassOrObject> findClassOrObjectDeclarations(@NotNull FqName fqName, @NotNull GlobalSearchScope searchScope) {
|
||||
ClassDescriptor classDescriptor = getTrace().get(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, fqName.toUnsafe());
|
||||
if (classDescriptor != null) {
|
||||
PsiElement element = BindingContextUtils.classDescriptorToDeclaration(classDescriptor);
|
||||
PsiElement element = DescriptorToSourceUtils.classDescriptorToDeclaration(classDescriptor);
|
||||
if (element != null && PsiSearchScopeUtil.isInScope(searchScope, element)) {
|
||||
return Collections.singletonList((JetClassOrObject) element);
|
||||
}
|
||||
|
||||
@@ -48,10 +48,7 @@ import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory;
|
||||
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.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.TailRecursionKind;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
||||
@@ -469,7 +466,7 @@ public class JetFlowInformationProvider {
|
||||
if (variableDescriptor instanceof PropertyDescriptor && !ctxt.enterInitState.isInitialized && ctxt.exitInitState.isInitialized) {
|
||||
if (!variableDescriptor.isVar()) return false;
|
||||
if (!trace.get(BindingContext.BACKING_FIELD_REQUIRED, (PropertyDescriptor) variableDescriptor)) return false;
|
||||
PsiElement property = BindingContextUtils.descriptorToDeclaration(variableDescriptor);
|
||||
PsiElement property = DescriptorToSourceUtils.descriptorToDeclaration(variableDescriptor);
|
||||
assert property instanceof JetProperty;
|
||||
if (((PropertyDescriptor) variableDescriptor).getModality() == Modality.FINAL && ((JetProperty) property).getSetter() == null) {
|
||||
return false;
|
||||
@@ -505,7 +502,7 @@ public class JetFlowInformationProvider {
|
||||
report(Errors.NOT_PROPERTY_BACKING_FIELD.on(element), cxtx);
|
||||
return true;
|
||||
}
|
||||
PsiElement property = BindingContextUtils.descriptorToDeclaration(variableDescriptor);
|
||||
PsiElement property = DescriptorToSourceUtils.descriptorToDeclaration(variableDescriptor);
|
||||
boolean insideSelfAccessors = PsiTreeUtil.isAncestor(property, element, false);
|
||||
if (!trace.get(BindingContext.BACKING_FIELD_REQUIRED, (PropertyDescriptor) variableDescriptor) &&
|
||||
// not to generate error in accessors of abstract properties, there is one: declared accessor of abstract property
|
||||
|
||||
@@ -28,8 +28,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
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.DescriptorToSourceUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -52,9 +51,9 @@ public class DiagnosticUtils {
|
||||
}
|
||||
|
||||
public static String atLocation(DeclarationDescriptor descriptor) {
|
||||
PsiElement element = BindingContextUtils.descriptorToDeclaration(descriptor);
|
||||
PsiElement element = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
|
||||
if (element == null) {
|
||||
element = BindingContextUtils.descriptorToDeclaration(descriptor.getOriginal());
|
||||
element = DescriptorToSourceUtils.descriptorToDeclaration(descriptor.getOriginal());
|
||||
}
|
||||
if (element == null && descriptor instanceof ASTNode) {
|
||||
element = DiagnosticUtils.getClosestPsiElement((ASTNode) descriptor);
|
||||
|
||||
@@ -156,7 +156,7 @@ public interface BindingContext {
|
||||
return false;
|
||||
}
|
||||
backingFieldRequired = valueNotFound ? false : backingFieldRequired;
|
||||
PsiElement declarationPsiElement = BindingContextUtils.descriptorToDeclaration(propertyDescriptor);
|
||||
PsiElement declarationPsiElement = DescriptorToSourceUtils.descriptorToDeclaration(propertyDescriptor);
|
||||
if (declarationPsiElement instanceof JetParameter) {
|
||||
JetParameter jetParameter = (JetParameter) declarationPsiElement;
|
||||
return jetParameter.hasValOrVarNode() ||
|
||||
|
||||
@@ -29,19 +29,14 @@ import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPacka
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.source.SourcePackage;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.JetTypeInfo;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.jet.util.slicedmap.ReadOnlySlice;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor.Kind.DECLARATION;
|
||||
import static org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor.Kind.SYNTHESIZED;
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.AMBIGUOUS_LABEL;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
||||
|
||||
@@ -74,7 +69,7 @@ public class BindingContextUtils {
|
||||
DeclarationDescriptor descriptor = findTopLevelParent(declarationDescriptor);
|
||||
if (descriptor == null) return null;
|
||||
|
||||
PsiElement declaration = descriptorToDeclaration(descriptor);
|
||||
PsiElement declaration = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
|
||||
if (declaration == null) return null;
|
||||
|
||||
PsiFile containingFile = declaration.getContainingFile();
|
||||
@@ -94,77 +89,6 @@ public class BindingContextUtils {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiElement doGetDescriptorToDeclaration(@NotNull DeclarationDescriptor descriptor) {
|
||||
DeclarationDescriptor original = descriptor.getOriginal();
|
||||
if (!(original instanceof DeclarationDescriptorWithSource)) {
|
||||
return null;
|
||||
}
|
||||
return SourcePackage.getPsi(((DeclarationDescriptorWithSource) original).getSource());
|
||||
}
|
||||
|
||||
// NOTE this is also used by KDoc
|
||||
@Nullable
|
||||
public static PsiElement descriptorToDeclaration(@NotNull DeclarationDescriptor descriptor) {
|
||||
if (descriptor instanceof CallableMemberDescriptor) {
|
||||
return callableDescriptorToDeclaration((CallableMemberDescriptor) descriptor);
|
||||
}
|
||||
else if (descriptor instanceof ClassDescriptor) {
|
||||
return classDescriptorToDeclaration((ClassDescriptor) descriptor);
|
||||
}
|
||||
else {
|
||||
return doGetDescriptorToDeclaration(descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<PsiElement> descriptorToDeclarations(@NotNull DeclarationDescriptor descriptor) {
|
||||
if (descriptor instanceof CallableMemberDescriptor) {
|
||||
return callableDescriptorToDeclarations((CallableMemberDescriptor) descriptor);
|
||||
}
|
||||
else {
|
||||
PsiElement psiElement = descriptorToDeclaration(descriptor);
|
||||
if (psiElement != null) {
|
||||
return Lists.newArrayList(psiElement);
|
||||
} else {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement callableDescriptorToDeclaration(@NotNull CallableMemberDescriptor callable) {
|
||||
if (callable.getKind() == DECLARATION || callable.getKind() == SYNTHESIZED) {
|
||||
return doGetDescriptorToDeclaration(callable);
|
||||
}
|
||||
//TODO: should not use this method for fake_override and delegation
|
||||
Set<? extends CallableMemberDescriptor> overriddenDescriptors = callable.getOverriddenDescriptors();
|
||||
if (overriddenDescriptors.size() == 1) {
|
||||
return callableDescriptorToDeclaration(overriddenDescriptors.iterator().next());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<PsiElement> callableDescriptorToDeclarations(@NotNull CallableMemberDescriptor callable) {
|
||||
if (callable.getKind() == DECLARATION || callable.getKind() == SYNTHESIZED) {
|
||||
PsiElement psiElement = doGetDescriptorToDeclaration(callable);
|
||||
return psiElement != null ? Lists.newArrayList(psiElement) : Lists.<PsiElement>newArrayList();
|
||||
}
|
||||
|
||||
List<PsiElement> r = new ArrayList<PsiElement>();
|
||||
Set<? extends CallableMemberDescriptor> overriddenDescriptors = callable.getOverriddenDescriptors();
|
||||
for (CallableMemberDescriptor overridden : overriddenDescriptors) {
|
||||
r.addAll(callableDescriptorToDeclarations(overridden));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement classDescriptorToDeclaration(@NotNull ClassDescriptor clazz) {
|
||||
return doGetDescriptorToDeclaration(clazz);
|
||||
}
|
||||
|
||||
public static void recordFunctionDeclarationToDescriptor(@NotNull BindingTrace trace,
|
||||
@NotNull PsiElement psiElement, @NotNull SimpleFunctionDescriptor function) {
|
||||
|
||||
@@ -221,7 +145,7 @@ public class BindingContextUtils {
|
||||
) {
|
||||
Collection<PsiElement> targets = Lists.newArrayList();
|
||||
for (DeclarationDescriptor descriptor : declarationsByLabel) {
|
||||
PsiElement element = descriptorToDeclaration(descriptor);
|
||||
PsiElement element = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
|
||||
assert element != null : "Label can only point to something in the same lexical scope";
|
||||
targets.add(element);
|
||||
}
|
||||
@@ -281,10 +205,11 @@ public class BindingContextUtils {
|
||||
) {
|
||||
FunctionDescriptor containingFunctionDescriptor = DescriptorUtils.getParentOfType(startDescriptor, FunctionDescriptor.class, strict);
|
||||
PsiElement containingFunction =
|
||||
containingFunctionDescriptor != null ? callableDescriptorToDeclaration(containingFunctionDescriptor) : null;
|
||||
containingFunctionDescriptor != null ? DescriptorToSourceUtils.callableDescriptorToDeclaration(containingFunctionDescriptor) : null;
|
||||
while (containingFunction instanceof JetFunctionLiteral) {
|
||||
containingFunctionDescriptor = DescriptorUtils.getParentOfType(containingFunctionDescriptor, FunctionDescriptor.class);
|
||||
containingFunction = containingFunctionDescriptor != null ? callableDescriptorToDeclaration(containingFunctionDescriptor) : null;
|
||||
containingFunction = containingFunctionDescriptor != null ? DescriptorToSourceUtils
|
||||
.callableDescriptorToDeclaration(containingFunctionDescriptor) : null;
|
||||
}
|
||||
|
||||
return new Pair<FunctionDescriptor, PsiElement>(containingFunctionDescriptor, containingFunction);
|
||||
|
||||
@@ -330,7 +330,7 @@ public class DeclarationResolver {
|
||||
});
|
||||
}
|
||||
else {
|
||||
declarations = Collections.singletonList(BindingContextUtils.descriptorToDeclaration(declarationDescriptor));
|
||||
declarations = Collections.singletonList(DescriptorToSourceUtils.descriptorToDeclaration(declarationDescriptor));
|
||||
}
|
||||
return declarations;
|
||||
}
|
||||
@@ -379,11 +379,11 @@ public class DeclarationResolver {
|
||||
}
|
||||
|
||||
redeclarations.add(Pair.create(
|
||||
BindingContextUtils.classDescriptorToDeclaration((ClassDescriptor) descriptor), descriptor.getName()
|
||||
DescriptorToSourceUtils.classDescriptorToDeclaration((ClassDescriptor) descriptor), descriptor.getName()
|
||||
));
|
||||
if (descriptor2 instanceof PropertyDescriptor) {
|
||||
redeclarations.add(Pair.create(
|
||||
BindingContextUtils.descriptorToDeclaration(descriptor2), descriptor2.getName()
|
||||
DescriptorToSourceUtils.descriptorToDeclaration(descriptor2), descriptor2.getName()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ public class DeclarationsChecker {
|
||||
if (conflictingTypes.size() > 1) {
|
||||
DeclarationDescriptor containingDeclaration = typeParameterDescriptor.getContainingDeclaration();
|
||||
assert containingDeclaration instanceof ClassDescriptor : containingDeclaration;
|
||||
JetClassOrObject psiElement = (JetClassOrObject) BindingContextUtils.classDescriptorToDeclaration(classDescriptor);
|
||||
JetClassOrObject psiElement = (JetClassOrObject) DescriptorToSourceUtils.classDescriptorToDeclaration(classDescriptor);
|
||||
JetDelegationSpecifierList delegationSpecifierList = psiElement.getDelegationSpecifierList();
|
||||
assert delegationSpecifierList != null;
|
||||
// trace.getErrorHandler().genericError(delegationSpecifierList.getNode(), "Type parameter " + typeParameterDescriptor.getName() + " of " + containingDeclaration.getName() + " has inconsistent values: " + conflictingTypes);
|
||||
@@ -321,7 +321,7 @@ public class DeclarationsChecker {
|
||||
private void checkOpenMembers(ClassDescriptorWithResolutionScopes classDescriptor) {
|
||||
for (CallableMemberDescriptor memberDescriptor : classDescriptor.getDeclaredCallableMembers()) {
|
||||
if (memberDescriptor.getKind() != CallableMemberDescriptor.Kind.DECLARATION) continue;
|
||||
JetNamedDeclaration member = (JetNamedDeclaration) BindingContextUtils.descriptorToDeclaration(memberDescriptor);
|
||||
JetNamedDeclaration member = (JetNamedDeclaration) DescriptorToSourceUtils.descriptorToDeclaration(memberDescriptor);
|
||||
if (member != null && classDescriptor.getModality() == Modality.FINAL && member.hasModifier(JetTokens.OPEN_KEYWORD)) {
|
||||
trace.report(NON_FINAL_MEMBER_IN_FINAL_CLASS.on(member));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* 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.resolve;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorWithSource;
|
||||
import org.jetbrains.jet.lang.resolve.source.SourcePackage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor.Kind.DECLARATION;
|
||||
import static org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor.Kind.SYNTHESIZED;
|
||||
|
||||
public final class DescriptorToSourceUtils {
|
||||
|
||||
@Nullable
|
||||
private static PsiElement doGetDescriptorToDeclaration(@NotNull DeclarationDescriptor descriptor) {
|
||||
DeclarationDescriptor original = descriptor.getOriginal();
|
||||
if (!(original instanceof DeclarationDescriptorWithSource)) {
|
||||
return null;
|
||||
}
|
||||
return SourcePackage.getPsi(((DeclarationDescriptorWithSource) original).getSource());
|
||||
}
|
||||
|
||||
// NOTE this is also used by KDoc
|
||||
@Nullable
|
||||
public static PsiElement descriptorToDeclaration(@NotNull DeclarationDescriptor descriptor) {
|
||||
if (descriptor instanceof CallableMemberDescriptor) {
|
||||
return callableDescriptorToDeclaration((CallableMemberDescriptor) descriptor);
|
||||
}
|
||||
else if (descriptor instanceof ClassDescriptor) {
|
||||
return classDescriptorToDeclaration((ClassDescriptor) descriptor);
|
||||
}
|
||||
else {
|
||||
return doGetDescriptorToDeclaration(descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<PsiElement> descriptorToDeclarations(@NotNull DeclarationDescriptor descriptor) {
|
||||
if (descriptor instanceof CallableMemberDescriptor) {
|
||||
return callableDescriptorToDeclarations((CallableMemberDescriptor) descriptor);
|
||||
}
|
||||
else {
|
||||
PsiElement psiElement = descriptorToDeclaration(descriptor);
|
||||
if (psiElement != null) {
|
||||
return Lists.newArrayList(psiElement);
|
||||
} else {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement callableDescriptorToDeclaration(@NotNull CallableMemberDescriptor callable) {
|
||||
if (callable.getKind() == DECLARATION || callable.getKind() == SYNTHESIZED) {
|
||||
return doGetDescriptorToDeclaration(callable);
|
||||
}
|
||||
//TODO: should not use this method for fake_override and delegation
|
||||
Set<? extends CallableMemberDescriptor> overriddenDescriptors = callable.getOverriddenDescriptors();
|
||||
if (overriddenDescriptors.size() == 1) {
|
||||
return callableDescriptorToDeclaration(overriddenDescriptors.iterator().next());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<PsiElement> callableDescriptorToDeclarations(@NotNull CallableMemberDescriptor callable) {
|
||||
if (callable.getKind() == DECLARATION || callable.getKind() == SYNTHESIZED) {
|
||||
PsiElement psiElement = doGetDescriptorToDeclaration(callable);
|
||||
return psiElement != null ? Lists.newArrayList(psiElement) : Lists.<PsiElement>newArrayList();
|
||||
}
|
||||
|
||||
List<PsiElement> r = new ArrayList<PsiElement>();
|
||||
Set<? extends CallableMemberDescriptor> overriddenDescriptors = callable.getOverriddenDescriptors();
|
||||
for (CallableMemberDescriptor overridden : overriddenDescriptors) {
|
||||
r.addAll(callableDescriptorToDeclarations(overridden));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement classDescriptorToDeclaration(@NotNull ClassDescriptor clazz) {
|
||||
return doGetDescriptorToDeclaration(clazz);
|
||||
}
|
||||
|
||||
private DescriptorToSourceUtils() {}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class InlineDescriptorUtils {
|
||||
containingFunctionDescriptor = getContainingClassOrFunctionDescriptor(containingFunctionDescriptor, true);
|
||||
|
||||
containingFunction = containingFunctionDescriptor != null
|
||||
? BindingContextUtils.descriptorToDeclaration(containingFunctionDescriptor)
|
||||
? DescriptorToSourceUtils.descriptorToDeclaration(containingFunctionDescriptor)
|
||||
: null;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.jet.lang.descriptors.PackageFragmentDescriptor;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.callableDescriptorToDeclaration;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils.callableDescriptorToDeclaration;
|
||||
|
||||
public class LibrarySourceHacks {
|
||||
private LibrarySourceHacks() {
|
||||
|
||||
@@ -170,7 +170,7 @@ public class OverloadResolver {
|
||||
|
||||
OverloadUtil.OverloadCompatibilityInfo overloadable = OverloadUtil.isOverloadable(member, member2);
|
||||
if (!overloadable.isSuccess()) {
|
||||
JetDeclaration jetDeclaration = (JetDeclaration) BindingContextUtils.descriptorToDeclaration(member);
|
||||
JetDeclaration jetDeclaration = (JetDeclaration) DescriptorToSourceUtils.descriptorToDeclaration(member);
|
||||
if (jetDeclaration != null) {
|
||||
redeclarations.add(Pair.create(jetDeclaration, member));
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class OverrideResolver {
|
||||
}
|
||||
}
|
||||
|
||||
JetClassOrObject classOrObject = (JetClassOrObject) BindingContextUtils.classDescriptorToDeclaration(classDescriptor);
|
||||
JetClassOrObject classOrObject = (JetClassOrObject) DescriptorToSourceUtils.classDescriptorToDeclaration(classDescriptor);
|
||||
if (classOrObject != null) {
|
||||
DelegationResolver.generateDelegatesInAClass(classDescriptor, trace, classOrObject);
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public class OverrideResolver {
|
||||
|
||||
@Override
|
||||
public void conflict(@NotNull CallableMemberDescriptor fromSuper, @NotNull CallableMemberDescriptor fromCurrent) {
|
||||
JetDeclaration declaration = (JetDeclaration) BindingContextUtils.descriptorToDeclaration(fromCurrent);
|
||||
JetDeclaration declaration = (JetDeclaration) DescriptorToSourceUtils.descriptorToDeclaration(fromCurrent);
|
||||
//noinspection ConstantConditions
|
||||
trace.report(CONFLICTING_OVERLOADS.on(declaration, fromCurrent, fromCurrent.getContainingDeclaration().getName().asString()));
|
||||
}
|
||||
@@ -188,7 +188,7 @@ public class OverrideResolver {
|
||||
reportOn = descriptor;
|
||||
}
|
||||
//noinspection ConstantConditions
|
||||
PsiElement element = BindingContextUtils.descriptorToDeclaration(reportOn);
|
||||
PsiElement element = DescriptorToSourceUtils.descriptorToDeclaration(reportOn);
|
||||
if (element instanceof JetDeclaration) {
|
||||
trace.report(CANNOT_INFER_VISIBILITY.on((JetDeclaration) element, descriptor));
|
||||
}
|
||||
@@ -609,7 +609,7 @@ public class OverrideResolver {
|
||||
return;
|
||||
}
|
||||
|
||||
final JetNamedDeclaration member = (JetNamedDeclaration) BindingContextUtils.descriptorToDeclaration(declared);
|
||||
final JetNamedDeclaration member = (JetNamedDeclaration) DescriptorToSourceUtils.descriptorToDeclaration(declared);
|
||||
if (member == null) {
|
||||
throw new IllegalStateException("declared descriptor is not resolved to declaration: " + declared);
|
||||
}
|
||||
@@ -862,7 +862,7 @@ public class OverrideResolver {
|
||||
boolean isDeclaration = declared.getKind() == CallableMemberDescriptor.Kind.DECLARATION;
|
||||
if (isDeclaration) {
|
||||
// No check if the function is not marked as 'override'
|
||||
JetModifierListOwner declaration = (JetModifierListOwner) BindingContextUtils.descriptorToDeclaration(declared);
|
||||
JetModifierListOwner declaration = (JetModifierListOwner) DescriptorToSourceUtils.descriptorToDeclaration(declared);
|
||||
if (declaration != null && !declaration.hasModifier(JetTokens.OVERRIDE_KEYWORD)) {
|
||||
return;
|
||||
}
|
||||
@@ -892,7 +892,7 @@ public class OverrideResolver {
|
||||
}
|
||||
|
||||
private void checkNameAndDefaultForDeclaredParameter(@NotNull ValueParameterDescriptor descriptor, boolean multipleDefaultsInSuper) {
|
||||
JetParameter parameter = (JetParameter) BindingContextUtils.descriptorToDeclaration(descriptor);
|
||||
JetParameter parameter = (JetParameter) DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
|
||||
assert parameter != null : "Declaration not found for parameter: " + descriptor;
|
||||
|
||||
if (descriptor.declaresDefaultValue()) {
|
||||
@@ -921,7 +921,7 @@ public class OverrideResolver {
|
||||
boolean multipleDefaultsInSuper
|
||||
) {
|
||||
DeclarationDescriptor containingClass = containingFunction.getContainingDeclaration();
|
||||
JetClassOrObject classElement = (JetClassOrObject) BindingContextUtils.descriptorToDeclaration(containingClass);
|
||||
JetClassOrObject classElement = (JetClassOrObject) DescriptorToSourceUtils.descriptorToDeclaration(containingClass);
|
||||
assert classElement != null : "Declaration not found for class: " + containingClass;
|
||||
|
||||
if (multipleDefaultsInSuper) {
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ public class TraceBasedRedeclarationHandler implements RedeclarationHandler {
|
||||
}
|
||||
|
||||
private void report(DeclarationDescriptor descriptor) {
|
||||
PsiElement firstElement = BindingContextUtils.descriptorToDeclaration(descriptor);
|
||||
PsiElement firstElement = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
|
||||
if (firstElement != null) {
|
||||
trace.report(REDECLARATION.on(firstElement, descriptor.getName().asString()));
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ public class TypeHierarchyResolver {
|
||||
@NotNull ClassDescriptor classDescriptor,
|
||||
@NotNull ClassDescriptor superclass
|
||||
) {
|
||||
PsiElement psiElement = BindingContextUtils.classDescriptorToDeclaration(classDescriptor);
|
||||
PsiElement psiElement = DescriptorToSourceUtils.classDescriptorToDeclaration(classDescriptor);
|
||||
|
||||
PsiElement elementToMark = null;
|
||||
if (psiElement instanceof JetClassOrObject) {
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ public class LazyClassMemberScope extends AbstractLazyMemberScope<LazyClassDescr
|
||||
|
||||
@Override
|
||||
public void conflict(@NotNull CallableMemberDescriptor fromSuper, @NotNull CallableMemberDescriptor fromCurrent) {
|
||||
JetDeclaration declaration = (JetDeclaration) BindingContextUtils.descriptorToDeclaration(fromCurrent);
|
||||
JetDeclaration declaration = (JetDeclaration) DescriptorToSourceUtils.descriptorToDeclaration(fromCurrent);
|
||||
assert declaration != null : "fromCurrent can not be a fake override";
|
||||
trace.report(Errors.CONFLICTING_OVERLOADS
|
||||
.on(declaration, fromCurrent, fromCurrent.getContainingDeclaration().getName().asString()));
|
||||
|
||||
+1
-1
@@ -366,7 +366,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
|
||||
VariableDescriptor olderVariable = context.scope.getLocalVariable(variableDescriptor.getName());
|
||||
if (olderVariable != null && isLocal(context.scope.getContainingDeclaration(), olderVariable)) {
|
||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(variableDescriptor);
|
||||
PsiElement declaration = DescriptorToSourceUtils.descriptorToDeclaration(variableDescriptor);
|
||||
context.trace.report(Errors.NAME_SHADOWING.on(declaration, variableDescriptor.getName().asString()));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -142,7 +142,7 @@ public class ExpressionTypingUtils {
|
||||
@NotNull DeclarationDescriptor scopeContainer,
|
||||
@NotNull DeclarationDescriptor variableParent
|
||||
) {
|
||||
PsiElement scopeDeclaration = BindingContextUtils.descriptorToDeclaration(scopeContainer);
|
||||
PsiElement scopeDeclaration = DescriptorToSourceUtils.descriptorToDeclaration(scopeContainer);
|
||||
if (!(scopeDeclaration instanceof JetFunctionLiteral)) {
|
||||
return false;
|
||||
}
|
||||
@@ -429,7 +429,7 @@ public class ExpressionTypingUtils {
|
||||
|
||||
public static void checkVariableShadowing(@NotNull ExpressionTypingContext context, @NotNull VariableDescriptor variableDescriptor, VariableDescriptor oldDescriptor) {
|
||||
if (oldDescriptor != null && isLocal(variableDescriptor.getContainingDeclaration(), oldDescriptor)) {
|
||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(variableDescriptor);
|
||||
PsiElement declaration = DescriptorToSourceUtils.descriptorToDeclaration(variableDescriptor);
|
||||
if (declaration != null) {
|
||||
context.trace.report(Errors.NAME_SHADOWING.on(declaration, variableDescriptor.getName().asString()));
|
||||
}
|
||||
|
||||
@@ -22,10 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
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.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
@@ -142,7 +139,7 @@ public class LabelResolver {
|
||||
DeclarationDescriptor declarationDescriptor = declarationsByLabel.iterator().next();
|
||||
JetElement element;
|
||||
if (declarationDescriptor instanceof FunctionDescriptor || declarationDescriptor instanceof ClassDescriptor) {
|
||||
element = (JetElement) BindingContextUtils.descriptorToDeclaration(declarationDescriptor);
|
||||
element = (JetElement) DescriptorToSourceUtils.descriptorToDeclaration(declarationDescriptor);
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException(declarationDescriptor.getClass().toString()); // TODO
|
||||
@@ -198,7 +195,7 @@ public class LabelResolver {
|
||||
else {
|
||||
throw new UnsupportedOperationException("Unsupported descriptor: " + declarationDescriptor); // TODO
|
||||
}
|
||||
PsiElement element = BindingContextUtils.descriptorToDeclaration(declarationDescriptor);
|
||||
PsiElement element = DescriptorToSourceUtils.descriptorToDeclaration(declarationDescriptor);
|
||||
assert element != null : "No PSI element for descriptor: " + declarationDescriptor;
|
||||
context.trace.record(LABEL_TARGET, targetLabel, element);
|
||||
context.trace.record(REFERENCE_TARGET, referenceExpression, declarationDescriptor);
|
||||
|
||||
+1
-2
@@ -52,7 +52,6 @@ import org.jetbrains.jet.lang.psi.JetClassOrObject;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
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.BindingTraceContext;
|
||||
import org.jetbrains.jet.lang.resolve.Diagnostics;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
@@ -61,7 +60,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.descriptorToDeclaration;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
|
||||
|
||||
public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostics> implements CachedValueProvider<T> {
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
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.DescriptorToSourceUtils;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.JvmResolveUtil;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
@@ -279,7 +279,7 @@ public abstract class ExpectedResolveData {
|
||||
|
||||
PsiElement actual = referenceTarget == null
|
||||
? bindingContext.get(BindingContext.LABEL_TARGET, referenceExpression)
|
||||
: BindingContextUtils.descriptorToDeclaration(referenceTarget);
|
||||
: DescriptorToSourceUtils.descriptorToDeclaration(referenceTarget);
|
||||
if (actual instanceof JetSimpleNameExpression) {
|
||||
actual = ((JetSimpleNameExpression)actual).getIdentifier();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class MyDeclarations(
|
||||
{
|
||||
val functions = context.getSliceContents(BindingContext.FUNCTION)
|
||||
functionFoo = findFunctionByName(functions.values(), "foo")
|
||||
val function = BindingContextUtils.descriptorToDeclaration(functionFoo) as JetFunction
|
||||
val function = DescriptorToSourceUtils.descriptorToDeclaration(functionFoo) as JetFunction
|
||||
val fooBody = function.getBodyExpression()
|
||||
scopeToResolveTypeParameters = context.get(BindingContext.RESOLUTION_SCOPE, fooBody)!!
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user