mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
[performance-plugin] AT-264: Add command for set breakpoint in java and kotlin files
GitOrigin-RevId: 20b81a001ef3311a56f4e41653e03110a3cad9ec
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1fd0806e2f
commit
fba16154fa
@@ -16,5 +16,7 @@
|
||||
<orderEntry type="library" name="opentelemetry" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.java.ui" />
|
||||
<orderEntry type="module" module-name="intellij.platform.diagnostic.telemetry" />
|
||||
<orderEntry type="module" module-name="intellij.platform.debugger" />
|
||||
<orderEntry type="module" module-name="intellij.java.debugger.impl" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -13,7 +13,8 @@ final class JavaCommandProvider implements CommandProvider {
|
||||
return Map.of(
|
||||
FindUsagesJavaCommand.PREFIX, FindUsagesJavaCommand::new,
|
||||
BuildCommand.PREFIX, BuildCommand::new,
|
||||
SyncJpsLibrariesCommand.PREFIX, SyncJpsLibrariesCommand::new
|
||||
SyncJpsLibrariesCommand.PREFIX, SyncJpsLibrariesCommand::new,
|
||||
SetBreakpointCommand.PREFIX, SetBreakpointCommand::new
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.performancePlugin
|
||||
|
||||
import com.intellij.debugger.ui.breakpoints.JavaLineBreakpointType
|
||||
import com.intellij.openapi.application.WriteAction
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.ui.playback.PlaybackContext
|
||||
import com.intellij.openapi.util.ActionCallback
|
||||
import com.intellij.openapi.vfs.VirtualFileManager
|
||||
import com.intellij.xdebugger.XDebuggerManager
|
||||
import com.intellij.xdebugger.breakpoints.XBreakpointType
|
||||
import com.jetbrains.performancePlugin.utils.AbstractCallbackBasedCommand
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import java.io.IOException
|
||||
|
||||
class SetBreakpointCommand(text: String, line: Int) : AbstractCallbackBasedCommand(text, line, true) {
|
||||
override fun execute(callback: ActionCallback, context: PlaybackContext) {
|
||||
val lineNumber = extractCommandArgument(PREFIX).toInt() - 1
|
||||
val project = context.project
|
||||
val selectedEditor = FileEditorManager.getInstance(project).selectedEditor
|
||||
if (selectedEditor == null) {
|
||||
callback.reject("No opened editor")
|
||||
}
|
||||
val filePath = "file://" + selectedEditor!!.file.path
|
||||
val breakpointType = XBreakpointType.EXTENSION_POINT_NAME.findExtension(JavaLineBreakpointType::class.java)!!
|
||||
WriteAction.runAndWait<IOException> {
|
||||
val breakpointManager = XDebuggerManager.getInstance(project).breakpointManager
|
||||
VirtualFileManager.getInstance().refreshAndFindFileByUrl(filePath)
|
||||
val breakpoint = breakpointManager.addLineBreakpoint(breakpointType, filePath, lineNumber,
|
||||
breakpointType.createBreakpointProperties(selectedEditor.file, lineNumber))
|
||||
breakpointManager.updateBreakpointPresentation(breakpoint, null, null)
|
||||
}
|
||||
callback.setDone()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val LOG = Logger.getInstance(SetBreakpointCommand::class.java)
|
||||
const val PREFIX: @NonNls String = CMD_PREFIX + "setBreakpoint"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user