Highlight dynamic calls in the editor
This commit is contained in:
@@ -23,18 +23,16 @@ import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor;
|
||||
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.calls.tasks.TasksPackage;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypesPackage;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -119,12 +117,8 @@ public class DebugInfoUtil {
|
||||
if (declarationDescriptor != null) {
|
||||
target = declarationDescriptor.toString();
|
||||
|
||||
if (declarationDescriptor instanceof CallableDescriptor) {
|
||||
CallableDescriptor callableDescriptor = (CallableDescriptor) declarationDescriptor;
|
||||
ReceiverParameterDescriptor dispatchReceiverParameter = callableDescriptor.getDispatchReceiverParameter();
|
||||
if (dispatchReceiverParameter != null && TypesPackage.isDynamic(dispatchReceiverParameter.getReturnType())) {
|
||||
debugInfoReporter.reportDynamicCall(expression);
|
||||
}
|
||||
if (TasksPackage.isDynamic(declarationDescriptor)) {
|
||||
debugInfoReporter.reportDynamicCall(expression);
|
||||
}
|
||||
}
|
||||
if (target == null) {
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl
|
||||
import org.jetbrains.jet.lang.types.JetType
|
||||
import kotlin.platform.platformStatic
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.TransientReceiver
|
||||
import org.jetbrains.jet.lang.types.isDynamic
|
||||
|
||||
object DynamicCallableDescriptors {
|
||||
|
||||
@@ -123,4 +124,11 @@ object DynamicCallableDescriptors {
|
||||
SourceElement.NO_SOURCE
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun DeclarationDescriptor.isDynamic(): Boolean {
|
||||
if (this !is CallableDescriptor) return false
|
||||
val dispatchReceiverParameter = getDispatchReceiverParameter()
|
||||
return dispatchReceiverParameter != null && dispatchReceiverParameter.getType().isDynamic()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user