Run Code Clean up for org.jetbrains.kotlin.idea.debugger

This commit is contained in:
Natalia Ukhorskaya
2015-12-03 12:32:13 +03:00
parent 1ca6c695e6
commit 1dbe560734
28 changed files with 122 additions and 145 deletions
@@ -16,11 +16,11 @@
package org.jetbrains.kotlin.idea.debugger
import org.jetbrains.kotlin.resolve.diagnostics.DiagnosticsWithSuppression
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.codeFragmentUtil.suppressDiagnosticsInDebugMode
import org.jetbrains.kotlin.resolve.diagnostics.DiagnosticsWithSuppression
public class DiagnosticSuppressorForDebugger : DiagnosticsWithSuppression.DiagnosticSuppressor {
override fun isSuppressed(diagnostic: Diagnostic): Boolean {
@@ -24,10 +24,9 @@ import com.intellij.openapi.options.Configurable
import com.intellij.openapi.options.SimpleConfigurable
import com.intellij.openapi.util.Getter
import com.intellij.util.xmlb.XmlSerializerUtil
import com.intellij.xdebugger.XDebuggerUtil
import com.intellij.xdebugger.settings.DebuggerSettingsCategory
import com.intellij.xdebugger.settings.XDebuggerSettings
import com.intellij.xdebugger.XDebuggerUtil
import org.jetbrains.kotlin.idea.debugger.stepping.KotlinSteppingConfigurableUi
@State(name = "KotlinDebuggerSettings", storages = arrayOf(Storage(file = StoragePathMacros.APP_CONFIG + "/kotlin_debug.xml")))
@@ -38,7 +37,7 @@ public class KotlinDebuggerSettings : XDebuggerSettings<KotlinDebuggerSettings>(
companion object {
public fun getInstance(): KotlinDebuggerSettings {
return XDebuggerUtil.getInstance()?.getDebuggerSettings(javaClass<KotlinDebuggerSettings>())!!
return XDebuggerUtil.getInstance()?.getDebuggerSettings(KotlinDebuggerSettings::class.java)!!
}
}
@@ -48,13 +47,13 @@ public class KotlinDebuggerSettings : XDebuggerSettings<KotlinDebuggerSettings>(
listOf(SimpleConfigurable.create(
"reference.idesettings.debugger.kotlin.stepping",
"Kotlin",
javaClass<KotlinSteppingConfigurableUi>(),
KotlinSteppingConfigurableUi::class.java,
this))
DebuggerSettingsCategory.DATA_VIEWS ->
listOf(SimpleConfigurable.create(
"reference.idesettings.debugger.kotlin.data.view",
"Kotlin",
javaClass<KotlinDelegatedPropertyRendererConfigurableUi>(),
KotlinDelegatedPropertyRendererConfigurableUi::class.java,
this))
else -> listOf()
}
@@ -16,15 +16,15 @@
package org.jetbrains.kotlin.idea.debugger
import com.intellij.debugger.impl.EditorTextProvider
import com.intellij.psi.PsiElement
import com.intellij.debugger.engine.evaluation.TextWithImports
import com.intellij.openapi.util.TextRange
import com.intellij.openapi.util.Pair
import com.intellij.debugger.engine.evaluation.TextWithImportsImpl
import com.intellij.debugger.engine.evaluation.CodeFragmentKind
import org.jetbrains.kotlin.idea.KotlinFileType
import com.intellij.debugger.engine.evaluation.TextWithImports
import com.intellij.debugger.engine.evaluation.TextWithImportsImpl
import com.intellij.debugger.impl.EditorTextProvider
import com.intellij.openapi.util.Pair
import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.psi.*
class KotlinEditorTextProvider : EditorTextProvider {
@@ -58,7 +58,7 @@ class KotlinEditorTextProvider : EditorTextProvider {
fun findExpressionInner(element: PsiElement, allowMethodCalls: Boolean): KtExpression? {
if (!isAcceptedAsCodeFragmentContext(element)) return null
val jetElement = PsiTreeUtil.getParentOfType(element, javaClass<KtElement>())
val jetElement = PsiTreeUtil.getParentOfType(element, KtElement::class.java)
if (jetElement == null) return null
if (jetElement is KtProperty) {
@@ -119,7 +119,7 @@ class KotlinEditorTextProvider : EditorTextProvider {
arrayOf(KtUserType::class.java, KtImportDirective::class.java, KtPackageDirective::class.java)
fun isAcceptedAsCodeFragmentContext(element: PsiElement): Boolean {
return element.javaClass as Class<*> !in NOT_ACCEPTED_AS_CONTEXT_TYPES &&
return !NOT_ACCEPTED_AS_CONTEXT_TYPES.contains(element.javaClass as Class<*>) &&
PsiTreeUtil.getParentOfType(element, *NOT_ACCEPTED_AS_CONTEXT_TYPES) == null
}
}
@@ -28,14 +28,16 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.JavaPsiFacade
import com.intellij.psi.PsiElement
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.util.PsiTreeUtil
import com.sun.jdi.AbsentInformationException
import com.sun.jdi.ClassNotPreparedException
import com.sun.jdi.ReferenceType
import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinCodeFragmentFactory
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
import org.jetbrains.kotlin.resolve.BindingContextUtils
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
@@ -123,7 +125,7 @@ public class KotlinSourcePositionProvider: SourcePositionProvider() {
try {
val locations = type.allLineLocations()
if (!locations.isEmpty()) {
val lastLocation = locations.get(locations.size() - 1)
val lastLocation = locations.get(locations.size - 1)
return debugProcess.getPositionManager().getSourcePosition(lastLocation)
}
}
@@ -387,7 +387,7 @@ public class KotlinBreakpointFiltersPanel<T extends KotlinPropertyBreakpointProp
}
myPassCountCheckbox.setEnabled(passCountApplicable);
final boolean passCountSelected = myPassCountCheckbox.isSelected();
boolean passCountSelected = myPassCountCheckbox.isSelected();
myInstanceFiltersCheckBox.setEnabled(!passCountSelected);
myClassFiltersCheckBox.setEnabled(!passCountSelected);
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.idea.debugger.breakpoints
import com.intellij.debugger.engine.DebugProcessImpl
import com.intellij.debugger.engine.JavaBreakpointHandler
import com.intellij.debugger.engine.JavaBreakpointHandlerFactory
import com.intellij.debugger.ui.breakpoints.JavaLineBreakpointType
public class KotlinFieldBreakpointHandlerFactory : JavaBreakpointHandlerFactory {
override fun createHandler(process: DebugProcessImpl): JavaBreakpointHandler? {
@@ -33,5 +32,5 @@ public class KotlinLineBreakpointHandlerFactory: JavaBreakpointHandlerFactory {
}
}
public class KotlinFieldBreakpointHandler(process: DebugProcessImpl) : JavaBreakpointHandler(javaClass<KotlinFieldBreakpointType>(), process)
public class KotlinLineBreakpointHandler(process: DebugProcessImpl) : JavaBreakpointHandler(javaClass<KotlinLineBreakpointType>(), process)
public class KotlinFieldBreakpointHandler(process: DebugProcessImpl) : JavaBreakpointHandler(KotlinFieldBreakpointType::class.java, process)
public class KotlinLineBreakpointHandler(process: DebugProcessImpl) : JavaBreakpointHandler(KotlinLineBreakpointType::class.java, process)
@@ -85,11 +85,11 @@ class KotlinFieldBreakpoint(
}
private fun getProperty(sourcePosition: SourcePosition?): KtCallableDeclaration? {
val property: KtProperty? = PositionUtil.getPsiElementAt(getProject(), javaClass(), sourcePosition)
val property: KtProperty? = PositionUtil.getPsiElementAt(getProject(), KtProperty::class.java, sourcePosition)
if (property != null) {
return property
}
val parameter: KtParameter? = PositionUtil.getPsiElementAt(getProject(), javaClass(), sourcePosition)
val parameter: KtParameter? = PositionUtil.getPsiElementAt(getProject(), KtParameter::class.java, sourcePosition)
if (parameter != null) {
return parameter
}
@@ -105,7 +105,7 @@ class KotlinFieldBreakpoint(
getProperties().myClassName = JvmFileClassUtil.getFileClassInfoNoResolve(property.getContainingKtFile()).fileClassFqName.asString()
}
else {
val ktClass: KtClassOrObject? = PsiTreeUtil.getParentOfType(property, javaClass())
val ktClass: KtClassOrObject? = PsiTreeUtil.getParentOfType(property, KtClassOrObject::class.java)
if (ktClass is KtClassOrObject) {
val fqName = ktClass.getFqName()
if (fqName != null) {
@@ -215,7 +215,7 @@ class KotlinFieldBreakpoint(
}
}
else {
var entryRequest: MethodEntryRequest? = findRequest(debugProcess, javaClass(), this)
var entryRequest: MethodEntryRequest? = findRequest(debugProcess, MethodEntryRequest::class.java, this)
if (entryRequest == null) {
entryRequest = manager.createMethodEntryRequest(this)!!
if (LOG.isDebugEnabled()) {
@@ -24,8 +24,6 @@ import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel
import com.intellij.xdebugger.impl.breakpoints.XBreakpointBase
import org.jetbrains.kotlin.idea.KotlinBundle
import java.awt.BorderLayout
import java.awt.event.ActionEvent
import java.awt.event.ActionListener
import javax.swing.Box
import javax.swing.JCheckBox
import javax.swing.JComponent
@@ -63,25 +61,25 @@ public class KotlinFieldBreakpointPropertiesPanel: XBreakpointCustomPropertiesPa
innerPanel.add(Box.createHorizontalStrut(3), BorderLayout.WEST)
innerPanel.add(Box.createHorizontalStrut(3), BorderLayout.EAST)
mainPanel.add(innerPanel, BorderLayout.NORTH)
mainPanel.setBorder(IdeBorderFactory.createTitledBorder(DebuggerBundle.message("label.group.watch.events"), true))
mainPanel.border = IdeBorderFactory.createTitledBorder(DebuggerBundle.message("label.group.watch.events"), true)
return mainPanel
}
override fun loadFrom(breakpoint: XLineBreakpoint<KotlinPropertyBreakpointProperties>) {
myWatchInitializationCheckBox.setSelected(breakpoint.getProperties().WATCH_INITIALIZATION)
myWatchAccessCheckBox.setSelected(breakpoint.getProperties().WATCH_ACCESS)
myWatchModificationCheckBox.setSelected(breakpoint.getProperties().WATCH_MODIFICATION)
myWatchInitializationCheckBox.isSelected = breakpoint.properties.WATCH_INITIALIZATION
myWatchAccessCheckBox.isSelected = breakpoint.properties.WATCH_ACCESS
myWatchModificationCheckBox.isSelected = breakpoint.properties.WATCH_MODIFICATION
}
override fun saveTo(breakpoint: XLineBreakpoint<KotlinPropertyBreakpointProperties>) {
var changed = breakpoint.getProperties().WATCH_ACCESS != myWatchAccessCheckBox.isSelected()
breakpoint.getProperties().WATCH_ACCESS = myWatchAccessCheckBox.isSelected()
var changed = breakpoint.properties.WATCH_ACCESS != myWatchAccessCheckBox.isSelected
breakpoint.properties.WATCH_ACCESS = myWatchAccessCheckBox.isSelected
changed = breakpoint.getProperties().WATCH_MODIFICATION != myWatchModificationCheckBox.isSelected() || changed
breakpoint.getProperties().WATCH_MODIFICATION = myWatchModificationCheckBox.isSelected()
changed = breakpoint.properties.WATCH_MODIFICATION != myWatchModificationCheckBox.isSelected || changed
breakpoint.properties.WATCH_MODIFICATION = myWatchModificationCheckBox.isSelected
changed = breakpoint.getProperties().WATCH_INITIALIZATION != myWatchInitializationCheckBox.isSelected() || changed
breakpoint.getProperties().WATCH_INITIALIZATION = myWatchInitializationCheckBox.isSelected()
changed = breakpoint.properties.WATCH_INITIALIZATION != myWatchInitializationCheckBox.isSelected || changed
breakpoint.properties.WATCH_INITIALIZATION = myWatchInitializationCheckBox.isSelected
if (changed) {
(breakpoint as XBreakpointBase<*, *, *>).fireBreakpointChanged()
@@ -22,15 +22,13 @@ import com.intellij.debugger.ui.breakpoints.BreakpointManager
import com.intellij.debugger.ui.breakpoints.BreakpointWithHighlighter
import com.intellij.debugger.ui.breakpoints.JavaBreakpointType
import com.intellij.icons.AllIcons
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.Messages
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.*
import com.intellij.psi.JavaPsiFacade
import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.xdebugger.XDebuggerManager
import com.intellij.xdebugger.XDebuggerUtil
import com.intellij.xdebugger.breakpoints.XBreakpoint
import com.intellij.xdebugger.breakpoints.XLineBreakpoint
import com.intellij.xdebugger.breakpoints.XLineBreakpointType
@@ -38,15 +36,12 @@ import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel
import org.jetbrains.kotlin.asJava.KtLightClass
import org.jetbrains.kotlin.asJava.KtLightClassForExplicitDeclaration
import org.jetbrains.kotlin.asJava.KtLightClassForFacade
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.debugger.breakpoints.dialog.AddFieldBreakpointDialog
import org.jetbrains.kotlin.idea.util.application.runWriteAction
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.psi.KtDeclarationContainer
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtProperty
import javax.swing.JComponent
public class KotlinFieldBreakpointType : JavaBreakpointType<KotlinPropertyBreakpointProperties>, XLineBreakpointType<KotlinPropertyBreakpointProperties>(
@@ -71,7 +66,7 @@ public class KotlinFieldBreakpointType : JavaBreakpointType<KotlinPropertyBreakp
val dialog = object : AddFieldBreakpointDialog(project) {
override fun validateData(): Boolean {
val className = getClassName()
val className = className
if (className.isEmpty()) {
reportError(project, DebuggerBundle.message("error.field.breakpoint.class.name.not.specified"))
return false
@@ -83,7 +78,7 @@ public class KotlinFieldBreakpointType : JavaBreakpointType<KotlinPropertyBreakp
return false
}
val fieldName = getFieldName()
val fieldName = fieldName
if (fieldName.isEmpty()) {
reportError(project, DebuggerBundle.message("error.field.breakpoint.field.name.not.specified"))
return false
@@ -118,15 +113,15 @@ public class KotlinFieldBreakpointType : JavaBreakpointType<KotlinPropertyBreakp
className: String,
fieldName: String
): XLineBreakpoint<KotlinPropertyBreakpointProperties>? {
val project = file.getProject()
val property = declaration.getDeclarations().firstOrNull { it is KtProperty && it.getName() == fieldName } ?: return null
val project = file.project
val property = declaration.declarations.firstOrNull { it is KtProperty && it.name == fieldName } ?: return null
val document = PsiDocumentManager.getInstance(project).getDocument(file) ?: return null
val line = document.getLineNumber(property.getTextOffset())
val line = document.getLineNumber(property.textOffset)
return runWriteAction {
XDebuggerManager.getInstance(project).getBreakpointManager().addLineBreakpoint(
XDebuggerManager.getInstance(project).breakpointManager.addLineBreakpoint(
this,
file.getVirtualFile().getUrl(),
file.virtualFile.url,
line,
KotlinPropertyBreakpointProperties(fieldName, className)
)
@@ -150,7 +145,7 @@ public class KotlinFieldBreakpointType : JavaBreakpointType<KotlinPropertyBreakp
override fun canBeHitInOtherPlaces() = true
override fun getShortText(breakpoint: XLineBreakpoint<KotlinPropertyBreakpointProperties>): String? {
val properties = breakpoint.getProperties()
val properties = breakpoint.properties
val className = properties.myClassName
return if (!className.isEmpty()) className + "." + properties.myFieldName else properties.myFieldName
}
@@ -166,10 +161,10 @@ public class KotlinFieldBreakpointType : JavaBreakpointType<KotlinPropertyBreakp
override fun getDisplayText(breakpoint: XLineBreakpoint<KotlinPropertyBreakpointProperties>): String? {
val kotlinBreakpoint = BreakpointManager.getJavaBreakpoint(breakpoint) as? BreakpointWithHighlighter
if (kotlinBreakpoint != null) {
return kotlinBreakpoint.getDescription();
return kotlinBreakpoint.description;
}
else {
return super<XLineBreakpointType>.getDisplayText(breakpoint);
return super.getDisplayText(breakpoint);
}
}
@@ -16,10 +16,8 @@
package org.jetbrains.kotlin.idea.debugger.breakpoints
import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties
import org.jetbrains.java.debugger.breakpoints.properties.JavaFieldBreakpointProperties
import com.intellij.util.xmlb.annotations.Attribute
import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties
public class KotlinPropertyBreakpointProperties(
@Attribute var myFieldName: String = "",
@@ -27,7 +27,7 @@ fun PsiClass.collectProperties(): Array<DescriptorMemberChooserObject> {
if (this is KtLightClassForFacade) {
val result = arrayListOf<DescriptorMemberChooserObject>()
this.files.forEach {
it.getDeclarations().filterIsInstance<KtProperty>().forEach {
it.declarations.filterIsInstance<KtProperty>().forEach {
result.add(DescriptorMemberChooserObject(it, it.resolveToDescriptor()))
}
}
@@ -36,7 +36,7 @@ fun PsiClass.collectProperties(): Array<DescriptorMemberChooserObject> {
if (this is KtLightClass) {
val origin = this.getOrigin()
if (origin != null) {
return origin.getDeclarations().filterIsInstance<KtProperty>().map {
return origin.declarations.filterIsInstance<KtProperty>().map {
DescriptorMemberChooserObject(it, it.resolveToDescriptor())
}.toTypedArray()
}
@@ -158,7 +158,7 @@ class KotlinCodeFragmentFactory: CodeFragmentFactory() {
elementAt.textOffset
}
var result = PsiTreeUtil.findElementOfClassAtOffset(containingFile, lineStartOffset, javaClass<KtExpression>(), false)
var result = PsiTreeUtil.findElementOfClassAtOffset(containingFile, lineStartOffset, KtExpression::class.java, false)
if (result.check()) {
return CodeInsightUtils.getTopmostElementAtOffset(result!!, lineStartOffset, KtExpression::class.java)
}
@@ -177,7 +177,7 @@ class KotlinCodeFragmentFactory: CodeFragmentFactory() {
fun createCodeFragmentForLabeledObjects(project: Project, markupMap: Map<*, ValueMarkup>): Pair<String, Map<String, Value>> {
val sb = StringBuilder()
val labeledObjects = HashMap<String, Value>()
val entrySet: Set<Map.Entry<*, ValueMarkup>> = markupMap.entrySet()
val entrySet: Set<Map.Entry<*, ValueMarkup>> = markupMap.entries
for ((value, markup) in entrySet) {
val labelName = markup.text
if (!Name.isValidIdentifier(labelName)) continue
@@ -218,7 +218,7 @@ class KotlinCodeFragmentFactory: CodeFragmentFactory() {
val session = XDebuggerManager.getInstance(project).currentSession as? XDebugSessionImpl
?: return originalContext
val markupMap = session.valueMarkers?.getAllMarkers()
val markupMap = session.valueMarkers?.allMarkers
if (markupMap == null || markupMap.isEmpty()) return originalContext
val (text, labels) = createCodeFragmentForLabeledObjects(project, markupMap)
@@ -245,6 +245,6 @@ class KotlinCodeFragmentFactory: CodeFragmentFactory() {
}
})
return getContextElement(codeFragment.findElementAt(codeFragment.text.length() - 1))
return getContextElement(codeFragment.findElementAt(codeFragment.text.length - 1))
}
}
@@ -42,9 +42,9 @@ class KotlinEvaluateExpressionCache(val project: Project) {
}, false)
companion object {
private val LOG = Logger.getLogger(javaClass<KotlinEvaluateExpressionCache>())!!
private val LOG = Logger.getLogger(KotlinEvaluateExpressionCache::class.java)!!
fun getInstance(project: Project) = ServiceManager.getService(project, javaClass<KotlinEvaluateExpressionCache>())!!
fun getInstance(project: Project) = ServiceManager.getService(project, KotlinEvaluateExpressionCache::class.java)!!
fun getOrCreateCompiledData(
codeFragment: KtCodeFragment,
@@ -63,11 +63,11 @@ public abstract class KotlinRuntimeTypeEvaluator(
protected abstract fun typeCalculationFinished(type: KotlinType?)
override fun evaluate(evaluationContext: EvaluationContextImpl): KotlinType? {
val project = evaluationContext.getProject()
val project = evaluationContext.project
val evaluator = DebuggerInvocationUtil.commitAndRunReadAction<ExpressionEvaluator>(project, EvaluatingComputable {
val codeFragment = KtPsiFactory(myElement.getProject()).createExpressionCodeFragment(
myElement.getText(), myElement.getContainingFile().getContext())
val codeFragment = KtPsiFactory(myElement.project).createExpressionCodeFragment(
myElement.text, myElement.containingFile.context)
KotlinEvaluationBuilder.build(codeFragment, ContextUtil.getSourcePosition(evaluationContext))
})
@@ -84,7 +84,7 @@ public abstract class KotlinRuntimeTypeEvaluator(
val myValue = value.asValue()
var psiClass = myValue.asmType.getClassDescriptor(project)
if (psiClass != null) {
return psiClass.getDefaultType()
return psiClass.defaultType
}
val type = value.type()
@@ -93,14 +93,14 @@ public abstract class KotlinRuntimeTypeEvaluator(
if (superclass != null && CommonClassNames.JAVA_LANG_OBJECT != superclass.name()) {
psiClass = AsmType.getType(superclass.signature()).getClassDescriptor(project)
if (psiClass != null) {
return psiClass.getDefaultType()
return psiClass.defaultType
}
}
for (interfaceType in type.interfaces()) {
psiClass = AsmType.getType(interfaceType.signature()).getClassDescriptor(project)
if (psiClass != null) {
return psiClass.getDefaultType()
return psiClass.defaultType
}
}
}
@@ -26,7 +26,7 @@ import com.sun.jdi.ClassLoaderReference
import org.jetbrains.kotlin.idea.debugger.evaluate.CompilingEvaluatorUtils
public fun loadClasses(evaluationContext: EvaluationContextImpl, classes: Collection<Pair<String, ByteArray>>) {
val process = evaluationContext.getDebugProcess()
val process = evaluationContext.debugProcess
val classLoader: ClassLoaderReference
try {
@@ -36,11 +36,11 @@ public fun loadClasses(evaluationContext: EvaluationContextImpl, classes: Collec
throw EvaluateException("Error creating evaluation class loader: " + e, e)
}
val version = (process.getVirtualMachineProxy()).version()
val version = (process.virtualMachineProxy).version()
val sdkVersion = JdkVersionUtil.getVersion(version)
if (!SystemInfo.isJavaVersionAtLeast(sdkVersion.getDescription())) {
throw EvaluateException("Unable to compile for target level " + sdkVersion.getDescription() + ". Need to run IDEA on java version at least " + sdkVersion.getDescription() + ", currently running on " + SystemInfo.JAVA_RUNTIME_VERSION)
if (!SystemInfo.isJavaVersionAtLeast(sdkVersion.description)) {
throw EvaluateException("Unable to compile for target level " + sdkVersion.description + ". Need to run IDEA on java version at least " + sdkVersion.description + ", currently running on " + SystemInfo.JAVA_RUNTIME_VERSION)
}
try {
@@ -50,7 +50,7 @@ public fun loadClasses(evaluationContext: EvaluationContextImpl, classes: Collec
throw EvaluateException("Error during classes definition " + e, e)
}
evaluationContext.setClassLoader(classLoader)
evaluationContext.classLoader = classLoader
}
private fun defineClasses(
@@ -75,7 +75,7 @@ private val LAMBDA_SUPERCLASSES = listOf(
private class ClassBytes(val name: String) {
val bytes: ByteArray by lazy {
val inputStream = this.javaClass.getClassLoader().getResourceAsStream(name.replace('.', '/') + ".class")
val inputStream = this.javaClass.classLoader.getResourceAsStream(name.replace('.', '/') + ".class")
?: throw EvaluateException("Couldn't find $name class in current class loader")
try {
@@ -25,9 +25,9 @@ private val KOTLIN_STDLIB_FILTER = "kotlin.*"
public fun addKotlinStdlibDebugFilterIfNeeded() {
if (!KotlinDebuggerSettings.getInstance().DEBUG_IS_FILTER_FOR_STDLIB_ALREADY_ADDED) {
val settings = DebuggerSettings.getInstance()!!
val newFilters = (settings.getSteppingFilters() + ClassFilter(KOTLIN_STDLIB_FILTER))
val newFilters = (settings.steppingFilters + ClassFilter(KOTLIN_STDLIB_FILTER))
settings.setSteppingFilters(newFilters)
settings.steppingFilters = newFilters
KotlinDebuggerSettings.getInstance().DEBUG_IS_FILTER_FOR_STDLIB_ALREADY_ADDED = true
}
@@ -16,8 +16,8 @@
package org.jetbrains.kotlin.idea.debugger.filter
import com.intellij.ui.classFilter.DebuggerClassFilterProvider
import com.intellij.ui.classFilter.ClassFilter
import com.intellij.ui.classFilter.DebuggerClassFilterProvider
import org.jetbrains.kotlin.idea.debugger.KotlinDebuggerSettings
private val FILTERS = listOf(
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.idea.debugger.render
import com.intellij.debugger.DebuggerContext
import com.intellij.debugger.engine.evaluation.EvaluateException
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl
import com.intellij.debugger.settings.NodeRendererSettings
import com.intellij.debugger.ui.impl.watch.FieldDescriptorImpl
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiExpression
@@ -42,22 +41,22 @@ class DelegatedPropertyFieldDescriptor(
if (!renderDelegatedProperty) return super.calcValue(evaluationContext)
val method = findGetterForDelegatedProperty()
val threadReference = evaluationContext.getSuspendContext().getThread()?.getThreadReference()
val threadReference = evaluationContext.suspendContext.thread?.threadReference
if (method == null || threadReference == null) {
return super.calcValue(evaluationContext)
}
try {
return evaluationContext.getDebugProcess().invokeInstanceMethod(
return evaluationContext.debugProcess.invokeInstanceMethod(
evaluationContext,
getObject(),
`object`,
method,
listOf<Nothing>(),
evaluationContext.getSuspendContext().getSuspendPolicy()
evaluationContext.suspendContext.suspendPolicy
)
}
catch(e: EvaluateException) {
return e.getExceptionFromTargetVM()
return e.exceptionFromTargetVM
}
}
@@ -70,10 +69,10 @@ class DelegatedPropertyFieldDescriptor(
}
private fun findGetterForDelegatedProperty(): Method? {
val fieldName = getName()
val fieldName = name
if (!Name.isValidIdentifier(fieldName)) return null
return getObject().referenceType().methodsByName(JvmAbi.getterName(fieldName))?.firstOrNull()
return `object`.referenceType().methodsByName(JvmAbi.getterName(fieldName))?.firstOrNull()
}
override fun getDeclaredType(): String? {
@@ -16,28 +16,23 @@
package org.jetbrains.kotlin.idea.debugger.render
import com.intellij.debugger.ui.tree.render.ClassRenderer
import com.sun.jdi.Type as JdiType
import com.sun.jdi.Value
import com.intellij.debugger.ui.tree.render.ChildrenBuilder
import com.intellij.debugger.engine.evaluation.EvaluationContext
import com.intellij.debugger.ui.tree.DebuggerTreeNode
import org.jetbrains.org.objectweb.asm.Type as AsmType
import com.intellij.debugger.engine.DebuggerManagerThreadImpl
import com.sun.jdi.ObjectReference
import com.intellij.xdebugger.settings.XDebuggerSettingsManager
import com.intellij.debugger.ui.impl.watch.NodeManagerImpl
import com.intellij.debugger.engine.evaluation.EvaluationContext
import com.intellij.debugger.ui.impl.watch.MessageDescriptor
import java.util.ArrayList
import org.jetbrains.kotlin.load.java.JvmAbi
import com.sun.jdi.Field
import com.intellij.debugger.ui.impl.watch.NodeManagerImpl
import com.intellij.debugger.ui.tree.DebuggerTreeNode
import com.intellij.debugger.ui.tree.render.ChildrenBuilder
import com.intellij.debugger.ui.tree.render.ClassRenderer
import com.intellij.xdebugger.settings.XDebuggerSettingsManager
import com.sun.jdi.ObjectReference
import com.sun.jdi.ReferenceType
import com.sun.jdi.Type
import com.sun.jdi.Method
import org.jetbrains.kotlin.codegen.PropertyCodegen
import org.jetbrains.kotlin.name.Name
import com.intellij.debugger.engine.evaluation.EvaluateException
import com.sun.jdi.Value
import org.jetbrains.kotlin.idea.debugger.KotlinDebuggerSettings
import org.jetbrains.kotlin.load.java.JvmAbi
import java.util.*
import com.sun.jdi.Type as JdiType
import org.jetbrains.org.objectweb.asm.Type as AsmType
public class KotlinClassWithDelegatedPropertyRenderer : ClassRenderer() {
@@ -54,12 +49,12 @@ public class KotlinClassWithDelegatedPropertyRenderer : ClassRenderer() {
if (value !is ObjectReference) return
val nodeManager = builder.getNodeManager()!!
val nodeDescriptorFactory = builder.getDescriptorManager()!!
val nodeManager = builder.nodeManager!!
val nodeDescriptorFactory = builder.descriptorManager!!
val fields = value.referenceType().allFields()
if (fields.isEmpty()) {
builder.setChildren(listOf(nodeManager.createMessageNode(MessageDescriptor.CLASS_HAS_NO_FIELDS.getLabel())))
builder.setChildren(listOf(nodeManager.createMessageNode(MessageDescriptor.CLASS_HAS_NO_FIELDS.label)))
return
}
@@ -69,7 +64,7 @@ public class KotlinClassWithDelegatedPropertyRenderer : ClassRenderer() {
continue
}
val fieldDescriptor = nodeDescriptorFactory.getFieldDescriptor(builder.getParentDescriptor(), value, field)
val fieldDescriptor = nodeDescriptorFactory.getFieldDescriptor(builder.parentDescriptor, value, field)
if (field.name().endsWith(JvmAbi.DELEGATED_PROPERTY_NAME_SUFFIX)) {
val shouldRenderDelegatedProperty = KotlinDebuggerSettings.getInstance().DEBUG_RENDER_DELEGATED_PROPERTIES
@@ -78,7 +73,7 @@ public class KotlinClassWithDelegatedPropertyRenderer : ClassRenderer() {
}
val delegatedPropertyDescriptor = DelegatedPropertyFieldDescriptor(
context.getDebugProcess().getProject()!!,
context.debugProcess.project!!,
value,
field,
shouldRenderDelegatedProperty)
@@ -89,7 +84,7 @@ public class KotlinClassWithDelegatedPropertyRenderer : ClassRenderer() {
}
}
if (XDebuggerSettingsManager.getInstance()!!.getDataViewSettings().isSortValues()) {
if (XDebuggerSettingsManager.getInstance()!!.dataViewSettings.isSortValues) {
children.sortedWith(NodeManagerImpl.getNodeComparator())
}
@@ -35,8 +35,8 @@ public class KotlinBasicStepMethodFilter(
myTargetMethodName = when (resolvedElement) {
is KtAnonymousInitializer -> "<init>"
is KtConstructor<*> -> "<init>"
is KtPropertyAccessor -> JvmAbi.getterName((resolvedElement.getParent() as KtProperty).getName()!!)
else -> resolvedElement.getName()!!
is KtPropertyAccessor -> JvmAbi.getterName((resolvedElement.parent as KtProperty).name!!)
else -> resolvedElement.name!!
}
}
@@ -49,7 +49,7 @@ public class KotlinBasicStepMethodFilter(
if (myTargetMethodName != method.name()) return false
val sourcePosition = runReadAction { SourcePosition.createFromElement(resolvedElement) } ?: return false
val positionManager = process.getPositionManager() ?: return false
val positionManager = process.positionManager ?: return false
val classes = positionManager.getAllClasses(sourcePosition)
@@ -32,11 +32,11 @@ public class KotlinLambdaSmartStepTarget(
): SmartStepTarget(label, highlightElement, true, lines) {
override fun getIcon() = KotlinIcons.LAMBDA
fun getLambda() = getHighlightElement() as KtFunction
fun getLambda() = highlightElement as KtFunction
companion object {
fun calcLabel(descriptor: DeclarationDescriptor, paramName: Name): String {
return "${descriptor.getName().asString()}: ${paramName.asString()}.${OperatorNameConventions.INVOKE.asString()}()"
return "${descriptor.name.asString()}: ${paramName.asString()}.${OperatorNameConventions.INVOKE.asString()}()"
}
}
}
@@ -19,7 +19,7 @@ public class KotlinMethodSmartStepTarget(
): SmartStepTarget(label, highlightElement, false, lines) {
override fun getIcon(): Icon? {
return when {
resolvedElement is KtNamedFunction && resolvedElement.getReceiverTypeReference() != null -> KotlinIcons.EXTENSION_FUNCTION
resolvedElement is KtNamedFunction && resolvedElement.receiverTypeReference != null -> KotlinIcons.EXTENSION_FUNCTION
else -> KotlinIcons.FUNCTION
}
}
@@ -276,7 +276,7 @@ public class KotlinSteppingCommandProvider: JvmSteppingCommandProvider() {
return allInlineFunctionCalls.filter {
val shouldInclude = it.getLineNumber() in linesRange
if (shouldInclude) {
linesRange = Math.min(linesRange.start, it.getLineNumber())..Math.max(linesRange.end, it.getLineNumber(false))
linesRange = Math.min(linesRange.start, it.getLineNumber())..Math.max(linesRange.endInclusive, it.getLineNumber(false))
}
shouldInclude
}
@@ -286,7 +286,7 @@ public class KotlinSteppingCommandProvider: JvmSteppingCommandProvider() {
fun getStepOverPosition(
location: Location,
file: KtFile,
range: Range<Int>,
range: IntRange,
inlinedArguments: List<KtElement>,
elementsToSkip: List<PsiElement>
): XSourcePositionImpl? {
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.idea.debugger
import com.intellij.openapi.util.io.FileUtil
import org.jetbrains.kotlin.test.InTextDirectivesUtils
import org.jetbrains.kotlin.test.InTextDirectivesUtils.getPrefixedInt
import java.io.File
public abstract class AbstractKotlinSteppingTest : KotlinDebuggerTestBase() {
@@ -16,14 +16,7 @@
package org.jetbrains.kotlin.idea.debugger
import com.intellij.debugger.actions.MethodSmartStepTarget
import com.intellij.debugger.actions.SmartStepTarget
import com.intellij.psi.PsiSubstitutor
import com.intellij.psi.util.PsiFormatUtil
import com.intellij.psi.util.PsiFormatUtilBase
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
import org.jetbrains.kotlin.idea.debugger.stepping.KotlinLambdaSmartStepTarget
import org.jetbrains.kotlin.idea.debugger.stepping.KotlinSmartStepIntoHandler
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
@@ -64,13 +57,13 @@ public abstract class AbstractSmartStepIntoTest : KotlinLightCodeInsightFixtureT
private fun renderTableWithResults(expected: List<String>, actual: List<String>): String {
val sb = StringBuilder()
val maxExtStrSize = (expected.maxBy { it.length() }?.length() ?: 0) + 5
val longerList = (if (expected.size() < actual.size()) actual else expected).sorted()
val shorterList = (if (expected.size() < actual.size()) expected else actual).sorted()
val maxExtStrSize = (expected.maxBy { it.length }?.length ?: 0) + 5
val longerList = (if (expected.size < actual.size) actual else expected).sorted()
val shorterList = (if (expected.size < actual.size) expected else actual).sorted()
for ((i, element) in longerList.withIndex()) {
sb.append(element)
sb.append(" ".repeat(maxExtStrSize - element.length()))
if (i < shorterList.size()) sb.append(shorterList[i])
sb.append(" ".repeat(maxExtStrSize - element.length))
if (i < shorterList.size) sb.append(shorterList[i])
sb.append("\n")
}
@@ -410,7 +410,7 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
}
}
assert(sourceFiles.size() == 1) { "One source file should be found: name = $fileName, sourceFiles = $sourceFiles" }
assert(sourceFiles.size == 1) { "One source file should be found: name = $fileName, sourceFiles = $sourceFiles" }
val runnable = Runnable() {
val psiSourceFile = PsiManager.getInstance(project).findFile(sourceFiles.first())!!
@@ -16,9 +16,9 @@
package org.jetbrains.kotlin.idea.debugger
import com.intellij.psi.PsiElement
import com.intellij.debugger.SourcePosition
import com.intellij.openapi.editor.Editor
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
class MockSourcePosition(
@@ -62,7 +62,7 @@ import java.util.*
import javax.swing.tree.TreeNode
public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestBase() {
private val logger = Logger.getLogger(javaClass<KotlinEvaluateExpressionCache>())!!
private val logger = Logger.getLogger(KotlinEvaluateExpressionCache::class.java)!!
private var appender: AppenderSkeleton? = null
@@ -289,10 +289,10 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
private fun checkExceptions(exceptions: MutableMap<String, Throwable>) {
if (!exceptions.isEmpty()) {
for (exc in exceptions.values()) {
for (exc in exceptions.values) {
exc.printStackTrace()
}
throw AssertionError("Test failed:\n" + exceptions.map { "expression: ${it.key}, exception: ${it.value.getMessage()}" }.joinToString("\n"))
throw AssertionError("Test failed:\n" + exceptions.map { "expression: ${it.key}, exception: ${it.value.message}" }.joinToString("\n"))
}
}
@@ -308,7 +308,7 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
private fun loadTestDirectivesPairs(fileContent: String, directivePrefix: String, expectedPrefix: String): List<Pair<String, String>> {
val directives = InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileContent, directivePrefix)
val expected = InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileContent, expectedPrefix)
assert(directives.size() == expected.size()) { "Sizes of test directives are different" }
assert(directives.size == expected.size) { "Sizes of test directives are different" }
return directives.zip(expected)
}
@@ -328,7 +328,7 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
val markupMap = hashMapOf<com.sun.jdi.Value, ValueMarkup>()
for (labelAsText in labelsAsText) {
val labelParts = labelAsText.split("=")
assert(labelParts.size() == 2) { "Wrong format for DEBUG_LABEL directive: // DEBUG_LABEL: {localVariableName} = {labelText}"}
assert(labelParts.size == 2) { "Wrong format for DEBUG_LABEL directive: // DEBUG_LABEL: {localVariableName} = {labelText}"}
val localVariableName = labelParts[0].trim()
val labelName = labelParts[1].trim()
val localVariable = context.getFrameProxy()!!.visibleVariableByName(localVariableName)
@@ -366,7 +366,7 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
Assert.assertTrue("Evaluate expression returns wrong result for $text:\nexpected = $expectedResult\nactual = $actualResult\n", expectedResult == actualResult)
}
catch (e: EvaluateException) {
Assert.assertTrue("Evaluate expression throws wrong exception for $text:\nexpected = $expectedResult\nactual = ${e.getMessage()}\n", expectedResult == e.getMessage()?.replaceFirst(ID_PART_REGEX, "id=ID"))
Assert.assertTrue("Evaluate expression throws wrong exception for $text:\nexpected = $expectedResult\nactual = ${e.message}\n", expectedResult == e.message?.replaceFirst(ID_PART_REGEX, "id=ID"))
}
}
}