getBreakpointCategory() {
- return AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT;
- }
-}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java
index 1b370ca47ded..90974d82ccc3 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java
@@ -30,45 +30,62 @@ import com.intellij.debugger.engine.requests.RequestManagerImpl;
import com.intellij.debugger.jdi.StackFrameProxyImpl;
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
import com.intellij.debugger.requests.ClassPrepareRequestor;
+import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizerUtil;
import com.intellij.openapi.util.Key;
-import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiElement;
import com.intellij.ui.AppUIUtil;
+import com.intellij.ui.classFilter.ClassFilter;
import com.intellij.util.StringBuilderSpinAllocator;
-import com.sun.jdi.ObjectReference;
-import com.sun.jdi.ReferenceType;
-import com.sun.jdi.Value;
-import com.sun.jdi.VoidValue;
+import com.intellij.xdebugger.breakpoints.SuspendPolicy;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
+import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
+import com.sun.jdi.*;
import com.sun.jdi.event.LocatableEvent;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties;
import javax.swing.*;
import java.util.List;
-public abstract class Breakpoint extends FilteredRequestor implements ClassPrepareRequestor {
- public boolean ENABLED = true;
- public boolean LOG_ENABLED = false;
- public boolean LOG_EXPRESSION_ENABLED = false;
- public boolean REMOVE_AFTER_HIT = false;
- private TextWithImports myLogMessage; // an expression to be evaluated and printed
+public abstract class Breakpoint implements FilteredRequestor, ClassPrepareRequestor {
+ final XBreakpoint
myXBreakpoint;
+ protected final Project myProject;
+
+ //private boolean ENABLED = true;
+ //private boolean LOG_ENABLED = false;
+ //private boolean LOG_EXPRESSION_ENABLED = false;
+ //private boolean REMOVE_AFTER_HIT = false;
+ //private TextWithImports myLogMessage; // an expression to be evaluated and printed
@NonNls private static final String LOG_MESSAGE_OPTION_NAME = "LOG_MESSAGE";
public static final Breakpoint[] EMPTY_ARRAY = new Breakpoint[0];
protected boolean myCachedVerifiedState = false;
+ //private TextWithImportsImpl myLogMessage;
- protected Breakpoint(@NotNull Project project) {
- super(project);
- myLogMessage = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, "");
+ protected Breakpoint(@NotNull Project project, XBreakpoint
xBreakpoint) {
+ //super(project);
+ myProject = project;
+ myXBreakpoint = xBreakpoint;
+ //myLogMessage = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, "");
//noinspection AbstractMethodCallInConstructor
- final BreakpointDefaults defaults = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().getBreakpointDefaults(getCategory());
- SUSPEND_POLICY = defaults.getSuspendPolicy();
- CONDITION_ENABLED = defaults.isConditionEnabled();
+ //final BreakpointDefaults defaults = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().getBreakpointDefaults(getCategory());
+ //SUSPEND_POLICY = defaults.getSuspendPolicy();
+ //CONDITION_ENABLED = defaults.isConditionEnabled();
+ }
+
+ public Project getProject() {
+ return myProject;
+ }
+
+ protected P getProperties() {
+ return myXBreakpoint.getProperties();
}
public abstract PsiClass getPsiClass();
@@ -100,6 +117,16 @@ public abstract class Breakpoint extends FilteredRequestor implements ClassPrepa
myCachedVerifiedState = isVerified;
}
+ public boolean isRemoveAfterHit() {
+ return myXBreakpoint instanceof XLineBreakpoint && ((XLineBreakpoint)myXBreakpoint).isTemporary();
+ }
+
+ public void setRemoveAfterHit(boolean value) {
+ if (myXBreakpoint instanceof XLineBreakpoint) {
+ ((XLineBreakpoint)myXBreakpoint).setTemporary(value);
+ }
+ }
+
@Nullable
public String getShortClassName() {
final String className = getClassName();
@@ -210,19 +237,19 @@ public abstract class Breakpoint extends FilteredRequestor implements ClassPrepa
private void runAction(final EvaluationContextImpl context, LocatableEvent event) {
final DebugProcessImpl debugProcess = context.getDebugProcess();
- if (LOG_ENABLED || LOG_EXPRESSION_ENABLED) {
+ if (isLogEnabled() || isLogExpressionEnabled()) {
final StringBuilder buf = StringBuilderSpinAllocator.alloc();
try {
- if (LOG_ENABLED) {
+ if (myXBreakpoint.isLogMessage()) {
buf.append(getEventMessage(event));
buf.append("\n");
}
- final TextWithImports expressionToEvaluate = getLogMessage();
- if (LOG_EXPRESSION_ENABLED && expressionToEvaluate != null && !"".equals(expressionToEvaluate.getText())) {
+ if (isLogExpressionEnabled()) {
if(!debugProcess.isAttached()) {
return;
}
-
+
+ final TextWithImports expressionToEvaluate = getLogMessage();
try {
ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(getProject(), new EvaluatingComputable() {
@Override
@@ -252,11 +279,112 @@ public abstract class Breakpoint extends FilteredRequestor implements ClassPrepa
StringBuilderSpinAllocator.dispose(buf);
}
}
- if (REMOVE_AFTER_HIT) {
+ if (isRemoveAfterHit()) {
handleTemporaryBreakpointHit(debugProcess);
}
}
+ /**
+ * @return true if the ID was added or false otherwise
+ */
+ private boolean hasObjectID(long id) {
+ for (InstanceFilter instanceFilter : getInstanceFilters()) {
+ if (instanceFilter.getId() == id) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean evaluateCondition(final EvaluationContextImpl context, LocatableEvent event) throws EvaluateException {
+ if(isCountFilterEnabled()) {
+ final DebugProcessImpl debugProcess = context.getDebugProcess();
+ debugProcess.getVirtualMachineProxy().suspend();
+ debugProcess.getRequestsManager().deleteRequest(this);
+ ((Breakpoint)this).createRequest(debugProcess);
+ debugProcess.getVirtualMachineProxy().resume();
+ }
+ if (isInstanceFiltersEnabled()) {
+ Value value = context.getThisObject();
+ if (value != null) { // non-static
+ ObjectReference reference = (ObjectReference)value;
+ if(!hasObjectID(reference.uniqueID())) {
+ return false;
+ }
+ }
+ }
+
+ if (isClassFiltersEnabled()) {
+ String typeName = calculateEventClass(context, event);
+ if (!typeMatchesClassFilters(typeName)) return false;
+ }
+
+ if (isConditionEnabled() && !getCondition().getText().isEmpty()) {
+ try {
+ ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(context.getProject(), new EvaluatingComputable() {
+ public ExpressionEvaluator compute() throws EvaluateException {
+ final SourcePosition contextSourcePosition = ContextUtil.getSourcePosition(context);
+ // IMPORTANT: calculate context psi element basing on the location where the exception
+ // has been hit, not on the location where it was set. (For line breakpoints these locations are the same, however,
+ // for method, exception and field breakpoints these locations differ)
+ PsiElement contextPsiElement = ContextUtil.getContextElement(contextSourcePosition);
+ if (contextPsiElement == null) {
+ contextPsiElement = getEvaluationElement(); // as a last resort
+ }
+ return EvaluatorBuilderImpl.build(getCondition(), contextPsiElement, contextSourcePosition);
+ }
+ });
+ final Value value = evaluator.evaluate(context);
+ if (!(value instanceof BooleanValue)) {
+ throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.boolean.expected"));
+ }
+ if(!((BooleanValue)value).booleanValue()) {
+ return false;
+ }
+ }
+ catch (EvaluateException ex) {
+ if(ex.getCause() instanceof VMDisconnectedException) {
+ return false;
+ }
+ throw EvaluateExceptionUtil.createEvaluateException(
+ DebuggerBundle.message("error.failed.evaluating.breakpoint.condition", getCondition(), ex.getMessage())
+ );
+ }
+ return true;
+ }
+
+ return true;
+ }
+
+ protected String calculateEventClass(EvaluationContextImpl context, LocatableEvent event) throws EvaluateException {
+ return event.location().declaringType().name();
+ }
+
+ private boolean typeMatchesClassFilters(@Nullable String typeName) {
+ if (typeName == null) {
+ return true;
+ }
+ boolean matches = false, hasEnabled = false;
+ for (ClassFilter classFilter : getClassFilters()) {
+ if (classFilter.isEnabled()) {
+ hasEnabled = true;
+ if (classFilter.matches(typeName)) {
+ matches = true;
+ break;
+ }
+ }
+ }
+ if(hasEnabled && !matches) {
+ return false;
+ }
+ for (ClassFilter classFilter : getClassExclusionFilters()) {
+ if (classFilter.isEnabled() && classFilter.matches(typeName)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
private void handleTemporaryBreakpointHit(final DebugProcessImpl debugProcess) {
debugProcess.addDebugProcessListener(new DebugProcessAdapter() {
@Override
@@ -288,26 +416,208 @@ public abstract class Breakpoint extends FilteredRequestor implements ClassPrepa
RequestManagerImpl.deleteRequests(this);
}
- @Override
public void readExternal(Element parentNode) throws InvalidDataException {
- super.readExternal(parentNode);
- String logMessage = JDOMExternalizerUtil.readField(parentNode, LOG_MESSAGE_OPTION_NAME);
- if (logMessage != null) {
- setLogMessage(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, logMessage));
+ FilteredRequestorImpl requestor = new FilteredRequestorImpl(myProject);
+ requestor.readTo(parentNode, this);
+ try {
+ setEnabled(Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "ENABLED")));
+ } catch (Exception e) {
+ }
+ try {
+ setLogEnabled(Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "LOG_ENABLED")));
+ } catch (Exception e) {
+ }
+ try {
+ if (Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "LOG_EXPRESSION_ENABLED"))) {
+ String logMessage = JDOMExternalizerUtil.readField(parentNode, LOG_MESSAGE_OPTION_NAME);
+ if (logMessage != null) {
+ setLogMessage(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, logMessage));
+ }
+ }
+ } catch (Exception e) {
+ }
+ try {
+ setRemoveAfterHit(Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "REMOVE_AFTER_HIT")));
+ } catch (Exception e) {
}
}
+ //@Override
+ //public void writeExternal(Element parentNode) throws WriteExternalException {
+ //super.writeExternal(parentNode);
+ //JDOMExternalizerUtil.writeField(parentNode, LOG_MESSAGE_OPTION_NAME, getLogMessage().toExternalForm());
+ //}
+
+ //public void setLogMessage(TextWithImports logMessage) {
+ // myLogMessage = logMessage;
+ //}
+
+ public abstract PsiElement getEvaluationElement();
+
+ protected TextWithImports getLogMessage() {
+ return new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, myXBreakpoint.getLogExpression());
+ }
+
+ protected TextWithImports getCondition() {
+ return new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, myXBreakpoint.getCondition());
+ }
+
+ public boolean isEnabled() {
+ return myXBreakpoint.isEnabled();
+ }
+
+ public void setEnabled(boolean enabled) {
+ myXBreakpoint.setEnabled(enabled);
+ }
+
+ protected boolean isLogEnabled() {
+ return myXBreakpoint.isLogMessage();
+ }
+
+ public void setLogEnabled(boolean logEnabled) {
+ myXBreakpoint.setLogMessage(logEnabled);
+ }
+
+ protected boolean isLogExpressionEnabled() {
+ String expression = myXBreakpoint.getLogExpression();
+ if (expression == null || expression.isEmpty()) {
+ return false;
+ }
+ return !getLogMessage().isEmpty();
+ }
+
@Override
- public void writeExternal(Element parentNode) throws WriteExternalException {
- super.writeExternal(parentNode);
- JDOMExternalizerUtil.writeField(parentNode, LOG_MESSAGE_OPTION_NAME, getLogMessage().toExternalForm());
+ public boolean isCountFilterEnabled() {
+ if (getProperties() == null) {
+ return false;
+ }
+ return getProperties().COUNT_FILTER_ENABLED;
+ }
+ public void setCountFilterEnabled(boolean enabled) {
+ getProperties().COUNT_FILTER_ENABLED = enabled;
}
- public TextWithImports getLogMessage() {
- return myLogMessage;
+ @Override
+ public int getCountFilter() {
+ return getProperties().COUNT_FILTER;
}
- public void setLogMessage(TextWithImports logMessage) {
- myLogMessage = logMessage;
+ public void setCountFilter(int filter) {
+ getProperties().COUNT_FILTER = filter;
+ }
+
+ @Override
+ public boolean isClassFiltersEnabled() {
+ if (getProperties() == null) {
+ return false;
+ }
+ return getProperties().CLASS_FILTERS_ENABLED;
+ }
+
+ public void setClassFiltersEnabled(boolean enabled) {
+ getProperties().CLASS_FILTERS_ENABLED = enabled;
+ }
+
+ @Override
+ public ClassFilter[] getClassFilters() {
+ return getProperties().getClassFilters();
+ }
+
+ public void setClassFilters(ClassFilter[] filters) {
+ getProperties().setClassFilters(filters);
+ }
+
+ @Override
+ public ClassFilter[] getClassExclusionFilters() {
+ return getProperties().getClassExclusionFilters();
+ }
+
+ protected void setClassExclusionFilters(ClassFilter[] filters) {
+ getProperties().setClassExclusionFilters(filters);
+ }
+
+ @Override
+ public boolean isInstanceFiltersEnabled() {
+ if (getProperties() == null) {
+ return false;
+ }
+ return getProperties().INSTANCE_FILTERS_ENABLED;
+ }
+
+ public void setInstanceFiltersEnabled(boolean enabled) {
+ getProperties().INSTANCE_FILTERS_ENABLED = enabled;
+ }
+
+ @Override
+ public InstanceFilter[] getInstanceFilters() {
+ return getProperties().getInstanceFilters();
+ }
+
+ public void setInstanceFilters(InstanceFilter[] filters) {
+ getProperties().setInstanceFilters(filters);
+ }
+
+ private static String getSuspendPolicy(XBreakpoint breakpoint) {
+ switch (breakpoint.getSuspendPolicy()) {
+ case ALL:
+ return DebuggerSettings.SUSPEND_ALL;
+ case THREAD:
+ return DebuggerSettings.SUSPEND_THREAD;
+ case NONE:
+ return DebuggerSettings.SUSPEND_NONE;
+
+ default:
+ throw new IllegalArgumentException("unknown suspend policy");
+ }
+ }
+
+ static SuspendPolicy transformSuspendPolicy(String policy) {
+ if (DebuggerSettings.SUSPEND_ALL.equals(policy)) {
+ return SuspendPolicy.ALL;
+ } else if (DebuggerSettings.SUSPEND_THREAD.equals(policy)) {
+ return SuspendPolicy.THREAD;
+ } else if (DebuggerSettings.SUSPEND_NONE.equals(policy)) {
+ return SuspendPolicy.NONE;
+ } else {
+ throw new IllegalArgumentException("unknown suspend policy");
+ }
+ }
+
+ protected boolean isSuspend() {
+ return myXBreakpoint.getSuspendPolicy() != SuspendPolicy.NONE;
+ }
+
+ @Override
+ public String getSuspendPolicy() {
+ return getSuspendPolicy(myXBreakpoint);
+ }
+
+ public void setSuspendPolicy(String policy) {
+ myXBreakpoint.setSuspendPolicy(transformSuspendPolicy(policy));
+ }
+
+ protected void setLogMessage(TextWithImports logMessage) {
+ if (!logMessage.getText().isEmpty()) {
+ myXBreakpoint.setLogExpression(logMessage.getText());
+ }
+ else {
+ myXBreakpoint.setLogExpression(null);
+ }
+ }
+
+ protected boolean isConditionEnabled() {
+ String condition = myXBreakpoint.getCondition();
+ if (condition == null || condition.isEmpty()) {
+ return false;
+ }
+ return !getCondition().isEmpty();
+ }
+
+ public void setCondition(String condition) {
+ myXBreakpoint.setCondition(condition);
+ }
+
+ protected void addInstanceFilter(long l) {
+ getProperties().addInstanceFilter(l);
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointFactory.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointFactory.java
deleted file mode 100644
index 67c32935849e..000000000000
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointFactory.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.debugger.ui.breakpoints;
-
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.extensions.ExtensionPointName;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Key;
-import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
-import org.jdom.Element;
-import org.jetbrains.annotations.Nullable;
-
-import javax.swing.*;
-
-/**
- * Used to deexternalize breakpoints of certain category while reading saved configuration and for creating configuration UI
- */
-public abstract class BreakpointFactory {
- public static final ExtensionPointName EXTENSION_POINT_NAME =
- ExtensionPointName.create("com.intellij.debugger.breakpointFactory");
-
- public static BreakpointFactory[] getBreakpointFactories() {
- return ApplicationManager.getApplication().getExtensions(EXTENSION_POINT_NAME);
- }
-
- public abstract Breakpoint createBreakpoint(Project project, final Element element);
-
- public abstract Key extends Breakpoint> getBreakpointCategory();
-
- public abstract Icon getIcon();
-
- public abstract Icon getDisabledIcon();
-
- @Nullable
- public static BreakpointFactory getInstance(Key extends Breakpoint> category) {
- final BreakpointFactory[] allFactories = getBreakpointFactories();
- for (final BreakpointFactory factory : allFactories) {
- if (category.equals(factory.getBreakpointCategory())) {
- return factory;
- }
- }
- return null;
- }
-
- protected abstract String getHelpID();
-
- public abstract String getDisplayName();
-
- @Nullable
- public abstract BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact);
-
- @Nullable
- public Breakpoint addBreakpoint(Project project) {
- return null;
- }
-
- public boolean canAddBreakpoints() {
- return false;
- }
-
- public boolean breakpointCanBeRemoved(Breakpoint breakpoint) {
- return true;
- }
-
- public BreakpointItem createBreakpointItem(final Breakpoint breakpoint) {
- return new JavaBreakpointItem(this, breakpoint);
- }
-}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java
index 1bcbf3e9954b..aac9ffd510c3 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java
@@ -20,14 +20,11 @@
*/
package com.intellij.debugger.ui.breakpoints;
-import com.intellij.codeInsight.folding.impl.actions.ExpandRegionAction;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.DebuggerInvocationUtil;
import com.intellij.debugger.SourcePosition;
import com.intellij.debugger.engine.BreakpointStepMethodFilter;
import com.intellij.debugger.engine.DebugProcessImpl;
-import com.intellij.debugger.engine.evaluation.CodeFragmentKind;
-import com.intellij.debugger.engine.evaluation.TextWithImportsImpl;
import com.intellij.debugger.engine.requests.RequestManagerImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.impl.DebuggerContextListener;
@@ -35,41 +32,32 @@ import com.intellij.debugger.impl.DebuggerManagerImpl;
import com.intellij.debugger.impl.DebuggerSession;
import com.intellij.debugger.ui.JavaDebuggerSupport;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.editor.EditorFactory;
-import com.intellij.openapi.editor.event.*;
import com.intellij.openapi.editor.markup.GutterIconRenderer;
-import com.intellij.openapi.editor.markup.MarkupEditorFilterFactory;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.fileEditor.FileDocumentManager;
-import com.intellij.openapi.fileEditor.FileEditor;
-import com.intellij.openapi.fileEditor.FileEditorManager;
-import com.intellij.openapi.fileEditor.TextEditor;
-import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.util.*;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiField;
import com.intellij.psi.PsiFile;
import com.intellij.util.Alarm;
import com.intellij.util.EventDispatcher;
-import com.intellij.util.IJSwingUtilities;
-import com.intellij.util.SystemProperties;
-import com.intellij.util.containers.MultiMap;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.XDebuggerUtil;
-import com.intellij.xdebugger.breakpoints.XBreakpointType;
+import com.intellij.xdebugger.breakpoints.*;
import com.intellij.xdebugger.impl.DebuggerSupport;
import com.intellij.xdebugger.impl.XDebugSessionImpl;
-import com.sun.jdi.Field;
+import com.intellij.xdebugger.impl.breakpoints.BreakpointState;
+import com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl;
+import com.intellij.xdebugger.impl.breakpoints.XDependentBreakpointManager;
import com.sun.jdi.InternalException;
-import com.sun.jdi.ObjectReference;
import com.sun.jdi.ThreadReference;
import com.sun.jdi.request.*;
import gnu.trove.THashMap;
@@ -78,11 +66,9 @@ import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.java.debugger.breakpoints.JavaBreakpointAdapter;
-import org.jetbrains.java.debugger.breakpoints.JavaBreakpointType;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpointProperties;
import javax.swing.*;
-import java.awt.event.MouseEvent;
import java.util.*;
public class BreakpointManager {
@@ -94,15 +80,13 @@ public class BreakpointManager {
@NonNls private static final String DEFAULT_CONDITION_STATE_ATTRIBUTE_NAME = "default_condition_enabled";
@NonNls private static final String RULES_GROUP_NAME = "breakpoint_rules";
+ private static final String CONVERTED_PARAM = "converted";
private final Project myProject;
- private AnyExceptionBreakpoint myAnyExceptionBreakpoint;
- private final List myBreakpoints = new ArrayList(); // breakpoints storage, access should be synchronized
- private final List myBreakpointRules = new ArrayList(); // breakpoint rules
+ private final Map myBreakpoints = new HashMap(); // breakpoints storage, access should be synchronized
@Nullable private List myBreakpointsListForIteration = null; // another list for breakpoints iteration, unsynchronized access ok
- private final MultiMap myDocumentBreakpoints = MultiMap.createSmartList();
private final Map myUIProperties = new LinkedHashMap();
- private final Map, BreakpointDefaults> myBreakpointDefaults = new LinkedHashMap, BreakpointDefaults>();
+ //private final Map, BreakpointDefaults> myBreakpointDefaults = new LinkedHashMap, BreakpointDefaults>();
private final EventDispatcher myDispatcher = EventDispatcher.create(BreakpointManagerListener.class);
@@ -155,212 +139,35 @@ public class BreakpointManager {
}
}
});
-
- if (!project.isDefault()) {
- XDebuggerManager.getInstance(project).getBreakpointManager().addBreakpointListener(
- XBreakpointType.EXTENSION_POINT_NAME.findExtension(JavaBreakpointType.class), new JavaBreakpointAdapter(project), project);
- }
}
public void init() {
- EditorEventMulticaster eventMulticaster = EditorFactory.getInstance().getEventMulticaster();
- eventMulticaster.addEditorMouseListener(new EditorMouseAdapter() {
- @Nullable private EditorMouseEvent myMousePressedEvent;
-
- @Nullable
- private Breakpoint toggleBreakpoint(final boolean mostSuitingBreakpoint, final int line, boolean temporary) {
- final Editor editor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
- if (editor == null) {
- return null;
- }
- final Document document = editor.getDocument();
- final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(document);
- if (!JavaBreakpointType.doCanPutAt(psiFile)) {
- return null;
- }
-
- if (SystemProperties.getBooleanProperty("java.debugger.xBreakpoint", false) &&
- XBreakpointType.EXTENSION_POINT_NAME.findExtension(JavaBreakpointType.class)
- .canPutAt(psiFile.getVirtualFile(), line, myProject)) {
- return null;
- }
-
- PsiDocumentManager.getInstance(myProject).commitDocument(document);
-
- int offset = editor.getCaretModel().getOffset();
- int editorLine = editor.getDocument().getLineNumber(offset);
- if (editorLine != line) {
- if (line < 0 || line >= document.getLineCount()) {
- return null;
- }
- offset = editor.getDocument().getLineStartOffset(line);
- }
-
- ExpandRegionAction.expandRegionAtOffset(myProject, editor, offset);
-
- Breakpoint breakpoint = findBreakpoint(document, offset, null);
- if (breakpoint == null) {
- boolean isInsideCompiledClass = StdFileTypes.CLASS.equals(psiFile.getFileType());
- if (mostSuitingBreakpoint || isInsideCompiledClass) {
- breakpoint = addFieldBreakpoint(document, offset);
- if (breakpoint == null) {
- breakpoint = addMethodBreakpoint(document, line);
- }
- if (breakpoint == null && !isInsideCompiledClass) {
- breakpoint = addLineBreakpoint(document, line);
- }
- }
- else {
- breakpoint = addLineBreakpoint(document, line);
-
- if (breakpoint == null) {
- breakpoint = addMethodBreakpoint(document, line);
- }
- }
-
- if (breakpoint != null) {
- breakpoint.REMOVE_AFTER_HIT = temporary;
- RequestManagerImpl.createRequests(breakpoint);
- }
- return breakpoint;
- }
- else {
- removeBreakpoint(breakpoint);
- return null;
- }
- }
-
- private boolean isFromMyProject(Editor editor) {
- FileEditor[] allEditors = FileEditorManager.getInstance(myProject).getAllEditors();
- for (FileEditor ed : allEditors) {
- if (!(ed instanceof TextEditor)) {
- continue;
- }
- if (((TextEditor)ed).getEditor().equals(editor)) {
- return true;
- }
- }
- return false;
- }
-
- //mousePressed + mouseReleased is a hack to keep selection in editor when shift is pressed
+ XBreakpointManager manager = XDebuggerManager.getInstance(myProject).getBreakpointManager();
+ manager.addBreakpointListener(new XBreakpointListener() {
@Override
- public void mousePressed(@NotNull EditorMouseEvent e) {
- if (MarkupEditorFilterFactory.createIsDiffFilter().avaliableIn(e.getEditor())) return;
-
- if (e.isConsumed()) return;
-
- if (e.getArea() == EditorMouseEventArea.LINE_MARKERS_AREA && e.getMouseEvent().isShiftDown()) {
- myMousePressedEvent = e;
- e.consume();
+ public void breakpointAdded(@NotNull XBreakpoint xBreakpoint) {
+ if (isJavaType(xBreakpoint)) {
+ onBreakpointAdded(xBreakpoint);
}
}
@Override
- public void mouseReleased(@NotNull EditorMouseEvent e) {
- if (myMousePressedEvent != null) {
- mouseClicked(e);
- }
- myMousePressedEvent = null;
+ public void breakpointRemoved(@NotNull XBreakpoint xBreakpoint) {
+ onBreakpointRemoved(xBreakpoint);
}
@Override
- public void mouseClicked(@NotNull final EditorMouseEvent e) {
- if (MarkupEditorFilterFactory.createIsDiffFilter().avaliableIn(e.getEditor())) return;
-
- if (e.isConsumed()) return;
-
- if (e.getArea() == EditorMouseEventArea.LINE_MARKERS_AREA) {
- PsiDocumentManager.getInstance(myProject).commitAndRunReadAction(new Runnable() {
- @Override
- public void run() {
- final Editor editor = e.getEditor();
- if (!isFromMyProject(editor)) {
- return;
- }
- final int line = editor.xyToLogicalPosition(e.getMouseEvent().getPoint()).line;
- final Document document = editor.getDocument();
- if (line < 0 || line >= document.getLineCount()) {
- return;
- }
- MouseEvent event = e.getMouseEvent();
- if (event.isPopupTrigger()) {
- return;
- }
- if (event.getButton() != 1) {
- return;
- }
- if (e.getMouseEvent().isControlDown() || e.getMouseEvent().isMetaDown()) {
- return;
- }
-
- VirtualFile file = FileDocumentManager.getInstance().getFile(document);
- if (file != null && XDebuggerUtil.getInstance().canPutBreakpointAt(myProject, file, line)) {
- return;
- }
- e.consume();
-
- DebuggerInvocationUtil.invokeLater(myProject, new Runnable() {
- @Override
- public void run() {
- final boolean suitingBreakpoint = e.getMouseEvent().isAltDown() && !e.getMouseEvent().isShiftDown();
- final boolean temporary = e.getMouseEvent().isAltDown() && e.getMouseEvent().isShiftDown();
-
- final Breakpoint breakpoint = toggleBreakpoint(suitingBreakpoint, line, temporary);
-
-
- if (!e.getMouseEvent().isAltDown() && e.getMouseEvent().isShiftDown() && breakpoint != null) {
- breakpoint.LOG_EXPRESSION_ENABLED = true;
- String selection = editor.getSelectionModel().getSelectedText();
- String text = selection != null ? selection : DebuggerBundle.message("breakpoint.log.message",
- breakpoint.getDisplayName());
- breakpoint.setLogMessage(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, text));
- breakpoint.SUSPEND = false;
- editBreakpoint(breakpoint, editor);
-
-
- //DialogWrapper dialog = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager()
- // .createConfigurationDialog(breakpoint, BreakpointPropertiesPanel.CONTROL_LOG_MESSAGE);
- //dialog.show();
- //
- //if (!dialog.isOK()) {
- // removeBreakpoint(breakpoint);
- //}
- }
- }
- });
- }
- });
+ public void breakpointChanged(@NotNull XBreakpoint xBreakpoint) {
+ Breakpoint breakpoint = myBreakpoints.get(xBreakpoint);
+ if (breakpoint != null) {
+ fireBreakpointChanged(breakpoint);
}
}
- }, myProject);
+ });
+ }
- eventMulticaster.addDocumentListener(new DocumentAdapter() {
- private final Alarm myUpdateAlarm = new Alarm();
-
- @Override
- public void documentChanged(@NotNull final DocumentEvent e) {
- final Document document = e.getDocument();
- //noinspection SynchronizeOnThis
- synchronized (BreakpointManager.this) {
- Collection breakpoints = myDocumentBreakpoints.get(document);
- if (!breakpoints.isEmpty()) {
- myUpdateAlarm.cancelAllRequests();
- // must create new array in order to avoid "concurrent modification" errors
- final List breakpointsToUpdate = new ArrayList(breakpoints);
- myUpdateAlarm.addRequest(new Runnable() {
- @Override
- public void run() {
- if (!myProject.isDisposed()) {
- PsiDocumentManager.getInstance(myProject).commitDocument(document);
- update(breakpointsToUpdate);
- }
- }
- }, 300, ModalityState.NON_MODAL);
- }
- }
- }
- }, myProject);
+ private XBreakpointManager getXBreakpointManager() {
+ return XDebuggerManager.getInstance(myProject).getBreakpointManager();
}
public void editBreakpoint(final Breakpoint breakpoint, final Editor editor) {
@@ -380,17 +187,34 @@ public class BreakpointManager {
});
}
- @NotNull
- public BreakpointDefaults getBreakpointDefaults(Key extends Breakpoint> category) {
- BreakpointDefaults defaults = myBreakpointDefaults.get(category);
- if (defaults == null) {
- defaults = new BreakpointDefaults();
- }
- return defaults;
- }
+ //@NotNull
+ //public BreakpointDefaults getBreakpointDefaults(Key extends Breakpoint> category) {
+ // BreakpointDefaults defaults = myBreakpointDefaults.get(category);
+ // if (defaults == null) {
+ // defaults = new BreakpointDefaults();
+ // }
+ // return defaults;
+ //}
public void setBreakpointDefaults(Key extends Breakpoint> category, BreakpointDefaults defaults) {
- myBreakpointDefaults.put(category, defaults);
+ Class typeCls = null;
+ if (LineBreakpoint.CATEGORY.toString().equals(category.toString())) {
+ typeCls = JavaLineBreakpointType.class;
+ }
+ else if (MethodBreakpoint.CATEGORY.toString().equals(category.toString())) {
+ typeCls = JavaMethodBreakpointType.class;
+ }
+ else if (FieldBreakpoint.CATEGORY.toString().equals(category.toString())) {
+ typeCls = JavaFieldBreakpointType.class;
+ }
+ else if (ExceptionBreakpoint.CATEGORY.toString().equals(category.toString())) {
+ typeCls = JavaExceptionBreakpointType.class;
+ }
+ if (typeCls != null) {
+ XBreakpointType, ?> type = XDebuggerUtil.getInstance().findBreakpointType(typeCls);
+ ((XBreakpointManagerImpl)getXBreakpointManager()).getBreakpointDefaults(type).setSuspendPolicy(Breakpoint.transformSuspendPolicy(defaults.getSuspendPolicy()));
+ }
+ //myBreakpointDefaults.put(category, defaults);
}
@@ -410,8 +234,8 @@ public class BreakpointManager {
if (!LineBreakpoint.canAddLineBreakpoint(myProject, document, lineIndex)) {
return null;
}
-
- LineBreakpoint breakpoint = LineBreakpoint.create(myProject, document, lineIndex);
+ XLineBreakpoint xLineBreakpoint = addXLineBreakpoint(JavaLineBreakpointType.class, document, lineIndex);
+ LineBreakpoint breakpoint = LineBreakpoint.create(myProject, xLineBreakpoint);
if (breakpoint == null) {
return null;
}
@@ -420,15 +244,15 @@ public class BreakpointManager {
return breakpoint;
}
- @Nullable
- public FieldBreakpoint addFieldBreakpoint(Field field, ObjectReference object) {
- ApplicationManager.getApplication().assertIsDispatchThread();
- final FieldBreakpoint fieldBreakpoint = FieldBreakpoint.create(myProject, field, object);
- if (fieldBreakpoint != null) {
- addBreakpoint(fieldBreakpoint);
- }
- return fieldBreakpoint;
- }
+ //@Nullable
+ //public FieldBreakpoint addFieldBreakpoint(Field field, ObjectReference object) {
+ // ApplicationManager.getApplication().assertIsDispatchThread();
+ // final FieldBreakpoint fieldBreakpoint = FieldBreakpoint.create(myProject, field, object, null);
+ // if (fieldBreakpoint != null) {
+ // addBreakpoint(fieldBreakpoint);
+ // }
+ // return fieldBreakpoint;
+ //}
@Nullable
public FieldBreakpoint addFieldBreakpoint(@NotNull Document document, int offset) {
@@ -449,7 +273,8 @@ public class BreakpointManager {
@Nullable
public FieldBreakpoint addFieldBreakpoint(Document document, int lineIndex, String fieldName) {
ApplicationManager.getApplication().assertIsDispatchThread();
- FieldBreakpoint fieldBreakpoint = FieldBreakpoint.create(myProject, document, lineIndex, fieldName);
+ XLineBreakpoint xBreakpoint = addXLineBreakpoint(JavaFieldBreakpointType.class, document, lineIndex);
+ FieldBreakpoint fieldBreakpoint = FieldBreakpoint.create(myProject, fieldName, xBreakpoint);
if (fieldBreakpoint != null) {
addBreakpoint(fieldBreakpoint);
}
@@ -457,21 +282,30 @@ public class BreakpointManager {
}
@NotNull
- public ExceptionBreakpoint addExceptionBreakpoint(@NotNull String exceptionClassName, String packageName) {
+ public ExceptionBreakpoint addExceptionBreakpoint(@NotNull final String exceptionClassName, final String packageName) {
ApplicationManager.getApplication().assertIsDispatchThread();
- ExceptionBreakpoint breakpoint = new ExceptionBreakpoint(myProject, exceptionClassName, packageName);
- addBreakpoint(breakpoint);
- if (LOG.isDebugEnabled()) {
- LOG.debug("ExceptionBreakpoint Added");
- }
- return breakpoint;
+ final JavaExceptionBreakpointType type = (JavaExceptionBreakpointType)XDebuggerUtil.getInstance().findBreakpointType(JavaExceptionBreakpointType.class);
+ return ApplicationManager.getApplication().runWriteAction(new Computable() {
+ @Override
+ public ExceptionBreakpoint compute() {
+ XBreakpoint xBreakpoint = XDebuggerManager.getInstance(myProject).getBreakpointManager()
+ .addBreakpoint(type, new JavaExceptionBreakpointProperties(exceptionClassName, packageName));
+ ExceptionBreakpoint breakpoint = new ExceptionBreakpoint(myProject, exceptionClassName, packageName, xBreakpoint);
+ addBreakpoint(breakpoint);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("ExceptionBreakpoint Added");
+ }
+ return breakpoint;
+ }
+ });
}
@Nullable
public MethodBreakpoint addMethodBreakpoint(Document document, int lineIndex) {
ApplicationManager.getApplication().assertIsDispatchThread();
- MethodBreakpoint breakpoint = MethodBreakpoint.create(myProject, document, lineIndex);
+ XLineBreakpoint xBreakpoint = addXLineBreakpoint(JavaMethodBreakpointType.class, document, lineIndex);
+ MethodBreakpoint breakpoint = MethodBreakpoint.create(myProject, xBreakpoint);
if (breakpoint == null) {
return null;
}
@@ -482,10 +316,23 @@ public class BreakpointManager {
return breakpoint;
}
+ private > XLineBreakpoint addXLineBreakpoint(Class extends XBreakpointType> typeCls, Document document, final int lineIndex) {
+ final XBreakpointType type = XDebuggerUtil.getInstance().findBreakpointType(typeCls);
+ final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
+ return ApplicationManager.getApplication().runWriteAction(new Computable() {
+ @Override
+ public XLineBreakpoint compute() {
+ return XDebuggerManager.getInstance(myProject).getBreakpointManager()
+ .addLineBreakpoint((XLineBreakpointType)type, file.getUrl(), lineIndex,
+ ((XLineBreakpointType)type).createBreakpointProperties(file, lineIndex));
+ }
+ });
+ }
+
@Nullable
public WildcardMethodBreakpoint addMethodBreakpoint(String classPattern, String methodName) {
ApplicationManager.getApplication().assertIsDispatchThread();
- WildcardMethodBreakpoint breakpoint = WildcardMethodBreakpoint.create(myProject, classPattern, methodName);
+ WildcardMethodBreakpoint breakpoint = WildcardMethodBreakpoint.create(myProject, classPattern, methodName, null);
if (breakpoint == null) {
return null;
}
@@ -531,14 +378,6 @@ public class BreakpointManager {
*/
@Nullable
public T findBreakpoint(final Document document, final int offset, @Nullable final Key category) {
- for (BreakpointWithHighlighter breakpointWithHighlighter : myDocumentBreakpoints.get(document)) {
- if (breakpointWithHighlighter.isAt(document, offset) &&
- (category == null || category.equals(breakpointWithHighlighter.getCategory()))) {
- //noinspection unchecked
- return (T)breakpointWithHighlighter;
- }
- }
-
for (final Breakpoint breakpoint : getBreakpoints()) {
if (breakpoint instanceof BreakpointWithHighlighter && ((BreakpointWithHighlighter)breakpoint).isAt(document, offset)) {
if (category == null || category.equals(breakpoint.getCategory())) {
@@ -550,7 +389,17 @@ public class BreakpointManager {
return null;
}
+ public Breakpoint findBreakpoint(XBreakpoint xBreakpoint) {
+ return myBreakpoints.get(xBreakpoint);
+ }
+
+ private List myOriginalBreakpointsNodes = new ArrayList();
+
public void readExternal(@NotNull final Element parentNode) {
+ // save old breakpoints
+ for (Element element : parentNode.getChildren()) {
+ myOriginalBreakpointsNodes.add(element.clone());
+ }
if (myProject.isOpen()) {
doRead(parentNode);
}
@@ -577,6 +426,10 @@ public class BreakpointManager {
if (group.getName().equals(RULES_GROUP_NAME)) {
continue;
}
+ // skip already converted
+ if (group.getAttribute(CONVERTED_PARAM) != null) {
+ continue;
+ }
final String categoryName = group.getName();
final Key breakpointCategory = BreakpointCategory.lookup(categoryName);
final String defaultPolicy = group.getAttributeValue(DEFAULT_SUSPEND_POLICY_ATTRIBUTE_NAME);
@@ -586,16 +439,16 @@ public class BreakpointManager {
if (!AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT.equals(breakpointCategory)) {
// for compatibility with previous format
anyExceptionBreakpointGroup = group.getChild(AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT.toString());
- final BreakpointFactory factory = BreakpointFactory.getInstance(breakpointCategory);
- if (factory != null) {
- for (final Object o : group.getChildren("breakpoint")) {
- Element breakpointNode = (Element)o;
- Breakpoint breakpoint = factory.createBreakpoint(myProject, breakpointNode);
+ //final BreakpointFactory factory = BreakpointFactory.getInstance(breakpointCategory);
+ //if (factory != null) {
+ for (Element breakpointNode : group.getChildren("breakpoint")) {
+ //Breakpoint breakpoint = factory.createBreakpoint(myProject, breakpointNode);
+ Breakpoint breakpoint = createBreakpoint(categoryName, breakpointNode);
breakpoint.readExternal(breakpointNode);
addBreakpoint(breakpoint);
nameToBreakpointMap.put(breakpoint.getDisplayName(), breakpoint);
}
- }
+ //}
}
else {
anyExceptionBreakpointGroup = group;
@@ -604,10 +457,14 @@ public class BreakpointManager {
if (anyExceptionBreakpointGroup != null) {
final Element breakpointElement = group.getChild("breakpoint");
if (breakpointElement != null) {
- getAnyExceptionBreakpoint().readExternal(breakpointElement);
+ XBreakpointManager manager = XDebuggerManager.getInstance(myProject).getBreakpointManager();
+ JavaExceptionBreakpointType type = (JavaExceptionBreakpointType)XDebuggerUtil.getInstance().findBreakpointType(JavaExceptionBreakpointType.class);
+ XBreakpoint xBreakpoint = manager.getDefaultBreakpoint(type);
+ Breakpoint breakpoint = createJavaBreakpoint(xBreakpoint);
+ breakpoint.readExternal(breakpointElement);
+ addBreakpoint(breakpoint);
}
}
-
}
}
catch (InvalidDataException ignored) {
@@ -615,9 +472,12 @@ public class BreakpointManager {
final Element rulesGroup = parentNode.getChild(RULES_GROUP_NAME);
if (rulesGroup != null) {
- final List rules = rulesGroup.getChildren("rule");
- for (final Object rule1 : rules) {
- final Element rule = (Element)rule1;
+ final List rules = rulesGroup.getChildren("rule");
+ for (Element rule : rules) {
+ // skip already converted
+ if (rule.getAttribute(CONVERTED_PARAM) != null) {
+ continue;
+ }
final Element master = rule.getChild(MASTER_BREAKPOINT_TAGNAME);
if (master == null) {
continue;
@@ -634,7 +494,11 @@ public class BreakpointManager {
if (slaveBreakpoint == null) {
continue;
}
- addBreakpointRule(new EnableBreakpointRule(BreakpointManager.this, masterBreakpoint, slaveBreakpoint, "true".equalsIgnoreCase(rule.getAttributeValue("leaveEnabled"))));
+
+ boolean leaveEnabled = "true".equalsIgnoreCase(rule.getAttributeValue("leaveEnabled"));
+ XDependentBreakpointManager dependentBreakpointManager = ((XBreakpointManagerImpl)getXBreakpointManager()).getDependentBreakpointManager();
+ dependentBreakpointManager.setMasterBreakpoint(slaveBreakpoint.myXBreakpoint, masterBreakpoint.myXBreakpoint, leaveEnabled);
+ //addBreakpointRule(new EnableBreakpointRule(BreakpointManager.this, masterBreakpoint, slaveBreakpoint, leaveEnabled));
}
}
@@ -662,112 +526,182 @@ public class BreakpointManager {
}
}
+ private Breakpoint createBreakpoint(String category, Element breakpointNode) throws InvalidDataException {
+ if (category.equals(LineBreakpoint.CATEGORY.toString())) {
+ XLineBreakpoint xBreakpoint = createXLineBreakpoint(JavaLineBreakpointType.class, breakpointNode);
+ return LineBreakpoint.create(myProject, xBreakpoint);
+ }
+ else if (category.equals(MethodBreakpoint.CATEGORY.toString())) {
+ XLineBreakpoint xBreakpoint = createXLineBreakpoint(JavaMethodBreakpointType.class, breakpointNode);
+ return MethodBreakpoint.create(myProject, xBreakpoint);
+ }
+ else if (category.equals(FieldBreakpoint.CATEGORY.toString())) {
+ XLineBreakpoint xBreakpoint = createXLineBreakpoint(JavaFieldBreakpointType.class, breakpointNode);
+ return FieldBreakpoint.create(myProject, "", xBreakpoint);
+ }
+ else if (category.equals(ExceptionBreakpoint.CATEGORY.toString())) {
+ XBreakpoint xBreakpoint = createXBreakpoint(JavaExceptionBreakpointType.class, breakpointNode);
+ return new ExceptionBreakpoint(myProject, xBreakpoint);
+ }
+ throw new IllegalStateException("Unknown breakpoint category " + category);
+ }
+
+ private > XBreakpoint createXBreakpoint(Class extends XBreakpointType> typeCls,
+ Element breakpointNode) throws InvalidDataException {
+ final XBreakpointType type = XDebuggerUtil.getInstance().findBreakpointType(typeCls);
+ return ApplicationManager.getApplication().runWriteAction(new Computable() {
+ @Override
+ public XBreakpoint compute() {
+ return XDebuggerManager.getInstance(myProject).getBreakpointManager()
+ .addBreakpoint((XBreakpointType)type, type.createProperties());
+ }});
+ }
+
+ private > XLineBreakpoint createXLineBreakpoint(Class extends XBreakpointType> typeCls,
+ Element breakpointNode) throws InvalidDataException {
+ final String url = breakpointNode.getAttributeValue("url");
+ VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(url);
+ if (vFile == null) {
+ throw new InvalidDataException(DebuggerBundle.message("error.breakpoint.file.not.found", url));
+ }
+ final Document doc = FileDocumentManager.getInstance().getDocument(vFile);
+ if (doc == null) {
+ throw new InvalidDataException(DebuggerBundle.message("error.cannot.load.breakpoint.file", url));
+ }
+
+ final int line;
+ try {
+ //noinspection HardCodedStringLiteral
+ line = Integer.parseInt(breakpointNode.getAttributeValue("line"));
+ }
+ catch (Exception e) {
+ throw new InvalidDataException("Line number is invalid for breakpoint");
+ }
+ return addXLineBreakpoint(typeCls, doc, line);
+ }
+
//used in Fabrique
public synchronized void addBreakpoint(Breakpoint breakpoint) {
- myBreakpoints.add(breakpoint);
+ myBreakpoints.put(breakpoint.myXBreakpoint, breakpoint);
myBreakpointsListForIteration = null;
- if (breakpoint instanceof BreakpointWithHighlighter) {
- BreakpointWithHighlighter breakpointWithHighlighter = (BreakpointWithHighlighter)breakpoint;
- final Document document = breakpointWithHighlighter.getDocument();
- if (document != null) {
- myDocumentBreakpoints.putValue(document, breakpointWithHighlighter);
- }
- }
+ breakpoint.updateUI();
+ RequestManagerImpl.createRequests(breakpoint);
myDispatcher.getMulticaster().breakpointsChanged();
}
- public synchronized void removeBreakpoint(@Nullable final Breakpoint breakpoint) {
- ApplicationManager.getApplication().assertIsDispatchThread();
+ private synchronized void onBreakpointAdded(XBreakpoint xBreakpoint) {
+ Breakpoint breakpoint = createJavaBreakpoint(xBreakpoint);
+ addBreakpoint(breakpoint);
+ }
+
+ public void removeBreakpoint(@Nullable final Breakpoint breakpoint) {
if (breakpoint == null) {
return;
}
-
- if (myBreakpoints.remove(breakpoint)) {
- updateBreakpointRules(breakpoint);
- myBreakpointsListForIteration = null;
- if (breakpoint instanceof BreakpointWithHighlighter) {
- for (Document document : myDocumentBreakpoints.keySet()) {
- if (myDocumentBreakpoints.remove(document, (BreakpointWithHighlighter)breakpoint)) {
- break;
- }
- }
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ @Override
+ public void run() {
+ getXBreakpointManager().removeBreakpoint(breakpoint.myXBreakpoint);
}
+ });
+ }
+
+ private synchronized void onBreakpointRemoved(@Nullable final XBreakpoint xBreakpoint) {
+ ApplicationManager.getApplication().assertIsDispatchThread();
+ if (xBreakpoint == null) {
+ return;
+ }
+
+ Breakpoint breakpoint = myBreakpoints.remove(xBreakpoint);
+ if (breakpoint != null) {
+ //updateBreakpointRules(breakpoint);
+ myBreakpointsListForIteration = null;
//we delete breakpoints inside release, so gutter will not fire events to deleted breakpoints
breakpoint.delete();
+ RequestManagerImpl.deleteRequests(breakpoint);
myDispatcher.getMulticaster().breakpointsChanged();
}
}
public void writeExternal(@NotNull final Element parentNode) {
- ApplicationManager.getApplication().runReadAction(new Runnable() {
- @Override
- public void run() {
- removeInvalidBreakpoints();
- final Map, Element> categoryToElementMap = new THashMap, Element>();
- for (Key extends Breakpoint> category : myBreakpointDefaults.keySet()) {
- final Element group = getCategoryGroupElement(categoryToElementMap, category, parentNode);
- final BreakpointDefaults defaults = getBreakpointDefaults(category);
- group.setAttribute(DEFAULT_SUSPEND_POLICY_ATTRIBUTE_NAME, String.valueOf(defaults.getSuspendPolicy()));
- group.setAttribute(DEFAULT_CONDITION_STATE_ATTRIBUTE_NAME, String.valueOf(defaults.isConditionEnabled()));
- }
- // don't store invisible breakpoints
- for (Breakpoint breakpoint : getBreakpoints()) {
- if (breakpoint.isValid() &&
- (!(breakpoint instanceof BreakpointWithHighlighter) || ((BreakpointWithHighlighter)breakpoint).isVisible())) {
- writeBreakpoint(getCategoryGroupElement(categoryToElementMap, breakpoint.getCategory(), parentNode), breakpoint);
- }
- }
- final AnyExceptionBreakpoint anyExceptionBreakpoint = getAnyExceptionBreakpoint();
- final Element group = getCategoryGroupElement(categoryToElementMap, anyExceptionBreakpoint.getCategory(), parentNode);
- writeBreakpoint(group, anyExceptionBreakpoint);
-
- final Element rules = new Element(RULES_GROUP_NAME);
- parentNode.addContent(rules);
- for (EnableBreakpointRule myBreakpointRule : myBreakpointRules) {
- writeRule(myBreakpointRule, rules);
- }
+ // restore old breakpoints
+ for (Element group : myOriginalBreakpointsNodes) {
+ if (group.getAttribute(CONVERTED_PARAM) == null) {
+ group.setAttribute(CONVERTED_PARAM, "true");
}
- });
-
- final Element uiProperties = new Element("ui_properties");
- parentNode.addContent(uiProperties);
- for (final String name : myUIProperties.keySet()) {
- Element property = new Element("property");
- uiProperties.addContent(property);
- property.setAttribute("name", name);
- property.setAttribute("value", myUIProperties.get(name));
+ group.detach();
}
+
+ parentNode.addContent(myOriginalBreakpointsNodes);
+ //ApplicationManager.getApplication().runReadAction(new Runnable() {
+ // @Override
+ // public void run() {
+ // removeInvalidBreakpoints();
+ // final Map, Element> categoryToElementMap = new THashMap, Element>();
+ // for (Key extends Breakpoint> category : myBreakpointDefaults.keySet()) {
+ // final Element group = getCategoryGroupElement(categoryToElementMap, category, parentNode);
+ // final BreakpointDefaults defaults = getBreakpointDefaults(category);
+ // group.setAttribute(DEFAULT_SUSPEND_POLICY_ATTRIBUTE_NAME, String.valueOf(defaults.getSuspendPolicy()));
+ // group.setAttribute(DEFAULT_CONDITION_STATE_ATTRIBUTE_NAME, String.valueOf(defaults.isConditionEnabled()));
+ // }
+ // // don't store invisible breakpoints
+ // for (Breakpoint breakpoint : getBreakpoints()) {
+ // if (breakpoint.isValid() &&
+ // (!(breakpoint instanceof BreakpointWithHighlighter) || ((BreakpointWithHighlighter)breakpoint).isVisible())) {
+ // writeBreakpoint(getCategoryGroupElement(categoryToElementMap, breakpoint.getCategory(), parentNode), breakpoint);
+ // }
+ // }
+ // final AnyExceptionBreakpoint anyExceptionBreakpoint = getAnyExceptionBreakpoint();
+ // final Element group = getCategoryGroupElement(categoryToElementMap, anyExceptionBreakpoint.getCategory(), parentNode);
+ // writeBreakpoint(group, anyExceptionBreakpoint);
+ //
+ // final Element rules = new Element(RULES_GROUP_NAME);
+ // parentNode.addContent(rules);
+ // //for (EnableBreakpointRule myBreakpointRule : myBreakpointRules) {
+ // // writeRule(myBreakpointRule, rules);
+ // //}
+ // }
+ //});
+ //
+ //final Element uiProperties = new Element("ui_properties");
+ //parentNode.addContent(uiProperties);
+ //for (final String name : myUIProperties.keySet()) {
+ // Element property = new Element("property");
+ // uiProperties.addContent(property);
+ // property.setAttribute("name", name);
+ // property.setAttribute("value", myUIProperties.get(name));
+ //}
}
- @SuppressWarnings({"HardCodedStringLiteral"})
- private static void writeRule(@NotNull final EnableBreakpointRule enableBreakpointRule, @NotNull Element element) {
- Element rule = new Element("rule");
- if (enableBreakpointRule.isLeaveEnabled()) {
- rule.setAttribute("leaveEnabled", Boolean.toString(true));
- }
- element.addContent(rule);
- writeRuleBreakpoint(rule, MASTER_BREAKPOINT_TAGNAME, enableBreakpointRule.getMasterBreakpoint());
- writeRuleBreakpoint(rule, SLAVE_BREAKPOINT_TAGNAME, enableBreakpointRule.getSlaveBreakpoint());
- }
+ //@SuppressWarnings({"HardCodedStringLiteral"})
+ //private static void writeRule(@NotNull final EnableBreakpointRule enableBreakpointRule, @NotNull Element element) {
+ // Element rule = new Element("rule");
+ // if (enableBreakpointRule.isLeaveEnabled()) {
+ // rule.setAttribute("leaveEnabled", Boolean.toString(true));
+ // }
+ // element.addContent(rule);
+ // writeRuleBreakpoint(rule, MASTER_BREAKPOINT_TAGNAME, enableBreakpointRule.getMasterBreakpoint());
+ // writeRuleBreakpoint(rule, SLAVE_BREAKPOINT_TAGNAME, enableBreakpointRule.getSlaveBreakpoint());
+ //}
- @SuppressWarnings({"HardCodedStringLiteral"}) private static void writeRuleBreakpoint(@NotNull final Element element, final String tagName, @NotNull final Breakpoint breakpoint) {
- Element master = new Element(tagName);
- element.addContent(master);
- master.setAttribute("name", breakpoint.getDisplayName());
- }
+ //@SuppressWarnings({"HardCodedStringLiteral"}) private static void writeRuleBreakpoint(@NotNull final Element element, final String tagName, @NotNull final Breakpoint breakpoint) {
+ // Element master = new Element(tagName);
+ // element.addContent(master);
+ // master.setAttribute("name", breakpoint.getDisplayName());
+ //}
- @SuppressWarnings({"HardCodedStringLiteral"})
- private static void writeBreakpoint(@NotNull final Element group, @NotNull final Breakpoint breakpoint) {
- Element breakpointNode = new Element("breakpoint");
- group.addContent(breakpointNode);
- try {
- breakpoint.writeExternal(breakpointNode);
- }
- catch (WriteExternalException e) {
- LOG.error(e);
- }
- }
+ //@SuppressWarnings({"HardCodedStringLiteral"})
+ //private static void writeBreakpoint(@NotNull final Element group, @NotNull final Breakpoint breakpoint) {
+ // Element breakpointNode = new Element("breakpoint");
+ // group.addContent(breakpointNode);
+ // try {
+ // breakpoint.writeExternal(breakpointNode);
+ // }
+ // catch (WriteExternalException e) {
+ // LOG.error(e);
+ // }
+ //}
private static Element getCategoryGroupElement(@NotNull final Map, Element> categoryToElementMap, @NotNull final Key category, @NotNull final Element parentNode) {
Element group = categoryToElementMap.get(category);
@@ -814,18 +748,37 @@ public class BreakpointManager {
@NotNull
public synchronized List getBreakpoints() {
if (myBreakpointsListForIteration == null) {
- myBreakpointsListForIteration = new ArrayList(myBreakpoints.size() + 1);
- myBreakpointsListForIteration.addAll(myBreakpoints);
- myBreakpointsListForIteration.add(getAnyExceptionBreakpoint());
+ myBreakpointsListForIteration = new ArrayList(myBreakpoints.size());
+
+ XBreakpoint>[] xBreakpoints = ApplicationManager.getApplication().runReadAction(new Computable[]>() {
+ public XBreakpoint>[] compute() {
+ return getXBreakpointManager().getAllBreakpoints();
+ }
+ });
+ for (XBreakpoint> xBreakpoint : xBreakpoints) {
+ if (isJavaType(xBreakpoint)) {
+ Breakpoint breakpoint = myBreakpoints.get(xBreakpoint);
+ if (breakpoint == null) {
+ breakpoint = createJavaBreakpoint(xBreakpoint);
+ myBreakpoints.put(xBreakpoint, breakpoint);
+ }
+ }
+ }
+
+ myBreakpointsListForIteration.addAll(myBreakpoints.values());
}
return myBreakpointsListForIteration;
}
- public AnyExceptionBreakpoint getAnyExceptionBreakpoint() {
- if (myAnyExceptionBreakpoint == null) {
- myAnyExceptionBreakpoint = new AnyExceptionBreakpoint(myProject);
+ private boolean isJavaType(XBreakpoint xBreakpoint) {
+ return xBreakpoint.getType() instanceof JavaBreakpointType;
+ }
+
+ private Breakpoint createJavaBreakpoint(XBreakpoint xBreakpoint) {
+ if (xBreakpoint.getType() instanceof JavaBreakpointType) {
+ return ((JavaBreakpointType)xBreakpoint.getType()).createJavaBreakpoint(myProject, xBreakpoint);
}
- return myAnyExceptionBreakpoint;
+ throw new IllegalStateException("Unsupported breakpoint type:" + xBreakpoint.getType());
}
//interaction with RequestManagerImpl
@@ -963,6 +916,8 @@ public class BreakpointManager {
private boolean myAllowMulticasting = true;
private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
public void fireBreakpointChanged(Breakpoint breakpoint) {
+ breakpoint.reload();
+ breakpoint.updateUI();
RequestManagerImpl.updateRequests(breakpoint);
if (myAllowMulticasting) {
// can be invoked from non-AWT thread
@@ -988,84 +943,103 @@ public class BreakpointManager {
}
public void setBreakpointEnabled(@NotNull final Breakpoint breakpoint, final boolean enabled) {
- if (breakpoint.ENABLED != enabled) {
- breakpoint.ENABLED = enabled;
- fireBreakpointChanged(breakpoint);
- breakpoint.updateUI();
+ if (breakpoint.isEnabled() != enabled) {
+ breakpoint.setEnabled(enabled);
+ //fireBreakpointChanged(breakpoint);
+ //breakpoint.updateUI();
}
}
public void addBreakpointRule(@NotNull EnableBreakpointRule rule) {
- rule.init();
- myBreakpointRules.add(rule);
+ //rule.init();
+ //myBreakpointRules.add(rule);
}
public boolean removeBreakpointRule(@NotNull EnableBreakpointRule rule) {
- final boolean removed = myBreakpointRules.remove(rule);
- if (removed) {
- rule.dispose();
- }
- return removed;
+ //final boolean removed = myBreakpointRules.remove(rule);
+ //if (removed) {
+ // rule.dispose();
+ //}
+ //return removed;
+ return false;
}
public boolean removeBreakpointRule(@NotNull Breakpoint slaveBreakpoint) {
- for (final EnableBreakpointRule rule : myBreakpointRules) {
- if (slaveBreakpoint.equals(rule.getSlaveBreakpoint())) {
- removeBreakpointRule(rule);
- return true;
- }
- }
+ //for (final EnableBreakpointRule rule : myBreakpointRules) {
+ // if (slaveBreakpoint.equals(rule.getSlaveBreakpoint())) {
+ // removeBreakpointRule(rule);
+ // return true;
+ // }
+ //}
return false;
}
- private void updateBreakpointRules(@NotNull Breakpoint removedBreakpoint) {
- for (Iterator it = myBreakpointRules.iterator(); it.hasNext();) {
- final EnableBreakpointRule rule = it.next();
- if (removedBreakpoint.equals(rule.getMasterBreakpoint()) || removedBreakpoint.equals(rule.getSlaveBreakpoint())) {
- it.remove();
- }
- }
- }
+ //private void updateBreakpointRules(@NotNull Breakpoint removedBreakpoint) {
+ // for (Iterator it = myBreakpointRules.iterator(); it.hasNext();) {
+ // final EnableBreakpointRule rule = it.next();
+ // if (removedBreakpoint.equals(rule.getMasterBreakpoint()) || removedBreakpoint.equals(rule.getSlaveBreakpoint())) {
+ // it.remove();
+ // }
+ // }
+ //}
+ // copied from XDebugSessionImpl processDependencies
public void processBreakpointHit(@NotNull final Breakpoint breakpoint) {
- for (final EnableBreakpointRule rule : myBreakpointRules) {
- rule.processBreakpointHit(breakpoint);
+ XDependentBreakpointManager dependentBreakpointManager = ((XBreakpointManagerImpl)getXBreakpointManager()).getDependentBreakpointManager();
+ XBreakpoint xBreakpoint = breakpoint.myXBreakpoint;
+ if (!dependentBreakpointManager.isMasterOrSlave(xBreakpoint)) {
+ return;
+ }
+ List> breakpoints = dependentBreakpointManager.getSlaveBreakpoints(xBreakpoint);
+ for (final XBreakpoint> slaveBreakpoint : breakpoints) {
+ DebuggerInvocationUtil.invokeLater(myProject, new Runnable() {
+ @Override
+ public void run() {
+ slaveBreakpoint.setEnabled(true);
+ }
+ });
+ }
+
+ if (dependentBreakpointManager.getMasterBreakpoint(xBreakpoint) != null && !dependentBreakpointManager.isLeaveEnabled(xBreakpoint)) {
+ DebuggerInvocationUtil.invokeLater(myProject, new Runnable() {
+ @Override
+ public void run() {
+ breakpoint.setEnabled(false);
+ }
+ });
+ //myDebuggerManager.getBreakpointManager().getLineBreakpointManager().queueBreakpointUpdate(breakpoint);
}
}
public void setInitialBreakpointsState() {
- myAllowMulticasting = false;
- for (final EnableBreakpointRule myBreakpointRule : myBreakpointRules) {
- myBreakpointRule.init();
- }
- myAllowMulticasting = true;
- if (!myBreakpointRules.isEmpty()) {
- IJSwingUtilities.invoke(new Runnable() {
- @Override
- public void run() {
- myDispatcher.getMulticaster().breakpointsChanged();
- }
- });
- }
+ //myAllowMulticasting = false;
+ //for (final EnableBreakpointRule myBreakpointRule : myBreakpointRules) {
+ // myBreakpointRule.init();
+ //}
+ //myAllowMulticasting = true;
+ //if (!myBreakpointRules.isEmpty()) {
+ // IJSwingUtilities.invoke(new Runnable() {
+ // @Override
+ // public void run() {
+ // myDispatcher.getMulticaster().breakpointsChanged();
+ // }
+ // });
+ //}
}
@Nullable
public Breakpoint findMasterBreakpoint(@NotNull Breakpoint dependentBreakpoint) {
- for (final EnableBreakpointRule rule : myBreakpointRules) {
- if (dependentBreakpoint.equals(rule.getSlaveBreakpoint())) {
- return rule.getMasterBreakpoint();
- }
- }
- return null;
+ XDependentBreakpointManager dependentBreakpointManager = ((XBreakpointManagerImpl)getXBreakpointManager()).getDependentBreakpointManager();
+ return myBreakpoints.get(dependentBreakpointManager.getMasterBreakpoint(dependentBreakpoint.myXBreakpoint));
}
@Nullable
public EnableBreakpointRule findBreakpointRule(@NotNull Breakpoint dependentBreakpoint) {
- for (final EnableBreakpointRule rule : myBreakpointRules) {
- if (dependentBreakpoint.equals(rule.getSlaveBreakpoint())) {
- return rule;
- }
- }
+ //for (final EnableBreakpointRule rule : myBreakpointRules) {
+ // if (dependentBreakpoint.equals(rule.getSlaveBreakpoint())) {
+ // return rule;
+ // }
+ //}
return null;
}
@@ -1076,4 +1050,14 @@ public class BreakpointManager {
public String setProperty(String name, String value) {
return myUIProperties.put(name, value);
}
+
+ public static PsiFile getPsiFile(XBreakpoint xBreakpoint, Project project) {
+ try {
+ final Document document = FileDocumentManager.getInstance().getDocument(xBreakpoint.getSourcePosition().getFile());
+ return PsiDocumentManager.getInstance(project).getPsiFile(document);
+ } catch (Exception e) {
+ LOG.error(e);
+ }
+ return null;
+ }
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java
index d52044bbeb71..afeeb13aeb10 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java
@@ -59,6 +59,9 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+/*
+ * Not used any more, since move to xBreakpoints
+ */
public abstract class BreakpointPropertiesPanel {
private BreakpointChooser myMasterBreakpointChooser;
@@ -208,8 +211,8 @@ public abstract class BreakpointPropertiesPanel {
final ItemListener suspendPolicyChangeListener = new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
- final BreakpointDefaults defaults = getBreakpointManager(myProject).getBreakpointDefaults(breakpointCategory);
- myMakeDefaultButton.setEnabled(!defaults.getSuspendPolicy().equals(getSelectedSuspendPolicy()) || defaults.isConditionEnabled() != myConditionCheckbox.isSelected());
+ //final BreakpointDefaults defaults = getBreakpointManager(myProject).getBreakpointDefaults(breakpointCategory);
+ //myMakeDefaultButton.setEnabled(!defaults.getSuspendPolicy().equals(getSelectedSuspendPolicy()) || defaults.isConditionEnabled() != myConditionCheckbox.isSelected());
}
};
@@ -426,13 +429,13 @@ public abstract class BreakpointPropertiesPanel {
}
private void updateSuspendPolicyRbFont() {
- final String defPolicy = getBreakpointManager(myProject).getBreakpointDefaults(myBreakpointCategory).getSuspendPolicy();
+ //final String defPolicy = getBreakpointManager(myProject).getBreakpointDefaults(myBreakpointCategory).getSuspendPolicy();
final Font font = myRbSuspendAll.getFont().deriveFont(Font.PLAIN);
final Font boldFont = font.deriveFont(Font.BOLD);
- myRbSuspendAll.setFont(DebuggerSettings.SUSPEND_ALL.equals(defPolicy)? boldFont : font);
- myRbSuspendThread.setFont(DebuggerSettings.SUSPEND_THREAD.equals(defPolicy)? boldFont : font);
+ //myRbSuspendAll.setFont(DebuggerSettings.SUSPEND_ALL.equals(defPolicy)? boldFont : font);
+ //myRbSuspendThread.setFont(DebuggerSettings.SUSPEND_THREAD.equals(defPolicy)? boldFont : font);
}
protected ClassFilter createClassConditionFilter() {
@@ -459,125 +462,126 @@ public abstract class BreakpointPropertiesPanel {
* Init UI components with the values from Breakpoint
*/
public void initFrom(Breakpoint breakpoint, boolean moreOptionsVisible1) {
- myBreakpoint = breakpoint;
- boolean moreOptionsVisible = moreOptionsVisible1;
- boolean actionsPanelVisible = moreOptionsVisible1;
-
- initMasterBreakpointPanel();
-
- if (breakpoint.COUNT_FILTER > 0) {
- myPassCountField.setText(Integer.toString(breakpoint.COUNT_FILTER));
- moreOptionsVisible = true;
- }
- else {
- myPassCountField.setText("");
- }
-
- PsiElement context = breakpoint.getEvaluationElement();
- myPassCountCheckbox.setSelected(breakpoint.COUNT_FILTER_ENABLED);
-
- myConditionCheckbox.setSelected(breakpoint.CONDITION_ENABLED);
-
- myConditionCombo.setEnabled(breakpoint.CONDITION_ENABLED);
-
- myConditionCombo.setContext(context);
- myConditionCombo.setText(breakpoint.getCondition() != null ? breakpoint.getCondition() : emptyText());
-
- myCbSuspend.setSelected(breakpoint.SUSPEND);
- myRbSuspendThread.setEnabled(myCbSuspend.isSelected());
- myRbSuspendAll.setEnabled(myCbSuspend.isSelected());
-
- if(!breakpoint.SUSPEND) {
- actionsPanelVisible = true;
- }
- if(DebuggerSettings.SUSPEND_THREAD.equals(breakpoint.SUSPEND_POLICY)){
- myRbSuspendThread.setSelected(true);
- }
- else {
- myRbSuspendAll.setSelected(true);
- }
-
- myCbSuspend.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- if (!myActionsPanel.isVisible()) {
- if (!myCbSuspend.isSelected()) {
- if (myDelegate != null) {
- myDelegate.showActionsPanel();
- }
- }
- }
- myRbSuspendThread.setEnabled(myCbSuspend.isSelected());
- myRbSuspendAll.setEnabled(myCbSuspend.isSelected());
- }
- });
- myLogMessageCheckBox.setSelected(breakpoint.LOG_ENABLED);
- myTemporaryCheckBox.setSelected(breakpoint.REMOVE_AFTER_HIT);
- myEnabledCheckbox.setSelected(breakpoint.ENABLED);
- myEnabledCheckbox.setText(breakpoint.getShortName() + " enabled");
-
- DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().addBreakpointManagerListener(new BreakpointManagerListener() {
- @Override
- public void breakpointsChanged() {
- myEnabledCheckbox.setSelected(myBreakpoint.ENABLED);
- }
- });
-
- myEnabledCheckbox.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- if (myBreakpoint.ENABLED != myEnabledCheckbox.isSelected()) {
- myBreakpoint.ENABLED = myEnabledCheckbox.isSelected();
- getBreakpointManager(myProject).fireBreakpointChanged(myBreakpoint);
- myBreakpoint.updateUI();
- }
- }
- });
- myTemporaryCheckBox.setVisible(breakpoint instanceof LineBreakpoint);
- myLogExpressionCheckBox.setSelected(breakpoint.LOG_EXPRESSION_ENABLED);
- if (breakpoint.LOG_ENABLED || breakpoint.LOG_EXPRESSION_ENABLED || (breakpoint instanceof LineBreakpoint && breakpoint.REMOVE_AFTER_HIT)) {
- actionsPanelVisible = true;
- }
-
- myLogExpressionCombo.setContext(context);
-
- if (breakpoint.getLogMessage() != null) {
- myLogExpressionCombo.setText(breakpoint.getLogMessage());
- }
- else {
- myLogExpressionCombo.setText(emptyText());
- }
-
- myLogExpressionCombo.setEnabled(breakpoint.LOG_EXPRESSION_ENABLED);
- if (breakpoint.LOG_EXPRESSION_ENABLED) {
- actionsPanelVisible = true;
- }
-
- myInstanceFiltersCheckBox.setSelected(breakpoint.INSTANCE_FILTERS_ENABLED);
- myInstanceFiltersField.setEnabled(breakpoint.INSTANCE_FILTERS_ENABLED);
- myInstanceFiltersField.getTextField().setEditable(breakpoint.INSTANCE_FILTERS_ENABLED);
- myInstanceFilters = breakpoint.getInstanceFilters();
- updateInstanceFilterEditor(true);
- if (breakpoint.INSTANCE_FILTERS_ENABLED) {
- moreOptionsVisible = true;
- }
-
- myClassFiltersCheckBox.setSelected(breakpoint.CLASS_FILTERS_ENABLED);
- myClassFiltersField.setEnabled(breakpoint.CLASS_FILTERS_ENABLED);
- myClassFiltersField.getTextField().setEditable(breakpoint.CLASS_FILTERS_ENABLED);
- myClassFilters = breakpoint.getClassFilters();
- myClassExclusionFilters = breakpoint.getClassExclusionFilters();
- updateClassFilterEditor(true);
- if (breakpoint.CLASS_FILTERS_ENABLED) {
- moreOptionsVisible = true;
- }
-
- myBreakpointPsiClass = breakpoint.getPsiClass();
-
- updateCheckboxes();
-
- setActionsPanelVisible(actionsPanelVisible && !moreOptionsVisible1);
- setMoreOptionsVisible(moreOptionsVisible);
+ //myBreakpoint = breakpoint;
+ //boolean moreOptionsVisible = moreOptionsVisible1;
+ //boolean actionsPanelVisible = moreOptionsVisible1;
+ //
+ //initMasterBreakpointPanel();
+ //
+ //if (breakpoint.getCountFilter() > 0) {
+ // myPassCountField.setText(Integer.toString(breakpoint.getCountFilter()));
+ // moreOptionsVisible = true;
+ //}
+ //else {
+ // myPassCountField.setText("");
+ //}
+ //
+ //PsiElement context = breakpoint.getEvaluationElement();
+ //myPassCountCheckbox.setSelected(breakpoint.isCountFilterEnabled());
+ //
+ //myConditionCheckbox.setSelected(breakpoint.isConditionEnabled());
+ //
+ //myConditionCombo.setEnabled(breakpoint.isConditionEnabled());
+ //
+ //myConditionCombo.setContext(context);
+ //myConditionCombo.setText(breakpoint.getCondition() != null ? breakpoint.getCondition() : emptyText());
+ //
+ //myCbSuspend.setSelected(breakpoint.isSuspend());
+ //myRbSuspendThread.setEnabled(myCbSuspend.isSelected());
+ //myRbSuspendAll.setEnabled(myCbSuspend.isSelected());
+ //
+ //if(!breakpoint.isSuspend()) {
+ // actionsPanelVisible = true;
+ //}
+ //if(DebuggerSettings.SUSPEND_THREAD.equals(breakpoint.getSuspendPolicy())){
+ // myRbSuspendThread.setSelected(true);
+ //}
+ //else {
+ // myRbSuspendAll.setSelected(true);
+ //}
+ //
+ //myCbSuspend.addActionListener(new ActionListener() {
+ // @Override
+ // public void actionPerformed(ActionEvent event) {
+ // if (!myActionsPanel.isVisible()) {
+ // if (!myCbSuspend.isSelected()) {
+ // if (myDelegate != null) {
+ // myDelegate.showActionsPanel();
+ // }
+ // }
+ // }
+ // myRbSuspendThread.setEnabled(myCbSuspend.isSelected());
+ // myRbSuspendAll.setEnabled(myCbSuspend.isSelected());
+ // }
+ //});
+ //myLogMessageCheckBox.setSelected(breakpoint.isLogEnabled());
+ //myTemporaryCheckBox.setSelected(breakpoint.isRemoveAfterHit());
+ //myEnabledCheckbox.setSelected(breakpoint.isEnabled());
+ //myEnabledCheckbox.setText(breakpoint.getShortName() + " enabled");
+ //
+ //DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().addBreakpointManagerListener(new BreakpointManagerListener() {
+ // @Override
+ // public void breakpointsChanged() {
+ // myEnabledCheckbox.setSelected(myBreakpoint.isEnabled());
+ // }
+ //});
+ //
+ //myEnabledCheckbox.addActionListener(new ActionListener() {
+ // @Override
+ // public void actionPerformed(ActionEvent event) {
+ // if (myBreakpoint.isEnabled() != myEnabledCheckbox.isSelected()) {
+ // myBreakpoint.setEnabled(myEnabledCheckbox.isSelected());
+ // getBreakpointManager(myProject).fireBreakpointChanged(myBreakpoint);
+ // myBreakpoint.updateUI();
+ // }
+ // }
+ //});
+ //myTemporaryCheckBox.setVisible(breakpoint instanceof LineBreakpoint);
+ //myLogExpressionCheckBox.setSelected(breakpoint.isLogExpressionEnabled());
+ //if (breakpoint.isLogEnabled() ||
+ // breakpoint.isLogExpressionEnabled() || (breakpoint instanceof LineBreakpoint && breakpoint.isRemoveAfterHit())) {
+ // actionsPanelVisible = true;
+ //}
+ //
+ //myLogExpressionCombo.setContext(context);
+ //
+ //if (breakpoint.getLogMessage() != null) {
+ // myLogExpressionCombo.setText(breakpoint.getLogMessage());
+ //}
+ //else {
+ // myLogExpressionCombo.setText(emptyText());
+ //}
+ //
+ //myLogExpressionCombo.setEnabled(breakpoint.isLogExpressionEnabled());
+ //if (breakpoint.isLogExpressionEnabled()) {
+ // actionsPanelVisible = true;
+ //}
+ //
+ //myInstanceFiltersCheckBox.setSelected(breakpoint.isInstanceFiltersEnabled());
+ //myInstanceFiltersField.setEnabled(breakpoint.isInstanceFiltersEnabled());
+ //myInstanceFiltersField.getTextField().setEditable(breakpoint.isInstanceFiltersEnabled());
+ //myInstanceFilters = breakpoint.getInstanceFilters();
+ //updateInstanceFilterEditor(true);
+ //if (breakpoint.isInstanceFiltersEnabled()) {
+ // moreOptionsVisible = true;
+ //}
+ //
+ //myClassFiltersCheckBox.setSelected(breakpoint.isClassFiltersEnabled());
+ //myClassFiltersField.setEnabled(breakpoint.isClassFiltersEnabled());
+ //myClassFiltersField.getTextField().setEditable(breakpoint.isClassFiltersEnabled());
+ //myClassFilters = breakpoint.getClassFilters();
+ //myClassExclusionFilters = breakpoint.getClassExclusionFilters();
+ //updateClassFilterEditor(true);
+ //if (breakpoint.isClassFiltersEnabled()) {
+ // moreOptionsVisible = true;
+ //}
+ //
+ //myBreakpointPsiClass = breakpoint.getPsiClass();
+ //
+ //updateCheckboxes();
+ //
+ //setActionsPanelVisible(actionsPanelVisible && !moreOptionsVisible1);
+ //setMoreOptionsVisible(moreOptionsVisible);
}
private void initMasterBreakpointPanel() {
@@ -632,41 +636,41 @@ public abstract class BreakpointPropertiesPanel {
*/
public void saveTo(Breakpoint breakpoint) {
- saveMasterBreakpoint();
- try {
- String text = myPassCountField.getText().trim();
- breakpoint.COUNT_FILTER = !text.isEmpty() ? Integer.parseInt(text) : 0;
- if (breakpoint.COUNT_FILTER < 0) {
- breakpoint.COUNT_FILTER = 0;
- }
- }
- catch (Exception ignored) {
- }
-
- breakpoint.COUNT_FILTER_ENABLED = breakpoint.COUNT_FILTER > 0 && myPassCountCheckbox.isSelected();
- breakpoint.setCondition(myConditionCombo.getText());
- breakpoint.CONDITION_ENABLED = myConditionCheckbox.isSelected();
- breakpoint.setLogMessage(myLogExpressionCombo.getText());
- breakpoint.LOG_EXPRESSION_ENABLED = !breakpoint.getLogMessage().isEmpty() && myLogExpressionCheckBox.isSelected();
- breakpoint.LOG_ENABLED = myLogMessageCheckBox.isSelected();
- breakpoint.ENABLED = myEnabledCheckbox.isSelected();
- breakpoint.REMOVE_AFTER_HIT = myTemporaryCheckBox.isSelected();
- breakpoint.SUSPEND = myCbSuspend.isSelected();
- breakpoint.SUSPEND_POLICY = getSelectedSuspendPolicy();
- reloadInstanceFilters();
- reloadClassFilters();
- updateInstanceFilterEditor(true);
- updateClassFilterEditor(true);
-
- breakpoint.INSTANCE_FILTERS_ENABLED = myInstanceFiltersField.getText().length() > 0 && myInstanceFiltersCheckBox.isSelected();
- breakpoint.CLASS_FILTERS_ENABLED = myClassFiltersField.getText().length() > 0 && myClassFiltersCheckBox.isSelected();
- breakpoint.setClassFilters(myClassFilters);
- breakpoint.setClassExclusionFilters(myClassExclusionFilters);
- breakpoint.setInstanceFilters(myInstanceFilters);
-
- myConditionCombo.addRecent(myConditionCombo.getText());
- myLogExpressionCombo.addRecent(myLogExpressionCombo.getText());
- breakpoint.updateUI();
+ //saveMasterBreakpoint();
+ //try {
+ // String text = myPassCountField.getText().trim();
+ // breakpoint.setCountFilter(!text.isEmpty() ? Integer.parseInt(text) : 0);
+ // if (breakpoint.getCountFilter() < 0) {
+ // breakpoint.setCountFilter(0);
+ // }
+ //}
+ //catch (Exception ignored) {
+ //}
+ //
+ //breakpoint.setCountFilterEnabled(breakpoint.getCountFilter() > 0 && myPassCountCheckbox.isSelected());
+ //breakpoint.setCondition(myConditionCombo.getText().getText());
+ ////breakpoint.setConditionEnabled(myConditionCheckbox.isSelected());
+ //breakpoint.setLogMessage(myLogExpressionCombo.getText());
+ //breakpoint.setLogExpressionEnabled(!breakpoint.getLogMessage().isEmpty() && myLogExpressionCheckBox.isSelected());
+ //breakpoint.setLogEnabled(myLogMessageCheckBox.isSelected());
+ //breakpoint.setEnabled(myEnabledCheckbox.isSelected());
+ //breakpoint.setRemoveAfterHit(myTemporaryCheckBox.isSelected());
+ ////breakpoint.setSuspend(myCbSuspend.isSelected());
+ //breakpoint.setSuspendPolicy(getSelectedSuspendPolicy());
+ //reloadInstanceFilters();
+ //reloadClassFilters();
+ //updateInstanceFilterEditor(true);
+ //updateClassFilterEditor(true);
+ //
+ //breakpoint.setInstanceFiltersEnabled(myInstanceFiltersField.getText().length() > 0 && myInstanceFiltersCheckBox.isSelected());
+ //breakpoint.setClassFiltersEnabled(myClassFiltersField.getText().length() > 0 && myClassFiltersCheckBox.isSelected());
+ //breakpoint.setClassFilters(myClassFilters);
+ //breakpoint.setClassExclusionFilters(myClassExclusionFilters);
+ //breakpoint.setInstanceFilters(myInstanceFilters);
+ //
+ //myConditionCombo.addRecent(myConditionCombo.getText());
+ //myLogExpressionCombo.addRecent(myLogExpressionCombo.getText());
+ //breakpoint.updateUI();
}
private static String concatWithEx(List s, String concator, int N, String NthConcator) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java
index 16b75279099e..a1c2df838e65 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java
@@ -25,49 +25,48 @@ import com.intellij.debugger.engine.events.DebuggerCommandImpl;
import com.intellij.debugger.engine.requests.RequestManagerImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.settings.DebuggerSettings;
-import com.intellij.debugger.ui.JavaDebuggerSupport;
-import com.intellij.openapi.actionSystem.ActionGroup;
-import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.ex.MarkupModelEx;
import com.intellij.openapi.editor.impl.DocumentMarkupModel;
-import com.intellij.openapi.editor.markup.*;
-import com.intellij.openapi.fileEditor.FileDocumentManager;
+import com.intellij.openapi.editor.markup.MarkupEditorFilterFactory;
+import com.intellij.openapi.editor.markup.RangeHighlighter;
+import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.*;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.VirtualFileManager;
+import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.InvalidDataException;
+import com.intellij.openapi.util.Key;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiDocumentManager;
+import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiManager;
import com.intellij.psi.jsp.JspFile;
-import com.intellij.ui.AppUIUtil;
import com.intellij.ui.classFilter.ClassFilter;
import com.intellij.util.StringBuilderSpinAllocator;
-import com.intellij.xdebugger.impl.DebuggerSupport;
-import com.intellij.xdebugger.impl.actions.EditBreakpointAction;
+import com.intellij.xdebugger.XDebuggerManager;
+import com.intellij.xdebugger.XDebuggerUtil;
+import com.intellij.xdebugger.XSourcePosition;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
+import com.intellij.xdebugger.breakpoints.XBreakpointManager;
+import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.intellij.xdebugger.ui.DebuggerColors;
import com.intellij.xml.util.XmlStringUtil;
import com.sun.jdi.ReferenceType;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties;
import javax.swing.*;
-import java.awt.*;
-import java.awt.dnd.DragSource;
/**
* User: lex
* Date: Sep 2, 2003
* Time: 3:22:55 PM
*/
-public abstract class BreakpointWithHighlighter extends Breakpoint {
+public abstract class BreakpointWithHighlighter extends Breakpoint
{
@Nullable
private RangeHighlighter myHighlighter;
@@ -150,7 +149,7 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
private Icon calcIcon(@Nullable DebugProcessImpl debugProcess) {
final boolean muted = debugProcess != null && isMuted(debugProcess);
- if (!ENABLED) {
+ if (!isEnabled()) {
return getDisabledIcon(muted);
}
@@ -184,13 +183,14 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
return getSetIcon(muted);
}
- protected BreakpointWithHighlighter(@NotNull Project project) {
+ protected BreakpointWithHighlighter(@NotNull Project project, XBreakpoint xBreakpoint) {
//for persistency
- super(project);
+ super(project, xBreakpoint);
+ reload();
}
- public BreakpointWithHighlighter(@NotNull final Project project, @NotNull final RangeHighlighter highlighter) {
- super(project);
+ public BreakpointWithHighlighter(@NotNull final Project project, @NotNull final RangeHighlighter highlighter, XBreakpoint breakpoint) {
+ super(project, breakpoint);
myHighlighter = highlighter;
setEditorFilter(highlighter);
reload();
@@ -208,10 +208,10 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
@Override
public boolean isValid() {
- return isPositionValid(getSourcePosition());
+ return isPositionValid(myXBreakpoint.getSourcePosition());
}
- private static boolean isPositionValid(@Nullable final SourcePosition sourcePosition) {
+ protected static boolean isPositionValid(@Nullable final XSourcePosition sourcePosition) {
return ApplicationManager.getApplication().runReadAction(new Computable() {
@Override
public Boolean compute() {
@@ -238,34 +238,34 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
}
buf.append("
");
buf.append(DebuggerBundle.message("breakpoint.property.name.suspend.policy")).append(" : ");
- if (DebuggerSettings.SUSPEND_NONE.equals(SUSPEND_POLICY) || !SUSPEND) {
+ if (DebuggerSettings.SUSPEND_NONE.equals(getSuspendPolicy()) || !isSuspend()) {
buf.append(DebuggerBundle.message("breakpoint.properties.panel.option.suspend.none"));
}
- else if (DebuggerSettings.SUSPEND_ALL.equals(SUSPEND_POLICY)) {
+ else if (DebuggerSettings.SUSPEND_ALL.equals(getSuspendPolicy())) {
buf.append(DebuggerBundle.message("breakpoint.properties.panel.option.suspend.all"));
}
- else if (DebuggerSettings.SUSPEND_THREAD.equals(SUSPEND_POLICY)) {
+ else if (DebuggerSettings.SUSPEND_THREAD.equals(getSuspendPolicy())) {
buf.append(DebuggerBundle.message("breakpoint.properties.panel.option.suspend.thread"));
}
buf.append("
");
buf.append(DebuggerBundle.message("breakpoint.property.name.log.message")).append(": ");
- buf.append(LOG_ENABLED ? CommonBundle.getYesButtonText() : CommonBundle.getNoButtonText());
- if (LOG_EXPRESSION_ENABLED) {
+ buf.append(isLogEnabled() ? CommonBundle.getYesButtonText() : CommonBundle.getNoButtonText());
+ if (isLogExpressionEnabled()) {
buf.append("
");
buf.append(DebuggerBundle.message("breakpoint.property.name.log.expression")).append(": ");
buf.append(XmlStringUtil.escapeString(getLogMessage().getText()));
}
- if (CONDITION_ENABLED && getCondition() != null && getCondition().getText() != null && !getCondition().getText().isEmpty()) {
+ if (isConditionEnabled() && getCondition() != null && getCondition().getText() != null && !getCondition().getText().isEmpty()) {
buf.append("
");
buf.append(DebuggerBundle.message("breakpoint.property.name.condition")).append(": ");
buf.append(XmlStringUtil.escapeString(getCondition().getText()));
}
- if (COUNT_FILTER_ENABLED) {
+ if (isCountFilterEnabled()) {
buf.append("
");
buf.append(DebuggerBundle.message("breakpoint.property.name.pass.count")).append(": ");
- buf.append(COUNT_FILTER);
+ buf.append(getCountFilter());
}
- if (CLASS_FILTERS_ENABLED) {
+ if (isClassFiltersEnabled()) {
buf.append("
");
buf.append(DebuggerBundle.message("breakpoint.property.name.class.filters")).append(": ");
ClassFilter[] classFilters = getClassFilters();
@@ -273,7 +273,7 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
buf.append(classFilter.getPattern()).append(" ");
}
}
- if (INSTANCE_FILTERS_ENABLED) {
+ if (isInstanceFiltersEnabled()) {
buf.append("
");
buf.append(DebuggerBundle.message("breakpoint.property.name.instance.filters"));
InstanceFilter[] instanceFilters = getInstanceFilters();
@@ -290,25 +290,23 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
}
@Override
- public final void reload() {
+ public void reload() {
ApplicationManager.getApplication().assertReadAccessAllowed();
- RangeHighlighter highlighter = myHighlighter;
- if (highlighter != null && highlighter.isValid()) {
- PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(highlighter.getDocument());
- if (psiFile != null) {
- mySourcePosition = SourcePosition.createFromOffset(psiFile, highlighter.getStartOffset());
- reload(psiFile);
- return;
- }
+ final XSourcePosition position = myXBreakpoint.getSourcePosition();
+ try {
+ PsiElement element = XDebuggerUtil.getInstance().findContextElement(position.getFile(), position.getOffset(), myProject, false);
+ mySourcePosition = SourcePosition.createFromOffset(element.getContainingFile(), position.getOffset());
+ } catch (Exception e) {
+ mySourcePosition = null;
}
- mySourcePosition = null;
+ reload(BreakpointManager.getPsiFile(myXBreakpoint, myProject));
}
@Override
public void createRequest(@NotNull DebugProcessImpl debugProcess) {
DebuggerManagerThreadImpl.assertIsManagerThread();
// check is this breakpoint is enabled, vm reference is valid and there're no requests created yet
- if (!ENABLED ||
+ if (!isEnabled() ||
!debugProcess.isAttached() ||
isMuted(debugProcess) ||
!debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
@@ -329,7 +327,7 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
@Override
public void processClassPrepare(final DebugProcess debugProcess, final ReferenceType classType) {
- if (!ENABLED || !isValid()) {
+ if (!isEnabled() || !isValid()) {
return;
}
createRequestForPreparedClass((DebugProcessImpl)debugProcess, classType);
@@ -383,20 +381,24 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
private void updateGutter() {
if (myVisible) {
- RangeHighlighter highlighter = myHighlighter;
- if (highlighter != null && highlighter.isValid() && isValid()) {
- AppUIUtil.invokeLaterIfProjectAlive(myProject, new Runnable() {
- @Override
- public void run() {
- if (isValid()) {
- setupGutterRenderer(myHighlighter);
- }
- }
- });
- }
- else {
- DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().removeBreakpoint(this);
+ if (isValid()) {
+ final XBreakpointManager breakpointManager = XDebuggerManager.getInstance(myProject).getBreakpointManager();
+ breakpointManager.updateBreakpointPresentation((XLineBreakpoint)myXBreakpoint, getIcon(), getDescription());
}
+ //RangeHighlighter highlighter = myHighlighter;
+ //if (highlighter != null && highlighter.isValid() && isValid()) {
+ // AppUIUtil.invokeLaterIfProjectAlive(myProject, new Runnable() {
+ // @Override
+ // public void run() {
+ // if (isValid()) {
+ // setupGutterRenderer(myHighlighter);
+ // }
+ // }
+ // });
+ //}
+ //else {
+ // DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().removeBreakpoint(this);
+ //}
}
}
@@ -448,9 +450,9 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
});
}
- private void setupGutterRenderer(@NotNull RangeHighlighter highlighter) {
- highlighter.setGutterIconRenderer(new MyGutterIconRenderer(getIcon(), getDescription()));
- }
+ //private void setupGutterRenderer(@NotNull RangeHighlighter highlighter) {
+ // highlighter.setGutterIconRenderer(new MyGutterIconRenderer(getIcon(), getDescription()));
+ //}
@Override
public abstract Key extends BreakpointWithHighlighter> getCategory();
@@ -559,7 +561,7 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
public void readExternal(@NotNull Element breakpointNode) throws InvalidDataException {
super.readExternal(breakpointNode);
//noinspection HardCodedStringLiteral
- final String url = breakpointNode.getAttributeValue("url");
+ //final String url = breakpointNode.getAttributeValue("url");
//noinspection HardCodedStringLiteral
final String className = breakpointNode.getAttributeValue("class");
@@ -573,146 +575,146 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
myPackageName = packageName;
}
- VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(url);
- if (vFile == null) {
- throw new InvalidDataException(DebuggerBundle.message("error.breakpoint.file.not.found", url));
- }
- final Document doc = FileDocumentManager.getInstance().getDocument(vFile);
- if (doc == null) {
- throw new InvalidDataException(DebuggerBundle.message("error.cannot.load.breakpoint.file", url));
- }
-
- // line number
- final int line;
- try {
- //noinspection HardCodedStringLiteral
- line = Integer.parseInt(breakpointNode.getAttributeValue("line"));
- }
- catch (Exception e) {
- throw new InvalidDataException("Line number is invalid for breakpoint");
- }
- if (line < 0) {
- throw new InvalidDataException("Line number is invalid for breakpoint");
- }
-
- RangeHighlighter highlighter = createHighlighter(myProject, doc, line);
-
- if (highlighter == null) {
- throw new InvalidDataException("");
- }
-
- myHighlighter = highlighter;
- reload();
+ //VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(url);
+ //if (vFile == null) {
+ // throw new InvalidDataException(DebuggerBundle.message("error.breakpoint.file.not.found", url));
+ //}
+ //final Document doc = FileDocumentManager.getInstance().getDocument(vFile);
+ //if (doc == null) {
+ // throw new InvalidDataException(DebuggerBundle.message("error.cannot.load.breakpoint.file", url));
+ //}
+ //
+ //// line number
+ //final int line;
+ //try {
+ // //noinspection HardCodedStringLiteral
+ // line = Integer.parseInt(breakpointNode.getAttributeValue("line"));
+ //}
+ //catch (Exception e) {
+ // throw new InvalidDataException("Line number is invalid for breakpoint");
+ //}
+ //if (line < 0) {
+ // throw new InvalidDataException("Line number is invalid for breakpoint");
+ //}
+ //
+ //RangeHighlighter highlighter = createHighlighter(myProject, doc, line);
+ //
+ //if (highlighter == null) {
+ // throw new InvalidDataException("");
+ //}
+ //
+ //myHighlighter = highlighter;
+ //reload();
}
+ //
+ //@Override
+ //@SuppressWarnings({"HardCodedStringLiteral"})
+ //public void writeExternal(@NotNull Element parentNode) throws WriteExternalException {
+ // super.writeExternal(parentNode);
+ // PsiFile psiFile = getSourcePosition().getFile();
+ // final VirtualFile virtualFile = psiFile.getVirtualFile();
+ // final String url = virtualFile != null ? virtualFile.getUrl() : "";
+ // parentNode.setAttribute("url", url);
+ // parentNode.setAttribute("line", Integer.toString(getSourcePosition().getLine()));
+ // if (myClassName != null) {
+ // parentNode.setAttribute("class", myClassName);
+ // }
+ // if (myPackageName != null) {
+ // parentNode.setAttribute("package", myPackageName);
+ // }
+ //}
- @Override
- @SuppressWarnings({"HardCodedStringLiteral"})
- public void writeExternal(@NotNull Element parentNode) throws WriteExternalException {
- super.writeExternal(parentNode);
- PsiFile psiFile = getSourcePosition().getFile();
- final VirtualFile virtualFile = psiFile.getVirtualFile();
- final String url = virtualFile != null ? virtualFile.getUrl() : "";
- parentNode.setAttribute("url", url);
- parentNode.setAttribute("line", Integer.toString(getSourcePosition().getLine()));
- if (myClassName != null) {
- parentNode.setAttribute("class", myClassName);
- }
- if (myPackageName != null) {
- parentNode.setAttribute("package", myPackageName);
- }
- }
-
- private class MyGutterIconRenderer extends GutterIconRenderer {
- private final Icon myIcon;
- private final String myDescription;
-
- public MyGutterIconRenderer(@NotNull Icon icon, @NotNull String description) {
- myIcon = icon;
- myDescription = description;
- }
-
- @Override
- @NotNull
- public Icon getIcon() {
- return myIcon;
- }
-
- @Override
- public String getTooltipText() {
- return myDescription;
- }
-
- @Override
- public Alignment getAlignment() {
- return Alignment.RIGHT;
- }
-
- @Override
- public AnAction getClickAction() {
- return new AnAction() {
- @Override
- public void actionPerformed(AnActionEvent e) {
- DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().removeBreakpoint(BreakpointWithHighlighter.this);
- }
- };
- }
-
- @Override
- public AnAction getMiddleButtonClickAction() {
- return new AnAction() {
- @Override
- public void actionPerformed(AnActionEvent e) {
- ENABLED = !ENABLED;
- DebuggerManagerEx.getInstanceEx(getProject()).getBreakpointManager().fireBreakpointChanged(BreakpointWithHighlighter.this);
- updateUI();
- }
- };
- }
-
- @Override
- public ActionGroup getPopupMenuActions() {
- return null;
- }
-
- @Nullable
- @Override
- public AnAction getRightButtonClickAction() {
- return new EditBreakpointAction.ContextAction(this, BreakpointWithHighlighter.this, DebuggerSupport.getDebuggerSupport(JavaDebuggerSupport.class));
- }
-
- @Override
- public GutterDraggableObject getDraggableObject() {
- return new GutterDraggableObject() {
- @Override
- public boolean copy(int line, @NotNull VirtualFile file) {
- final PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file);
- return psiFile != null && moveTo(SourcePosition.createFromLine(psiFile, line));
- }
-
- @Override
- public Cursor getCursor(int line) {
- final SourcePosition newPosition = SourcePosition.createFromLine(getSourcePosition().getFile(), line);
- return canMoveTo(newPosition) ? DragSource.DefaultMoveDrop : DragSource.DefaultMoveNoDrop;
- }
- };
- }
-
- @Override
- public boolean equals(@NotNull Object obj) {
- return obj instanceof MyGutterIconRenderer &&
- Comparing.equal(getTooltipText(), ((MyGutterIconRenderer)obj).getTooltipText()) &&
- Comparing.equal(getIcon(), ((MyGutterIconRenderer)obj).getIcon());
- }
-
- @Override
- public int hashCode() {
- return getIcon().hashCode();
- }
-
- @Override
- public String toString() {
- return "LB " + getDisplayName();
- }
- }
+ //private class MyGutterIconRenderer extends GutterIconRenderer {
+ // private final Icon myIcon;
+ // private final String myDescription;
+ //
+ // public MyGutterIconRenderer(@NotNull Icon icon, @NotNull String description) {
+ // myIcon = icon;
+ // myDescription = description;
+ // }
+ //
+ // @Override
+ // @NotNull
+ // public Icon getIcon() {
+ // return myIcon;
+ // }
+ //
+ // @Override
+ // public String getTooltipText() {
+ // return myDescription;
+ // }
+ //
+ // @Override
+ // public Alignment getAlignment() {
+ // return Alignment.RIGHT;
+ // }
+ //
+ // @Override
+ // public AnAction getClickAction() {
+ // return new AnAction() {
+ // @Override
+ // public void actionPerformed(AnActionEvent e) {
+ // DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().removeBreakpoint(BreakpointWithHighlighter.this);
+ // }
+ // };
+ // }
+ //
+ // @Override
+ // public AnAction getMiddleButtonClickAction() {
+ // return new AnAction() {
+ // @Override
+ // public void actionPerformed(AnActionEvent e) {
+ // setEnabled(!isEnabled());
+ // DebuggerManagerEx.getInstanceEx(getProject()).getBreakpointManager().fireBreakpointChanged(BreakpointWithHighlighter.this);
+ // updateUI();
+ // }
+ // };
+ // }
+ //
+ // @Override
+ // public ActionGroup getPopupMenuActions() {
+ // return null;
+ // }
+ //
+ // @Nullable
+ // @Override
+ // public AnAction getRightButtonClickAction() {
+ // return new EditBreakpointAction.ContextAction(this, BreakpointWithHighlighter.this, DebuggerSupport.getDebuggerSupport(JavaDebuggerSupport.class));
+ // }
+ //
+ // @Override
+ // public GutterDraggableObject getDraggableObject() {
+ // return new GutterDraggableObject() {
+ // @Override
+ // public boolean copy(int line, @NotNull VirtualFile file) {
+ // final PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file);
+ // return psiFile != null && moveTo(SourcePosition.createFromLine(psiFile, line));
+ // }
+ //
+ // @Override
+ // public Cursor getCursor(int line) {
+ // final SourcePosition newPosition = SourcePosition.createFromLine(getSourcePosition().getFile(), line);
+ // return canMoveTo(newPosition) ? DragSource.DefaultMoveDrop : DragSource.DefaultMoveNoDrop;
+ // }
+ // };
+ // }
+ //
+ // @Override
+ // public boolean equals(@NotNull Object obj) {
+ // return obj instanceof MyGutterIconRenderer &&
+ // Comparing.equal(getTooltipText(), ((MyGutterIconRenderer)obj).getTooltipText()) &&
+ // Comparing.equal(getIcon(), ((MyGutterIconRenderer)obj).getIcon());
+ // }
+ //
+ // @Override
+ // public int hashCode() {
+ // return getIcon().hashCode();
+ // }
+ //
+ // @Override
+ // public String toString() {
+ // return "LB " + getDisplayName();
+ // }
+ //}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpoint.java
index c6a19557f4e8..8a0b5159d5f7 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpoint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpoint.java
@@ -34,13 +34,14 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.InvalidDataException;
+import com.intellij.openapi.util.JDOMExternalizerUtil;
import com.intellij.openapi.util.Key;
-import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.sun.jdi.AbsentInformationException;
import com.sun.jdi.Location;
import com.sun.jdi.ObjectReference;
@@ -50,36 +51,32 @@ import com.sun.jdi.event.LocatableEvent;
import com.sun.jdi.request.ExceptionRequest;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpointProperties;
import javax.swing.*;
-public class ExceptionBreakpoint extends Breakpoint {
+public class ExceptionBreakpoint extends Breakpoint {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.breakpoints.ExceptionBreakpoint");
- public boolean NOTIFY_CAUGHT = true;
- public boolean NOTIFY_UNCAUGHT = true;
- private String myQualifiedName;
- private String myPackageName;
-
protected final static String READ_NO_CLASS_NAME = DebuggerBundle.message("error.absent.exception.breakpoint.class.name");
public static final @NonNls Key CATEGORY = BreakpointCategory.lookup("exception_breakpoints");
- public ExceptionBreakpoint(Project project) {
- super(project);
+ public ExceptionBreakpoint(Project project, XBreakpoint xBreakpoint) {
+ super(project, xBreakpoint);
}
public Key extends ExceptionBreakpoint> getCategory() {
return CATEGORY;
}
- protected ExceptionBreakpoint(Project project, String qualifiedName, String packageName) {
- super(project);
- myQualifiedName = qualifiedName;
+ protected ExceptionBreakpoint(Project project, String qualifiedName, String packageName, XBreakpoint xBreakpoint) {
+ super(project, xBreakpoint);
+ setQualifiedName(qualifiedName);
if (packageName == null) {
- myPackageName = calcPackageName(qualifiedName);
+ setPackageName(calcPackageName(qualifiedName));
}
else {
- myPackageName = packageName;
+ setPackageName(packageName);
}
}
@@ -92,27 +89,27 @@ public class ExceptionBreakpoint extends Breakpoint {
}
public String getClassName() {
- return myQualifiedName;
+ return getQualifiedName();
}
public String getPackageName() {
- return myPackageName;
+ return getProperties().myPackageName;
}
public PsiClass getPsiClass() {
return PsiDocumentManager.getInstance(myProject).commitAndRunReadAction(new Computable() {
public PsiClass compute() {
- return myQualifiedName != null ? DebuggerUtilsEx.findClass(myQualifiedName, myProject, GlobalSearchScope.allScope(myProject)) : null;
+ return getQualifiedName() != null ? DebuggerUtilsEx.findClass(getQualifiedName(), myProject, GlobalSearchScope.allScope(myProject)) : null;
}
});
}
public String getDisplayName() {
- return DebuggerBundle.message("breakpoint.exception.breakpoint.display.name", myQualifiedName);
+ return DebuggerBundle.message("breakpoint.exception.breakpoint.display.name", getQualifiedName());
}
public Icon getIcon() {
- if (!ENABLED) {
+ if (!isEnabled()) {
final Breakpoint master = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().findMasterBreakpoint(this);
return master == null? AllIcons.Debugger.Db_disabled_exception_breakpoint : AllIcons.Debugger.Db_dep_exception_breakpoint;
}
@@ -124,20 +121,20 @@ public class ExceptionBreakpoint extends Breakpoint {
public void createRequest(final DebugProcessImpl debugProcess) {
DebuggerManagerThreadImpl.assertIsManagerThread();
- if (!ENABLED || !debugProcess.isAttached() || debugProcess.areBreakpointsMuted() || !debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
+ if (!isEnabled() || !debugProcess.isAttached() || debugProcess.areBreakpointsMuted() || !debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
return;
}
SourcePosition classPosition = PsiDocumentManager.getInstance(myProject).commitAndRunReadAction(new Computable() {
public SourcePosition compute() {
- PsiClass psiClass = DebuggerUtilsEx.findClass(myQualifiedName, myProject, debugProcess.getSearchScope());
+ PsiClass psiClass = DebuggerUtilsEx.findClass(getQualifiedName(), myProject, debugProcess.getSearchScope());
return psiClass != null ? SourcePosition.createFromElement(psiClass) : null;
}
});
if(classPosition == null) {
- createOrWaitPrepare(debugProcess, myQualifiedName);
+ createOrWaitPrepare(debugProcess, getQualifiedName());
}
else {
createOrWaitPrepare(debugProcess, classPosition);
@@ -146,11 +143,12 @@ public class ExceptionBreakpoint extends Breakpoint {
public void processClassPrepare(DebugProcess process, ReferenceType refType) {
DebugProcessImpl debugProcess = (DebugProcessImpl)process;
- if (!ENABLED) {
+ if (!isEnabled()) {
return;
}
// trying to create a request
- ExceptionRequest request = debugProcess.getRequestsManager().createExceptionRequest(this, refType, NOTIFY_CAUGHT, NOTIFY_UNCAUGHT);
+ ExceptionRequest request = debugProcess.getRequestsManager().createExceptionRequest(this, refType, isNotifyCaught(),
+ isNotifyUncaught());
debugProcess.getRequestsManager().enableRequest(request);
if (LOG.isDebugEnabled()) {
if (refType != null) {
@@ -170,7 +168,7 @@ public class ExceptionBreakpoint extends Breakpoint {
}
public String getEventMessage(LocatableEvent event) {
- String exceptionName = (myQualifiedName != null)? myQualifiedName : "java.lang.Throwable";
+ String exceptionName = (getQualifiedName() != null)? getQualifiedName() : "java.lang.Throwable";
String threadName = null;
if (event instanceof ExceptionEvent) {
ExceptionEvent exceptionEvent = (ExceptionEvent)event;
@@ -216,15 +214,15 @@ public class ExceptionBreakpoint extends Breakpoint {
return true;
}
- @SuppressWarnings({"HardCodedStringLiteral"}) public void writeExternal(Element parentNode) throws WriteExternalException {
- super.writeExternal(parentNode);
- if(myQualifiedName != null) {
- parentNode.setAttribute("class_name", myQualifiedName);
- }
- if(myPackageName != null) {
- parentNode.setAttribute("package_name", myPackageName);
- }
- }
+ //@SuppressWarnings({"HardCodedStringLiteral"}) public void writeExternal(Element parentNode) throws WriteExternalException {
+ // super.writeExternal(parentNode);
+ // if(getQualifiedName() != null) {
+ // parentNode.setAttribute("class_name", getQualifiedName());
+ // }
+ // if(getPackageName() != null) {
+ // parentNode.setAttribute("package_name", getPackageName());
+ // }
+ //}
public PsiElement getEvaluationElement() {
if (getClassName() == null) {
@@ -235,16 +233,45 @@ public class ExceptionBreakpoint extends Breakpoint {
public void readExternal(Element parentNode) throws InvalidDataException {
super.readExternal(parentNode);
- //noinspection HardCodedStringLiteral
- String className = parentNode.getAttributeValue("class_name");
- myQualifiedName = className;
- if(className == null) {
- throw new InvalidDataException(READ_NO_CLASS_NAME);
- }
//noinspection HardCodedStringLiteral
String packageName = parentNode.getAttributeValue("package_name");
- myPackageName = packageName != null? packageName : calcPackageName(packageName);
+ setPackageName(packageName != null? packageName : calcPackageName(packageName));
+
+ try {
+ getProperties().NOTIFY_CAUGHT = Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "NOTIFY_CAUGHT"));
+ } catch (Exception e) {
+ }
+ try {
+ getProperties().NOTIFY_UNCAUGHT = Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "NOTIFY_UNCAUGHT"));
+ } catch (Exception e) {
+ }
+
+ //noinspection HardCodedStringLiteral
+ String className = parentNode.getAttributeValue("class_name");
+ setQualifiedName(className);
+ if(className == null) {
+ throw new InvalidDataException(READ_NO_CLASS_NAME);
+ }
}
+ private boolean isNotifyCaught() {
+ return getProperties().NOTIFY_CAUGHT;
+ }
+
+ private boolean isNotifyUncaught() {
+ return getProperties().NOTIFY_UNCAUGHT;
+ }
+
+ private String getQualifiedName() {
+ return getProperties().myQualifiedName;
+ }
+
+ private void setQualifiedName(String qualifiedName) {
+ getProperties().myQualifiedName = qualifiedName;
+ }
+
+ private void setPackageName(String packageName) {
+ getProperties().myPackageName = packageName;
+ }
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointFactory.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointFactory.java
deleted file mode 100644
index 40b75c4ffc71..000000000000
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointFactory.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.debugger.ui.breakpoints;
-
-import com.intellij.debugger.DebuggerBundle;
-import com.intellij.debugger.DebuggerManagerEx;
-import com.intellij.debugger.HelpID;
-import com.intellij.debugger.engine.JVMNameUtil;
-import com.intellij.icons.AllIcons;
-import com.intellij.ide.util.TreeClassChooser;
-import com.intellij.ide.util.TreeClassChooserFactory;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Key;
-import com.intellij.psi.JavaPsiFacade;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiClassOwner;
-import com.intellij.psi.search.GlobalSearchScope;
-import org.jdom.Element;
-
-import javax.swing.*;
-
-/**
- * @author Eugene Zhuravlev
- * Date: Apr 26, 2005
- */
-public class ExceptionBreakpointFactory extends BreakpointFactory {
- public Breakpoint createBreakpoint(Project project, final Element element) {
- return new ExceptionBreakpoint(project);
- }
-
- public Icon getIcon() {
- return AllIcons.Debugger.Db_exception_breakpoint;
- }
-
- public Icon getDisabledIcon() {
- return AllIcons.Debugger.Db_disabled_exception_breakpoint;
- }
-
- @Override
- protected String getHelpID() {
- return HelpID.EXCEPTION_BREAKPOINTS;
- }
-
- @Override
- public String getDisplayName() {
- return DebuggerBundle.message("exception.breakpoints.tab.title");
- }
-
- @Override
- public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) {
- return new ExceptionBreakpointPropertiesPanel(project, compact);
- }
-
- public Key getBreakpointCategory() {
- return ExceptionBreakpoint.CATEGORY;
- }
-
- @Override
- public boolean canAddBreakpoints() {
- return true;
- }
-
- @Override
- public Breakpoint addBreakpoint(Project project) {
- ExceptionBreakpoint breakpoint = null;
- final PsiClass throwableClass =
- JavaPsiFacade.getInstance(project).findClass("java.lang.Throwable", GlobalSearchScope.allScope(project));
- TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project)
- .createInheritanceClassChooser(DebuggerBundle.message("add.exception.breakpoint.classchooser.title"),
- GlobalSearchScope.allScope(project), throwableClass, true, true, null);
- chooser.showDialog();
- PsiClass selectedClass = chooser.getSelected();
- String qName = selectedClass == null ? null : JVMNameUtil.getNonAnonymousClassName(selectedClass);
-
- if (qName != null && qName.length() > 0) {
- breakpoint = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager()
- .addExceptionBreakpoint(qName, ((PsiClassOwner)selectedClass.getContainingFile()).getPackageName());
- }
- return breakpoint;
- }
-}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointPropertiesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointPropertiesPanel.java
index 6d02499f227c..4af7275d1258 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointPropertiesPanel.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointPropertiesPanel.java
@@ -21,31 +21,34 @@
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
-import com.intellij.ide.util.ClassFilter;
-import com.intellij.openapi.project.Project;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.util.ui.DialogUtil;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
+import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpointProperties;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-public class ExceptionBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
+public class ExceptionBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPanel> {
private JCheckBox myNotifyCaughtCheckBox;
private JCheckBox myNotifyUncaughtCheckBox;
- private ExceptionBreakpoint myExceptionBreakpoint;
+ //private ExceptionBreakpoint myExceptionBreakpoint;
- public ExceptionBreakpointPropertiesPanel(Project project, boolean compact) {
- super(project, ExceptionBreakpoint.CATEGORY, compact);
- }
+ //public ExceptionBreakpointPropertiesPanel(Project project, boolean compact) {
+ // super(project, ExceptionBreakpoint.CATEGORY, compact);
+ //}
- protected ClassFilter createClassConditionFilter() {
- return null;
- }
-
- protected JComponent createSpecialBox() {
+ //protected ClassFilter createClassConditionFilter() {
+ // return null;
+ //}
+ @NotNull
+ @Override
+ public JComponent getComponent() {
myNotifyCaughtCheckBox = new JCheckBox(DebuggerBundle.message("label.exception.breakpoint.properties.panel.caught.exception"));
myNotifyUncaughtCheckBox = new JCheckBox(DebuggerBundle.message("label.exception.breakpoint.properties.panel.uncaught.exception"));
DialogUtil.registerMnemonic(myNotifyCaughtCheckBox);
@@ -91,25 +94,20 @@ public class ExceptionBreakpointPropertiesPanel extends BreakpointPropertiesPane
return _panel;
}
- protected void updateCheckboxes() {
- super.updateCheckboxes();
- myPassCountCheckbox.setEnabled(!(myExceptionBreakpoint instanceof AnyExceptionBreakpoint));
+ //protected void updateCheckboxes() {
+ // super.updateCheckboxes();
+ // myPassCountCheckbox.setEnabled(!(myExceptionBreakpoint instanceof AnyExceptionBreakpoint));
+ //}
+
+ @Override
+ public void loadFrom(@NotNull XBreakpoint breakpoint) {
+ myNotifyCaughtCheckBox.setSelected(breakpoint.getProperties().NOTIFY_CAUGHT);
+ myNotifyUncaughtCheckBox.setSelected(breakpoint.getProperties().NOTIFY_UNCAUGHT);
}
- public void initFrom(Breakpoint breakpoint, boolean moreOptionsVisible) {
- ExceptionBreakpoint exceptionBreakpoint = (ExceptionBreakpoint)breakpoint;
- myExceptionBreakpoint = exceptionBreakpoint;
- super.initFrom(breakpoint, moreOptionsVisible);
-
- myNotifyCaughtCheckBox.setSelected(exceptionBreakpoint.NOTIFY_CAUGHT);
- myNotifyUncaughtCheckBox.setSelected(exceptionBreakpoint.NOTIFY_UNCAUGHT);
- }
-
- public void saveTo(Breakpoint breakpoint) {
- ExceptionBreakpoint exceptionBreakpoint = (ExceptionBreakpoint)breakpoint;
- exceptionBreakpoint.NOTIFY_CAUGHT = myNotifyCaughtCheckBox.isSelected();
- exceptionBreakpoint.NOTIFY_UNCAUGHT = myNotifyUncaughtCheckBox.isSelected();
-
- super.saveTo(breakpoint);
+ @Override
+ public void saveTo(@NotNull XBreakpoint breakpoint) {
+ breakpoint.getProperties().NOTIFY_CAUGHT = myNotifyCaughtCheckBox.isSelected();
+ breakpoint.getProperties().NOTIFY_UNCAUGHT = myNotifyUncaughtCheckBox.isSelected();
}
}
\ No newline at end of file
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpoint.java
index 365ae242b36d..aa3a29511a2f 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpoint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpoint.java
@@ -33,19 +33,17 @@ import com.intellij.icons.AllIcons;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.InvalidDataException;
+import com.intellij.openapi.util.JDOMExternalizerUtil;
import com.intellij.openapi.util.Key;
-import com.intellij.openapi.util.WriteExternalException;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.Processor;
import com.intellij.util.text.CharArrayUtil;
import com.intellij.xdebugger.XDebuggerUtil;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.sun.jdi.*;
import com.sun.jdi.event.AccessWatchpointEvent;
import com.sun.jdi.event.LocatableEvent;
@@ -55,26 +53,23 @@ import com.sun.jdi.request.ModificationWatchpointRequest;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaFieldBreakpointProperties;
import javax.swing.*;
-import java.util.List;
-public class FieldBreakpoint extends BreakpointWithHighlighter {
+public class FieldBreakpoint extends BreakpointWithHighlighter {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.breakpoints.FieldBreakpoint");
- public boolean WATCH_MODIFICATION = true;
- public boolean WATCH_ACCESS = false;
private boolean myIsStatic;
- private String myFieldName;
@NonNls public static final Key CATEGORY = BreakpointCategory.lookup("field_breakpoints");
- protected FieldBreakpoint(Project project) {
- super(project);
+ protected FieldBreakpoint(Project project, XBreakpoint breakpoint) {
+ super(project, breakpoint);
}
- private FieldBreakpoint(Project project, RangeHighlighter highlighter, @NotNull String fieldName) {
- super(project, highlighter);
- myFieldName = fieldName;
+ private FieldBreakpoint(Project project, @NotNull String fieldName, XBreakpoint breakpoint) {
+ super(project, breakpoint);
+ setFieldName(fieldName);
}
public boolean isStatic() {
@@ -82,10 +77,9 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
}
public String getFieldName() {
- return myFieldName;
+ return getProperties().myFieldName;
}
-
@Override
protected Icon getDisabledIcon(boolean isMuted) {
final Breakpoint master = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().findMasterBreakpoint(this);
@@ -128,7 +122,7 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
@Override
public PsiField compute() {
final PsiClass psiClass = getPsiClassAt(sourcePosition);
- return psiClass != null ? psiClass.findFieldByName(myFieldName, true) : null;
+ return psiClass != null ? psiClass.findFieldByName(getFieldName(), true) : null;
}
});
if (field != null) {
@@ -142,11 +136,15 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
super.reload(psiFile);
PsiField field = PositionUtil.getPsiElementAt(getProject(), PsiField.class, getSourcePosition());
if(field != null) {
- myFieldName = field.getName();
+ setFieldName(field.getName());
+ PsiClass psiClass = field.getContainingClass();
+ if (psiClass != null) {
+ getProperties().myClassName = psiClass.getQualifiedName();
+ }
myIsStatic = field.hasModifierProperty(PsiModifier.STATIC);
}
if (myIsStatic) {
- INSTANCE_FILTERS_ENABLED = false;
+ setInstanceFiltersEnabled(false);
}
}
@@ -181,20 +179,21 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
ReferenceType refType) {
VirtualMachineProxy vm = debugProcess.getVirtualMachineProxy();
try {
- Field field = refType.fieldByName(myFieldName);
+ Field field = refType.fieldByName(getFieldName());
if (field == null) {
- debugProcess.getRequestsManager().setInvalid(this, DebuggerBundle.message("error.invalid.breakpoint.missing.field.in.class", myFieldName, refType.name()));
+ debugProcess.getRequestsManager().setInvalid(this, DebuggerBundle.message("error.invalid.breakpoint.missing.field.in.class",
+ getFieldName(), refType.name()));
return;
}
RequestManagerImpl manager = debugProcess.getRequestsManager();
- if (WATCH_MODIFICATION && vm.canWatchFieldModification()) {
+ if (isWatchModification() && vm.canWatchFieldModification()) {
ModificationWatchpointRequest request = manager.createModificationWatchpointRequest(this, field);
debugProcess.getRequestsManager().enableRequest(request);
if (LOG.isDebugEnabled()) {
LOG.debug("Modification request added");
}
}
- if (WATCH_ACCESS && vm.canWatchFieldAccess()) {
+ if (isWatchAccess() && vm.canWatchFieldAccess()) {
AccessWatchpointRequest request = manager.createAccessWatchpointRequest(this, field);
debugProcess.getRequestsManager().enableRequest(request);
if (LOG.isDebugEnabled()) {
@@ -284,11 +283,11 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
return DebuggerBundle.message("status.breakpoint.invalid");
}
final String className = getClassName();
- return className != null && !className.isEmpty() ? className + "." + myFieldName : myFieldName;
+ return className != null && !className.isEmpty() ? className + "." + getFieldName() : getFieldName();
}
- public static FieldBreakpoint create(@NotNull Project project, @NotNull Document document, int lineIndex, String fieldName) {
- FieldBreakpoint breakpoint = new FieldBreakpoint(project, createHighlighter(project, document, lineIndex), fieldName);
+ public static FieldBreakpoint create(@NotNull Project project, String fieldName, XBreakpoint xBreakpoint) {
+ FieldBreakpoint breakpoint = new FieldBreakpoint(project, fieldName, xBreakpoint);
return (FieldBreakpoint)breakpoint.init();
}
@@ -308,39 +307,39 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
return field == getPsiField();
}
- protected static FieldBreakpoint create(@NotNull Project project, @NotNull Field field, ObjectReference object) {
- String fieldName = field.name();
- int line = 0;
- Document document = null;
- try {
- List locations = field.declaringType().allLineLocations();
- if(!locations.isEmpty()) {
- Location location = (Location)locations.get(0);
- line = location.lineNumber();
- VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(location.sourcePath());
- if(file != null) {
- PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
- if(psiFile != null) {
- document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
- }
- }
- }
- }
- catch (AbsentInformationException e) {
- LOG.debug(e);
- }
- catch (InternalError e) {
- LOG.debug(e);
- }
-
- if(document == null) return null;
-
- FieldBreakpoint fieldBreakpoint = new FieldBreakpoint(project, createHighlighter(project, document, line), fieldName);
- if (!fieldBreakpoint.isStatic()) {
- fieldBreakpoint.addInstanceFilter(object.uniqueID());
- }
- return (FieldBreakpoint)fieldBreakpoint.init();
- }
+ //protected static FieldBreakpoint create(@NotNull Project project, @NotNull Field field, ObjectReference object, XBreakpoint xBreakpoint) {
+ // String fieldName = field.name();
+ // int line = 0;
+ // Document document = null;
+ // try {
+ // List locations = field.declaringType().allLineLocations();
+ // if(!locations.isEmpty()) {
+ // Location location = (Location)locations.get(0);
+ // line = location.lineNumber();
+ // VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(location.sourcePath());
+ // if(file != null) {
+ // PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
+ // if(psiFile != null) {
+ // document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
+ // }
+ // }
+ // }
+ // }
+ // catch (AbsentInformationException e) {
+ // LOG.debug(e);
+ // }
+ // catch (InternalError e) {
+ // LOG.debug(e);
+ // }
+ //
+ // if(document == null) return null;
+ //
+ // FieldBreakpoint fieldBreakpoint = new FieldBreakpoint(project, createHighlighter(project, document, line), fieldName, xBreakpoint);
+ // if (!fieldBreakpoint.isStatic()) {
+ // fieldBreakpoint.addInstanceFilter(object.uniqueID());
+ // }
+ // return (FieldBreakpoint)fieldBreakpoint.init();
+ //}
public static PsiField findField(Project project, Document document, int offset) {
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
@@ -373,21 +372,41 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
public void readExternal(@NotNull Element breakpointNode) throws InvalidDataException {
super.readExternal(breakpointNode);
//noinspection HardCodedStringLiteral
- myFieldName = breakpointNode.getAttributeValue("field_name");
- if(myFieldName == null) {
+ setFieldName(breakpointNode.getAttributeValue("field_name"));
+ if(getFieldName() == null) {
throw new InvalidDataException("No field name for field breakpoint");
}
+ try {
+ getProperties().WATCH_MODIFICATION = Boolean.valueOf(JDOMExternalizerUtil.readField(breakpointNode, "WATCH_MODIFICATION"));
+ } catch (Exception e) {
+ }
+ try {
+ getProperties().WATCH_ACCESS = Boolean.valueOf(JDOMExternalizerUtil.readField(breakpointNode, "WATCH_ACCESS"));
+ } catch (Exception e) {
+ }
}
-
- @Override
- @SuppressWarnings({"HardCodedStringLiteral"})
- public void writeExternal(@NotNull Element parentNode) throws WriteExternalException {
- super.writeExternal(parentNode);
- parentNode.setAttribute("field_name", getFieldName());
- }
+ //
+ //@Override
+ //@SuppressWarnings({"HardCodedStringLiteral"})
+ //public void writeExternal(@NotNull Element parentNode) throws WriteExternalException {
+ // super.writeExternal(parentNode);
+ // parentNode.setAttribute("field_name", getFieldName());
+ //}
@Override
public PsiElement getEvaluationElement() {
return getPsiClass();
}
+
+ private boolean isWatchModification() {
+ return getProperties().WATCH_MODIFICATION;
+ }
+
+ private boolean isWatchAccess() {
+ return getProperties().WATCH_ACCESS;
+ }
+
+ private void setFieldName(String fieldName) {
+ getProperties().myFieldName = fieldName;
+ }
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointFactory.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointFactory.java
deleted file mode 100644
index 1bdef0c862e7..000000000000
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointFactory.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.debugger.ui.breakpoints;
-
-import com.intellij.CommonBundle;
-import com.intellij.debugger.DebuggerBundle;
-import com.intellij.debugger.DebuggerManagerEx;
-import com.intellij.debugger.HelpID;
-import com.intellij.icons.AllIcons;
-import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.Messages;
-import com.intellij.openapi.util.Key;
-import com.intellij.openapi.util.Ref;
-import com.intellij.psi.*;
-import com.intellij.psi.search.GlobalSearchScope;
-import org.jdom.Element;
-
-import javax.swing.*;
-
-/**
- * @author Eugene Zhuravlev
- * Date: Apr 26, 2005
- */
-public class FieldBreakpointFactory extends BreakpointFactory{
- public Breakpoint createBreakpoint(Project project, final Element element) {
- return new FieldBreakpoint(project);
- }
-
- public Icon getIcon() {
- return AllIcons.Debugger.Db_field_breakpoint;
- }
-
- public Icon getDisabledIcon() {
- return AllIcons.Debugger.Db_disabled_field_breakpoint;
- }
-
- @Override
- protected String getHelpID() {
- return HelpID.FIELD_WATCHPOINTS;
- }
-
- @Override
- public String getDisplayName() {
- return DebuggerBundle.message("field.watchpoints.tab.title");
- }
-
- @Override
- public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) {
- return new FieldBreakpointPropertiesPanel(project, compact);
- }
-
- public Key getBreakpointCategory() {
- return FieldBreakpoint.CATEGORY;
- }
-
- @Override
- public Breakpoint addBreakpoint(final Project project) {
- final Ref result = Ref.create(null);
- AddFieldBreakpointDialog dialog = new AddFieldBreakpointDialog(project) {
- protected boolean validateData() {
- String className = getClassName();
- if (className.length() == 0) {
- Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.class.name.not.specified"),
- DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon());
- return false;
- }
- String fieldName = getFieldName();
- if (fieldName.length() == 0) {
- Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.field.name.not.specified"),
- DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon());
- return false;
- }
- PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(className, GlobalSearchScope.allScope(project));
- if (psiClass != null) {
- PsiFile psiFile = psiClass.getContainingFile();
- Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
- if(document != null) {
- PsiField field = psiClass.findFieldByName(fieldName, true);
- if(field != null) {
- int line = document.getLineNumber(field.getTextOffset());
- FieldBreakpoint fieldBreakpoint = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().addFieldBreakpoint(document, line, fieldName);
- if (fieldBreakpoint != null) {
- result.set(fieldBreakpoint);
- return true;
- }
- }
- else {
- Messages.showMessageDialog(project,
- DebuggerBundle.message("error.field.breakpoint.field.not.found", className, fieldName, fieldName),
- CommonBundle.getErrorTitle(),
- Messages.getErrorIcon()
- );
- }
- }
- } else {
- Messages.showMessageDialog(project,
- DebuggerBundle.message("error.field.breakpoint.class.sources.not.found", className, fieldName, className),
- CommonBundle.getErrorTitle(),
- Messages.getErrorIcon()
- );
- }
- return false;
- }
- };
- dialog.show();
- return result.get();
- }
-
- @Override
- public boolean canAddBreakpoints() {
- return true;
- }
-}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointPropertiesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointPropertiesPanel.java
index bec12645dd80..4d0bec2e165b 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointPropertiesPanel.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointPropertiesPanel.java
@@ -21,24 +21,30 @@
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
-import com.intellij.openapi.project.Project;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.util.ui.DialogUtil;
+import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
+import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaFieldBreakpointProperties;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-public class FieldBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
+public class FieldBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPanel> {
private JCheckBox myWatchAccessCheckBox;
private JCheckBox myWatchModificationCheckBox;
- public FieldBreakpointPropertiesPanel(final Project project, boolean compact) {
- super(project, FieldBreakpoint.CATEGORY, compact);
- }
+ //public FieldBreakpointPropertiesPanel(final Project project, boolean compact) {
+ // super(project, FieldBreakpoint.CATEGORY, compact);
+ //}
- protected JComponent createSpecialBox() {
+
+ @NotNull
+ @Override
+ public JComponent getComponent() {
JPanel _panel;
JPanel _panel0;
myWatchAccessCheckBox = new JCheckBox(DebuggerBundle.message("label.filed.breakpoint.properties.panel.field.access"));
@@ -86,20 +92,15 @@ public class FieldBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
return _panel;
}
- public void initFrom(Breakpoint breakpoint, boolean moreOptionsVisible) {
- super.initFrom(breakpoint, moreOptionsVisible);
- FieldBreakpoint fieldBreakpoint = (FieldBreakpoint)breakpoint;
-
- myWatchAccessCheckBox.setSelected(fieldBreakpoint.WATCH_ACCESS);
- myWatchModificationCheckBox.setSelected(fieldBreakpoint.WATCH_MODIFICATION);
+ @Override
+ public void loadFrom(@NotNull XLineBreakpoint breakpoint) {
+ myWatchAccessCheckBox.setSelected(breakpoint.getProperties().WATCH_ACCESS);
+ myWatchModificationCheckBox.setSelected(breakpoint.getProperties().WATCH_MODIFICATION);
}
- public void saveTo(Breakpoint breakpoint) {
- FieldBreakpoint fieldBreakpoint = (FieldBreakpoint)breakpoint;
-
- fieldBreakpoint.WATCH_ACCESS = myWatchAccessCheckBox.isSelected();
- fieldBreakpoint.WATCH_MODIFICATION = myWatchModificationCheckBox.isSelected();
-
- super.saveTo(breakpoint);
+ @Override
+ public void saveTo(@NotNull XLineBreakpoint breakpoint) {
+ breakpoint.getProperties().WATCH_ACCESS = myWatchAccessCheckBox.isSelected();
+ breakpoint.getProperties().WATCH_MODIFICATION = myWatchModificationCheckBox.isSelected();
}
}
\ No newline at end of file
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestor.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestor.java
index 8aa57bd351d8..6a628f189bc5 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestor.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,250 +13,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * class FilteredRequestor
- * @author Jeka
- */
package com.intellij.debugger.ui.breakpoints;
-import com.intellij.debugger.*;
-import com.intellij.debugger.engine.ContextUtil;
-import com.intellij.debugger.engine.DebugProcessImpl;
-import com.intellij.debugger.engine.evaluation.*;
-import com.intellij.debugger.engine.evaluation.expression.EvaluatorBuilderImpl;
-import com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator;
+import com.intellij.debugger.InstanceFilter;
import com.intellij.debugger.engine.requests.LocatableEventRequestor;
-import com.intellij.debugger.impl.DebuggerUtilsEx;
-import com.intellij.debugger.settings.DebuggerSettings;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.*;
-import com.intellij.psi.PsiElement;
import com.intellij.ui.classFilter.ClassFilter;
-import com.sun.jdi.BooleanValue;
-import com.sun.jdi.ObjectReference;
-import com.sun.jdi.VMDisconnectedException;
-import com.sun.jdi.Value;
-import com.sun.jdi.event.LocatableEvent;
-import org.jdom.Element;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import java.util.ArrayList;
-import java.util.List;
+/**
+ * @author egor
+ */
+public interface FilteredRequestor extends LocatableEventRequestor {
+ String getSuspendPolicy();
-public abstract class FilteredRequestor implements LocatableEventRequestor, JDOMExternalizable {
+ boolean isInstanceFiltersEnabled();
+ InstanceFilter[] getInstanceFilters();
- public String SUSPEND_POLICY = DebuggerSettings.SUSPEND_ALL;
- public boolean SUSPEND = true;
+ boolean isCountFilterEnabled();
+ int getCountFilter();
- public boolean COUNT_FILTER_ENABLED = false;
- public int COUNT_FILTER = 0;
-
- public boolean CONDITION_ENABLED = false;
- private TextWithImports myCondition;
-
- public boolean CLASS_FILTERS_ENABLED = false;
- private ClassFilter[] myClassFilters = ClassFilter.EMPTY_ARRAY;
- private ClassFilter[] myClassExclusionFilters = ClassFilter.EMPTY_ARRAY;
-
- public boolean INSTANCE_FILTERS_ENABLED = false;
- private InstanceFilter[] myInstanceFilters = InstanceFilter.EMPTY_ARRAY;
-
- @NonNls private static final String FILTER_OPTION_NAME = "filter";
- @NonNls private static final String EXCLUSION_FILTER_OPTION_NAME = "exclusion_filter";
- @NonNls private static final String INSTANCE_ID_OPTION_NAME = "instance_id";
- @NonNls private static final String CONDITION_OPTION_NAME = "CONDITION";
- protected final Project myProject;
-
- public FilteredRequestor(@NotNull Project project) {
- myProject = project;
- myCondition = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, "");
- }
-
- public InstanceFilter[] getInstanceFilters() {
- return myInstanceFilters;
- }
-
- public void setInstanceFilters(InstanceFilter[] instanceFilters) {
- myInstanceFilters = instanceFilters != null? instanceFilters : InstanceFilter.EMPTY_ARRAY;
- }
-
- public String getSuspendPolicy() {
- return SUSPEND? SUSPEND_POLICY : DebuggerSettings.SUSPEND_NONE;
- }
-
- /**
- * @return true if the ID was added or false otherwise
- */
- private boolean hasObjectID(long id) {
- for (InstanceFilter instanceFilter : myInstanceFilters) {
- if (instanceFilter.getId() == id) {
- return true;
- }
- }
- return false;
- }
-
- protected void addInstanceFilter(long l) {
- final InstanceFilter[] filters = new InstanceFilter[myInstanceFilters.length + 1];
- System.arraycopy(myInstanceFilters, 0, filters, 0, myInstanceFilters.length);
- filters[myInstanceFilters.length] = InstanceFilter.create(String.valueOf(l));
- myInstanceFilters = filters;
- }
-
- public final ClassFilter[] getClassFilters() {
- return myClassFilters;
- }
-
- public final void setClassFilters(ClassFilter[] classFilters) {
- myClassFilters = classFilters != null? classFilters : ClassFilter.EMPTY_ARRAY;
- }
-
- public ClassFilter[] getClassExclusionFilters() {
- return myClassExclusionFilters;
- }
-
- public void setClassExclusionFilters(ClassFilter[] classExclusionFilters) {
- myClassExclusionFilters = classExclusionFilters != null? classExclusionFilters : ClassFilter.EMPTY_ARRAY;
- }
-
- public void readExternal(Element parentNode) throws InvalidDataException {
- DefaultJDOMExternalizer.readExternal(this, parentNode);
- if (DebuggerSettings.SUSPEND_NONE.equals(SUSPEND_POLICY)) { // compatibility with older format
- SUSPEND = false;
- SUSPEND_POLICY = DebuggerSettings.SUSPEND_ALL;
- }
- String condition = JDOMExternalizerUtil.readField(parentNode, CONDITION_OPTION_NAME);
- if (condition != null) {
- setCondition(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, condition));
- }
-
- myClassFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(FILTER_OPTION_NAME));
- myClassExclusionFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(EXCLUSION_FILTER_OPTION_NAME));
-
- final ClassFilter [] instanceFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(INSTANCE_ID_OPTION_NAME));
- final List iFilters = new ArrayList(instanceFilters.length);
-
- for (ClassFilter instanceFilter : instanceFilters) {
- try {
- iFilters.add(InstanceFilter.create(instanceFilter));
- }
- catch (Exception e) {
- }
- }
- myInstanceFilters = iFilters.isEmpty() ? InstanceFilter.EMPTY_ARRAY : iFilters.toArray(new InstanceFilter[iFilters.size()]);
- }
-
- public void writeExternal(Element parentNode) throws WriteExternalException {
- DefaultJDOMExternalizer.writeExternal(this, parentNode);
- JDOMExternalizerUtil.writeField(parentNode, CONDITION_OPTION_NAME, getCondition().toExternalForm());
- DebuggerUtilsEx.writeFilters(parentNode, FILTER_OPTION_NAME, myClassFilters);
- DebuggerUtilsEx.writeFilters(parentNode, EXCLUSION_FILTER_OPTION_NAME, myClassExclusionFilters);
- DebuggerUtilsEx.writeFilters(parentNode, INSTANCE_ID_OPTION_NAME, InstanceFilter.createClassFilters(myInstanceFilters));
- }
-
- public boolean evaluateCondition(final EvaluationContextImpl context, LocatableEvent event) throws EvaluateException {
- if(COUNT_FILTER_ENABLED) {
- final DebugProcessImpl debugProcess = context.getDebugProcess();
- debugProcess.getVirtualMachineProxy().suspend();
- debugProcess.getRequestsManager().deleteRequest(this);
- ((Breakpoint)this).createRequest(debugProcess);
- debugProcess.getVirtualMachineProxy().resume();
- }
- if (INSTANCE_FILTERS_ENABLED) {
- Value value = context.getThisObject();
- if (value != null) { // non-static
- ObjectReference reference = (ObjectReference)value;
- if(!hasObjectID(reference.uniqueID())) {
- return false;
- }
- }
- }
-
- if (CLASS_FILTERS_ENABLED) {
- String typeName = calculateEventClass(context, event);
- if (!typeMatchesClassFilters(typeName)) return false;
- }
-
- if (CONDITION_ENABLED && getCondition() != null && !"".equals(getCondition().getText())) {
- try {
- ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(context.getProject(), new EvaluatingComputable() {
- public ExpressionEvaluator compute() throws EvaluateException {
- final SourcePosition contextSourcePosition = ContextUtil.getSourcePosition(context);
- // IMPORTANT: calculate context psi element basing on the location where the exception
- // has been hit, not on the location where it was set. (For line breakpoints these locations are the same, however,
- // for method, exception and field breakpoints these locations differ)
- PsiElement contextPsiElement = ContextUtil.getContextElement(contextSourcePosition);
- if (contextPsiElement == null) {
- contextPsiElement = getEvaluationElement(); // as a last resort
- }
- return EvaluatorBuilderImpl.build(getCondition(), contextPsiElement, contextSourcePosition);
- }
- });
- final Value value = evaluator.evaluate(context);
- if (!(value instanceof BooleanValue)) {
- throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.boolean.expected"));
- }
- if(!((BooleanValue)value).booleanValue()) {
- return false;
- }
- }
- catch (EvaluateException ex) {
- if(ex.getCause() instanceof VMDisconnectedException) {
- return false;
- }
- throw EvaluateExceptionUtil.createEvaluateException(
- DebuggerBundle.message("error.failed.evaluating.breakpoint.condition", getCondition(), ex.getMessage())
- );
- }
- return true;
- }
-
- return true;
- }
-
- protected String calculateEventClass(EvaluationContextImpl context, LocatableEvent event) throws EvaluateException {
- return event.location().declaringType().name();
- }
-
- private boolean typeMatchesClassFilters(@Nullable String typeName) {
- if (typeName == null) {
- return true;
- }
- boolean matches = false, hasEnabled = false;
- for (ClassFilter classFilter : getClassFilters()) {
- if (classFilter.isEnabled()) {
- hasEnabled = true;
- if (classFilter.matches(typeName)) {
- matches = true;
- break;
- }
- }
- }
- if(hasEnabled && !matches) {
- return false;
- }
- for (ClassFilter classFilter : getClassExclusionFilters()) {
- if (classFilter.isEnabled() && classFilter.matches(typeName)) {
- return false;
- }
- }
- return true;
- }
-
- public abstract PsiElement getEvaluationElement();
-
- public TextWithImports getCondition() {
- return myCondition;
- }
-
- public void setCondition(TextWithImports condition) {
- myCondition = condition;
- }
-
- public Project getProject() {
- return myProject;
- }
+ boolean isClassFiltersEnabled();
+ ClassFilter[] getClassFilters();
+ ClassFilter[] getClassExclusionFilters();
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestorImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestorImpl.java
new file mode 100644
index 000000000000..2637773cb0cc
--- /dev/null
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestorImpl.java
@@ -0,0 +1,243 @@
+/*
+ * Copyright 2000-2009 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * class FilteredRequestorImpl
+ * @author Jeka
+ */
+package com.intellij.debugger.ui.breakpoints;
+
+import com.intellij.debugger.InstanceFilter;
+import com.intellij.debugger.engine.evaluation.*;
+import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
+import com.intellij.debugger.impl.DebuggerUtilsEx;
+import com.intellij.debugger.settings.DebuggerSettings;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.*;
+import com.intellij.psi.PsiElement;
+import com.intellij.ui.classFilter.ClassFilter;
+import com.sun.jdi.event.LocatableEvent;
+import org.jdom.Element;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/*
+ * Not used any more, since move to xBreakpoints
+ */
+public class FilteredRequestorImpl implements JDOMExternalizable, FilteredRequestor {
+
+ public String SUSPEND_POLICY = DebuggerSettings.SUSPEND_ALL;
+ public boolean SUSPEND = true;
+
+ public boolean COUNT_FILTER_ENABLED = false;
+ public int COUNT_FILTER = 0;
+
+ public boolean CONDITION_ENABLED = false;
+ private TextWithImports myCondition;
+
+ public boolean CLASS_FILTERS_ENABLED = false;
+ private ClassFilter[] myClassFilters = ClassFilter.EMPTY_ARRAY;
+ private ClassFilter[] myClassExclusionFilters = ClassFilter.EMPTY_ARRAY;
+
+ public boolean INSTANCE_FILTERS_ENABLED = false;
+ private InstanceFilter[] myInstanceFilters = InstanceFilter.EMPTY_ARRAY;
+
+ @NonNls private static final String FILTER_OPTION_NAME = "filter";
+ @NonNls private static final String EXCLUSION_FILTER_OPTION_NAME = "exclusion_filter";
+ @NonNls private static final String INSTANCE_ID_OPTION_NAME = "instance_id";
+ @NonNls private static final String CONDITION_OPTION_NAME = "CONDITION";
+ protected final Project myProject;
+
+ public FilteredRequestorImpl(@NotNull Project project) {
+ myProject = project;
+ myCondition = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, "");
+ }
+
+ public InstanceFilter[] getInstanceFilters() {
+ return myInstanceFilters;
+ }
+
+ public void setInstanceFilters(InstanceFilter[] instanceFilters) {
+ myInstanceFilters = instanceFilters != null? instanceFilters : InstanceFilter.EMPTY_ARRAY;
+ }
+
+ public String getSuspendPolicy() {
+ return SUSPEND? SUSPEND_POLICY : DebuggerSettings.SUSPEND_NONE;
+ }
+
+ /**
+ * @return true if the ID was added or false otherwise
+ */
+ private boolean hasObjectID(long id) {
+ for (InstanceFilter instanceFilter : myInstanceFilters) {
+ if (instanceFilter.getId() == id) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected void addInstanceFilter(long l) {
+ final InstanceFilter[] filters = new InstanceFilter[myInstanceFilters.length + 1];
+ System.arraycopy(myInstanceFilters, 0, filters, 0, myInstanceFilters.length);
+ filters[myInstanceFilters.length] = InstanceFilter.create(String.valueOf(l));
+ myInstanceFilters = filters;
+ }
+
+ public final ClassFilter[] getClassFilters() {
+ return myClassFilters;
+ }
+
+ public final void setClassFilters(ClassFilter[] classFilters) {
+ myClassFilters = classFilters != null? classFilters : ClassFilter.EMPTY_ARRAY;
+ }
+
+ public ClassFilter[] getClassExclusionFilters() {
+ return myClassExclusionFilters;
+ }
+
+ public void setClassExclusionFilters(ClassFilter[] classExclusionFilters) {
+ myClassExclusionFilters = classExclusionFilters != null? classExclusionFilters : ClassFilter.EMPTY_ARRAY;
+ }
+
+ public void readTo(Element parentNode, Breakpoint breakpoint) throws InvalidDataException {
+ readExternal(parentNode);
+ if (SUSPEND) {
+ breakpoint.setSuspendPolicy(SUSPEND_POLICY);
+ }
+ else {
+ breakpoint.setSuspendPolicy(DebuggerSettings.SUSPEND_NONE);
+ }
+
+ breakpoint.setCountFilterEnabled(COUNT_FILTER_ENABLED);
+ breakpoint.setCountFilter(COUNT_FILTER);
+
+ breakpoint.setCondition(CONDITION_ENABLED && myCondition != null && !myCondition.getText().isEmpty() ? myCondition.getText() : null);
+
+ breakpoint.setClassFiltersEnabled(CLASS_FILTERS_ENABLED);
+ breakpoint.setClassFilters(getClassFilters());
+ breakpoint.setClassExclusionFilters(getClassExclusionFilters());
+
+ breakpoint.setInstanceFiltersEnabled(INSTANCE_FILTERS_ENABLED);
+ breakpoint.setInstanceFilters(getInstanceFilters());
+ }
+
+ public void readExternal(Element parentNode) throws InvalidDataException {
+ DefaultJDOMExternalizer.readExternal(this, parentNode);
+ if (DebuggerSettings.SUSPEND_NONE.equals(SUSPEND_POLICY)) { // compatibility with older format
+ SUSPEND = false;
+ SUSPEND_POLICY = DebuggerSettings.SUSPEND_ALL;
+ }
+ String condition = JDOMExternalizerUtil.readField(parentNode, CONDITION_OPTION_NAME);
+ if (condition != null) {
+ setCondition(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, condition));
+ }
+
+ myClassFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(FILTER_OPTION_NAME));
+ myClassExclusionFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(EXCLUSION_FILTER_OPTION_NAME));
+
+ final ClassFilter [] instanceFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(INSTANCE_ID_OPTION_NAME));
+ final List iFilters = new ArrayList(instanceFilters.length);
+
+ for (ClassFilter instanceFilter : instanceFilters) {
+ try {
+ iFilters.add(InstanceFilter.create(instanceFilter));
+ }
+ catch (Exception e) {
+ }
+ }
+ myInstanceFilters = iFilters.isEmpty() ? InstanceFilter.EMPTY_ARRAY : iFilters.toArray(new InstanceFilter[iFilters.size()]);
+ }
+
+ public void writeExternal(Element parentNode) throws WriteExternalException {
+ DefaultJDOMExternalizer.writeExternal(this, parentNode);
+ JDOMExternalizerUtil.writeField(parentNode, CONDITION_OPTION_NAME, getCondition().toExternalForm());
+ DebuggerUtilsEx.writeFilters(parentNode, FILTER_OPTION_NAME, myClassFilters);
+ DebuggerUtilsEx.writeFilters(parentNode, EXCLUSION_FILTER_OPTION_NAME, myClassExclusionFilters);
+ DebuggerUtilsEx.writeFilters(parentNode, INSTANCE_ID_OPTION_NAME, InstanceFilter.createClassFilters(myInstanceFilters));
+ }
+
+ protected String calculateEventClass(EvaluationContextImpl context, LocatableEvent event) throws EvaluateException {
+ return event.location().declaringType().name();
+ }
+
+ private boolean typeMatchesClassFilters(@Nullable String typeName) {
+ if (typeName == null) {
+ return true;
+ }
+ boolean matches = false, hasEnabled = false;
+ for (ClassFilter classFilter : getClassFilters()) {
+ if (classFilter.isEnabled()) {
+ hasEnabled = true;
+ if (classFilter.matches(typeName)) {
+ matches = true;
+ break;
+ }
+ }
+ }
+ if(hasEnabled && !matches) {
+ return false;
+ }
+ for (ClassFilter classFilter : getClassExclusionFilters()) {
+ if (classFilter.isEnabled() && classFilter.matches(typeName)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public PsiElement getEvaluationElement() {
+ return null;
+ }
+
+ public TextWithImports getCondition() {
+ return myCondition;
+ }
+
+ public void setCondition(TextWithImports condition) {
+ myCondition = condition;
+ }
+
+ public Project getProject() {
+ return myProject;
+ }
+
+ public boolean isCountFilterEnabled() {
+ return COUNT_FILTER_ENABLED;
+ }
+
+ public int getCountFilter() {
+ return COUNT_FILTER;
+ }
+
+ public boolean isClassFiltersEnabled() {
+ return CLASS_FILTERS_ENABLED;
+ }
+
+ public boolean isInstanceFiltersEnabled() {
+ return INSTANCE_FILTERS_ENABLED;
+ }
+
+ @Override
+ public boolean processLocatableEvent(SuspendContextCommandImpl action, LocatableEvent event)
+ throws EventProcessingException {
+ return false;
+ }
+}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointItem.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointItem.java
deleted file mode 100644
index ec3577cbae0a..000000000000
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointItem.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright 2000-2012 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.debugger.ui.breakpoints;
-
-import com.intellij.debugger.DebuggerManagerEx;
-import com.intellij.debugger.SourcePosition;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.ui.SimpleColoredComponent;
-import com.intellij.ui.SimpleTextAttributes;
-import com.intellij.ui.popup.util.DetailView;
-import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import javax.swing.*;
-
-class JavaBreakpointItem extends BreakpointItem {
- private final Breakpoint myBreakpoint;
- private BreakpointFactory myBreakpointFactory;
- private BreakpointPropertiesPanel myBreakpointPropertiesPanel;
-
- public JavaBreakpointItem(@Nullable BreakpointFactory breakpointFactory, Breakpoint breakpoint) {
- myBreakpointFactory = breakpointFactory;
- myBreakpoint = breakpoint;
- }
-
- @Override
- public void setupGenericRenderer(SimpleColoredComponent renderer, boolean plainView) {
- if (plainView) {
- renderer.setIcon(myBreakpoint.getIcon());
- }
- renderer.append(plainView ? StringUtil.shortenTextWithEllipsis(myBreakpoint.getShortName(), 60, 0) : myBreakpoint.getDisplayName(),
- isEnabled() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES);
- }
-
- @Override
- public Icon getIcon() {
- return myBreakpoint.getIcon();
- }
-
- @Override
- public String getDisplayText() {
- return myBreakpoint.getDisplayName();
- }
-
- @Override
- public String speedSearchText() {
- return myBreakpoint.getDisplayName();
- }
-
- @Override
- public String footerText() {
- return myBreakpoint.getDisplayName();
- }
-
- @Override
- protected void doUpdateDetailView(DetailView panel, boolean editorOnly) {
- //saveState();
- if (myBreakpointPropertiesPanel != null) {
- myBreakpointPropertiesPanel.dispose();
- myBreakpointPropertiesPanel = null;
- }
-
- if (!editorOnly) {
- myBreakpointPropertiesPanel = myBreakpointFactory != null ? myBreakpointFactory
- .createBreakpointPropertiesPanel(myBreakpoint.getProject(), false) : null;
-
- if (myBreakpointPropertiesPanel != null) {
- myBreakpointPropertiesPanel.initFrom(myBreakpoint, true);
-
- final JPanel mainPanel = myBreakpointPropertiesPanel.getPanel();
- panel.setPropertiesPanel(mainPanel);
- }
- else {
- panel.setPropertiesPanel(null);
- }
- }
-
- if (myBreakpoint instanceof BreakpointWithHighlighter) {
- SourcePosition sourcePosition = ((BreakpointWithHighlighter)myBreakpoint).getSourcePosition();
- VirtualFile virtualFile = sourcePosition.getFile().getVirtualFile();
- showInEditor(panel, virtualFile, sourcePosition.getLine());
- } else {
- panel.clearEditor();
- }
- if (myBreakpointPropertiesPanel != null) {
- myBreakpointPropertiesPanel.setDetailView(panel);
- }
- }
-
- @Override
- public void navigate(boolean requestFocus) {
- if (myBreakpoint instanceof BreakpointWithHighlighter) {
- ((BreakpointWithHighlighter)myBreakpoint).getSourcePosition().navigate(requestFocus);
- }
- }
-
- @Override
- public boolean canNavigate() {
- return myBreakpoint instanceof BreakpointWithHighlighter && ((BreakpointWithHighlighter)myBreakpoint).getSourcePosition().canNavigate();
- }
-
- @Override
- public boolean canNavigateToSource() {
- return myBreakpoint instanceof BreakpointWithHighlighter &&
- ((BreakpointWithHighlighter)myBreakpoint).getSourcePosition().canNavigateToSource();
- }
-
- @Override
- public boolean allowedToRemove() {
- return myBreakpointFactory != null && myBreakpointFactory.breakpointCanBeRemoved(myBreakpoint);
- }
-
- @Override
- public void removed(Project project) {
- dispose();
- DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().removeBreakpoint(myBreakpoint);
- }
-
- @Override
- public void saveState() {
- if (myBreakpointPropertiesPanel != null) {
- myBreakpointPropertiesPanel.saveTo(myBreakpoint);
- }
- }
-
- @Override
- public Object getBreakpoint() {
- return myBreakpoint;
- }
-
- @Override
- public boolean isEnabled() {
- return myBreakpoint.ENABLED;
- }
-
- @Override
- public void setEnabled(boolean state) {
- myBreakpoint.ENABLED = state;
- myBreakpoint.updateUI();
- DebuggerManagerEx.getInstanceEx(myBreakpoint.getProject()).getBreakpointManager().fireBreakpointChanged(myBreakpoint);
- }
-
- @Override
- public boolean isDefaultBreakpoint() {
- return myBreakpoint.getCategory().equals(ExceptionBreakpoint.CATEGORY);
- }
-
- @Override
- protected void dispose() {
- if (myBreakpointPropertiesPanel != null) {
- myBreakpointPropertiesPanel.dispose();
- myBreakpointPropertiesPanel = null;
- }
- }
-
- @Override
- public int compareTo(@NotNull BreakpointItem breakpointItem) {
- final Object breakpoint = breakpointItem.getBreakpoint();
- if (breakpoint instanceof Breakpoint) {
- return -getIndexOf(myBreakpoint) + getIndexOf((Breakpoint)breakpoint);
- }
- return getDisplayText().compareTo(breakpointItem.getDisplayText());
- }
-
- private int getIndexOf(Breakpoint breakpoint) {
- return DebuggerManagerEx.getInstanceEx(myBreakpoint.getProject()).getBreakpointManager().getBreakpoints().indexOf(breakpoint);
- }
-}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpointPropertiesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointType.java
similarity index 62%
rename from java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpointPropertiesPanel.java
rename to java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointType.java
index 802657b44fd9..2776032a2f4f 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpointPropertiesPanel.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointType.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,17 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/*
- * Class LineBreakpointPropertiesPanel
- * @author Jeka
- */
package com.intellij.debugger.ui.breakpoints;
import com.intellij.openapi.project.Project;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties;
-public class LineBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
- public LineBreakpointPropertiesPanel(Project project, boolean compact) {
- super(project, LineBreakpoint.CATEGORY, compact);
- }
-}
\ No newline at end of file
+/**
+ * Base class for all Java breakpoint types
+ * @author egor
+ */
+public interface JavaBreakpointType {
+ Breakpoint createJavaBreakpoint(Project project, XBreakpoint
breakpoint);
+}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointTypeBase.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointTypeBase.java
new file mode 100644
index 000000000000..69a5dbb32455
--- /dev/null
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointTypeBase.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.debugger.ui.breakpoints;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
+import com.intellij.xdebugger.breakpoints.XBreakpointType;
+import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
+import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.java.debugger.JavaDebuggerEditorsProvider;
+import org.jetbrains.java.debugger.breakpoints.JavaBreakpointFiltersPanel;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties;
+
+/**
+ * Base class for non-line java breakpoint
+ * @author egor
+ */
+public abstract class JavaBreakpointTypeBase extends XBreakpointType, T> {
+ protected JavaBreakpointTypeBase(@NonNls @NotNull String id, @Nls @NotNull String title) {
+ super(id, title, true);
+ }
+
+ @Override
+ public final boolean isAddBreakpointButtonVisible() {
+ return true;
+ }
+
+ @Nullable
+ @Override
+ public final XBreakpointCustomPropertiesPanel> createCustomRightPropertiesPanel(@NotNull Project project) {
+ return new JavaBreakpointFiltersPanel>(project);
+ }
+
+ @Nullable
+ @Override
+ public final XDebuggerEditorsProvider getEditorsProvider(@NotNull XBreakpoint breakpoint, @NotNull Project project) {
+ return new JavaDebuggerEditorsProvider();
+ }
+}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaExceptionBreakpointType.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaExceptionBreakpointType.java
new file mode 100644
index 000000000000..f19157b5bf7d
--- /dev/null
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaExceptionBreakpointType.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2000-2009 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.debugger.ui.breakpoints;
+
+import com.intellij.debugger.DebuggerBundle;
+import com.intellij.debugger.HelpID;
+import com.intellij.debugger.engine.JVMNameUtil;
+import com.intellij.icons.AllIcons;
+import com.intellij.ide.util.TreeClassChooser;
+import com.intellij.ide.util.TreeClassChooserFactory;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Computable;
+import com.intellij.psi.JavaPsiFacade;
+import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiClassOwner;
+import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.xdebugger.XDebuggerManager;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
+import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpointProperties;
+
+import javax.swing.*;
+
+/**
+ * @author Eugene Zhuravlev
+ * Date: Apr 26, 2005
+ */
+public class JavaExceptionBreakpointType extends JavaBreakpointTypeBase
+ implements JavaBreakpointType {
+ public JavaExceptionBreakpointType() {
+ super("java-exception", DebuggerBundle.message("exception.breakpoints.tab.title"));
+ }
+
+ @NotNull
+ @Override
+ public Icon getEnabledIcon() {
+ return AllIcons.Debugger.Db_exception_breakpoint;
+ }
+
+ @NotNull
+ @Override
+ public Icon getDisabledIcon() {
+ return AllIcons.Debugger.Db_disabled_exception_breakpoint;
+ }
+
+ //@Override
+ protected String getHelpID() {
+ return HelpID.EXCEPTION_BREAKPOINTS;
+ }
+
+ //@Override
+ public String getDisplayName() {
+ return DebuggerBundle.message("exception.breakpoints.tab.title");
+ }
+
+ @Override
+ public String getDisplayText(XBreakpoint breakpoint) {
+ String name = breakpoint.getProperties().myQualifiedName;
+ if (name != null) {
+ return DebuggerBundle.message("breakpoint.exception.breakpoint.display.name", name);
+ }
+ else {
+ return DebuggerBundle.message("breakpoint.any.exception.display.name");
+ }
+ }
+
+ @Nullable
+ @Override
+ public JavaExceptionBreakpointProperties createProperties() {
+ return new JavaExceptionBreakpointProperties();
+ }
+
+ @Nullable
+ @Override
+ public XBreakpointCustomPropertiesPanel> createCustomPropertiesPanel() {
+ return new ExceptionBreakpointPropertiesPanel();
+ }
+
+ @Nullable
+ @Override
+ public XBreakpoint createDefaultBreakpoint(@NotNull XBreakpointCreator creator) {
+ return creator.createBreakpoint(new JavaExceptionBreakpointProperties());
+ }
+
+ //public Key getBreakpointCategory() {
+ // return ExceptionBreakpoint.CATEGORY;
+ //}
+
+ @Nullable
+ @Override
+ public XBreakpoint addBreakpoint(final Project project, JComponent parentComponent) {
+ final PsiClass throwableClass =
+ JavaPsiFacade.getInstance(project).findClass("java.lang.Throwable", GlobalSearchScope.allScope(project));
+ TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project)
+ .createInheritanceClassChooser(DebuggerBundle.message("add.exception.breakpoint.classchooser.title"),
+ GlobalSearchScope.allScope(project), throwableClass, true, true, null);
+ chooser.showDialog();
+ final PsiClass selectedClass = chooser.getSelected();
+ final String qName = selectedClass == null ? null : JVMNameUtil.getNonAnonymousClassName(selectedClass);
+
+ if (qName != null && qName.length() > 0) {
+ return ApplicationManager.getApplication().runWriteAction(new Computable>() {
+ @Override
+ public XBreakpoint compute() {
+ return XDebuggerManager.getInstance(project).getBreakpointManager().addBreakpoint(
+ JavaExceptionBreakpointType.this, new JavaExceptionBreakpointProperties(qName, ((PsiClassOwner)selectedClass.getContainingFile()).getPackageName()));
+ }
+ });
+ }
+ return null;
+ }
+
+ @Override
+ public Breakpoint createJavaBreakpoint(Project project, XBreakpoint breakpoint) {
+ if (breakpoint.getProperties().myQualifiedName != null) {
+ return new ExceptionBreakpoint(project, breakpoint);
+ }
+ else {
+ return new AnyExceptionBreakpoint(project, breakpoint);
+ }
+ }
+}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaFieldBreakpointType.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaFieldBreakpointType.java
new file mode 100644
index 000000000000..66b8284ae4cb
--- /dev/null
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaFieldBreakpointType.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2000-2009 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.debugger.ui.breakpoints;
+
+import com.intellij.CommonBundle;
+import com.intellij.debugger.DebuggerBundle;
+import com.intellij.debugger.HelpID;
+import com.intellij.icons.AllIcons;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.util.Ref;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.*;
+import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.xdebugger.XDebuggerManager;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
+import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
+import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaFieldBreakpointProperties;
+
+import javax.swing.*;
+
+/**
+ * @author Eugene Zhuravlev
+ * Date: Apr 26, 2005
+ */
+public class JavaFieldBreakpointType extends JavaLineBreakpointTypeBase implements JavaBreakpointType {
+ public JavaFieldBreakpointType() {
+ super("java-field", DebuggerBundle.message("field.watchpoints.tab.title"));
+ }
+
+ @NotNull
+ @Override
+ public Icon getEnabledIcon() {
+ return AllIcons.Debugger.Db_field_breakpoint;
+ }
+
+ @NotNull
+ @Override
+ public Icon getDisabledIcon() {
+ return AllIcons.Debugger.Db_disabled_field_breakpoint;
+ }
+
+ //@Override
+ protected String getHelpID() {
+ return HelpID.FIELD_WATCHPOINTS;
+ }
+
+ //@Override
+ public String getDisplayName() {
+ return DebuggerBundle.message("field.watchpoints.tab.title");
+ }
+
+ @Override
+ public String getShortText(XLineBreakpoint breakpoint) {
+ return getDisplayText(breakpoint);
+ }
+
+ @Override
+ public String getDisplayText(XLineBreakpoint breakpoint) {
+ //if(!isValid()) {
+ // return DebuggerBundle.message("status.breakpoint.invalid");
+ //}
+
+ JavaFieldBreakpointProperties properties = breakpoint.getProperties();
+ final String className = properties.myClassName;
+ return className != null && !className.isEmpty() ? className + "." + properties.myFieldName : properties.myFieldName;
+ }
+
+ @Nullable
+ @Override
+ public XBreakpointCustomPropertiesPanel> createCustomPropertiesPanel() {
+ return new FieldBreakpointPropertiesPanel();
+ }
+
+ @Nullable
+ @Override
+ public JavaFieldBreakpointProperties createProperties() {
+ return new JavaFieldBreakpointProperties();
+ }
+
+ @Nullable
+ @Override
+ public JavaFieldBreakpointProperties createBreakpointProperties(@NotNull VirtualFile file, int line) {
+ return new JavaFieldBreakpointProperties();
+ }
+
+ @Nullable
+ @Override
+ public XLineBreakpoint addBreakpoint(final Project project, JComponent parentComponent) {
+ final Ref result = Ref.create(null);
+ AddFieldBreakpointDialog dialog = new AddFieldBreakpointDialog(project) {
+ protected boolean validateData() {
+ final String className = getClassName();
+ if (className.length() == 0) {
+ Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.class.name.not.specified"),
+ DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon());
+ return false;
+ }
+ final String fieldName = getFieldName();
+ if (fieldName.length() == 0) {
+ Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.field.name.not.specified"),
+ DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon());
+ return false;
+ }
+ PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(className, GlobalSearchScope.allScope(project));
+ if (psiClass != null) {
+ final PsiFile psiFile = psiClass.getContainingFile();
+ Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
+ if(document != null) {
+ PsiField field = psiClass.findFieldByName(fieldName, true);
+ if(field != null) {
+ final int line = document.getLineNumber(field.getTextOffset());
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ @Override
+ public void run() {
+ XLineBreakpoint fieldBreakpoint = XDebuggerManager.getInstance(project).getBreakpointManager()
+ .addLineBreakpoint(JavaFieldBreakpointType.this, psiFile.getVirtualFile().getUrl(), line, new JavaFieldBreakpointProperties(fieldName, className));
+ result.set(fieldBreakpoint);
+ }
+ });
+ return true;
+ }
+ else {
+ Messages.showMessageDialog(project,
+ DebuggerBundle.message("error.field.breakpoint.field.not.found", className, fieldName, fieldName),
+ CommonBundle.getErrorTitle(),
+ Messages.getErrorIcon()
+ );
+ }
+ }
+ } else {
+ Messages.showMessageDialog(project,
+ DebuggerBundle.message("error.field.breakpoint.class.sources.not.found", className, fieldName, className),
+ CommonBundle.getErrorTitle(),
+ Messages.getErrorIcon()
+ );
+ }
+ return false;
+ }
+ };
+ dialog.show();
+ return result.get();
+ }
+
+ @Override
+ public Breakpoint createJavaBreakpoint(Project project, XBreakpoint breakpoint) {
+ return new FieldBreakpoint(project, breakpoint);
+ }
+}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointType.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointType.java
new file mode 100644
index 000000000000..4f67e68d9003
--- /dev/null
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointType.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.debugger.ui.breakpoints;
+
+import com.intellij.debugger.DebuggerBundle;
+import com.intellij.debugger.HelpID;
+import com.intellij.icons.AllIcons;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.xdebugger.XDebuggerUtil;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
+import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
+import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaLineBreakpointProperties;
+
+import javax.swing.*;
+import java.util.List;
+
+/**
+ * Base class for java line-connected exceptions (line, method, field)
+ * @author egor
+ */
+public class JavaLineBreakpointType extends JavaLineBreakpointTypeBase implements JavaBreakpointType {
+ public JavaLineBreakpointType() {
+ super("java-line", DebuggerBundle.message("line.breakpoints.tab.title"));
+ }
+
+ @NotNull
+ @Override
+ public Icon getEnabledIcon() {
+ return AllIcons.Debugger.Db_set_breakpoint;
+ }
+
+ @NotNull
+ @Override
+ public Icon getDisabledIcon() {
+ return AllIcons.Debugger.Db_disabled_breakpoint;
+ }
+
+ //@Override
+ protected String getHelpID() {
+ return HelpID.LINE_BREAKPOINTS;
+ }
+
+ //@Override
+ public String getDisplayName() {
+ return DebuggerBundle.message("line.breakpoints.tab.title");
+ }
+
+ @Override
+ public List, ?>> getGroupingRules() {
+ return XDebuggerUtil.getInstance().getGroupingByFileRuleAsList();
+ }
+
+ @Nullable
+ @Override
+ public JavaBreakpointProperties createProperties() {
+ return new JavaLineBreakpointProperties();
+ }
+
+ @Nullable
+ @Override
+ public JavaBreakpointProperties createBreakpointProperties(@NotNull VirtualFile file, int line) {
+ return new JavaLineBreakpointProperties();
+ }
+
+ @Override
+ public Breakpoint createJavaBreakpoint(Project project, XBreakpoint breakpoint) {
+ return new LineBreakpoint(project, breakpoint);
+ }
+}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointTypeBase.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointTypeBase.java
new file mode 100644
index 000000000000..b9d68e3b56a8
--- /dev/null
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointTypeBase.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2000-2009 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.debugger.ui.breakpoints;
+
+import com.intellij.debugger.engine.DebuggerUtils;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.fileEditor.FileDocumentManager;
+import com.intellij.openapi.fileTypes.FileType;
+import com.intellij.openapi.fileTypes.StdFileTypes;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Ref;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.*;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.Processor;
+import com.intellij.xdebugger.XDebuggerUtil;
+import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
+import com.intellij.xdebugger.breakpoints.XLineBreakpointType;
+import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
+import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.java.debugger.JavaDebuggerEditorsProvider;
+import org.jetbrains.java.debugger.breakpoints.JavaBreakpointFiltersPanel;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties;
+
+/**
+ * Base class for java line-connected exceptions (line, method, field)
+ * @author egor
+ */
+public abstract class JavaLineBreakpointTypeBase extends XLineBreakpointType
{
+ public JavaLineBreakpointTypeBase(@NonNls @NotNull String id, @Nls @NotNull String title) {
+ super(id, title);
+ }
+
+ @Override
+ public boolean isAddBreakpointButtonVisible() {
+ return true;
+ }
+
+ @Override
+ public final boolean isSuspendThreadSupported() {
+ return true;
+ }
+
+ @Nullable
+ @Override
+ public final XBreakpointCustomPropertiesPanel> createCustomRightPropertiesPanel(@NotNull Project project) {
+ return new JavaBreakpointFiltersPanel>(project);
+ }
+
+ @Nullable
+ @Override
+ public final XDebuggerEditorsProvider getEditorsProvider(@NotNull XLineBreakpoint
breakpoint, @NotNull Project project) {
+ return new JavaDebuggerEditorsProvider();
+ }
+
+ @Override
+ public final boolean canPutAt(@NotNull VirtualFile file, final int line, @NotNull Project project) {
+ PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
+ // JSPX supports jvm debugging, but not in XHTML files
+ if (psiFile == null || psiFile.getVirtualFile().getFileType() == StdFileTypes.XHTML) {
+ return false;
+ }
+
+ FileType fileType = psiFile.getFileType();
+ if (!StdFileTypes.CLASS.equals(fileType) &&
+ !DebuggerUtils.supportsJVMDebugging(fileType) &&
+ !DebuggerUtils.supportsJVMDebugging(psiFile)) {
+ return false;
+ }
+
+ final Document document = FileDocumentManager.getInstance().getDocument(file);
+ final Ref> result = Ref.create();
+ XDebuggerUtil.getInstance().iterateLine(project, document, line, new Processor() {
+ @Override
+ public boolean process(PsiElement element) {
+ // avoid comments
+ if ((element instanceof PsiWhiteSpace) || (PsiTreeUtil.getParentOfType(element, PsiComment.class, false) != null)) {
+ return true;
+ }
+ // first check fields
+ PsiField field = PsiTreeUtil.getParentOfType(element, PsiField.class, false);
+ if(field != null) {
+ result.set(JavaFieldBreakpointType.class);
+ return false;
+ }
+ // then methods
+ PsiMethod method = PsiTreeUtil.getParentOfType(element, PsiMethod.class, false);
+ if(method != null && document.getLineNumber(method.getTextOffset()) == line) {
+ result.set(JavaMethodBreakpointType.class);
+ return false;
+ }
+ // then regular statements
+ PsiElement child = element;
+ while(element != null) {
+
+ final int offset = element.getTextOffset();
+ if (offset >= 0) {
+ if (document.getLineNumber(offset) != line) {
+ break;
+ }
+ }
+ child = element;
+ element = element.getParent();
+ }
+
+ if(child instanceof PsiMethod && child.getTextRange().getEndOffset() >= document.getLineEndOffset(line)) {
+ PsiCodeBlock body = ((PsiMethod)child).getBody();
+ if(body != null) {
+ PsiStatement[] statements = body.getStatements();
+ if (statements.length > 0 && document.getLineNumber(statements[0].getTextOffset()) == line) {
+ result.set(JavaLineBreakpointType.class);
+ }
+ }
+ }
+ else {
+ result.set(JavaLineBreakpointType.class);
+ }
+ return true;
+ }
+ });
+ return result.get() == getClass();
+ }
+}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaMethodBreakpointType.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaMethodBreakpointType.java
new file mode 100644
index 000000000000..3e4afd7ac5cb
--- /dev/null
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaMethodBreakpointType.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2000-2009 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.debugger.ui.breakpoints;
+
+import com.intellij.debugger.DebuggerBundle;
+import com.intellij.debugger.HelpID;
+import com.intellij.icons.AllIcons;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.StringBuilderSpinAllocator;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
+import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
+import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties;
+
+import javax.swing.*;
+
+/**
+ * @author Eugene Zhuravlev
+ * Date: Apr 26, 2005
+ */
+public class JavaMethodBreakpointType extends JavaLineBreakpointTypeBase implements JavaBreakpointType {
+ public JavaMethodBreakpointType() {
+ super("java-method", DebuggerBundle.message("method.breakpoints.tab.title"));
+ }
+
+ @NotNull
+ @Override
+ public Icon getEnabledIcon() {
+ return AllIcons.Debugger.Db_method_breakpoint;
+ }
+
+ @NotNull
+ @Override
+ public Icon getDisabledIcon() {
+ return AllIcons.Debugger.Db_disabled_method_breakpoint;
+ }
+
+ //@Override
+ protected String getHelpID() {
+ return HelpID.METHOD_BREAKPOINTS;
+ }
+
+ @Override
+ public boolean isAddBreakpointButtonVisible() {
+ return false;
+ }
+
+ //@Override
+ public String getDisplayName() {
+ return DebuggerBundle.message("method.breakpoints.tab.title");
+ }
+
+ @Override
+ public String getShortText(XLineBreakpoint breakpoint) {
+ return getDisplayText(breakpoint);
+ }
+
+ @Override
+ public String getDisplayText(XLineBreakpoint breakpoint) {
+ return getText(breakpoint);
+ }
+
+ static String getText(XBreakpoint breakpoint) {
+ final StringBuilder buffer = StringBuilderSpinAllocator.alloc();
+ try {
+ //if(isValid()) {
+ final String className = breakpoint.getProperties().myClassPattern;
+ final boolean classNameExists = className != null && className.length() > 0;
+ if (classNameExists) {
+ buffer.append(className);
+ }
+ if(breakpoint.getProperties().myMethodName != null) {
+ if (classNameExists) {
+ buffer.append(".");
+ }
+ buffer.append(breakpoint.getProperties().myMethodName);
+ }
+ //}
+ //else {
+ // buffer.append(DebuggerBundle.message("status.breakpoint.invalid"));
+ //}
+ return buffer.toString();
+ }
+ finally {
+ StringBuilderSpinAllocator.dispose(buffer);
+ }
+ }
+
+ @Nullable
+ @Override
+ public XBreakpointCustomPropertiesPanel createCustomPropertiesPanel() {
+ return new MethodBreakpointPropertiesPanel();
+ }
+
+ @Nullable
+ @Override
+ public JavaMethodBreakpointProperties createProperties() {
+ return new JavaMethodBreakpointProperties();
+ }
+
+ @Nullable
+ @Override
+ public JavaMethodBreakpointProperties createBreakpointProperties(@NotNull VirtualFile file, int line) {
+ return new JavaMethodBreakpointProperties();
+ }
+
+ @Override
+ public Breakpoint createJavaBreakpoint(Project project, XBreakpoint breakpoint) {
+ return new MethodBreakpoint(project, breakpoint);
+ }
+}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaWildcardMethodBreakpointType.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaWildcardMethodBreakpointType.java
new file mode 100644
index 000000000000..dd28ee241f1a
--- /dev/null
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaWildcardMethodBreakpointType.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.debugger.ui.breakpoints;
+
+import com.intellij.debugger.DebuggerBundle;
+import com.intellij.debugger.HelpID;
+import com.intellij.icons.AllIcons;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Computable;
+import com.intellij.xdebugger.XDebuggerManager;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
+import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties;
+
+import javax.swing.*;
+
+/**
+ * @author Egor
+ */
+public class JavaWildcardMethodBreakpointType extends JavaBreakpointTypeBase implements JavaBreakpointType {
+ public JavaWildcardMethodBreakpointType() {
+ super("java-wildcard-method", DebuggerBundle.message("method.breakpoints.tab.title"));
+ }
+
+ @NotNull
+ @Override
+ public Icon getEnabledIcon() {
+ return AllIcons.Debugger.Db_method_breakpoint;
+ }
+
+ @NotNull
+ @Override
+ public Icon getDisabledIcon() {
+ return AllIcons.Debugger.Db_disabled_method_breakpoint;
+ }
+
+ //@Override
+ protected String getHelpID() {
+ return HelpID.METHOD_BREAKPOINTS;
+ }
+
+ //@Override
+ public String getDisplayName() {
+ return DebuggerBundle.message("method.breakpoints.tab.title");
+ }
+
+ @Override
+ public String getDisplayText(XBreakpoint breakpoint) {
+ return JavaMethodBreakpointType.getText(breakpoint);
+ }
+
+ @Nullable
+ @Override
+ public XBreakpointCustomPropertiesPanel> createCustomPropertiesPanel() {
+ return new MethodBreakpointPropertiesPanel();
+ }
+
+ //@Override
+ //public Key getBreakpointCategory() {
+ // return MethodBreakpoint.CATEGORY;
+ //}
+
+ @Nullable
+ @Override
+ public JavaMethodBreakpointProperties createProperties() {
+ return new JavaMethodBreakpointProperties();
+ }
+
+ @Nullable
+ @Override
+ public XBreakpoint addBreakpoint(final Project project, JComponent parentComponent) {
+ final AddWildcardBreakpointDialog dialog = new AddWildcardBreakpointDialog(project);
+ dialog.show();
+ if (!dialog.isOK()) {
+ return null;
+ }
+ return ApplicationManager.getApplication().runWriteAction(new Computable>() {
+ @Override
+ public XBreakpoint compute() {
+ return XDebuggerManager.getInstance(project).getBreakpointManager().addBreakpoint(JavaWildcardMethodBreakpointType.this, new JavaMethodBreakpointProperties(
+ dialog.getClassPattern(),
+ dialog.getMethodName()));
+ }
+ });
+ }
+
+ @Override
+ public Breakpoint createJavaBreakpoint(Project project, XBreakpoint breakpoint) {
+ return new WildcardMethodBreakpoint(project, breakpoint);
+ }
+}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java
index 307b9629b99f..2b3239122373 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java
@@ -54,6 +54,7 @@ import com.intellij.util.Processor;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xdebugger.XDebuggerUtil;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.sun.jdi.*;
import com.sun.jdi.event.LocatableEvent;
import com.sun.jdi.request.BreakpointRequest;
@@ -74,12 +75,8 @@ public class LineBreakpoint extends BreakpointWithHighlighter {
private String myOwnerMethodName;
public static final @NonNls Key CATEGORY = BreakpointCategory.lookup("line_breakpoints");
- protected LineBreakpoint(Project project) {
- super(project);
- }
-
- public LineBreakpoint(Project project, RangeHighlighter highlighter) {
- super(project, highlighter);
+ protected LineBreakpoint(Project project, XBreakpoint xBreakpoint) {
+ super(project, xBreakpoint);
}
@Override
@@ -95,7 +92,7 @@ public class LineBreakpoint extends BreakpointWithHighlighter {
@Override
protected Icon getSetIcon(boolean isMuted) {
- if (REMOVE_AFTER_HIT) {
+ if (isRemoveAfterHit()) {
return isMuted ? AllIcons.Debugger.Db_muted_temporary_breakpoint : AllIcons.Debugger.Db_temporary_breakpoint;
}
return isMuted? AllIcons.Debugger.Db_muted_breakpoint : AllIcons.Debugger.Db_set_breakpoint;
@@ -108,7 +105,7 @@ public class LineBreakpoint extends BreakpointWithHighlighter {
@Override
protected Icon getVerifiedIcon(boolean isMuted) {
- if (REMOVE_AFTER_HIT) {
+ if (isRemoveAfterHit()) {
return isMuted ? AllIcons.Debugger.Db_muted_temporary_breakpoint : AllIcons.Debugger.Db_temporary_breakpoint;
}
return isMuted? AllIcons.Debugger.Db_muted_verified_breakpoint : AllIcons.Debugger.Db_verified_breakpoint;
@@ -349,9 +346,8 @@ public class LineBreakpoint extends BreakpointWithHighlighter {
}
private String getDisplayInfoInternal(boolean showPackageInfo, int totalTextLength) {
- final RangeHighlighter highlighter = getHighlighter();
- if(highlighter != null && highlighter.isValid() && isValid()) {
- final int lineNumber = (highlighter.getDocument().getLineNumber(highlighter.getStartOffset()) + 1);
+ if(isValid()) {
+ final int lineNumber = getSourcePosition().getLine() + 1;
String className = getClassName();
final boolean hasClassInfo = className != null && className.length() > 0;
final String methodName = getMethodName();
@@ -471,24 +467,19 @@ public class LineBreakpoint extends BreakpointWithHighlighter {
return ContextUtil.getContextElement(getSourcePosition());
}
- public static LineBreakpoint create(@NotNull Project project, @NotNull Document document, int lineIndex) {
- final RangeHighlighter highlighter = createHighlighter(project, document, lineIndex);
- if (highlighter == null) {
- return null;
- }
-
- LineBreakpoint breakpoint = new LineBreakpoint(project, highlighter);
+ public static LineBreakpoint create(@NotNull Project project, XBreakpoint xBreakpoint) {
+ LineBreakpoint breakpoint = new LineBreakpoint(project, xBreakpoint);
return (LineBreakpoint)breakpoint.init();
}
- @Override
- public boolean canMoveTo(SourcePosition position) {
- if (!super.canMoveTo(position)) {
- return false;
- }
- final Document document = PsiDocumentManager.getInstance(getProject()).getDocument(position.getFile());
- return canAddLineBreakpoint(myProject, document, position.getLine());
- }
+ //@Override
+ //public boolean canMoveTo(SourcePosition position) {
+ // if (!super.canMoveTo(position)) {
+ // return false;
+ // }
+ // final Document document = PsiDocumentManager.getInstance(getProject()).getDocument(position.getFile());
+ // return canAddLineBreakpoint(myProject, document, position.getLine());
+ //}
public static boolean canAddLineBreakpoint(Project project, final Document document, final int lineIndex) {
if (lineIndex < 0 || lineIndex >= document.getLineCount()) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpointFactory.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpointFactory.java
deleted file mode 100644
index 0042074dc798..000000000000
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpointFactory.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.debugger.ui.breakpoints;
-
-import com.intellij.debugger.DebuggerBundle;
-import com.intellij.debugger.HelpID;
-import com.intellij.icons.AllIcons;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Key;
-import org.jdom.Element;
-
-import javax.swing.*;
-
-/**
- * @author Eugene Zhuravlev
- * Date: Apr 26, 2005
- */
-public class LineBreakpointFactory extends BreakpointFactory {
- @Override
- public Breakpoint createBreakpoint(Project project, final Element element) {
- return new LineBreakpoint(project);
- }
-
- @Override
- public Icon getIcon() {
- return AllIcons.Debugger.Db_set_breakpoint;
- }
-
- @Override
- public Icon getDisabledIcon() {
- return AllIcons.Debugger.Db_disabled_breakpoint;
- }
-
- @Override
- protected String getHelpID() {
- return HelpID.LINE_BREAKPOINTS;
- }
-
- @Override
- public String getDisplayName() {
- return DebuggerBundle.message("line.breakpoints.tab.title");
- }
-
- @Override
- public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) {
- return new LineBreakpointPropertiesPanel(project, compact);
- }
-
- @Override
- public Key getBreakpointCategory() {
- return LineBreakpoint.CATEGORY;
- }
-}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java
index 90a839d425d4..be10d56113f8 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java
@@ -38,10 +38,13 @@ import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.InvalidDataException;
+import com.intellij.openapi.util.JDOMExternalizerUtil;
import com.intellij.openapi.util.Key;
import com.intellij.psi.*;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.text.CharArrayUtil;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.sun.jdi.AbsentInformationException;
import com.sun.jdi.Location;
import com.sun.jdi.Method;
@@ -52,31 +55,29 @@ import com.sun.jdi.event.MethodExitEvent;
import com.sun.jdi.request.EventRequest;
import com.sun.jdi.request.MethodEntryRequest;
import com.sun.jdi.request.MethodExitRequest;
+import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties;
import javax.swing.*;
import java.util.Iterator;
import java.util.Set;
-public class MethodBreakpoint extends BreakpointWithHighlighter {
+public class MethodBreakpoint extends BreakpointWithHighlighter {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.breakpoints.MethodBreakpoint");
- public boolean WATCH_ENTRY = true;
- public boolean WATCH_EXIT = true;
-
- @Nullable private String myMethodName;
@Nullable private JVMName mySignature;
private boolean myIsStatic;
public static final @NonNls Key CATEGORY = BreakpointCategory.lookup("method_breakpoints");
- protected MethodBreakpoint(@NotNull Project project) {
- super(project);
+ protected MethodBreakpoint(@NotNull Project project, XBreakpoint breakpoint) {
+ super(project, breakpoint);
}
private MethodBreakpoint(@NotNull Project project, @NotNull RangeHighlighter highlighter) {
- super(project, highlighter);
+ super(project, highlighter, null);
}
public boolean isStatic() {
@@ -104,21 +105,25 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
}
public boolean isValid() {
- return super.isValid() && myMethodName != null;
+ return super.isValid() && getMethodName() != null;
}
protected void reload(@NotNull PsiFile psiFile) {
- myMethodName = null;
+ setMethodName(null);
mySignature = null;
MethodDescriptor descriptor = getMethodDescriptor(myProject, psiFile, getSourcePosition());
if (descriptor != null) {
- myMethodName = descriptor.methodName;
+ setMethodName(descriptor.methodName);
mySignature = descriptor.methodSignature;
myIsStatic = descriptor.isStatic;
}
+ PsiClass psiClass = getPsiClass();
+ if (psiClass != null) {
+ getProperties().myClassPattern = psiClass.getQualifiedName();
+ }
if (myIsStatic) {
- INSTANCE_FILTERS_ENABLED = false;
+ setInstanceFiltersEnabled(false);
}
}
@@ -130,7 +135,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
String signature = method.signature();
String name = method.name();
- if (myMethodName.equals(name) && mySignature.getName(debugProcess).equals(signature)) {
+ if (getMethodName().equals(name) && mySignature.getName(debugProcess).equals(signature)) {
hasMethod = true;
break;
}
@@ -144,7 +149,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
}
RequestManagerImpl requestManager = debugProcess.getRequestsManager();
- if (WATCH_ENTRY) {
+ if (isWatchEntry()) {
MethodEntryRequest entryRequest = (MethodEntryRequest)findRequest(debugProcess, MethodEntryRequest.class);
if (entryRequest == null) {
entryRequest = requestManager.createMethodEntryRequest(this);
@@ -157,7 +162,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
entryRequest.addClassFilter(classType);
debugProcess.getRequestsManager().enableRequest(entryRequest);
}
- if (WATCH_EXIT) {
+ if (isWatchExit()) {
MethodExitRequest exitRequest = (MethodExitRequest)findRequest(debugProcess, MethodExitRequest.class);
if (exitRequest == null) {
exitRequest = requestManager.createMethodExitRequest(this);
@@ -256,11 +261,11 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
if (classNameExists) {
buffer.append(className);
}
- if(myMethodName != null) {
+ if(getMethodName() != null) {
if (classNameExists) {
buffer.append(".");
}
- buffer.append(myMethodName);
+ buffer.append(getMethodName());
}
}
else {
@@ -281,16 +286,16 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
}
public boolean matchesEvent(@NotNull final LocatableEvent event, final DebugProcessImpl process) throws EvaluateException {
- if (myMethodName == null || mySignature == null) {
+ if (getMethodName() == null || mySignature == null) {
return false;
}
final Method method = event.location().method();
- return method != null && method.name().equals(myMethodName) && method.signature().equals(mySignature.getName(process));
+ return method != null && method.name().equals(getMethodName()) && method.signature().equals(mySignature.getName(process));
}
@Nullable
- public static MethodBreakpoint create(@NotNull Project project, @NotNull Document document, int lineIndex) {
- final MethodBreakpoint breakpoint = new MethodBreakpoint(project, createHighlighter(project, document, lineIndex));
+ public static MethodBreakpoint create(@NotNull Project project, XBreakpoint xBreakpoint) {
+ final MethodBreakpoint breakpoint = new MethodBreakpoint(project, xBreakpoint);
return (MethodBreakpoint)breakpoint.init();
}
@@ -362,6 +367,19 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
return null;
}
+ @Override
+ public void readExternal(@NotNull Element breakpointNode) throws InvalidDataException {
+ super.readExternal(breakpointNode);
+ try {
+ getProperties().WATCH_ENTRY = Boolean.valueOf(JDOMExternalizerUtil.readField(breakpointNode, "WATCH_ENTRY"));
+ } catch (Exception e) {
+ }
+ try {
+ getProperties().WATCH_EXIT = Boolean.valueOf(JDOMExternalizerUtil.readField(breakpointNode, "WATCH_EXIT"));
+ } catch (Exception e) {
+ }
+ }
+
public String toString() {
return getDescription();
}
@@ -376,6 +394,23 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
return false;
}
+ private boolean isWatchEntry() {
+ return getProperties().WATCH_ENTRY;
+ }
+
+ private boolean isWatchExit() {
+ return getProperties().WATCH_EXIT;
+ }
+
+ @Nullable
+ private String getMethodName() {
+ return getProperties().myMethodName;
+ }
+
+ private void setMethodName(@Nullable String methodName) {
+ getProperties().myMethodName = methodName;
+ }
+
private static final class MethodDescriptor {
String methodName;
JVMName methodSignature;
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointFactory.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointFactory.java
deleted file mode 100644
index a08e2a123ae6..000000000000
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointFactory.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.debugger.ui.breakpoints;
-
-import com.intellij.debugger.DebuggerBundle;
-import com.intellij.debugger.DebuggerManagerEx;
-import com.intellij.debugger.HelpID;
-import com.intellij.icons.AllIcons;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Key;
-import org.jdom.Element;
-
-import javax.swing.*;
-
-/**
- * @author Eugene Zhuravlev
- * Date: Apr 26, 2005
- */
-public class MethodBreakpointFactory extends BreakpointFactory{
- @Override
- public Breakpoint createBreakpoint(Project project, final Element element) {
- return element.getAttributeValue(WildcardMethodBreakpoint.JDOM_LABEL) != null? new WildcardMethodBreakpoint(project) : new MethodBreakpoint(project);
- }
-
- @Override
- public Icon getIcon() {
- return AllIcons.Debugger.Db_method_breakpoint;
- }
-
- @Override
- public Icon getDisabledIcon() {
- return AllIcons.Debugger.Db_disabled_method_breakpoint;
- }
-
- @Override
- protected String getHelpID() {
- return HelpID.METHOD_BREAKPOINTS;
- }
-
- @Override
- public String getDisplayName() {
- return DebuggerBundle.message("method.breakpoints.tab.title");
- }
-
- @Override
- public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) {
- return new MethodBreakpointPropertiesPanel(project, compact);
- }
-
- @Override
- public Key getBreakpointCategory() {
- return MethodBreakpoint.CATEGORY;
- }
-
- @Override
- public boolean canAddBreakpoints() {
- return true;
- }
-
- @Override
- public WildcardMethodBreakpoint addBreakpoint(Project project) {
- AddWildcardBreakpointDialog dialog = new AddWildcardBreakpointDialog(project);
- dialog.show();
- WildcardMethodBreakpoint methodBreakpoint;
- methodBreakpoint = !dialog.isOK()
- ? null
- : DebuggerManagerEx.getInstanceEx(project).getBreakpointManager()
- .addMethodBreakpoint(dialog.getClassPattern(), dialog.getMethodName());
- return methodBreakpoint;
- }
-}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointPropertiesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointPropertiesPanel.java
index c50b6995d038..bf7419264105 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointPropertiesPanel.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointPropertiesPanel.java
@@ -21,24 +21,30 @@
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
-import com.intellij.openapi.project.Project;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.util.ui.DialogUtil;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
+import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-public class MethodBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
+public class MethodBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPanel> {
private JCheckBox myWatchEntryCheckBox;
private JCheckBox myWatchExitCheckBox;
- public MethodBreakpointPropertiesPanel(final Project project, boolean compact) {
- super(project, MethodBreakpoint.CATEGORY, compact);
- }
+ //public MethodBreakpointPropertiesPanel(final Project project, boolean compact) {
+ // super(project, MethodBreakpoint.CATEGORY, compact);
+ //}
- protected JComponent createSpecialBox() {
+
+ @NotNull
+ @Override
+ public JComponent getComponent() {
JPanel _panel, _panel0;
myWatchEntryCheckBox = new JCheckBox(DebuggerBundle.message("label.method.breakpoint.properties.panel.method.entry"));
@@ -86,31 +92,15 @@ public class MethodBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
return _panel;
}
- public void initFrom(Breakpoint breakpoint, boolean moreOptionsVisible) {
- super.initFrom(breakpoint, moreOptionsVisible);
- if (breakpoint instanceof MethodBreakpoint) {
- MethodBreakpoint methodBreakpoint = (MethodBreakpoint)breakpoint;
- myWatchEntryCheckBox.setSelected(methodBreakpoint.WATCH_ENTRY);
- myWatchExitCheckBox.setSelected(methodBreakpoint.WATCH_EXIT);
- }
- else if (breakpoint instanceof WildcardMethodBreakpoint){
- final WildcardMethodBreakpoint methodBreakpoint = ((WildcardMethodBreakpoint)breakpoint);
- myWatchEntryCheckBox.setSelected(methodBreakpoint.WATCH_ENTRY);
- myWatchExitCheckBox.setSelected(methodBreakpoint.WATCH_EXIT);
- }
+ @Override
+ public void loadFrom(@NotNull XBreakpoint breakpoint) {
+ myWatchEntryCheckBox.setSelected(breakpoint.getProperties().WATCH_ENTRY);
+ myWatchExitCheckBox.setSelected(breakpoint.getProperties().WATCH_EXIT);
}
- public void saveTo(Breakpoint breakpoint) {
- if (breakpoint instanceof MethodBreakpoint) {
- MethodBreakpoint methodBreakpoint = (MethodBreakpoint)breakpoint;
- methodBreakpoint.WATCH_ENTRY = myWatchEntryCheckBox.isSelected();
- methodBreakpoint.WATCH_EXIT = myWatchExitCheckBox.isSelected();
- }
- else if (breakpoint instanceof WildcardMethodBreakpoint){
- final WildcardMethodBreakpoint methodBreakpoint = ((WildcardMethodBreakpoint)breakpoint);
- methodBreakpoint.WATCH_ENTRY = myWatchEntryCheckBox.isSelected();
- methodBreakpoint.WATCH_EXIT = myWatchExitCheckBox.isSelected();
- }
- super.saveTo(breakpoint);
+ @Override
+ public void saveTo(@NotNull XBreakpoint breakpoint) {
+ breakpoint.getProperties().WATCH_ENTRY = myWatchEntryCheckBox.isSelected();
+ breakpoint.getProperties().WATCH_EXIT = myWatchExitCheckBox.isSelected();
}
}
\ No newline at end of file
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/RunToCursorBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/RunToCursorBreakpoint.java
index 82f617a14f6b..19a187da03c4 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/RunToCursorBreakpoint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/RunToCursorBreakpoint.java
@@ -18,10 +18,11 @@ package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.SourcePosition;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -31,18 +32,11 @@ import org.jetbrains.annotations.Nullable;
*/
public class RunToCursorBreakpoint extends LineBreakpoint {
private final boolean myRestoreBreakpoints;
- @Nullable
private final SourcePosition myCustomPosition;
-
- protected RunToCursorBreakpoint(@NotNull Project project, @NotNull RangeHighlighter highlighter, boolean restoreBreakpoints) {
- super(project, highlighter);
- setVisible(false);
- myRestoreBreakpoints = restoreBreakpoints;
- myCustomPosition = null;
- }
+ private String mySuspendPolicy;
protected RunToCursorBreakpoint(@NotNull Project project, @NotNull SourcePosition pos, boolean restoreBreakpoints) {
- super(project);
+ super(project, null);
myCustomPosition = pos;
setVisible(false);
myRestoreBreakpoints = restoreBreakpoints;
@@ -50,7 +44,51 @@ public class RunToCursorBreakpoint extends LineBreakpoint {
@Override
public SourcePosition getSourcePosition() {
- return myCustomPosition != null ? myCustomPosition : super.getSourcePosition();
+ return myCustomPosition;
+ }
+
+ @Override
+ public void reload() {
+ }
+
+ @Override
+ public String getSuspendPolicy() {
+ return mySuspendPolicy;
+ }
+
+ public void setSuspendPolicy(String policy) {
+ mySuspendPolicy = policy;
+ }
+
+ protected boolean isLogEnabled() {
+ return false;
+ }
+
+ @Override
+ protected boolean isLogExpressionEnabled() {
+ return false;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ public boolean isCountFilterEnabled() {
+ return false;
+ }
+
+ public boolean isClassFiltersEnabled() {
+ return false;
+ }
+
+ public boolean isInstanceFiltersEnabled() {
+ return false;
+ }
+
+ @Override
+ protected boolean isConditionEnabled() {
+ return false;
}
public boolean isRestoreBreakpoints() {
@@ -62,6 +100,11 @@ public class RunToCursorBreakpoint extends LineBreakpoint {
return false;
}
+ @Override
+ public boolean isValid() {
+ return true;
+ }
+
@Override
protected boolean isMuted(@NotNull final DebugProcessImpl debugProcess) {
return false; // always enabled
@@ -74,17 +117,9 @@ public class RunToCursorBreakpoint extends LineBreakpoint {
return null;
}
- final RangeHighlighter highlighter = createHighlighter(project, document, lineIndex);
- if (highlighter == null) {
- return null;
- }
+ PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
+ SourcePosition pos = SourcePosition.createFromLine(psiFile, lineIndex);
- final RunToCursorBreakpoint breakpoint = new RunToCursorBreakpoint(project, highlighter, restoreBreakpoints);
- final RangeHighlighter h = breakpoint.getHighlighter();
- if (h != null) {
- h.dispose();
- }
-
- return (RunToCursorBreakpoint)breakpoint.init();
+ return new RunToCursorBreakpoint(project, pos, restoreBreakpoints);
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StepIntoBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StepIntoBreakpoint.java
index 6e39e5ac1d29..af7d6755523a 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StepIntoBreakpoint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StepIntoBreakpoint.java
@@ -153,7 +153,7 @@ public class StepIntoBreakpoint extends RunToCursorBreakpoint {
if (pos != null) {
final StepIntoBreakpoint breakpoint = new StepIntoBreakpoint(project, pos, filter);
breakpoint.init();
- breakpoint.LOG_ENABLED = false;
+ breakpoint.setLogEnabled(false);
return breakpoint;
}
return null;
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/WildcardMethodBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/WildcardMethodBreakpoint.java
index f6c0dc3c3ab2..ec7f42667561 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/WildcardMethodBreakpoint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/WildcardMethodBreakpoint.java
@@ -26,12 +26,11 @@ import com.intellij.debugger.engine.requests.RequestManagerImpl;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.Key;
-import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.util.StringBuilderSpinAllocator;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.sun.jdi.AbsentInformationException;
import com.sun.jdi.Location;
import com.sun.jdi.Method;
@@ -42,40 +41,35 @@ import com.sun.jdi.event.MethodExitEvent;
import com.sun.jdi.request.EventRequest;
import com.sun.jdi.request.MethodEntryRequest;
import com.sun.jdi.request.MethodExitRequest;
-import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties;
import javax.swing.*;
import java.util.Iterator;
import java.util.Set;
-public class WildcardMethodBreakpoint extends Breakpoint {
+public class WildcardMethodBreakpoint extends Breakpoint {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.breakpoints.ExceptionBreakpoint");
- public boolean WATCH_ENTRY = true;
- public boolean WATCH_EXIT = true;
- private String myClassPattern;
- private String myMethodName;
-
public static final String JDOM_LABEL = "wildcard_breakpoint";
- public WildcardMethodBreakpoint(Project project) {
- super(project);
+ public WildcardMethodBreakpoint(Project project, XBreakpoint breakpoint) {
+ super(project, breakpoint);
}
public Key getCategory() {
return MethodBreakpoint.CATEGORY;
}
- protected WildcardMethodBreakpoint(Project project, @NotNull String classPattern, @NotNull String methodName) {
- super(project);
- myClassPattern = classPattern;
- myMethodName = methodName;
+ protected WildcardMethodBreakpoint(Project project, @NotNull String classPattern, @NotNull String methodName, XBreakpoint breakpoint) {
+ super(project, breakpoint);
+ setClassPattern(classPattern);
+ setMethodName(methodName);
}
public String getClassName() {
- return myClassPattern;
+ return getClassPattern();
}
public @Nullable String getShortClassName() {
@@ -83,7 +77,7 @@ public class WildcardMethodBreakpoint extends Breakpoint {
}
public String getMethodName() {
- return myMethodName;
+ return getProperties().myMethodName;
}
public PsiClass getPsiClass() {
@@ -96,9 +90,9 @@ public class WildcardMethodBreakpoint extends Breakpoint {
}
final StringBuilder buffer = StringBuilderSpinAllocator.alloc();
try {
- buffer.append(myClassPattern);
+ buffer.append(getClassPattern());
buffer.append(".");
- buffer.append(myMethodName);
+ buffer.append(getMethodName());
buffer.append("()");
return buffer.toString();
}
@@ -108,7 +102,7 @@ public class WildcardMethodBreakpoint extends Breakpoint {
}
public Icon getIcon() {
- if (!ENABLED) {
+ if (!isEnabled()) {
final Breakpoint master = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().findMasterBreakpoint(this);
return master == null? AllIcons.Debugger.Db_disabled_method_breakpoint : AllIcons.Debugger.Db_dep_method_breakpoint;
}
@@ -124,12 +118,12 @@ public class WildcardMethodBreakpoint extends Breakpoint {
public void createRequest(DebugProcessImpl debugProcess) {
DebuggerManagerThreadImpl.assertIsManagerThread();
- if (!ENABLED || !debugProcess.isAttached() || debugProcess.areBreakpointsMuted() || !debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
+ if (!isEnabled() || !debugProcess.isAttached() || debugProcess.areBreakpointsMuted() || !debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
return;
}
try {
RequestManagerImpl requestManager = debugProcess.getRequestsManager();
- if (WATCH_ENTRY) {
+ if (isWatchEntry()) {
MethodEntryRequest entryRequest = (MethodEntryRequest)findRequest(debugProcess, MethodEntryRequest.class);
if (entryRequest == null) {
entryRequest = requestManager.createMethodEntryRequest(this);
@@ -137,10 +131,10 @@ public class WildcardMethodBreakpoint extends Breakpoint {
else {
entryRequest.disable();
}
- entryRequest.addClassFilter(myClassPattern);
+ entryRequest.addClassFilter(getClassPattern());
debugProcess.getRequestsManager().enableRequest(entryRequest);
}
- if (WATCH_EXIT) {
+ if (isWatchExit()) {
MethodExitRequest exitRequest = (MethodExitRequest)findRequest(debugProcess, MethodExitRequest.class);
if (exitRequest == null) {
exitRequest = requestManager.createMethodExitRequest(this);
@@ -148,7 +142,7 @@ public class WildcardMethodBreakpoint extends Breakpoint {
else {
exitRequest.disable();
}
- exitRequest.addClassFilter(myClassPattern);
+ exitRequest.addClassFilter(getClassPattern());
debugProcess.getRequestsManager().enableRequest(exitRequest);
}
}
@@ -212,46 +206,74 @@ public class WildcardMethodBreakpoint extends Breakpoint {
}
public boolean isValid() {
- return myClassPattern != null && myMethodName != null;
+ return getClassPattern() != null && getMethodName() != null;
}
- @SuppressWarnings({"HardCodedStringLiteral"}) public void writeExternal(Element parentNode) throws WriteExternalException {
- super.writeExternal(parentNode);
- parentNode.setAttribute(JDOM_LABEL, "true");
- if (myClassPattern != null) {
- parentNode.setAttribute("class_name", myClassPattern);
- }
- if (myMethodName != null) {
- parentNode.setAttribute("method_name", myMethodName);
- }
- }
+ //@SuppressWarnings({"HardCodedStringLiteral"}) public void writeExternal(Element parentNode) throws WriteExternalException {
+ // super.writeExternal(parentNode);
+ // parentNode.setAttribute(JDOM_LABEL, "true");
+ // if (getClassPattern() != null) {
+ // parentNode.setAttribute("class_name", getClassPattern());
+ // }
+ // if (getMethodName() != null) {
+ // parentNode.setAttribute("method_name", getMethodName());
+ // }
+ //}
public PsiElement getEvaluationElement() {
return null;
}
- public void readExternal(Element parentNode) throws InvalidDataException {
- super.readExternal(parentNode);
-
- //noinspection HardCodedStringLiteral
- String className = parentNode.getAttributeValue("class_name");
- myClassPattern = className;
-
- //noinspection HardCodedStringLiteral
- String methodName = parentNode.getAttributeValue("method_name");
- myMethodName = methodName;
-
- if(className == null || methodName == null) {
- throw new InvalidDataException();
- }
- }
+ //public void readExternal(Element parentNode) throws InvalidDataException {
+ // super.readExternal(parentNode);
+ //
+ // //noinspection HardCodedStringLiteral
+ // String className = parentNode.getAttributeValue("class_name");
+ // setClassPattern(className);
+ //
+ // //noinspection HardCodedStringLiteral
+ // String methodName = parentNode.getAttributeValue("method_name");
+ // setMethodName(methodName);
+ //
+ // if(className == null || methodName == null) {
+ // throw new InvalidDataException();
+ // }
+ //}
public boolean matchesEvent(final LocatableEvent event){
final Method method = event.location().method();
- return method != null && myMethodName.equals(method.name());
+ return method != null && getMethodName().equals(method.name());
}
- public static WildcardMethodBreakpoint create(Project project, final String classPattern, final String methodName) {
- return new WildcardMethodBreakpoint(project, classPattern, methodName);
+ public static WildcardMethodBreakpoint create(Project project, final String classPattern, final String methodName, XBreakpoint xBreakpoint) {
+ return new WildcardMethodBreakpoint(project, classPattern, methodName, xBreakpoint);
+ }
+
+ private boolean isWatchEntry() {
+ return getProperties().WATCH_ENTRY;
+ }
+
+ private void setWatchEntry(boolean WATCH_ENTRY) {
+ getProperties().WATCH_ENTRY = WATCH_ENTRY;
+ }
+
+ private boolean isWatchExit() {
+ return getProperties().WATCH_EXIT;
+ }
+
+ private void setWatchExit(boolean WATCH_EXIT) {
+ getProperties().WATCH_EXIT = WATCH_EXIT;
+ }
+
+ private String getClassPattern() {
+ return getProperties().myClassPattern;
+ }
+
+ private void setClassPattern(String classPattern) {
+ getProperties().myClassPattern = classPattern;
+ }
+
+ private void setMethodName(String methodName) {
+ getProperties().myMethodName = methodName;
}
}
diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/JavaDebuggerEditorsProvider.java b/java/debugger/impl/src/org/jetbrains/java/debugger/JavaDebuggerEditorsProvider.java
index 21cdb36a3a4e..9815a7fd110d 100644
--- a/java/debugger/impl/src/org/jetbrains/java/debugger/JavaDebuggerEditorsProvider.java
+++ b/java/debugger/impl/src/org/jetbrains/java/debugger/JavaDebuggerEditorsProvider.java
@@ -1,16 +1,28 @@
package org.jetbrains.java.debugger;
+import com.intellij.debugger.engine.evaluation.CodeFragmentKind;
+import com.intellij.debugger.engine.evaluation.TextWithImports;
+import com.intellij.debugger.engine.evaluation.TextWithImportsImpl;
+import com.intellij.debugger.ui.DebuggerExpressionComboBox;
import com.intellij.ide.highlighter.JavaFileType;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.JavaCodeFragmentFactory;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
+import com.intellij.xdebugger.XSourcePosition;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
+import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
+import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProviderBase;
+import com.intellij.xdebugger.impl.breakpoints.ui.XDebuggerComboBoxProvider;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-public class JavaDebuggerEditorsProvider extends XDebuggerEditorsProviderBase {
+import javax.swing.*;
+
+public class JavaDebuggerEditorsProvider extends XDebuggerEditorsProviderBase implements XDebuggerComboBoxProvider {
@NotNull
@Override
public FileType getFileType() {
@@ -21,4 +33,72 @@ public class JavaDebuggerEditorsProvider extends XDebuggerEditorsProviderBase {
protected PsiFile createExpressionCodeFragment(@NotNull Project project, @NotNull String text, @Nullable PsiElement context, boolean isPhysical) {
return JavaCodeFragmentFactory.getInstance(project).createExpressionCodeFragment(text, context, null, isPhysical);
}
+
+ @Override
+ public XBreakpointCustomPropertiesPanel> createConditionComboBoxPanel(Project project,
+ XDebuggerEditorsProvider debuggerEditorsProvider,
+ String historyId,
+ XSourcePosition sourcePosition) {
+ return new ExpressionComboBoxPanel(project, historyId, sourcePosition) {
+ @Override
+ public void saveTo(@NotNull XBreakpoint> breakpoint) {
+ TextWithImports text = myComboBox.getText();
+ final String condition = !text.getText().isEmpty() ? text.toExternalForm() : null;
+ breakpoint.setCondition(condition);
+ if (condition != null) {
+ myComboBox.addRecent(text);
+ }
+ }
+
+ @Override
+ public void loadFrom(@NotNull XBreakpoint> breakpoint) {
+ myComboBox.setText(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, StringUtil.notNullize(breakpoint.getCondition())));
+ }
+ };
+ }
+
+ @Override
+ public XBreakpointCustomPropertiesPanel> createLogExpressionComboBoxPanel(Project project,
+ XDebuggerEditorsProvider debuggerEditorsProvider,
+ String historyId,
+ XSourcePosition sourcePosition) {
+ return new ExpressionComboBoxPanel(project, historyId, sourcePosition) {
+ @Override
+ public void saveTo(@NotNull XBreakpoint> breakpoint) {
+ TextWithImports text = myComboBox.getText();
+ breakpoint.setLogExpression(myComboBox.isEnabled() && !text.getText().isEmpty() ? text.toExternalForm() : null);
+ if (text != null) {
+ myComboBox.addRecent(text);
+ }
+ }
+
+ @Override
+ public void loadFrom(@NotNull XBreakpoint> breakpoint) {
+ myComboBox.setText(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, StringUtil.notNullize(breakpoint.getLogExpression())));
+ }
+ };
+ }
+
+ private abstract class ExpressionComboBoxPanel extends XBreakpointCustomPropertiesPanel> {
+ protected final DebuggerExpressionComboBox myComboBox;
+
+ private ExpressionComboBoxPanel(Project project,
+ String historyId,
+ XSourcePosition sourcePosition) {
+ myComboBox = new DebuggerExpressionComboBox(project, historyId);
+ if (sourcePosition != null) {
+ PsiElement element = getContextElement(sourcePosition.getFile(), sourcePosition.getOffset(), project);
+ myComboBox.setContext(element);
+ }
+ else {
+ myComboBox.setContext(null);
+ }
+ }
+
+ @NotNull
+ @Override
+ public JComponent getComponent() {
+ return myComboBox;
+ }
+ }
}
\ No newline at end of file
diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointAdapter.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointAdapter.java
deleted file mode 100644
index a6705848a44d..000000000000
--- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointAdapter.java
+++ /dev/null
@@ -1,157 +0,0 @@
-package org.jetbrains.java.debugger.breakpoints;
-
-import com.intellij.debugger.engine.evaluation.CodeFragmentKind;
-import com.intellij.debugger.engine.evaluation.TextWithImportsImpl;
-import com.intellij.debugger.engine.requests.RequestManagerImpl;
-import com.intellij.debugger.settings.DebuggerSettings;
-import com.intellij.debugger.ui.breakpoints.LineBreakpoint;
-import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.editor.markup.RangeHighlighter;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Key;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.xdebugger.breakpoints.XBreakpointProperties;
-import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
-import com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Arrays;
-
-public class JavaBreakpointAdapter extends JavaBreakpointAdapterBase {
- private static final Key OLD_JAVA_BREAKPOINT_KEY = Key.create("oldJavaBreakpoint");
-
- public JavaBreakpointAdapter(Project project) {
- super(project);
- }
-
- @Override
- protected void configureCreatedBreakpoint(LineBreakpoint oldBreakpoint, XLineBreakpoint breakpoint) {
- oldBreakpoint.SUSPEND_POLICY = transformSuspendPolicy(breakpoint);
- applyCondition(oldBreakpoint, breakpoint);
- applyFilters(oldBreakpoint, breakpoint);
- }
-
- private boolean applyFilters(LineBreakpoint oldBreakpoint, XLineBreakpoint breakpoint) {
- boolean changed = false;
- JavaBreakpointProperties properties = (JavaBreakpointProperties)breakpoint.getProperties();
-
- changed |= oldBreakpoint.COUNT_FILTER_ENABLED != properties.COUNT_FILTER_ENABLED;
- oldBreakpoint.COUNT_FILTER_ENABLED = properties.COUNT_FILTER_ENABLED;
-
- changed |= oldBreakpoint.COUNT_FILTER != properties.COUNT_FILTER;
- oldBreakpoint.COUNT_FILTER = properties.COUNT_FILTER;
-
- changed |= oldBreakpoint.CLASS_FILTERS_ENABLED != properties.CLASS_FILTERS_ENABLED;
- oldBreakpoint.CLASS_FILTERS_ENABLED = properties.CLASS_FILTERS_ENABLED;
-
- changed |= !Arrays.equals(oldBreakpoint.getClassFilters(), properties.getClassFilters());
- oldBreakpoint.setClassFilters(properties.getClassFilters());
-
- changed |= !Arrays.equals(oldBreakpoint.getClassExclusionFilters(), properties.getClassExclusionFilters());
- oldBreakpoint.setClassExclusionFilters(properties.getClassExclusionFilters());
-
- changed |= oldBreakpoint.INSTANCE_FILTERS_ENABLED != properties.INSTANCE_FILTERS_ENABLED;
- oldBreakpoint.INSTANCE_FILTERS_ENABLED = properties.INSTANCE_FILTERS_ENABLED;
-
- changed |= !Arrays.equals(oldBreakpoint.getInstanceFilters(), properties.getInstanceFilters());
- oldBreakpoint.setInstanceFilters(properties.getInstanceFilters());
-
- return changed;
- }
-
- private static void applyCondition(LineBreakpoint oldBreakpoint, XLineBreakpoint breakpoint) {
- if (breakpoint.getCondition() != null) {
- oldBreakpoint.CONDITION_ENABLED = true;
- oldBreakpoint.setCondition(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, breakpoint.getCondition()));
- }
- else {
- oldBreakpoint.CONDITION_ENABLED = false;
- if (!StringUtil.isEmptyOrSpaces(oldBreakpoint.getCondition().getText())) {
- oldBreakpoint.setCondition(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, ""));
- }
- }
- }
-
- @Override
- protected void updateBreakpoint(LineBreakpoint jBreakpoint, XLineBreakpoint breakpoint) {
- boolean changed = false;
- if (jBreakpoint.ENABLED != breakpoint.isEnabled()) {
- jBreakpoint.ENABLED = breakpoint.isEnabled();
- changed = true;
- }
-
- String suspendPolicy = transformSuspendPolicy(breakpoint);
- if (jBreakpoint.SUSPEND_POLICY != suspendPolicy) {
- jBreakpoint.SUSPEND_POLICY = suspendPolicy;
- changed = true;
- }
-
- if (StringUtil.compare(breakpoint.getCondition(), jBreakpoint.getCondition().getText(), false) != 0) {
- applyCondition(jBreakpoint, breakpoint);
- changed = true;
- }
-
- if (applyFilters(jBreakpoint, breakpoint)) {
- changed = true;
- }
-
- if (jBreakpoint.getSourcePosition().getLine() != breakpoint.getLine()) {
- jBreakpoint.reload();
- changed = true;
- }
-
- if (changed) {
- RequestManagerImpl.updateRequests(jBreakpoint);
- jBreakpoint.updateUI();
- }
- }
-
- @Override
- protected LineBreakpoint findBreakpoint(XLineBreakpoint breakpoint) {
- return OLD_JAVA_BREAKPOINT_KEY.get(breakpoint);
- }
-
- public LineBreakpoint getOrCreate(XLineBreakpoint breakpoint) {
- LineBreakpoint oldBreakpoint = findBreakpoint(breakpoint);
- if (oldBreakpoint == null) {
- oldBreakpoint = createBreakpoint(breakpoint);
- OLD_JAVA_BREAKPOINT_KEY.set(breakpoint, oldBreakpoint);
- }
- return oldBreakpoint;
- }
-
- @Override
- public void breakpointRemoved(@NotNull XLineBreakpoint breakpoint) {
- LineBreakpoint jBreakpoint = findBreakpoint(breakpoint);
- if (jBreakpoint != null) {
- jBreakpoint.delete();
- }
- }
-
- @Override
- protected LineBreakpoint doCreateInstance(Project project, Document document, XLineBreakpoint breakpoint) {
- LineBreakpoint lineBreakpoint = new LineBreakpoint(project, ((XLineBreakpointImpl)breakpoint).getHighlighter()) {
- @Override
- protected void setEditorFilter(RangeHighlighter highlighter) {
- }
- };
-
- lineBreakpoint.setVisible(false);
- lineBreakpoint.init();
- return lineBreakpoint;
- }
-
- private static String transformSuspendPolicy(XLineBreakpoint breakpoint) {
- switch (breakpoint.getSuspendPolicy()) {
- case ALL:
- return DebuggerSettings.SUSPEND_ALL;
- case THREAD:
- return DebuggerSettings.SUSPEND_THREAD;
- case NONE:
- return DebuggerSettings.SUSPEND_NONE;
-
- default:
- throw new IllegalArgumentException("unknown suspend policy");
- }
- }
-}
diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointAdapterBase.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointAdapterBase.java
index 6b249356d340..686de9aad6eb 100644
--- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointAdapterBase.java
+++ b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointAdapterBase.java
@@ -56,11 +56,11 @@ public abstract class JavaBreakpointAdapterBase extends XBreakpointAdapter breakpoint) {
- return LineBreakpoint.create(project, document, breakpoint.getLine());
+ protected LineBreakpoint doCreateInstance(Project project, Document document, XLineBreakpoint xBreakpoint) {
+ return LineBreakpoint.create(project, xBreakpoint);
}
}
diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointPropertiesPanel.form b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.form
similarity index 99%
rename from java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointPropertiesPanel.form
rename to java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.form
index db560b3feaeb..39507678f8ff 100644
--- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointPropertiesPanel.form
+++ b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.form
@@ -1,5 +1,5 @@
-