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