// 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.xdebugger; import com.intellij.openapi.extensions.ExtensionPoint; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.testFramework.HeavyPlatformTestCase; import com.intellij.util.xmlb.annotations.Attribute; import com.intellij.xdebugger.breakpoints.*; import com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl; import org.jetbrains.annotations.NotNull; public abstract class XDebuggerTestCase extends HeavyPlatformTestCase { public static final MyLineBreakpointType MY_LINE_BREAKPOINT_TYPE = new MyLineBreakpointType(); protected static final MySimpleBreakpointType MY_SIMPLE_BREAKPOINT_TYPE = new MySimpleBreakpointType(); @NotNull static XBreakpoint addBreakpoint(XBreakpointManagerImpl breakpointManager, MyBreakpointProperties abc) { return breakpointManager.addBreakpoint(MY_SIMPLE_BREAKPOINT_TYPE, abc); } @NotNull static XLineBreakpoint addLineBreakpoint(XBreakpointManagerImpl breakpointManager, String url, int line, MyBreakpointProperties properties) { return breakpointManager.addLineBreakpoint(MY_LINE_BREAKPOINT_TYPE, url, line, properties); } static void removeBreakPoint(XBreakpointManagerImpl breakpointManager, XBreakpoint breakpoint) { breakpointManager.removeBreakpoint(breakpoint); } @Override protected void initApplication() throws Exception { super.initApplication(); final ExtensionPoint point = XBreakpointType.EXTENSION_POINT_NAME.getPoint(); point.registerExtension(MY_LINE_BREAKPOINT_TYPE, getTestRootDisposable()); point.registerExtension(MY_SIMPLE_BREAKPOINT_TYPE, getTestRootDisposable()); } public static class MyLineBreakpointType extends XLineBreakpointType { public MyLineBreakpointType() { super("testLine", "239"); } @Override public MyBreakpointProperties createBreakpointProperties(@NotNull final VirtualFile file, final int line) { return null; } @Override public MyBreakpointProperties createProperties() { return new MyBreakpointProperties(); } } public static class MySimpleBreakpointType extends XBreakpointType,MyBreakpointProperties> { public MySimpleBreakpointType() { super("test", "239"); } @Override public String getDisplayText(final XBreakpoint breakpoint) { return ""; } @Override public MyBreakpointProperties createProperties() { return new MyBreakpointProperties(); } @Override public XBreakpoint createDefaultBreakpoint(@NotNull XBreakpointCreator creator) { final XBreakpoint breakpoint = creator.createBreakpoint(new MyBreakpointProperties("default")); breakpoint.setEnabled(true); return breakpoint; } } protected static class MyBreakpointProperties extends XBreakpointProperties { @Attribute("option") public String myOption; public MyBreakpointProperties() { } public MyBreakpointProperties(final String option) { myOption = option; } @Override public MyBreakpointProperties getState() { return this; } @Override public void loadState(@NotNull final MyBreakpointProperties state) { myOption = state.myOption; } } }