Break Point display for PL/pg SQL debugger
已完成
Hi,
I'm writing a debugger plugin for Postres, I'm using database tools API for Intellij Ultimate (Datagrip also)
I can register breakpoints but they don't show up on the line(breakpoint icon not displayed).
Here are my class and the picture of the problem
class PlLineBreakpointProperties : SqlLineBreakpointProperties() {}
class PlLineBreakpointType :
SqlLineBreakpointType<PlLineBreakpointProperties>("plpg_line_breakpoint", "PLpg/SQL") {
private val fileRegex = Regex("^.+\\..+\\[\\d+\\]\\.sql\$")
private val fileRegexTest = Regex("^.+\\.sql\$")
override fun createBreakpointProperties(file: VirtualFile, line: Int): PlLineBreakpointProperties? {
return PlLineBreakpointProperties()
}
override fun canPutAt(file: VirtualFile, line: Int, project: Project): Boolean {
if (!fileRegexTest.matches(file.name)) {
return false
}
var goodCandidate = false
val psi: PsiFile? = PsiManager.getInstance(project).findFile(file)
val funcEl = psi?.firstChild
if (funcEl is PgCreateFunctionStatementImpl) {
val begin = PsiTreeUtil.collectElements(funcEl, PsiElementFilter {
it is SqlTokenElement && it.text.uppercase() == "BEGIN"
}).firstOrNull()
if (begin != null) {
val doc = FileDocumentManager.getInstance().getDocument(file)
val beginPos = doc?.getLineNumber(begin.textOffset)
if (beginPos != null) {
goodCandidate = beginPos < line
}
}
}
return goodCandidate
}
override fun getEditorsProvider(
breakpoint: XLineBreakpoint<PlLineBreakpointProperties>,
project: Project
): XDebuggerEditorsProvider? {
return PlEditorProvider
}
}
inner class BreakPointHandler :
XBreakpointHandler<XLineBreakpoint<PlLineBreakpointProperties>>(PlLineBreakpointType::class.java) {
override fun registerBreakpoint(breakpoint: XLineBreakpoint<PlLineBreakpointProperties>) {
stack.addBreakPoint(breakpoint.shortFilePath, breakpoint.line)
}
override fun unregisterBreakpoint(breakpoint: XLineBreakpoint<PlLineBreakpointProperties>, temporary: Boolean) {
stack.deleteBreakPoint(breakpoint.shortFilePath, breakpoint.line)
}
}
请先登录再写评论。
obsolete