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)!!
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||
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.plugin.libraries.DecompiledNavigationUtils;
|
||||
import org.jetbrains.jet.plugin.references.BuiltInsReferenceResolver;
|
||||
|
||||
@@ -41,7 +41,7 @@ public final class DescriptorToDeclarationUtil {
|
||||
|
||||
@Nullable
|
||||
public static PsiElement getDeclaration(@NotNull Project project, @NotNull DeclarationDescriptor descriptor) {
|
||||
Collection<PsiElement> elements = BindingContextUtils.descriptorToDeclarations(descriptor);
|
||||
Collection<PsiElement> elements = DescriptorToSourceUtils.descriptorToDeclarations(descriptor);
|
||||
if (elements.isEmpty()) {
|
||||
elements = findDecompiledAndBuiltInDeclarations(project, descriptor);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
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.DescriptorToSourceUtils;
|
||||
import org.jetbrains.jet.lang.resolve.OverrideResolver;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
@@ -102,7 +102,7 @@ public class GotoSuperActionHandler implements CodeInsightActionHandler {
|
||||
if (KotlinBuiltIns.getInstance().getAny() == descriptor) {
|
||||
return null;
|
||||
}
|
||||
return BindingContextUtils.descriptorToDeclaration(descriptor);
|
||||
return DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
|
||||
}
|
||||
});
|
||||
if (superDeclarations.isEmpty()) return;
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetElement;
|
||||
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.DescriptorToSourceUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class JetTypeDeclarationProvider implements TypeDeclarationProvider {
|
||||
if (type != null) {
|
||||
ClassifierDescriptor classifierDescriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
if (classifierDescriptor != null) {
|
||||
PsiElement typeElement = BindingContextUtils.descriptorToDeclaration(classifierDescriptor);
|
||||
PsiElement typeElement = DescriptorToSourceUtils.descriptorToDeclaration(classifierDescriptor);
|
||||
if (typeElement != null) {
|
||||
return new PsiElement[] {typeElement};
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ import com.intellij.psi.PsiElement;
|
||||
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.DescriptorToSourceUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.KotlinCodeAnalyzer;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -126,7 +125,7 @@ public final class DescriptorLookupConverter {
|
||||
if (descriptor instanceof CallableMemberDescriptor) {
|
||||
descriptor = DescriptorUtils.unwrapFakeOverride((CallableMemberDescriptor) descriptor);
|
||||
}
|
||||
return createLookupElement(analyzer, descriptor, BindingContextUtils.descriptorToDeclaration(descriptor));
|
||||
return createLookupElement(analyzer, descriptor, DescriptorToSourceUtils.descriptorToDeclaration(descriptor));
|
||||
}
|
||||
|
||||
public static LookupElement[] collectLookupElements(
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.plugin.completion.ExpectedInfo
|
||||
import org.jetbrains.jet.plugin.util.makeNotNullable
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
|
||||
class ThisItems(val bindingContext: BindingContext) {
|
||||
public fun addToCollection(collection: MutableCollection<LookupElement>, context: JetExpression, expectedInfos: Collection<ExpectedInfo>) {
|
||||
@@ -68,7 +69,7 @@ class ThisItems(val bindingContext: BindingContext) {
|
||||
val name: Name = descriptor.getName()
|
||||
if (!name.isSpecial()) return name.asString()
|
||||
|
||||
val psiElement = BindingContextUtils.descriptorToDeclaration(descriptor)
|
||||
val psiElement = DescriptorToSourceUtils.descriptorToDeclaration(descriptor)
|
||||
val expression: JetExpression? = when (psiElement) {
|
||||
is JetFunctionLiteral -> psiElement.getParent() as? JetFunctionLiteralExpression
|
||||
is JetObjectDeclaration -> psiElement.getParent() as? JetObjectLiteralExpression
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.intellij.psi.PsiMethod
|
||||
import org.jetbrains.jet.plugin.codeInsight.CodeInsightUtils
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
|
||||
public class KotlinSmartStepIntoHandler : JvmSmartStepIntoHandler() {
|
||||
|
||||
@@ -131,7 +132,7 @@ public class KotlinSmartStepIntoHandler : JvmSmartStepIntoHandler() {
|
||||
if (getterDescriptor != null && !getterDescriptor.isDefault()) {
|
||||
val delegatedResolvedCall = bindingContext[BindingContext.DELEGATED_PROPERTY_RESOLVED_CALL, getterDescriptor]
|
||||
if (delegatedResolvedCall == null) {
|
||||
val getter = BindingContextUtils.callableDescriptorToDeclaration(getterDescriptor)
|
||||
val getter = DescriptorToSourceUtils.callableDescriptorToDeclaration(getterDescriptor)
|
||||
if (getter is JetPropertyAccessor && (getter.getBodyExpression() != null || getter.getEqualsToken() != null)) {
|
||||
val psiMethod = LightClassUtil.getLightClassAccessorMethod(getter)
|
||||
if (psiMethod != null) {
|
||||
@@ -142,7 +143,7 @@ public class KotlinSmartStepIntoHandler : JvmSmartStepIntoHandler() {
|
||||
else {
|
||||
val delegatedPropertyGetterDescriptor = delegatedResolvedCall.getResultingDescriptor()
|
||||
if (delegatedPropertyGetterDescriptor is CallableMemberDescriptor) {
|
||||
val function = BindingContextUtils.callableDescriptorToDeclaration(delegatedPropertyGetterDescriptor)
|
||||
val function = DescriptorToSourceUtils.callableDescriptorToDeclaration(delegatedPropertyGetterDescriptor)
|
||||
if (function is JetNamedFunction) {
|
||||
val psiMethod = LightClassUtil.getLightClassMethod(function)
|
||||
if (psiMethod != null) {
|
||||
@@ -163,7 +164,7 @@ public class KotlinSmartStepIntoHandler : JvmSmartStepIntoHandler() {
|
||||
|
||||
val descriptor = resolvedCall.getResultingDescriptor()
|
||||
if (descriptor is CallableMemberDescriptor) {
|
||||
val function = BindingContextUtils.callableDescriptorToDeclaration(descriptor)
|
||||
val function = DescriptorToSourceUtils.callableDescriptorToDeclaration(descriptor)
|
||||
if (function is JetNamedFunction) {
|
||||
val psiMethod = LightClassUtil.getLightClassMethod(function)
|
||||
if (psiMethod != null) {
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
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;
|
||||
|
||||
public abstract class CalleeReferenceVisitorBase extends JetTreeVisitorVoid {
|
||||
private final BindingContext bindingContext;
|
||||
@@ -50,7 +50,7 @@ public abstract class CalleeReferenceVisitorBase extends JetTreeVisitorVoid {
|
||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, expression);
|
||||
if (descriptor == null) return;
|
||||
|
||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(descriptor);
|
||||
PsiElement declaration = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
|
||||
if (declaration == null) return;
|
||||
|
||||
if (isProperty(descriptor, declaration) || isCallable(descriptor, declaration, expression)) {
|
||||
|
||||
@@ -57,7 +57,7 @@ import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.Modality;
|
||||
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.OverrideResolver;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
@@ -299,7 +299,7 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
|
||||
if (overriddenMembers.isEmpty()) return;
|
||||
List<PsiElement> list = Lists.newArrayList();
|
||||
for (CallableMemberDescriptor overriddenMember : overriddenMembers) {
|
||||
PsiElement declarationPsiElement = BindingContextUtils.descriptorToDeclaration(overriddenMember);
|
||||
PsiElement declarationPsiElement = DescriptorToSourceUtils.descriptorToDeclaration(overriddenMember);
|
||||
list.add(declarationPsiElement);
|
||||
}
|
||||
if (list.isEmpty()) {
|
||||
|
||||
+2
-1
@@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||
import org.jetbrains.jet.plugin.references.JetReference
|
||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
|
||||
public class ReplaceExplicitFunctionLiteralParamWithItIntention() : PsiElementBaseIntentionAction() {
|
||||
override fun invoke(project: Project, editor: Editor, element: PsiElement) {
|
||||
@@ -78,7 +79,7 @@ public class ReplaceExplicitFunctionLiteralParamWithItIntention() : PsiElementBa
|
||||
if (variableDescriptor != null) {
|
||||
val containingDescriptor = variableDescriptor.getContainingDeclaration()
|
||||
if (containingDescriptor is AnonymousFunctionDescriptor) {
|
||||
return BindingContextUtils.descriptorToDeclaration(containingDescriptor) as? JetFunctionLiteral
|
||||
return DescriptorToSourceUtils.descriptorToDeclaration(containingDescriptor) as? JetFunctionLiteral
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -33,6 +33,7 @@ import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||
import org.jetbrains.jet.lang.psi.JetFunctionLiteral
|
||||
import org.jetbrains.jet.plugin.references.JetReference
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
|
||||
public class ReplaceItWithExplicitFunctionLiteralParamIntention() : PsiElementBaseIntentionAction() {
|
||||
override fun invoke(project: Project, editor: Editor, element: PsiElement) {
|
||||
@@ -41,7 +42,7 @@ public class ReplaceItWithExplicitFunctionLiteralParamIntention() : PsiElementBa
|
||||
val simpleNameReference = simpleNameExpression.getReference() as JetReference?
|
||||
val target = simpleNameReference?.resolveToDescriptors()?.first()!!
|
||||
|
||||
val funcExpr = BindingContextUtils.descriptorToDeclaration(target.getContainingDeclaration()!!) as JetFunctionLiteral
|
||||
val funcExpr = DescriptorToSourceUtils.descriptorToDeclaration(target.getContainingDeclaration()!!) as JetFunctionLiteral
|
||||
|
||||
val newExpr = JetPsiFactory.createExpression(project, "{ it -> 42 }") as JetFunctionLiteralExpression
|
||||
funcExpr.addRangeAfter(newExpr.getFunctionLiteral().getValueParameterList(),
|
||||
|
||||
@@ -34,7 +34,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.DescriptorToSourceUtils;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingComponents;
|
||||
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||
@@ -83,7 +83,7 @@ public abstract class BaseJetVariableMacro extends Macro {
|
||||
|
||||
List<JetNamedDeclaration> declarations = new ArrayList<JetNamedDeclaration>();
|
||||
for (DeclarationDescriptor declarationDescriptor : TipsManager.excludeNotCallableExtensions(filteredDescriptors, scope)) {
|
||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(declarationDescriptor);
|
||||
PsiElement declaration = DescriptorToSourceUtils.descriptorToDeclaration(declarationDescriptor);
|
||||
assert declaration == null || declaration instanceof PsiNamedElement;
|
||||
|
||||
if (declaration instanceof JetProperty || declaration instanceof JetParameter) {
|
||||
|
||||
@@ -36,7 +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.DescriptorToSourceUtils;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
||||
@@ -102,7 +102,7 @@ public class JetAnonymousSuperMacro extends Macro {
|
||||
if (!classDescriptor.getModality().isOverridable()) continue;
|
||||
ClassKind kind = classDescriptor.getKind();
|
||||
if (kind == ClassKind.TRAIT || kind == ClassKind.CLASS) {
|
||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(descriptor);
|
||||
PsiElement declaration = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
|
||||
if (declaration != null) {
|
||||
result.add((PsiNamedElement) declaration);
|
||||
}
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.PsiUtilPackage;
|
||||
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.JetVisibilityChecker;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
@@ -161,7 +161,7 @@ public class JetFunctionParameterInfoHandler implements ParameterInfoHandlerWith
|
||||
.append(": ")
|
||||
.append(DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(getActualParameterType(parameter)));
|
||||
if (parameter.hasDefaultValue()) {
|
||||
PsiElement parameterDeclaration = BindingContextUtils.descriptorToDeclaration(parameter);
|
||||
PsiElement parameterDeclaration = DescriptorToSourceUtils.descriptorToDeclaration(parameter);
|
||||
builder.append(" = ").append(getDefaultExpressionString(parameterDeclaration));
|
||||
}
|
||||
if (named) builder.append("]");
|
||||
|
||||
@@ -31,8 +31,8 @@ import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
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.DescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
@@ -145,7 +145,8 @@ public class ChangeFunctionReturnTypeFix extends JetIntentionAction<JetFunction>
|
||||
BindingContext context = ResolvePackage.getBindingContext((JetFile) entry.getContainingFile().getContainingFile());
|
||||
ResolvedCall<FunctionDescriptor> resolvedCall = context.get(BindingContext.COMPONENT_RESOLVED_CALL, entry);
|
||||
if (resolvedCall == null) return null;
|
||||
JetFunction componentFunction = (JetFunction) BindingContextUtils.descriptorToDeclaration(resolvedCall.getCandidateDescriptor());
|
||||
JetFunction componentFunction = (JetFunction) DescriptorToSourceUtils
|
||||
.descriptorToDeclaration(resolvedCall.getCandidateDescriptor());
|
||||
JetType expectedType = context.get(BindingContext.TYPE, entry.getTypeRef());
|
||||
if (componentFunction != null && expectedType != null) {
|
||||
return new ChangeFunctionReturnTypeFix(componentFunction, expectedType);
|
||||
@@ -166,7 +167,8 @@ public class ChangeFunctionReturnTypeFix extends JetIntentionAction<JetFunction>
|
||||
BindingContext context = ResolvePackage.getBindingContext(expression.getContainingJetFile());
|
||||
ResolvedCall<FunctionDescriptor> resolvedCall = context.get(BindingContext.LOOP_RANGE_HAS_NEXT_RESOLVED_CALL, expression);
|
||||
if (resolvedCall == null) return null;
|
||||
JetFunction hasNextFunction = (JetFunction) BindingContextUtils.descriptorToDeclaration(resolvedCall.getCandidateDescriptor());
|
||||
JetFunction hasNextFunction = (JetFunction) DescriptorToSourceUtils
|
||||
.descriptorToDeclaration(resolvedCall.getCandidateDescriptor());
|
||||
if (hasNextFunction != null) {
|
||||
return new ChangeFunctionReturnTypeFix(hasNextFunction, KotlinBuiltIns.getInstance().getBooleanType());
|
||||
}
|
||||
@@ -186,7 +188,7 @@ public class ChangeFunctionReturnTypeFix extends JetIntentionAction<JetFunction>
|
||||
BindingContext context = ResolvePackage.getBindingContext(expression.getContainingJetFile());
|
||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCall(expression, context);
|
||||
if (resolvedCall == null) return null;
|
||||
PsiElement compareTo = BindingContextUtils.descriptorToDeclaration(resolvedCall.getCandidateDescriptor());
|
||||
PsiElement compareTo = DescriptorToSourceUtils.descriptorToDeclaration(resolvedCall.getCandidateDescriptor());
|
||||
if (!(compareTo instanceof JetFunction)) return null;
|
||||
return new ChangeFunctionReturnTypeFix((JetFunction) compareTo, KotlinBuiltIns.getInstance().getIntType());
|
||||
}
|
||||
@@ -224,7 +226,8 @@ public class ChangeFunctionReturnTypeFix extends JetIntentionAction<JetFunction>
|
||||
}
|
||||
|
||||
if (overriddenMismatchingFunctions.size() == 1) {
|
||||
PsiElement overriddenFunction = BindingContextUtils.descriptorToDeclaration(overriddenMismatchingFunctions.get(0));
|
||||
PsiElement overriddenFunction = DescriptorToSourceUtils
|
||||
.descriptorToDeclaration(overriddenMismatchingFunctions.get(0));
|
||||
if (overriddenFunction instanceof JetFunction) {
|
||||
actions.add(new ChangeFunctionReturnTypeFix((JetFunction) overriddenFunction, functionType));
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithParameters2;
|
||||
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.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
@@ -79,7 +79,7 @@ public abstract class ChangeFunctionSignatureFix extends JetIntentionAction<PsiE
|
||||
return false;
|
||||
}
|
||||
|
||||
List<PsiElement> declarations = BindingContextUtils.callableDescriptorToDeclarations(functionDescriptor);
|
||||
List<PsiElement> declarations = DescriptorToSourceUtils.callableDescriptorToDeclarations(functionDescriptor);
|
||||
if (declarations.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
|
||||
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.plugin.JetBundle;
|
||||
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||
|
||||
@@ -73,7 +74,7 @@ public class ChangeVariableMutabilityFix implements IntentionAction {
|
||||
BindingContext bindingContext = ResolvePackage.getBindingContext(file);
|
||||
VariableDescriptor descriptor = BindingContextUtils.extractVariableDescriptorIfAny(bindingContext, simpleNameExpression, true);
|
||||
if (descriptor != null) {
|
||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(descriptor);
|
||||
PsiElement declaration = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
|
||||
if (declaration instanceof JetProperty) {
|
||||
return (JetProperty) declaration;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
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.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
@@ -112,7 +112,8 @@ public class ChangeVariableTypeFix extends JetIntentionAction<JetVariableDeclara
|
||||
BindingContext context = ResolvePackage.getBindingContext(entry.getContainingJetFile());
|
||||
ResolvedCall<FunctionDescriptor> resolvedCall = context.get(BindingContext.COMPONENT_RESOLVED_CALL, entry);
|
||||
if (resolvedCall == null) return null;
|
||||
JetFunction componentFunction = (JetFunction) BindingContextUtils.descriptorToDeclaration(resolvedCall.getCandidateDescriptor());
|
||||
JetFunction componentFunction = (JetFunction) DescriptorToSourceUtils
|
||||
.descriptorToDeclaration(resolvedCall.getCandidateDescriptor());
|
||||
if (componentFunction == null) return null;
|
||||
JetType expectedType = resolvedCall.getCandidateDescriptor().getReturnType();
|
||||
return expectedType == null ? null : new ChangeVariableTypeFix(entry, expectedType);
|
||||
@@ -168,7 +169,8 @@ public class ChangeVariableTypeFix extends JetIntentionAction<JetVariableDeclara
|
||||
}
|
||||
|
||||
if (overriddenMismatchingProperties.size() == 1 && canChangeOverriddenPropertyType) {
|
||||
PsiElement overriddenProperty = BindingContextUtils.descriptorToDeclaration(overriddenMismatchingProperties.get(0));
|
||||
PsiElement overriddenProperty = DescriptorToSourceUtils
|
||||
.descriptorToDeclaration(overriddenMismatchingProperties.get(0));
|
||||
if (overriddenProperty instanceof JetProperty) {
|
||||
actions.add(new ChangeVariableTypeFix((JetProperty) overriddenProperty, propertyType));
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ import org.jetbrains.jet.plugin.caches.resolve.getAnalysisResults
|
||||
import org.jetbrains.jet.plugin.caches.resolve.getBindingContext
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory
|
||||
import org.jetbrains.jet.lang.diagnostics
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
|
||||
private val TYPE_PARAMETER_LIST_VARIABLE_NAME = "typeParameterList"
|
||||
private val TEMPLATE_FROM_USAGE_FUNCTION_BODY = "New Kotlin Function Body.kt"
|
||||
@@ -572,7 +573,7 @@ public class CreateFunctionFromUsageFix internal (
|
||||
// gather relevant information
|
||||
ownerClassDescriptor = DescriptorUtils.getClassDescriptorForType(selectedReceiverType.theType)
|
||||
val receiverType = ownerClassDescriptor.getDefaultType()
|
||||
val classDeclaration = BindingContextUtils.classDescriptorToDeclaration(ownerClassDescriptor)
|
||||
val classDeclaration = DescriptorToSourceUtils.classDescriptorToDeclaration(ownerClassDescriptor)
|
||||
if (classDeclaration is JetClass) {
|
||||
ownerClass = classDeclaration
|
||||
isExtension = !ownerClass.isWritable()
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.jetbrains.jet.plugin.project.ResolveSessionForBodies;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor.Kind.*;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.descriptorToDeclaration;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
|
||||
import static org.jetbrains.jet.lexer.JetTokens.OPEN_KEYWORD;
|
||||
|
||||
public class MakeOverriddenMemberOpenFix extends JetIntentionAction<JetDeclaration> {
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
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.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.types.DeferredType;
|
||||
@@ -122,7 +122,7 @@ public class QuickFixUtil {
|
||||
|
||||
@Nullable
|
||||
public static PsiElement safeGetDeclaration(@NotNull ResolvedCall<?> resolvedCall) {
|
||||
List<PsiElement> declarations = BindingContextUtils.descriptorToDeclarations(resolvedCall.getResultingDescriptor());
|
||||
List<PsiElement> declarations = DescriptorToSourceUtils.descriptorToDeclarations(resolvedCall.getResultingDescriptor());
|
||||
//do not create fix if descriptor has more than one overridden declaration
|
||||
if (declarations.size() == 1) {
|
||||
return declarations.iterator().next();
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.jetbrains.jet.lang.descriptors.impl.LocalVariableDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.PsiUtilPackage;
|
||||
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.OverrideResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.KotlinLightMethod;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -221,7 +221,7 @@ public class JetRefactoringUtil {
|
||||
|
||||
@NotNull
|
||||
public static String formatClass(@NotNull DeclarationDescriptor classDescriptor, boolean inCode) {
|
||||
PsiElement element = BindingContextUtils.descriptorToDeclaration(classDescriptor);
|
||||
PsiElement element = DescriptorToSourceUtils.descriptorToDeclaration(classDescriptor);
|
||||
if (element instanceof PsiClass) {
|
||||
return formatPsiClass((PsiClass) element, false, inCode);
|
||||
}
|
||||
@@ -231,7 +231,7 @@ public class JetRefactoringUtil {
|
||||
|
||||
@NotNull
|
||||
public static String formatFunction(@NotNull DeclarationDescriptor functionDescriptor, boolean inCode) {
|
||||
PsiElement element = BindingContextUtils.descriptorToDeclaration(functionDescriptor);
|
||||
PsiElement element = DescriptorToSourceUtils.descriptorToDeclaration(functionDescriptor);
|
||||
if (element instanceof PsiMethod) {
|
||||
return formatPsiMethod((PsiMethod) element, false, inCode);
|
||||
}
|
||||
|
||||
+5
-5
@@ -37,7 +37,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl;
|
||||
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.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -146,7 +146,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
|
||||
if (!changeInfo.isConstructor() && functionScope != null && !info.getNewName().isEmpty()) {
|
||||
for (FunctionDescriptor conflict : functionScope.getFunctions(Name.identifier(info.getNewName()))) {
|
||||
if (conflict != oldDescriptor && getFunctionParameterTypes(conflict).equals(getFunctionParameterTypes(oldDescriptor))) {
|
||||
PsiElement conflictElement = BindingContextUtils.descriptorToDeclaration(conflict);
|
||||
PsiElement conflictElement = DescriptorToSourceUtils.descriptorToDeclaration(conflict);
|
||||
result.putValue(conflictElement, "Function already exists: '" + DescriptorRenderer.SHORT_NAMES_IN_TYPES.render(conflict) + "'");
|
||||
break;
|
||||
}
|
||||
@@ -163,7 +163,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
|
||||
if (parametersScope != null) {
|
||||
if (changeInfo.isConstructor() && valOrVar != JetValVar.None) {
|
||||
for (VariableDescriptor property : parametersScope.getProperties(Name.identifier(parameterName))) {
|
||||
PsiElement propertyDeclaration = BindingContextUtils.descriptorToDeclaration(property);
|
||||
PsiElement propertyDeclaration = DescriptorToSourceUtils.descriptorToDeclaration(property);
|
||||
|
||||
if (propertyDeclaration != null && !(propertyDeclaration.getParent() instanceof JetParameterList)) {
|
||||
result.putValue(propertyDeclaration, "Duplicating property '" + parameterName + "'");
|
||||
@@ -175,7 +175,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
|
||||
VariableDescriptor variable = parametersScope.getLocalVariable(Name.identifier(parameterName));
|
||||
|
||||
if (variable != null && !(variable instanceof ValueParameterDescriptor)) {
|
||||
PsiElement conflictElement = BindingContextUtils.descriptorToDeclaration(variable);
|
||||
PsiElement conflictElement = DescriptorToSourceUtils.descriptorToDeclaration(variable);
|
||||
result.putValue(conflictElement, "Duplicating local variable '" + parameterName + "'");
|
||||
}
|
||||
}
|
||||
@@ -190,7 +190,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
|
||||
if (containingDeclaration instanceof ClassDescriptor)
|
||||
return ((ClassDescriptor) containingDeclaration).getMemberScope(ContainerUtil.<TypeProjection>emptyList());
|
||||
else if (containingDeclaration instanceof FunctionDescriptorImpl) {
|
||||
PsiElement container = BindingContextUtils.descriptorToDeclaration(containingDeclaration);
|
||||
PsiElement container = DescriptorToSourceUtils.descriptorToDeclaration(containingDeclaration);
|
||||
|
||||
if (container instanceof JetFunction)
|
||||
return getFunctionBodyScope((JetFunction) container, bindingContext);
|
||||
|
||||
@@ -50,6 +50,7 @@ import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||
import org.jetbrains.jet.lang.psi.JetFunctionLiteral
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
|
||||
data class ExtractionOptions(val inferUnitTypeForUnusedValues: Boolean) {
|
||||
class object {
|
||||
@@ -105,7 +106,7 @@ class ExtractionData(
|
||||
val refOffsetToDeclaration by Delegates.lazy {
|
||||
fun isExtractableIt(descriptor: DeclarationDescriptor, context: BindingContext): Boolean {
|
||||
if (!(descriptor is ValueParameterDescriptor && (context[BindingContext.AUTO_CREATED_IT, descriptor] ?: false))) return false
|
||||
val function = BindingContextUtils.descriptorToDeclaration(descriptor.getContainingDeclaration()) as? JetFunctionLiteral
|
||||
val function = DescriptorToSourceUtils.descriptorToDeclaration(descriptor.getContainingDeclaration()) as? JetFunctionLiteral
|
||||
return function == null || !function.isInsideOf(originalElements)
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -65,6 +65,7 @@ import org.jetbrains.jet.lang.cfg.pseudocodeTraverser.TraversalOrder
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getTargetFunctionDescriptor
|
||||
import com.intellij.psi.PsiWhiteSpace
|
||||
import org.jetbrains.jet.lang.resolve.OverridingUtil
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
|
||||
private val DEFAULT_FUNCTION_NAME = "myFun"
|
||||
private val DEFAULT_RETURN_TYPE = KotlinBuiltIns.getInstance().getUnitType()
|
||||
@@ -291,7 +292,7 @@ private fun JetType.processTypeIfExtractable(
|
||||
return collectReferencedTypes(processTypeArguments).fold(true) { (extractable, typeToCheck) ->
|
||||
val parameterTypeDescriptor = typeToCheck.getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor
|
||||
val typeParameter = parameterTypeDescriptor?.let {
|
||||
BindingContextUtils.descriptorToDeclaration(it)
|
||||
DescriptorToSourceUtils.descriptorToDeclaration(it)
|
||||
} as? JetTypeParameter
|
||||
|
||||
when {
|
||||
|
||||
+2
-1
@@ -44,6 +44,7 @@ import org.jetbrains.jet.lang.resolve.OverridingUtil
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.jet.asJava.namedUnwrappedElement
|
||||
import org.jetbrains.jet.lang.resolve.OverrideResolver
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
|
||||
public class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() {
|
||||
override fun canProcessElement(element: PsiElement): Boolean = element.namedUnwrappedElement is JetProperty
|
||||
@@ -185,7 +186,7 @@ public class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() {
|
||||
// Take one of supers for now - API doesn't support substitute to several elements (IDEA-48796)
|
||||
val deepest = supers.first()
|
||||
if (deepest != descriptor) {
|
||||
val superPsiElement = BindingContextUtils.descriptorToDeclaration(deepest)
|
||||
val superPsiElement = DescriptorToSourceUtils.descriptorToDeclaration(deepest)
|
||||
return superPsiElement as? JetProperty
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -34,6 +34,7 @@ import org.jetbrains.jet.plugin.references.JetReference
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.getParentByType
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.isAncestor
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.parameterIndex
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
|
||||
public class KotlinJavaSafeDeleteDelegate : JavaSafeDeleteDelegate {
|
||||
override fun createUsageInfoForParameter(
|
||||
@@ -57,7 +58,7 @@ public class KotlinJavaSafeDeleteDelegate : JavaSafeDeleteDelegate {
|
||||
val originalDeclaration = method.unwrapped
|
||||
if (originalDeclaration !is PsiMethod && originalDeclaration !is JetDeclaration) return
|
||||
|
||||
if (originalDeclaration != BindingContextUtils.descriptorToDeclaration(descriptor)) return
|
||||
if (originalDeclaration != DescriptorToSourceUtils.descriptorToDeclaration(descriptor)) return
|
||||
|
||||
val args = callExpression.getValueArguments()
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ public class BuiltInsReferenceResolver extends AbstractProjectComponent {
|
||||
public Collection<PsiElement> resolveBuiltInSymbol(@NotNull DeclarationDescriptor declarationDescriptor) {
|
||||
DeclarationDescriptor descriptor = findCurrentDescriptor(declarationDescriptor.getOriginal());
|
||||
if (descriptor != null) {
|
||||
return BindingContextUtils.descriptorToDeclarations(descriptor);
|
||||
return DescriptorToSourceUtils.descriptorToDeclarations(descriptor);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.jetbrains.jet.lang.psi.JetElement
|
||||
import org.jetbrains.jet.utils.keysToMap
|
||||
import com.intellij.psi.PsiMethod
|
||||
import org.jetbrains.jet.plugin.search.allScope
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
|
||||
public trait JetReference : PsiPolyVariantReference {
|
||||
public fun resolveToDescriptors(): Collection<DeclarationDescriptor>
|
||||
@@ -114,7 +115,7 @@ abstract class AbstractJetReference<T : JetElement>(element: T)
|
||||
private fun resolveToPsiElements(targetDescriptor: DeclarationDescriptor): Collection<PsiElement> {
|
||||
val result = HashSet<PsiElement>()
|
||||
val project = expression.getProject()
|
||||
result.addAll(BindingContextUtils.descriptorToDeclarations(targetDescriptor))
|
||||
result.addAll(DescriptorToSourceUtils.descriptorToDeclarations(targetDescriptor))
|
||||
result.addAll(DescriptorToDeclarationUtil.findDecompiledAndBuiltInDeclarations(project, targetDescriptor))
|
||||
|
||||
if (targetDescriptor is PackageViewDescriptor) {
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.jetbrains.jet.lang.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.KotlinLightMethod
|
||||
import org.jetbrains.jet.asJava.unwrapped
|
||||
import org.jetbrains.jet.lang.resolve.OverrideResolver
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
|
||||
// Navigation element of the resolved reference
|
||||
// For property accessor return enclosing property
|
||||
@@ -103,7 +104,7 @@ fun PsiReference.isConstructorUsage(jetClassOrObject: JetClassOrObject): Boolean
|
||||
val descriptor = getCallDescriptor(bindingContext)
|
||||
if (descriptor !is ConstructorDescriptor) return false
|
||||
|
||||
return BindingContextUtils.descriptorToDeclaration(descriptor.getContainingDeclaration()) == jetClassOrObject
|
||||
return DescriptorToSourceUtils.descriptorToDeclaration(descriptor.getContainingDeclaration()) == jetClassOrObject
|
||||
}
|
||||
|
||||
checkJavaUsage() || checkKotlinUsage()
|
||||
|
||||
@@ -47,6 +47,7 @@ import org.jetbrains.jet.getString
|
||||
import org.jetbrains.jet.getNullableString
|
||||
import org.jetbrains.jet.plugin.search.allScope
|
||||
import org.jetbrains.jet.plugin.caches.resolve.getBindingContext
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
|
||||
private enum class RenameType {
|
||||
JAVA_CLASS
|
||||
@@ -190,7 +191,7 @@ public abstract class AbstractRenameTest : MultiFileTestCase() {
|
||||
val bindingContext = jetFile.getBindingContext()
|
||||
val classDescriptor = bindingContext.get(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, classFqName)!!
|
||||
|
||||
val psiElement = BindingContextUtils.descriptorToDeclaration(findDescriptorToRename(classDescriptor))!!
|
||||
val psiElement = DescriptorToSourceUtils.descriptorToDeclaration(findDescriptorToRename(classDescriptor))!!
|
||||
|
||||
val substitution = RenamePsiElementProcessor.forElement(psiElement).substituteElementToRename(psiElement, null)
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.jetbrains.k2js.translate.utils.JsAstUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.descriptorToDeclaration;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
|
||||
import static org.jetbrains.k2js.translate.utils.AnnotationsUtils.getNameForAnnotatedObjectWithOverrides;
|
||||
import static org.jetbrains.k2js.translate.utils.AnnotationsUtils.isLibraryObject;
|
||||
import static org.jetbrains.k2js.translate.utils.JsDescriptorUtils.*;
|
||||
|
||||
@@ -23,6 +23,7 @@ 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.DescriptorToSourceUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
@@ -76,14 +77,14 @@ public final class BindingUtils {
|
||||
|
||||
@NotNull
|
||||
public static JetFunction getFunctionForDescriptor(@NotNull SimpleFunctionDescriptor descriptor) {
|
||||
PsiElement result = BindingContextUtils.callableDescriptorToDeclaration(descriptor);
|
||||
PsiElement result = DescriptorToSourceUtils.callableDescriptorToDeclaration(descriptor);
|
||||
assert result instanceof JetFunction : message(descriptor, "SimpleFunctionDescriptor should have declaration of type JetFunction");
|
||||
return (JetFunction) result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static JetParameter getParameterForDescriptor(@NotNull ValueParameterDescriptor descriptor) {
|
||||
PsiElement result = BindingContextUtils.descriptorToDeclaration(descriptor);
|
||||
PsiElement result = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
|
||||
assert result instanceof JetParameter : message(descriptor, "ValueParameterDescriptor should have corresponding JetParameter");
|
||||
return (JetParameter) result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user