java move to xbreakpoints:

- removed java own breakpoints UI
 - added UI for java filters
 - added support for all kinds of java breakpoints
This commit is contained in:
Egor.Ushakov
2014-02-27 20:54:42 +04:00
parent 88189ccf34
commit 7a3a6cfbcf
57 changed files with 2665 additions and 2836 deletions
@@ -1,116 +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.actions;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.ui.breakpoints.BreakpointFactory;
import com.intellij.debugger.ui.breakpoints.BreakpointPropertiesPanel;
import com.intellij.debugger.ui.breakpoints.BreakpointWithHighlighter;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.markup.GutterIconRenderer;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.Balloon;
import com.intellij.openapi.ui.popup.JBPopupListener;
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.util.ui.UIUtil;
import com.intellij.xdebugger.impl.actions.EditBreakpointActionHandler;
import com.intellij.xdebugger.impl.breakpoints.XBreakpointUtil;
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialogFactory;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
public class JavaEditBreakpointActionHandler extends EditBreakpointActionHandler {
@Override
protected void doShowPopup(final Project project, final JComponent component, final Point whereToShow, final Object breakpoint) {
if (!(breakpoint instanceof BreakpointWithHighlighter)) {
return;
}
final BreakpointWithHighlighter javaBreakpoint = (BreakpointWithHighlighter)breakpoint;
BreakpointFactory breakpointFactory = null;
for (BreakpointFactory factory : BreakpointFactory.EXTENSION_POINT_NAME.getExtensions()) {
if (factory.getBreakpointCategory().equals(javaBreakpoint.getCategory())) {
breakpointFactory = factory;
}
}
assert breakpointFactory != null : "can't find factory for breakpoint " + javaBreakpoint;
final BreakpointPropertiesPanel propertiesPanel = breakpointFactory.createBreakpointPropertiesPanel(project, true);
assert propertiesPanel != null;
propertiesPanel.initFrom(javaBreakpoint, false);
final JComponent mainPanel = propertiesPanel.getPanel();
final JBPopupListener saveOnClose = new JBPopupListener.Adapter() {
@Override
public void onClosed(LightweightWindowEvent event) {
propertiesPanel.saveTo(javaBreakpoint);
propertiesPanel.dispose();
DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().fireBreakpointChanged(javaBreakpoint);
}
};
final Runnable showMoreOptions = new Runnable() {
@Override
public void run() {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
BreakpointsDialogFactory.getInstance(project).showDialog(javaBreakpoint);
}
});
}
};
final Balloon balloon = DebuggerUIUtil.showBreakpointEditor(project, mainPanel, whereToShow, component, showMoreOptions, breakpoint);
balloon.addListener(saveOnClose);
propertiesPanel.setDelegate(new BreakpointPropertiesPanel.Delegate() {
@Override
public void showActionsPanel() {
propertiesPanel.setActionsPanelVisible(true);
balloon.hide();
DebuggerUIUtil.showBreakpointEditor(project, mainPanel, whereToShow, component, showMoreOptions, breakpoint).addListener(saveOnClose);
}
});
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
IdeFocusManager.findInstance().requestFocus(mainPanel, true);
}
});
}
@Override
public boolean isEnabled(@NotNull Project project, AnActionEvent event) {
DataContext dataContext = event.getDataContext();
Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
if (editor == null) {
return false;
}
final Pair<GutterIconRenderer,Object> pair = XBreakpointUtil.findSelectedBreakpoint(project, editor);
return pair.first != null && pair.second instanceof BreakpointWithHighlighter;
}
}
@@ -22,7 +22,6 @@ import com.intellij.debugger.ui.breakpoints.BreakpointManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.FileEditorManager;
@@ -41,7 +40,7 @@ public class ToggleBreakpointEnabledAction extends AnAction {
Breakpoint breakpoint = findBreakpoint(project);
if (breakpoint != null) {
final BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
breakpointManager.setBreakpointEnabled(breakpoint, !breakpoint.ENABLED);
breakpointManager.setBreakpointEnabled(breakpoint, !breakpoint.isEnabled());
}
}
@@ -81,7 +81,7 @@ public class ToggleFieldBreakpointAction extends AnAction {
long id = object.uniqueID();
InstanceFilter[] instanceFilters = new InstanceFilter[] { InstanceFilter.create(Long.toString(id))};
fieldBreakpoint.setInstanceFilters(instanceFilters);
fieldBreakpoint.INSTANCE_FILTERS_ENABLED = true;
fieldBreakpoint.setInstanceFiltersEnabled(true);
}
}
}
@@ -1,163 +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.actions;
import com.intellij.codeInsight.folding.impl.actions.ExpandRegionAction;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.engine.DebuggerUtils;
import com.intellij.debugger.engine.requests.RequestManagerImpl;
import com.intellij.debugger.ui.breakpoints.Breakpoint;
import com.intellij.debugger.ui.breakpoints.BreakpointManager;
import com.intellij.debugger.ui.breakpoints.LineBreakpoint;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.FoldRegion;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.xdebugger.impl.actions.DebuggerActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class ToggleLineBreakpointActionHandler extends DebuggerActionHandler {
private final boolean myTemporary;
public ToggleLineBreakpointActionHandler(boolean temporary) {
myTemporary = temporary;
}
public boolean isEnabled(@NotNull final Project project, final AnActionEvent event) {
PlaceInDocument place = getPlace(project, event);
if (place != null) {
final Document document = place.getDocument();
final int offset = place.getOffset();
int line = document.getLineNumber(offset);
VirtualFile file = FileDocumentManager.getInstance().getFile(document);
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (DebuggerUtils.supportsJVMDebugging(file.getFileType()) || DebuggerUtils.supportsJVMDebugging(psiFile)) {
final BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
return breakpointManager.findBreakpoint(document, offset, LineBreakpoint.CATEGORY) != null ||
LineBreakpoint.canAddLineBreakpoint(project, document, line);
}
}
return false;
}
public void perform(@NotNull final Project project, final AnActionEvent event) {
PlaceInDocument place = getPlace(project, event);
if(place == null) {
return;
}
Editor editor = event.getData(CommonDataKeys.EDITOR);
ExpandRegionAction.expandRegionAtCaret(project, editor);
Document document = place.getDocument();
int line = document.getLineNumber(place.getOffset());
if (editor != null && editor.getCaretModel().getVisualPosition().line != line) {
editor.getCaretModel().moveToOffset(place.getOffset());
}
DebuggerManagerEx debugManager = DebuggerManagerEx.getInstanceEx(project);
if (debugManager == null) {
return;
}
BreakpointManager manager = debugManager.getBreakpointManager();
final Breakpoint breakpoint = manager.findBreakpoint(document, place.getOffset(), LineBreakpoint.CATEGORY);
if(breakpoint == null) {
LineBreakpoint lineBreakpoint = manager.addLineBreakpoint(document, line);
if(lineBreakpoint != null) {
lineBreakpoint.REMOVE_AFTER_HIT = myTemporary;
RequestManagerImpl.createRequests(lineBreakpoint);
}
}
else {
if (!breakpoint.REMOVE_AFTER_HIT && myTemporary) {
breakpoint.REMOVE_AFTER_HIT = true;
breakpoint.updateUI();
}
else {
manager.removeBreakpoint(breakpoint);
}
}
}
private static boolean containsOnlyDeclarations(int line, Document document, PsiFile file) {
int lineStart = document.getLineStartOffset(line);
int lineEnd = document.getLineEndOffset(line);
PsiElement start = file.findElementAt(lineStart);
PsiElement end = file.findElementAt(lineEnd - 1);
if (start == null || end == null) return false;
PsiElement commonParent = PsiTreeUtil.findCommonParent(start, end);
for (PsiElement element : PsiTreeUtil.findChildrenOfAnyType(commonParent, PsiStatement.class, PsiExpression.class)) {
if (new TextRange(lineStart, lineEnd).contains(element.getTextRange().getStartOffset())) {
return false;
}
}
return true;
}
@Nullable
private static PlaceInDocument getPlace(@NotNull final Project project, AnActionEvent event) {
Editor editor = event.getData(CommonDataKeys.EDITOR);
if(editor == null) {
editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
}
if (editor == null) {
return null;
}
final Document document = editor.getDocument();
PsiDocumentManager.getInstance(project).commitDocument(document);
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
if (file == null) {
return null;
}
// if several lines are merged into one visual line (using folding), try to find the most appropriate of those lines
int visualLine = editor.getCaretModel().getVisualPosition().getLine();
int visibleOffset = editor.getCaretModel().getOffset();
while (editor.offsetToVisualPosition(visibleOffset).line == visualLine) {
int line = document.getLineNumber(visibleOffset);
if (!containsOnlyDeclarations(line, document, file)) {
return new PlaceInDocument(document, visibleOffset);
}
int lineEndOffset = document.getLineEndOffset(line);
FoldRegion region = editor.getFoldingModel().getCollapsedRegionAtOffset(lineEndOffset);
if (region != null) {
int foldEnd = region.getEndOffset();
if (foldEnd > lineEndOffset) {
visibleOffset = foldEnd;
continue;
}
}
visibleOffset = lineEndOffset + 1;
}
return new PlaceInDocument(document, editor.getCaretModel().getOffset());
}
}
@@ -1409,7 +1409,7 @@ public abstract class DebugProcessImpl implements DebugProcess {
hint.setIgnoreFilters(myForcedIgnoreFilters || mySession.shouldIgnoreSteppingFilters());
applyThreadFilter(stepThread);
if (myBreakpoint != null) {
myBreakpoint.SUSPEND_POLICY = suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD? DebuggerSettings.SUSPEND_THREAD : DebuggerSettings.SUSPEND_ALL;
myBreakpoint.setSuspendPolicy(suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD? DebuggerSettings.SUSPEND_THREAD : DebuggerSettings.SUSPEND_ALL);
myBreakpoint.createRequest(suspendContext.getDebugProcess());
myRunToCursorBreakpoint = myBreakpoint;
}
@@ -1476,8 +1476,8 @@ public abstract class DebugProcessImpl implements DebugProcess {
}
applyThreadFilter(getContextThread());
final SuspendContextImpl context = getSuspendContext();
myRunToCursorBreakpoint.SUSPEND_POLICY = context.getSuspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD? DebuggerSettings.SUSPEND_THREAD : DebuggerSettings.SUSPEND_ALL;
myRunToCursorBreakpoint.LOG_ENABLED = false;
myRunToCursorBreakpoint.setSuspendPolicy(context.getSuspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD? DebuggerSettings.SUSPEND_THREAD : DebuggerSettings.SUSPEND_ALL);
myRunToCursorBreakpoint.setLogEnabled(false);
myRunToCursorBreakpoint.createRequest(context.getDebugProcess());
DebugProcessImpl.this.myRunToCursorBreakpoint = myRunToCursorBreakpoint;
super.contextAction();
@@ -30,9 +30,7 @@ import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.debugger.ui.breakpoints.Breakpoint;
import com.intellij.debugger.ui.breakpoints.BreakpointManager;
import com.intellij.debugger.ui.breakpoints.FilteredRequestor;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
@@ -40,15 +38,10 @@ import com.intellij.openapi.util.Key;
import com.intellij.psi.PsiClass;
import com.intellij.ui.classFilter.ClassFilter;
import com.intellij.util.containers.HashMap;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.breakpoints.XBreakpointProperties;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.sun.jdi.*;
import com.sun.jdi.event.ClassPrepareEvent;
import com.sun.jdi.request.*;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.java.debugger.breakpoints.JavaBreakpointAdapter;
import org.jetbrains.java.debugger.breakpoints.JavaBreakpointType;
import java.util.Collections;
import java.util.HashSet;
@@ -158,11 +151,11 @@ public class RequestManagerImpl extends DebugProcessAdapterImpl implements Reque
request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
}
if (requestor.COUNT_FILTER_ENABLED && requestor.COUNT_FILTER > 0) {
request.addCountFilter(requestor.COUNT_FILTER);
if (requestor.isCountFilterEnabled() && requestor.getCountFilter() > 0) {
request.addCountFilter(requestor.getCountFilter());
}
if (requestor.CLASS_FILTERS_ENABLED && !(request instanceof BreakpointRequest) /*no built-in class filters support for breakpoint requests*/ ) {
if (requestor.isClassFiltersEnabled() && !(request instanceof BreakpointRequest) /*no built-in class filters support for breakpoint requests*/ ) {
ClassFilter[] classFilters = requestor.getClassFilters();
if (DebuggerUtilsEx.getEnabledNumber(classFilters) == 1) {
for (final ClassFilter filter : classFilters) {
@@ -408,17 +401,18 @@ public class RequestManagerImpl extends DebugProcessAdapterImpl implements Reque
breakpoint.createRequest(myDebugProcess);
}
AccessToken token = ReadAction.start();
try {
JavaBreakpointAdapter adapter = new JavaBreakpointAdapter(project);
for (XLineBreakpoint<XBreakpointProperties> breakpoint : XDebuggerManager.getInstance(project).getBreakpointManager()
.getBreakpoints(JavaBreakpointType.class)) {
adapter.getOrCreate(breakpoint).createRequest(myDebugProcess);
}
}
finally {
token.finish();
}
//AccessToken token = ReadAction.start();
//try {
// JavaBreakpointAdapter adapter = new JavaBreakpointAdapter(project);
// for (XLineBreakpoint breakpoint : XDebuggerManager.getInstance(project).getBreakpointManager()
// .getBreakpoints(JavaLineBreakpointType.class)) {
// //new JavaLineBreakpointRequestor(breakpoint).createRequest(myDebugProcess);
// //adapter.getOrCreate(breakpoint).createRequest(myDebugProcess);
// }
//}
//finally {
// token.finish();
//}
}
});
}
@@ -180,17 +180,17 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
@Override
public Element getState() {
Element state = new Element("state");
myBreakpointManager.writeExternal(state);
//myBreakpointManager.writeExternal(state);
return state;
}
@Override
public void loadState(Element state) {
myBreakpointManager.readExternal(state);
//myBreakpointManager.readExternal(state);
}
public void writeExternal(Element element) throws WriteExternalException {
myBreakpointManager.writeExternal(element);
//myBreakpointManager.writeExternal(element);
}
public DebuggerSession attachVirtualMachine(Executor executor,
@@ -19,19 +19,17 @@ import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.actions.*;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.settings.*;
import com.intellij.debugger.ui.breakpoints.*;
import com.intellij.debugger.ui.breakpoints.Breakpoint;
import com.intellij.ide.DataManager;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.markup.GutterIconRenderer;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xdebugger.AbstractDebuggerSession;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
import com.intellij.xdebugger.impl.DebuggerSupport;
@@ -45,9 +43,10 @@ import com.intellij.xdebugger.impl.evaluate.quick.common.QuickEvaluateHandler;
import com.intellij.xdebugger.impl.settings.DebuggerSettingsPanelProvider;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* @author nik
@@ -63,8 +62,6 @@ public class JavaDebuggerSupport extends DebuggerSupport {
private final ForceRunToCursorActionHandler myForceRunToCursorActionHandler = new ForceRunToCursorActionHandler();
private final ResumeActionHandler myResumeActionHandler = new ResumeActionHandler();
private final PauseActionHandler myPauseActionHandler = new PauseActionHandler();
private final ToggleLineBreakpointActionHandler myToggleLineBreakpointActionHandler = new ToggleLineBreakpointActionHandler(false);
private final ToggleLineBreakpointActionHandler myToggleTemporaryLineBreakpointActionHandler = new ToggleLineBreakpointActionHandler(true);
private final ShowExecutionPointActionHandler myShowExecutionPointActionHandler = new ShowExecutionPointActionHandler();
private final EvaluateActionHandler myEvaluateActionHandler = new EvaluateActionHandler();
private final QuickEvaluateActionHandler myQuickEvaluateHandler = new QuickEvaluateActionHandler();
@@ -73,7 +70,6 @@ public class JavaDebuggerSupport extends DebuggerSupport {
private final DebuggerActionHandler mySmartStepIntoHandler = new JvmSmartStepIntoActionHandler();
private final DebuggerActionHandler myAddToWatchedActionHandler = new AddToWatchActionHandler();
private final JavaMarkObjectActionHandler myMarkObjectActionHandler = new JavaMarkObjectActionHandler();
private final JavaEditBreakpointActionHandler myEditBreakpointActionHandler = new JavaEditBreakpointActionHandler();
@NotNull
public BreakpointPanelProvider<?> getBreakpointPanelProvider() {
@@ -132,13 +128,13 @@ public class JavaDebuggerSupport extends DebuggerSupport {
@NotNull
public DebuggerActionHandler getToggleLineBreakpointHandler() {
return myToggleLineBreakpointActionHandler;
return DISABLED;
}
@NotNull
@Override
public DebuggerActionHandler getToggleTemporaryLineBreakpointHandler() {
return myToggleTemporaryLineBreakpointActionHandler;
return DISABLED;
}
@NotNull
@@ -182,7 +178,7 @@ public class JavaDebuggerSupport extends DebuggerSupport {
@NotNull
@Override
public EditBreakpointActionHandler getEditBreakpointAction() {
return myEditBreakpointActionHandler;
return DISABLED_EDIT;
}
@NotNull
@@ -191,122 +187,124 @@ public class JavaDebuggerSupport extends DebuggerSupport {
}
private static class JavaBreakpointPanelProvider extends BreakpointPanelProvider<Breakpoint> {
private final List<MyBreakpointManagerListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
//private final List<MyBreakpointManagerListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
@Override
public AnAction[] getAddBreakpointActions(@NotNull Project project) {
List<AnAction> result = new ArrayList<AnAction>();
BreakpointFactory[] breakpointFactories = BreakpointFactory.getBreakpointFactories();
for (BreakpointFactory breakpointFactory : breakpointFactories) {
result.add(new AddJavaBreakpointAction(breakpointFactory));
}
return result.toArray(new AnAction[result.size()]);
//List<AnAction> result = new ArrayList<AnAction>();
//BreakpointFactory[] breakpointFactories = BreakpointFactory.getBreakpointFactories();
//for (BreakpointFactory breakpointFactory : breakpointFactories) {
// result.add(new AddJavaBreakpointAction(breakpointFactory));
//}
//return result.toArray(new AnAction[result.size()]);
return AnAction.EMPTY_ARRAY;
}
@Override
public void createBreakpointsGroupingRules(Collection<XBreakpointGroupingRule> rules) {
rules.add(new XBreakpointGroupingByCategoryRule());
//rules.add(new XBreakpointGroupingByCategoryRule());
rules.add(new XBreakpointGroupingByPackageRule());
rules.add(new XBreakpointGroupingByClassRule());
}
@Override
public void addListener(final BreakpointsListener listener, Project project, Disposable disposable) {
BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
final MyBreakpointManagerListener listener1 = new MyBreakpointManagerListener(listener, breakpointManager);
breakpointManager.addBreakpointManagerListener(listener1);
myListeners.add(listener1);
Disposer.register(disposable, new Disposable() {
@Override
public void dispose() {
removeListener(listener);
}
});
//BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
//final MyBreakpointManagerListener listener1 = new MyBreakpointManagerListener(listener, breakpointManager);
//breakpointManager.addBreakpointManagerListener(listener1);
//myListeners.add(listener1);
//Disposer.register(disposable, new Disposable() {
// @Override
// public void dispose() {
// removeListener(listener);
// }
//});
}
@Override
protected void removeListener(BreakpointsListener listener) {
for (MyBreakpointManagerListener managerListener : myListeners) {
if (managerListener.myListener == listener) {
BreakpointManager manager = managerListener.myBreakpointManager;
manager.removeBreakpointManagerListener(managerListener);
myListeners.remove(managerListener);
break;
}
}
//for (MyBreakpointManagerListener managerListener : myListeners) {
// if (managerListener.myListener == listener) {
// BreakpointManager manager = managerListener.myBreakpointManager;
// manager.removeBreakpointManagerListener(managerListener);
// myListeners.remove(managerListener);
// break;
// }
//}
}
public int getPriority() {
return 1;
return 100;
}
public Breakpoint findBreakpoint(@NotNull final Project project, @NotNull final Document document, final int offset) {
return DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().findBreakpoint(document, offset, null);
return null;
//return DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().findBreakpoint(document, offset, null);
}
@Override
public GutterIconRenderer getBreakpointGutterIconRenderer(Object breakpoint) {
if (breakpoint instanceof BreakpointWithHighlighter) {
final RangeHighlighter highlighter = ((BreakpointWithHighlighter)breakpoint).getHighlighter();
if (highlighter != null) {
return (GutterIconRenderer)highlighter.getGutterIconRenderer();
}
}
//if (breakpoint instanceof BreakpointWithHighlighter) {
// final RangeHighlighter highlighter = ((BreakpointWithHighlighter)breakpoint).getHighlighter();
// if (highlighter != null) {
// return (GutterIconRenderer)highlighter.getGutterIconRenderer();
// }
//}
return null;
}
public void onDialogClosed(final Project project) {
DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().updateAllRequests();
//DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().updateAllRequests();
}
@Override
public void provideBreakpointItems(Project project, Collection<BreakpointItem> items) {
for (BreakpointFactory breakpointFactory : BreakpointFactory.getBreakpointFactories()) {
Key<? extends Breakpoint> category = breakpointFactory.getBreakpointCategory();
Breakpoint[] breakpoints = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().getBreakpoints(category);
for (Breakpoint breakpoint : breakpoints) {
items.add(breakpointFactory.createBreakpointItem(breakpoint));
}
}
//for (BreakpointFactory breakpointFactory : BreakpointFactory.getBreakpointFactories()) {
// Key<? extends Breakpoint> category = breakpointFactory.getBreakpointCategory();
// Breakpoint[] breakpoints = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().getBreakpoints(category);
// for (Breakpoint breakpoint : breakpoints) {
// items.add(breakpointFactory.createBreakpointItem(breakpoint));
// }
//}
}
private static class AddJavaBreakpointAction extends AnAction {
private BreakpointFactory myBreakpointFactory;
//private static class AddJavaBreakpointAction extends AnAction {
// private BreakpointFactory myBreakpointFactory;
//
// public AddJavaBreakpointAction(BreakpointFactory breakpointFactory) {
// myBreakpointFactory = breakpointFactory;
// Presentation p = getTemplatePresentation();
// p.setIcon(myBreakpointFactory.getIcon());
// p.setText(breakpointFactory.getDisplayName());
// }
//
// @Override
// public void update(AnActionEvent e) {
// e.getPresentation().setVisible(myBreakpointFactory.canAddBreakpoints());
// }
//
// @Override
// public void actionPerformed(AnActionEvent e) {
// myBreakpointFactory.addBreakpoint(getEventProject(e));
// }
//}
public AddJavaBreakpointAction(BreakpointFactory breakpointFactory) {
myBreakpointFactory = breakpointFactory;
Presentation p = getTemplatePresentation();
p.setIcon(myBreakpointFactory.getIcon());
p.setText(breakpointFactory.getDisplayName());
}
@Override
public void update(AnActionEvent e) {
e.getPresentation().setVisible(myBreakpointFactory.canAddBreakpoints());
}
@Override
public void actionPerformed(AnActionEvent e) {
myBreakpointFactory.addBreakpoint(getEventProject(e));
}
}
private static class MyBreakpointManagerListener implements BreakpointManagerListener {
private final BreakpointsListener myListener;
public BreakpointManager myBreakpointManager;
public MyBreakpointManagerListener(BreakpointsListener listener, BreakpointManager breakpointManager) {
myListener = listener;
myBreakpointManager = breakpointManager;
}
@Override
public void breakpointsChanged() {
myListener.breakpointsChanged();
}
}
//private static class MyBreakpointManagerListener implements BreakpointManagerListener {
//
// private final BreakpointsListener myListener;
// public BreakpointManager myBreakpointManager;
//
//
// public MyBreakpointManagerListener(BreakpointsListener listener, BreakpointManager breakpointManager) {
// myListener = listener;
// myBreakpointManager = breakpointManager;
// }
//
// @Override
// public void breakpointsChanged() {
// myListener.breakpointsChanged();
// }
//}
}
public static class JavaDebuggerSettingsPanelProvider extends DebuggerSettingsPanelProvider {
@@ -341,4 +339,27 @@ public class JavaDebuggerSupport extends DebuggerSupport {
}
return ProjectManager.getInstance().getDefaultProject();
}
private static final DebuggerActionHandler DISABLED = new DebuggerActionHandler() {
@Override
public void perform(@NotNull Project project, AnActionEvent event) {
}
@Override
public boolean isEnabled(@NotNull Project project, AnActionEvent event) {
return false;
}
};
private static final EditBreakpointActionHandler DISABLED_EDIT = new EditBreakpointActionHandler() {
@Override
protected void doShowPopup(Project project, JComponent component, Point whereToShow, Object breakpoint) {
}
@Override
public boolean isEnabled(@NotNull Project project, AnActionEvent event) {
return false;
}
};
}
@@ -437,7 +437,7 @@ public class PositionHighlighter {
public void actionPerformed(AnActionEvent e) {
if (myEventsOutOfLine.size() == 1) {
Breakpoint breakpoint = myEventsOutOfLine.get(0).getFirst();
breakpoint.ENABLED = !breakpoint.ENABLED;
breakpoint.setEnabled(!breakpoint.isEnabled());
DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().fireBreakpointChanged(breakpoint);
}
}
@@ -1,81 +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;
import com.intellij.debugger.ui.breakpoints.Breakpoint;
import com.intellij.debugger.ui.breakpoints.BreakpointFactory;
import com.intellij.openapi.util.Key;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroup;
import com.intellij.xdebugger.impl.breakpoints.ui.grouping.XBreakpointTypeGroup;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* Created with IntelliJ IDEA.
* User: zajac
* Date: 23.05.12
* Time: 16:22
* To change this template use File | Settings | File Templates.
*/
public class XBreakpointCategoryGroup extends XBreakpointGroup {
private Key<? extends Breakpoint> myCategory;
private Icon myIcon;
private final String myName;
public XBreakpointCategoryGroup(BreakpointFactory factory) {
myCategory = factory.getBreakpointCategory();
myIcon = factory.getIcon();
final String name = factory.getDisplayName();
myName = name != null ? name : "UNKNOWN";
}
public Key<? extends Breakpoint> getCategory() {
return myCategory;
}
@Override
public Icon getIcon(boolean isOpen) {
return myIcon;
}
@NotNull
@Override
public String getName() {
return myName;
}
@Override
public int compareTo(XBreakpointGroup o) {
if (o instanceof XBreakpointTypeGroup) {
return -1;
}
if (o instanceof XBreakpointCategoryGroup) {
return getFactoryIndex() - ((XBreakpointCategoryGroup)o).getFactoryIndex();
}
return super.compareTo(o);
}
private int getFactoryIndex() {
BreakpointFactory[] breakpointFactories = BreakpointFactory.getBreakpointFactories();
for (int i = 0; i < breakpointFactories.length; ++i) {
if (breakpointFactories[i].getBreakpointCategory().equals(myCategory)) {
return i;
}
}
return -1;
}
}
@@ -1,64 +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;
import com.intellij.debugger.ui.breakpoints.AnyExceptionBreakpoint;
import com.intellij.debugger.ui.breakpoints.Breakpoint;
import com.intellij.debugger.ui.breakpoints.BreakpointFactory;
import com.intellij.debugger.ui.breakpoints.ExceptionBreakpoint;
import com.intellij.openapi.util.Key;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointsGroupingPriorities;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
class XBreakpointGroupingByCategoryRule<B> extends XBreakpointGroupingRule<B, XBreakpointCategoryGroup> {
XBreakpointGroupingByCategoryRule() {
super("XBreakpointGroupingByCategoryRule", "Type");
}
@Override
public boolean isAlwaysEnabled() {
return true;
}
@Override
public int getPriority() {
return XBreakpointsGroupingPriorities.BY_TYPE;
}
@Override
public XBreakpointCategoryGroup getGroup(@NotNull B b, @NotNull Collection<XBreakpointCategoryGroup> groups) {
if (b instanceof Breakpoint) {
final Breakpoint breakpoint = (Breakpoint)b;
Key<? extends Breakpoint> category = breakpoint.getCategory();
if (category.equals(AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT)) {
category = ExceptionBreakpoint.CATEGORY;
}
for (XBreakpointCategoryGroup group : groups) {
if (group.getCategory().equals(category)) {
return group;
}
}
final BreakpointFactory factory = BreakpointFactory.getInstance(category);
if (factory != null) {
return new XBreakpointCategoryGroup(factory);
}
}
return null;
}
}
@@ -41,7 +41,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
abstract class AddFieldBreakpointDialog extends DialogWrapper {
public abstract class AddFieldBreakpointDialog extends DialogWrapper {
private final Project myProject;
private JPanel myPanel;
private TextFieldWithBrowseButton myFieldChooser;
@@ -30,7 +30,7 @@ public class AddWildcardBreakpointDialog extends DialogWrapper {
private JTextField myClassPatternField;
private JTextField myMethodNameField;
protected AddWildcardBreakpointDialog(Project project) {
public AddWildcardBreakpointDialog(Project project) {
super(project, true);
setTitle("Add Method Breakpoint");
init();
@@ -27,6 +27,7 @@ import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.Key;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.sun.jdi.ReferenceType;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
@@ -34,9 +35,9 @@ import org.jetbrains.annotations.NonNls;
public class AnyExceptionBreakpoint extends ExceptionBreakpoint {
public static final @NonNls Key<AnyExceptionBreakpoint> ANY_EXCEPTION_BREAKPOINT = BreakpointCategory.lookup("breakpoint_any");
protected AnyExceptionBreakpoint(Project project) {
super(project, null, null);
ENABLED = false;
protected AnyExceptionBreakpoint(Project project, XBreakpoint xBreakpoint) {
super(project, null, null, xBreakpoint);
//setEnabled(false);
}
public Key<AnyExceptionBreakpoint> getCategory() {
@@ -49,7 +50,7 @@ public class AnyExceptionBreakpoint extends ExceptionBreakpoint {
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;
}
super.processClassPrepare(debugProcess, null);
@@ -59,13 +60,13 @@ public class AnyExceptionBreakpoint extends ExceptionBreakpoint {
// should be emty - does not make sense for this breakpoint
}
public void readExternal(Element parentNode) throws InvalidDataException {
try {
super.readExternal(parentNode);
}
catch (InvalidDataException e) {
if(!READ_NO_CLASS_NAME.equals(e.getMessage())) throw e;
}
}
//public void readExternal(Element parentNode) throws InvalidDataException {
// try {
// super.readExternal(parentNode);
// }
// catch (InvalidDataException e) {
// if(!READ_NO_CLASS_NAME.equals(e.getMessage())) throw e;
// }
//}
}
@@ -1,65 +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.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 AnyExceptionBreakpointFactory extends BreakpointFactory{
public Breakpoint createBreakpoint(Project project, final Element element) {
return new AnyExceptionBreakpoint(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 null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public String getDisplayName() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) {
return new ExceptionBreakpointPropertiesPanel(project, compact);
}
@Override
public boolean breakpointCanBeRemoved(Breakpoint breakpoint) {
return false;
}
public Key<AnyExceptionBreakpoint> getBreakpointCategory() {
return AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT;
}
}
@@ -30,45 +30,58 @@ 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
@NonNls private static final String LOG_MESSAGE_OPTION_NAME = "LOG_MESSAGE";
public abstract class Breakpoint<P extends JavaBreakpointProperties> implements FilteredRequestor, ClassPrepareRequestor {
final XBreakpoint<P> 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<P> 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 +113,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,15 +233,15 @@ 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 (myXBreakpoint.isLogMessage() || myXBreakpoint.getLogExpression() != null) {
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 (myXBreakpoint.getLogExpression() != null && !expressionToEvaluate.getText().isEmpty()) {
if(!debugProcess.isAttached()) {
return;
}
@@ -252,11 +275,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<ExpressionEvaluator>() {
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 +412,172 @@ 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));
//}
//}
//@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);
}
public boolean isLogEnabled() {
return myXBreakpoint.isLogMessage();
}
public void setLogEnabled(boolean logEnabled) {
myXBreakpoint.setLogMessage(logEnabled);
}
public boolean isLogExpressionEnabled() {
return myXBreakpoint.getLogExpression() != null;
}
public void setLogExpressionEnabled(boolean LOG_EXPRESSION_ENABLED) {
}
@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));
public boolean isCountFilterEnabled() {
return myXBreakpoint.getProperties().COUNT_FILTER_ENABLED;
}
public void setCountFilterEnabled(boolean enabled) {
myXBreakpoint.getProperties().COUNT_FILTER_ENABLED = enabled;
}
@Override
public int getCountFilter() {
return myXBreakpoint.getProperties().COUNT_FILTER;
}
public void setCountFilter(int filter) {
myXBreakpoint.getProperties().COUNT_FILTER = filter;
}
@Override
public boolean isClassFiltersEnabled() {
return myXBreakpoint.getProperties().CLASS_FILTERS_ENABLED;
}
public void setClassFiltersEnabled(boolean enabled) {
myXBreakpoint.getProperties().CLASS_FILTERS_ENABLED = enabled;
}
@Override
public ClassFilter[] getClassFilters() {
return myXBreakpoint.getProperties().getClassFilters();
}
public void setClassFilters(ClassFilter[] filters) {
myXBreakpoint.getProperties().setClassFilters(filters);
}
@Override
public ClassFilter[] getClassExclusionFilters() {
return myXBreakpoint.getProperties().getClassExclusionFilters();
}
public void setClassExclusionFilters(ClassFilter[] filters) {
myXBreakpoint.getProperties().setClassExclusionFilters(filters);
}
@Override
public boolean isInstanceFiltersEnabled() {
return myXBreakpoint.getProperties().INSTANCE_FILTERS_ENABLED;
}
public void setInstanceFiltersEnabled(boolean enabled) {
myXBreakpoint.getProperties().INSTANCE_FILTERS_ENABLED = enabled;
}
@Override
public InstanceFilter[] getInstanceFilters() {
return myXBreakpoint.getProperties().getInstanceFilters();
}
public void setInstanceFilters(InstanceFilter[] filters) {
myXBreakpoint.getProperties().setInstanceFilters(filters);
}
public 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");
}
}
@Override
public void writeExternal(Element parentNode) throws WriteExternalException {
super.writeExternal(parentNode);
JDOMExternalizerUtil.writeField(parentNode, LOG_MESSAGE_OPTION_NAME, getLogMessage().toExternalForm());
public 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");
}
}
public TextWithImports getLogMessage() {
return myLogMessage;
public boolean isSuspend() {
return myXBreakpoint.getSuspendPolicy() != SuspendPolicy.NONE;
}
@Override
public String getSuspendPolicy() {
return getSuspendPolicy(myXBreakpoint);
}
public void setSuspendPolicy(String policy) {
myXBreakpoint.setSuspendPolicy(transformSuspendPolicy(policy));
}
public void setLogMessage(TextWithImports logMessage) {
myLogMessage = logMessage;
myXBreakpoint.setLogExpression(logMessage.getText());
}
public boolean isConditionEnabled() {
return myXBreakpoint.getCondition() != null && !myXBreakpoint.getCondition().isEmpty();
}
public void setCondition(String condition) {
myXBreakpoint.setCondition(condition);
}
public void addInstanceFilter(long l) {
myXBreakpoint.getProperties().addInstanceFilter(l);
}
}
@@ -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<BreakpointFactory> 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);
}
}
File diff suppressed because it is too large Load Diff
@@ -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;
@@ -465,8 +468,8 @@ public abstract class BreakpointPropertiesPanel {
initMasterBreakpointPanel();
if (breakpoint.COUNT_FILTER > 0) {
myPassCountField.setText(Integer.toString(breakpoint.COUNT_FILTER));
if (breakpoint.getCountFilter() > 0) {
myPassCountField.setText(Integer.toString(breakpoint.getCountFilter()));
moreOptionsVisible = true;
}
else {
@@ -474,23 +477,23 @@ public abstract class BreakpointPropertiesPanel {
}
PsiElement context = breakpoint.getEvaluationElement();
myPassCountCheckbox.setSelected(breakpoint.COUNT_FILTER_ENABLED);
myPassCountCheckbox.setSelected(breakpoint.isCountFilterEnabled());
myConditionCheckbox.setSelected(breakpoint.CONDITION_ENABLED);
myConditionCheckbox.setSelected(breakpoint.isConditionEnabled());
myConditionCombo.setEnabled(breakpoint.CONDITION_ENABLED);
myConditionCombo.setEnabled(breakpoint.isConditionEnabled());
myConditionCombo.setContext(context);
myConditionCombo.setText(breakpoint.getCondition() != null ? breakpoint.getCondition() : emptyText());
myCbSuspend.setSelected(breakpoint.SUSPEND);
myCbSuspend.setSelected(breakpoint.isSuspend());
myRbSuspendThread.setEnabled(myCbSuspend.isSelected());
myRbSuspendAll.setEnabled(myCbSuspend.isSelected());
if(!breakpoint.SUSPEND) {
if(!breakpoint.isSuspend()) {
actionsPanelVisible = true;
}
if(DebuggerSettings.SUSPEND_THREAD.equals(breakpoint.SUSPEND_POLICY)){
if(DebuggerSettings.SUSPEND_THREAD.equals(breakpoint.getSuspendPolicy())){
myRbSuspendThread.setSelected(true);
}
else {
@@ -511,31 +514,32 @@ public abstract class BreakpointPropertiesPanel {
myRbSuspendAll.setEnabled(myCbSuspend.isSelected());
}
});
myLogMessageCheckBox.setSelected(breakpoint.LOG_ENABLED);
myTemporaryCheckBox.setSelected(breakpoint.REMOVE_AFTER_HIT);
myEnabledCheckbox.setSelected(breakpoint.ENABLED);
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.ENABLED);
myEnabledCheckbox.setSelected(myBreakpoint.isEnabled());
}
});
myEnabledCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
if (myBreakpoint.ENABLED != myEnabledCheckbox.isSelected()) {
myBreakpoint.ENABLED = myEnabledCheckbox.isSelected();
if (myBreakpoint.isEnabled() != myEnabledCheckbox.isSelected()) {
myBreakpoint.setEnabled(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)) {
myLogExpressionCheckBox.setSelected(breakpoint.isLogExpressionEnabled());
if (breakpoint.isLogEnabled() ||
breakpoint.isLogExpressionEnabled() || (breakpoint instanceof LineBreakpoint && breakpoint.isRemoveAfterHit())) {
actionsPanelVisible = true;
}
@@ -548,27 +552,27 @@ public abstract class BreakpointPropertiesPanel {
myLogExpressionCombo.setText(emptyText());
}
myLogExpressionCombo.setEnabled(breakpoint.LOG_EXPRESSION_ENABLED);
if (breakpoint.LOG_EXPRESSION_ENABLED) {
myLogExpressionCombo.setEnabled(breakpoint.isLogExpressionEnabled());
if (breakpoint.isLogExpressionEnabled()) {
actionsPanelVisible = true;
}
myInstanceFiltersCheckBox.setSelected(breakpoint.INSTANCE_FILTERS_ENABLED);
myInstanceFiltersField.setEnabled(breakpoint.INSTANCE_FILTERS_ENABLED);
myInstanceFiltersField.getTextField().setEditable(breakpoint.INSTANCE_FILTERS_ENABLED);
myInstanceFiltersCheckBox.setSelected(breakpoint.isInstanceFiltersEnabled());
myInstanceFiltersField.setEnabled(breakpoint.isInstanceFiltersEnabled());
myInstanceFiltersField.getTextField().setEditable(breakpoint.isInstanceFiltersEnabled());
myInstanceFilters = breakpoint.getInstanceFilters();
updateInstanceFilterEditor(true);
if (breakpoint.INSTANCE_FILTERS_ENABLED) {
if (breakpoint.isInstanceFiltersEnabled()) {
moreOptionsVisible = true;
}
myClassFiltersCheckBox.setSelected(breakpoint.CLASS_FILTERS_ENABLED);
myClassFiltersField.setEnabled(breakpoint.CLASS_FILTERS_ENABLED);
myClassFiltersField.getTextField().setEditable(breakpoint.CLASS_FILTERS_ENABLED);
myClassFiltersCheckBox.setSelected(breakpoint.isClassFiltersEnabled());
myClassFiltersField.setEnabled(breakpoint.isClassFiltersEnabled());
myClassFiltersField.getTextField().setEditable(breakpoint.isClassFiltersEnabled());
myClassFilters = breakpoint.getClassFilters();
myClassExclusionFilters = breakpoint.getClassExclusionFilters();
updateClassFilterEditor(true);
if (breakpoint.CLASS_FILTERS_ENABLED) {
if (breakpoint.isClassFiltersEnabled()) {
moreOptionsVisible = true;
}
@@ -635,31 +639,31 @@ public abstract class BreakpointPropertiesPanel {
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;
breakpoint.setCountFilter(!text.isEmpty() ? Integer.parseInt(text) : 0);
if (breakpoint.getCountFilter() < 0) {
breakpoint.setCountFilter(0);
}
}
catch (Exception ignored) {
}
breakpoint.COUNT_FILTER_ENABLED = breakpoint.COUNT_FILTER > 0 && myPassCountCheckbox.isSelected();
breakpoint.setCondition(myConditionCombo.getText());
breakpoint.CONDITION_ENABLED = myConditionCheckbox.isSelected();
breakpoint.setCountFilterEnabled(breakpoint.getCountFilter() > 0 && myPassCountCheckbox.isSelected());
breakpoint.setCondition(myConditionCombo.getText().getText());
//breakpoint.setConditionEnabled(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();
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.INSTANCE_FILTERS_ENABLED = myInstanceFiltersField.getText().length() > 0 && myInstanceFiltersCheckBox.isSelected();
breakpoint.CLASS_FILTERS_ENABLED = myClassFiltersField.getText().length() > 0 && myClassFiltersCheckBox.isSelected();
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);
@@ -25,49 +25,52 @@ 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.editor.markup.MarkupEditorFilterFactory;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.InvalidDataException;
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.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<P extends JavaBreakpointProperties> extends Breakpoint<P> {
@Nullable
private RangeHighlighter myHighlighter;
@@ -150,7 +153,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 +187,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 +212,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) {
private static boolean isPositionValid(@Nullable final XSourcePosition sourcePosition) {
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
@@ -238,34 +242,34 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
}
buf.append("&nbsp;<br>&nbsp;");
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("&nbsp;<br>&nbsp;");
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("&nbsp;<br>&nbsp;");
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("&nbsp;<br>&nbsp;");
buf.append(DebuggerBundle.message("breakpoint.property.name.condition")).append(": ");
buf.append(XmlStringUtil.escapeString(getCondition().getText()));
}
if (COUNT_FILTER_ENABLED) {
if (isCountFilterEnabled()) {
buf.append("&nbsp;<br>&nbsp;");
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("&nbsp;<br>&nbsp;");
buf.append(DebuggerBundle.message("breakpoint.property.name.class.filters")).append(": ");
ClassFilter[] classFilters = getClassFilters();
@@ -273,7 +277,7 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
buf.append(classFilter.getPattern()).append(" ");
}
}
if (INSTANCE_FILTERS_ENABLED) {
if (isInstanceFiltersEnabled()) {
buf.append("&nbsp;<br>&nbsp;");
buf.append(DebuggerBundle.message("breakpoint.property.name.instance.filters"));
InstanceFilter[] instanceFilters = getInstanceFilters();
@@ -292,23 +296,21 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
@Override
public final 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 +331,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 +385,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 +454,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();
@@ -555,164 +561,164 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
return highlighter;
}
@Override
public void readExternal(@NotNull Element breakpointNode) throws InvalidDataException {
super.readExternal(breakpointNode);
//noinspection HardCodedStringLiteral
final String url = breakpointNode.getAttributeValue("url");
//@Override
//public void readExternal(@NotNull Element breakpointNode) throws InvalidDataException {
// super.readExternal(breakpointNode);
// //noinspection HardCodedStringLiteral
// final String url = breakpointNode.getAttributeValue("url");
//
// //noinspection HardCodedStringLiteral
// final String className = breakpointNode.getAttributeValue("class");
// if (className != null) {
// myClassName = className;
// }
//
// //noinspection HardCodedStringLiteral
// final String packageName = breakpointNode.getAttributeValue("package");
// if (packageName != null) {
// 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();
//}
//
//@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);
// }
//}
//noinspection HardCodedStringLiteral
final String className = breakpointNode.getAttributeValue("class");
if (className != null) {
myClassName = className;
}
//noinspection HardCodedStringLiteral
final String packageName = breakpointNode.getAttributeValue("package");
if (packageName != null) {
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();
}
@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();
// }
//}
}
@@ -33,14 +33,13 @@ import com.intellij.icons.AllIcons;
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.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;
@@ -48,38 +47,33 @@ import com.sun.jdi.ReferenceType;
import com.sun.jdi.event.ExceptionEvent;
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<JavaExceptionBreakpointProperties> {
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<ExceptionBreakpoint> 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 +86,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<PsiClass>() {
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 +118,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<SourcePosition>() {
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 +140,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, isNOTIFY_CAUGHT(),
isNOTIFY_UNCAUGHT());
debugProcess.getRequestsManager().enableRequest(request);
if (LOG.isDebugEnabled()) {
if (refType != null) {
@@ -170,7 +165,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 +211,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) {
@@ -233,18 +228,37 @@ public class ExceptionBreakpoint extends Breakpoint {
return JavaPsiFacade.getInstance(myProject).findClass(getClassName(), GlobalSearchScope.allScope(myProject));
}
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);
}
//public void readExternal(Element parentNode) throws InvalidDataException {
// super.readExternal(parentNode);
// //noinspection HardCodedStringLiteral
// String className = parentNode.getAttributeValue("class_name");
// setQualifiedName(className);
// if(className == null) {
// throw new InvalidDataException(READ_NO_CLASS_NAME);
// }
//
// //noinspection HardCodedStringLiteral
// String packageName = parentNode.getAttributeValue("package_name");
// setPackageName(packageName != null? packageName : calcPackageName(packageName));
//}
//noinspection HardCodedStringLiteral
String packageName = parentNode.getAttributeValue("package_name");
myPackageName = packageName != null? packageName : calcPackageName(packageName);
public boolean isNOTIFY_CAUGHT() {
return getProperties().NOTIFY_CAUGHT;
}
public boolean isNOTIFY_UNCAUGHT() {
return getProperties().NOTIFY_UNCAUGHT;
}
public String getQualifiedName() {
return getProperties().myQualifiedName;
}
public void setQualifiedName(String qualifiedName) {
getProperties().myQualifiedName = qualifiedName;
}
public void setPackageName(String packageName) {
getProperties().myPackageName = packageName;
}
}
@@ -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<ExceptionBreakpoint> 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;
}
}
@@ -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<XBreakpoint<JavaExceptionBreakpointProperties>> {
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<JavaExceptionBreakpointProperties> 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<JavaExceptionBreakpointProperties> breakpoint) {
breakpoint.getProperties().NOTIFY_CAUGHT = myNotifyCaughtCheckBox.isSelected();
breakpoint.getProperties().NOTIFY_UNCAUGHT = myNotifyUncaughtCheckBox.isSelected();
}
}
@@ -36,9 +36,7 @@ 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.Key;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.psi.*;
@@ -46,35 +44,33 @@ 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;
import com.sun.jdi.event.ModificationWatchpointEvent;
import com.sun.jdi.request.AccessWatchpointRequest;
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<JavaFieldBreakpointProperties> {
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<FieldBreakpoint> 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, RangeHighlighter highlighter, @NotNull String fieldName, XBreakpoint breakpoint) {
super(project, highlighter, breakpoint);
setFieldName(fieldName);
}
public boolean isStatic() {
@@ -82,10 +78,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 +123,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 +137,11 @@ 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());
myIsStatic = field.hasModifierProperty(PsiModifier.STATIC);
}
if (myIsStatic) {
INSTANCE_FILTERS_ENABLED = false;
setInstanceFiltersEnabled(false);
}
}
@@ -181,20 +176,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 (isWATCH_MODIFICATION() && 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 (isWATCH_ACCESS() && vm.canWatchFieldAccess()) {
AccessWatchpointRequest request = manager.createAccessWatchpointRequest(this, field);
debugProcess.getRequestsManager().enableRequest(request);
if (LOG.isDebugEnabled()) {
@@ -284,11 +280,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, @NotNull Document document, int lineIndex, String fieldName, XBreakpoint xBreakpoint) {
FieldBreakpoint breakpoint = new FieldBreakpoint(project, createHighlighter(project, document, lineIndex), fieldName, xBreakpoint);
return (FieldBreakpoint)breakpoint.init();
}
@@ -308,7 +304,7 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
return field == getPsiField();
}
protected static FieldBreakpoint create(@NotNull Project project, @NotNull Field field, ObjectReference object) {
protected static FieldBreakpoint create(@NotNull Project project, @NotNull Field field, ObjectReference object, XBreakpoint xBreakpoint) {
String fieldName = field.name();
int line = 0;
Document document = null;
@@ -335,7 +331,7 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
if(document == null) return null;
FieldBreakpoint fieldBreakpoint = new FieldBreakpoint(project, createHighlighter(project, document, line), fieldName);
FieldBreakpoint fieldBreakpoint = new FieldBreakpoint(project, createHighlighter(project, document, line), fieldName, xBreakpoint);
if (!fieldBreakpoint.isStatic()) {
fieldBreakpoint.addInstanceFilter(object.uniqueID());
}
@@ -369,25 +365,37 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
return field;
}
@Override
public void readExternal(@NotNull Element breakpointNode) throws InvalidDataException {
super.readExternal(breakpointNode);
//noinspection HardCodedStringLiteral
myFieldName = breakpointNode.getAttributeValue("field_name");
if(myFieldName == null) {
throw new InvalidDataException("No field name for field breakpoint");
}
}
@Override
@SuppressWarnings({"HardCodedStringLiteral"})
public void writeExternal(@NotNull Element parentNode) throws WriteExternalException {
super.writeExternal(parentNode);
parentNode.setAttribute("field_name", getFieldName());
}
//@Override
//public void readExternal(@NotNull Element breakpointNode) throws InvalidDataException {
// super.readExternal(breakpointNode);
// //noinspection HardCodedStringLiteral
// setFieldName(breakpointNode.getAttributeValue("field_name"));
// if(getFieldName() == null) {
// throw new InvalidDataException("No field name for field breakpoint");
// }
//}
//
//@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();
}
public boolean isWATCH_MODIFICATION() {
return getProperties().WATCH_MODIFICATION;
}
public boolean isWATCH_ACCESS() {
return getProperties().WATCH_ACCESS;
}
public void setFieldName(String fieldName) {
getProperties().myFieldName = fieldName;
}
}
@@ -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<FieldBreakpoint> getBreakpointCategory() {
return FieldBreakpoint.CATEGORY;
}
@Override
public Breakpoint addBreakpoint(final Project project) {
final Ref<Breakpoint> 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;
}
}
@@ -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<XLineBreakpoint<JavaFieldBreakpointProperties>> {
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<JavaFieldBreakpointProperties> 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<JavaFieldBreakpointProperties> breakpoint) {
breakpoint.getProperties().WATCH_ACCESS = myWatchAccessCheckBox.isSelected();
breakpoint.getProperties().WATCH_MODIFICATION = myWatchModificationCheckBox.isSelected();
}
}
@@ -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<InstanceFilter> iFilters = new ArrayList<InstanceFilter>(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<ExpressionEvaluator>() {
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();
}
@@ -0,0 +1,221 @@
/*
* 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.*;
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.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;
/*
* Not used any more, since move to xBreakpoints
*/
public abstract 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 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<InstanceFilter> iFilters = new ArrayList<InstanceFilter>(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 abstract PsiElement getEvaluationElement();
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;
}
}
@@ -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);
}
}
@@ -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);
}
}
/**
* Base class for all Java breakpoint types
* @author egor
*/
public interface JavaBreakpointType<P extends JavaBreakpointProperties> {
Breakpoint createJavaBreakpoint(Project project, XBreakpoint<P> breakpoint);
}
@@ -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<T extends JavaBreakpointProperties> extends XBreakpointType<XBreakpoint<T>, 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<XBreakpoint<T>> createCustomRightPropertiesPanel(@NotNull Project project) {
return new JavaBreakpointFiltersPanel<T, XBreakpoint<T>>(project);
}
@Nullable
@Override
public final XDebuggerEditorsProvider getEditorsProvider(@NotNull XBreakpoint<T> breakpoint, @NotNull Project project) {
return new JavaDebuggerEditorsProvider();
}
}
@@ -0,0 +1,139 @@
/*
* 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.AccessToken;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.project.Project;
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<JavaExceptionBreakpointProperties>
implements JavaBreakpointType<JavaExceptionBreakpointProperties> {
public JavaExceptionBreakpointType() {
super("javaException", 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<JavaExceptionBreakpointProperties> 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<XBreakpoint<JavaExceptionBreakpointProperties>> createCustomPropertiesPanel() {
return new ExceptionBreakpointPropertiesPanel();
}
@Nullable
@Override
public XBreakpoint<JavaExceptionBreakpointProperties> createDefaultBreakpoint(@NotNull XBreakpointCreator<JavaExceptionBreakpointProperties> creator) {
return creator.createBreakpoint(new JavaExceptionBreakpointProperties());
}
//public Key<ExceptionBreakpoint> getBreakpointCategory() {
// return ExceptionBreakpoint.CATEGORY;
//}
@Nullable
@Override
public XBreakpoint<JavaExceptionBreakpointProperties> addBreakpoint(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();
PsiClass selectedClass = chooser.getSelected();
String qName = selectedClass == null ? null : JVMNameUtil.getNonAnonymousClassName(selectedClass);
if (qName != null && qName.length() > 0) {
AccessToken token = WriteAction.start();
try {
return XDebuggerManager.getInstance(project).getBreakpointManager().addBreakpoint(
this, new JavaExceptionBreakpointProperties(qName, ((PsiClassOwner)selectedClass.getContainingFile()).getPackageName()));
}
finally {
token.finish();
}
}
return null;
}
@Override
public Breakpoint createJavaBreakpoint(Project project, XBreakpoint<JavaExceptionBreakpointProperties> breakpoint) {
if (breakpoint.getProperties().myQualifiedName != null) {
return new ExceptionBreakpoint(project, breakpoint);
}
else {
return new AnyExceptionBreakpoint(project, breakpoint);
}
}
}
@@ -0,0 +1,170 @@
/*
* 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.AccessToken;
import com.intellij.openapi.application.WriteAction;
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<JavaFieldBreakpointProperties> implements JavaBreakpointType {
public JavaFieldBreakpointType() {
super("javaField", 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<JavaFieldBreakpointProperties> breakpoint) {
return getDisplayText(breakpoint);
}
@Override
public String getDisplayText(XLineBreakpoint<JavaFieldBreakpointProperties> breakpoint) {
//if(!isValid()) {
// return DebuggerBundle.message("status.breakpoint.invalid");
//}
JavaFieldBreakpointProperties properties = breakpoint.getProperties();
final String className = "Class";//properties.getClassName();
return className != null && !className.isEmpty() ? className + "." + properties.myFieldName : properties.myFieldName;
}
@Nullable
@Override
public XBreakpointCustomPropertiesPanel<XLineBreakpoint<JavaFieldBreakpointProperties>> 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<JavaFieldBreakpointProperties> addBreakpoint(final Project project, JComponent parentComponent) {
final Ref<XLineBreakpoint> 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());
AccessToken token = WriteAction.start();
try {
XLineBreakpoint<JavaFieldBreakpointProperties> fieldBreakpoint = XDebuggerManager.getInstance(project).getBreakpointManager()
.addLineBreakpoint(JavaFieldBreakpointType.this, psiFile.getVirtualFile().getUrl(), line, new JavaFieldBreakpointProperties(fieldName));
if (fieldBreakpoint != null) {
result.set(fieldBreakpoint);
return true;
}
}
finally {
token.finish();
}
}
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);
}
}
@@ -0,0 +1,86 @@
/*
* 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 javax.swing.*;
import java.util.List;
/**
* Base class for java line-connected exceptions (line, method, field)
* @author egor
*/
public class JavaLineBreakpointType extends JavaLineBreakpointTypeBase<JavaBreakpointProperties> implements JavaBreakpointType {
public JavaLineBreakpointType() {
super("javaLine", 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<XBreakpointGroupingRule<XLineBreakpoint<JavaBreakpointProperties>, ?>> getGroupingRules() {
return XDebuggerUtil.getInstance().getGroupingByFileRuleAsList();
}
@Nullable
@Override
public JavaBreakpointProperties createProperties() {
return new JavaBreakpointProperties();
}
@Nullable
@Override
public JavaBreakpointProperties createBreakpointProperties(@NotNull VirtualFile file, int line) {
return new JavaBreakpointProperties();
}
@Override
public Breakpoint createJavaBreakpoint(Project project, XBreakpoint breakpoint) {
return new LineBreakpoint(project, breakpoint);
}
}
@@ -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<P extends JavaBreakpointProperties> extends XLineBreakpointType<P> {
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<XLineBreakpoint<P>> createCustomRightPropertiesPanel(@NotNull Project project) {
return new JavaBreakpointFiltersPanel<P, XLineBreakpoint<P>>(project);
}
@Nullable
@Override
public final XDebuggerEditorsProvider getEditorsProvider(@NotNull XLineBreakpoint<P> 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<Class<? extends JavaLineBreakpointTypeBase>> result = Ref.create();
XDebuggerUtil.getInstance().iterateLine(project, document, line, new Processor<PsiElement>() {
@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();
}
}
@@ -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<JavaMethodBreakpointProperties> implements JavaBreakpointType {
public JavaMethodBreakpointType() {
super("javaMethod", 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<JavaMethodBreakpointProperties> breakpoint) {
return getDisplayText(breakpoint);
}
@Override
public String getDisplayText(XLineBreakpoint<JavaMethodBreakpointProperties> breakpoint) {
return getText(breakpoint);
}
static String getText(XBreakpoint<JavaMethodBreakpointProperties> 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);
}
}
@@ -0,0 +1,108 @@
/*
* 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.AccessToken;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.project.Project;
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<JavaMethodBreakpointProperties> implements JavaBreakpointType {
public JavaWildcardMethodBreakpointType() {
super("javaWildcardMethod", 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<JavaMethodBreakpointProperties> breakpoint) {
return JavaMethodBreakpointType.getText(breakpoint);
}
@Nullable
@Override
public XBreakpointCustomPropertiesPanel<XBreakpoint<JavaMethodBreakpointProperties>> createCustomPropertiesPanel() {
return new MethodBreakpointPropertiesPanel();
}
//@Override
//public Key<MethodBreakpoint> getBreakpointCategory() {
// return MethodBreakpoint.CATEGORY;
//}
@Nullable
@Override
public JavaMethodBreakpointProperties createProperties() {
return new JavaMethodBreakpointProperties();
}
@Nullable
@Override
public XBreakpoint<JavaMethodBreakpointProperties> addBreakpoint(Project project, JComponent parentComponent) {
AddWildcardBreakpointDialog dialog = new AddWildcardBreakpointDialog(project);
dialog.show();
if (!dialog.isOK()) {
return null;
}
AccessToken token = WriteAction.start();
try {
return XDebuggerManager.getInstance(project).getBreakpointManager().addBreakpoint(this, new JavaMethodBreakpointProperties(
dialog.getClassPattern(),
dialog.getMethodName()));
}
finally {
token.finish();
}
}
@Override
public Breakpoint createJavaBreakpoint(Project project, XBreakpoint breakpoint) {
return new WildcardMethodBreakpoint(project, breakpoint);
}
}
@@ -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,12 @@ public class LineBreakpoint extends BreakpointWithHighlighter {
private String myOwnerMethodName;
public static final @NonNls Key<LineBreakpoint> CATEGORY = BreakpointCategory.lookup("line_breakpoints");
protected LineBreakpoint(Project project) {
super(project);
protected LineBreakpoint(Project project, XBreakpoint xBreakpoint) {
super(project, xBreakpoint);
}
public LineBreakpoint(Project project, RangeHighlighter highlighter) {
super(project, highlighter);
public LineBreakpoint(Project project, RangeHighlighter highlighter, XBreakpoint xBreakpoint) {
super(project, highlighter, xBreakpoint);
}
@Override
@@ -95,7 +96,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 +109,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 +350,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 +471,24 @@ public class LineBreakpoint extends BreakpointWithHighlighter {
return ContextUtil.getContextElement(getSourcePosition());
}
public static LineBreakpoint create(@NotNull Project project, @NotNull Document document, int lineIndex) {
public static LineBreakpoint create(@NotNull Project project, @NotNull Document document, int lineIndex, XBreakpoint xBreakpoint) {
final RangeHighlighter highlighter = createHighlighter(project, document, lineIndex);
if (highlighter == null) {
return null;
}
LineBreakpoint breakpoint = new LineBreakpoint(project, highlighter);
LineBreakpoint breakpoint = new LineBreakpoint(project, highlighter, 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()) {
@@ -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<LineBreakpoint> getBreakpointCategory() {
return LineBreakpoint.CATEGORY;
}
}
@@ -35,13 +35,20 @@ import com.intellij.icons.AllIcons;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Key;
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.util.StringBuilderSpinAllocator;
import com.intellij.util.text.CharArrayUtil;
import com.intellij.xdebugger.XDebuggerUtil;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.sun.jdi.AbsentInformationException;
import com.sun.jdi.Location;
import com.sun.jdi.Method;
@@ -55,28 +62,25 @@ import com.sun.jdi.request.MethodExitRequest;
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<JavaMethodBreakpointProperties> {
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<MethodBreakpoint> 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 +108,21 @@ 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;
}
if (myIsStatic) {
INSTANCE_FILTERS_ENABLED = false;
setInstanceFiltersEnabled(false);
}
}
@@ -130,7 +134,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 +148,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
}
RequestManagerImpl requestManager = debugProcess.getRequestsManager();
if (WATCH_ENTRY) {
if (isWATCH_ENTRY()) {
MethodEntryRequest entryRequest = (MethodEntryRequest)findRequest(debugProcess, MethodEntryRequest.class);
if (entryRequest == null) {
entryRequest = requestManager.createMethodEntryRequest(this);
@@ -157,7 +161,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
entryRequest.addClassFilter(classType);
debugProcess.getRequestsManager().enableRequest(entryRequest);
}
if (WATCH_EXIT) {
if (isWATCH_EXIT()) {
MethodExitRequest exitRequest = (MethodExitRequest)findRequest(debugProcess, MethodExitRequest.class);
if (exitRequest == null) {
exitRequest = requestManager.createMethodExitRequest(this);
@@ -256,11 +260,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,15 +285,15 @@ 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) {
public static MethodBreakpoint create(@NotNull Project project, @NotNull Document document, int lineIndex, XBreakpoint xBreakpoint) {
final MethodBreakpoint breakpoint = new MethodBreakpoint(project, createHighlighter(project, document, lineIndex));
return (MethodBreakpoint)breakpoint.init();
}
@@ -376,6 +380,31 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
return false;
}
public boolean isWATCH_ENTRY() {
return getProperties().WATCH_ENTRY;
}
public void setWATCH_ENTRY(boolean WATCH_ENTRY) {
getProperties().WATCH_ENTRY = WATCH_ENTRY;
}
public boolean isWATCH_EXIT() {
return getProperties().WATCH_EXIT;
}
public void setWATCH_EXIT(boolean WATCH_EXIT) {
getProperties().WATCH_EXIT = WATCH_EXIT;
}
@Nullable
public String getMethodName() {
return getProperties().myMethodName;
}
public void setMethodName(@Nullable String methodName) {
getProperties().myMethodName = methodName;
}
private static final class MethodDescriptor {
String methodName;
JVMName methodSignature;
@@ -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<MethodBreakpoint> 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;
}
}
@@ -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<XBreakpoint<JavaMethodBreakpointProperties>> {
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<JavaMethodBreakpointProperties> 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<JavaMethodBreakpointProperties> breakpoint) {
breakpoint.getProperties().WATCH_ENTRY = myWatchEntryCheckBox.isSelected();
breakpoint.getProperties().WATCH_EXIT = myWatchExitCheckBox.isSelected();
}
}
@@ -22,6 +22,7 @@ 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.xdebugger.breakpoints.XBreakpoint;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -34,15 +35,15 @@ public class RunToCursorBreakpoint extends LineBreakpoint {
@Nullable
private final SourcePosition myCustomPosition;
protected RunToCursorBreakpoint(@NotNull Project project, @NotNull RangeHighlighter highlighter, boolean restoreBreakpoints) {
super(project, highlighter);
protected RunToCursorBreakpoint(@NotNull Project project, @NotNull RangeHighlighter highlighter, boolean restoreBreakpoints, XBreakpoint xBreakpoint) {
super(project, highlighter, xBreakpoint);
setVisible(false);
myRestoreBreakpoints = restoreBreakpoints;
myCustomPosition = null;
}
protected RunToCursorBreakpoint(@NotNull Project project, @NotNull SourcePosition pos, boolean restoreBreakpoints) {
super(project);
protected RunToCursorBreakpoint(@NotNull Project project, @NotNull SourcePosition pos, boolean restoreBreakpoints, XBreakpoint xBreakpoint) {
super(project, xBreakpoint);
myCustomPosition = pos;
setVisible(false);
myRestoreBreakpoints = restoreBreakpoints;
@@ -68,7 +69,7 @@ public class RunToCursorBreakpoint extends LineBreakpoint {
}
@Nullable
protected static RunToCursorBreakpoint create(@NotNull Project project, @NotNull Document document, int lineIndex, boolean restoreBreakpoints) {
protected static RunToCursorBreakpoint create(@NotNull Project project, @NotNull Document document, int lineIndex, boolean restoreBreakpoints, XBreakpoint xBreakpoint) {
VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document);
if (virtualFile == null) {
return null;
@@ -79,7 +80,7 @@ public class RunToCursorBreakpoint extends LineBreakpoint {
return null;
}
final RunToCursorBreakpoint breakpoint = new RunToCursorBreakpoint(project, highlighter, restoreBreakpoints);
final RunToCursorBreakpoint breakpoint = new RunToCursorBreakpoint(project, highlighter, restoreBreakpoints, xBreakpoint);
final RangeHighlighter h = breakpoint.getHighlighter();
if (h != null) {
h.dispose();
@@ -41,7 +41,7 @@ public class StepIntoBreakpoint extends RunToCursorBreakpoint {
private final BreakpointStepMethodFilter myFilter;
StepIntoBreakpoint(@NotNull Project project, @NotNull SourcePosition pos, @NotNull BreakpointStepMethodFilter filter) {
super(project, pos, false);
super(project, pos, false, null);
myFilter = filter;
}
@@ -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;
@@ -32,6 +32,7 @@ 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;
@@ -45,37 +46,33 @@ 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<JavaMethodBreakpointProperties> {
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<MethodBreakpoint> 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 +80,7 @@ public class WildcardMethodBreakpoint extends Breakpoint {
}
public String getMethodName() {
return myMethodName;
return getProperties().myMethodName;
}
public PsiClass getPsiClass() {
@@ -96,9 +93,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 +105,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 +121,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 (isWATCH_ENTRY()) {
MethodEntryRequest entryRequest = (MethodEntryRequest)findRequest(debugProcess, MethodEntryRequest.class);
if (entryRequest == null) {
entryRequest = requestManager.createMethodEntryRequest(this);
@@ -137,10 +134,10 @@ public class WildcardMethodBreakpoint extends Breakpoint {
else {
entryRequest.disable();
}
entryRequest.addClassFilter(myClassPattern);
entryRequest.addClassFilter(getClassPattern());
debugProcess.getRequestsManager().enableRequest(entryRequest);
}
if (WATCH_EXIT) {
if (isWATCH_EXIT()) {
MethodExitRequest exitRequest = (MethodExitRequest)findRequest(debugProcess, MethodExitRequest.class);
if (exitRequest == null) {
exitRequest = requestManager.createMethodExitRequest(this);
@@ -148,7 +145,7 @@ public class WildcardMethodBreakpoint extends Breakpoint {
else {
exitRequest.disable();
}
exitRequest.addClassFilter(myClassPattern);
exitRequest.addClassFilter(getClassPattern());
debugProcess.getRequestsManager().enableRequest(exitRequest);
}
}
@@ -212,46 +209,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);
}
public boolean isWATCH_ENTRY() {
return getProperties().WATCH_ENTRY;
}
public void setWATCH_ENTRY(boolean WATCH_ENTRY) {
getProperties().WATCH_ENTRY = WATCH_ENTRY;
}
public boolean isWATCH_EXIT() {
return getProperties().WATCH_EXIT;
}
public void setWATCH_EXIT(boolean WATCH_EXIT) {
getProperties().WATCH_EXIT = WATCH_EXIT;
}
public String getClassPattern() {
return getProperties().myClassPattern;
}
public void setClassPattern(String classPattern) {
getProperties().myClassPattern = classPattern;
}
public void setMethodName(String methodName) {
getProperties().myMethodName = methodName;
}
}
@@ -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<LineBreakpoint> OLD_JAVA_BREAKPOINT_KEY = Key.create("oldJavaBreakpoint");
public JavaBreakpointAdapter(Project project) {
super(project);
}
@Override
protected void configureCreatedBreakpoint(LineBreakpoint oldBreakpoint, XLineBreakpoint<XBreakpointProperties> breakpoint) {
oldBreakpoint.SUSPEND_POLICY = transformSuspendPolicy(breakpoint);
applyCondition(oldBreakpoint, breakpoint);
applyFilters(oldBreakpoint, breakpoint);
}
private boolean applyFilters(LineBreakpoint oldBreakpoint, XLineBreakpoint<XBreakpointProperties> 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<XBreakpointProperties> 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<XBreakpointProperties> 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<XBreakpointProperties> breakpoint) {
return OLD_JAVA_BREAKPOINT_KEY.get(breakpoint);
}
public LineBreakpoint getOrCreate(XLineBreakpoint<XBreakpointProperties> 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<XBreakpointProperties> breakpoint) {
LineBreakpoint jBreakpoint = findBreakpoint(breakpoint);
if (jBreakpoint != null) {
jBreakpoint.delete();
}
}
@Override
protected LineBreakpoint doCreateInstance(Project project, Document document, XLineBreakpoint<XBreakpointProperties> 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<XBreakpointProperties> 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");
}
}
}
@@ -56,11 +56,11 @@ public abstract class JavaBreakpointAdapterBase extends XBreakpointAdapter<XLine
LineBreakpoint oldBreakpoint = doCreateInstance(project, document, breakpoint);
oldBreakpoint.setVisible(false);
oldBreakpoint.updateUI();
oldBreakpoint.ENABLED = breakpoint.isEnabled();
oldBreakpoint.setEnabled(breakpoint.isEnabled());
return oldBreakpoint;
}
protected LineBreakpoint doCreateInstance(Project project, Document document, XLineBreakpoint<XBreakpointProperties> breakpoint) {
return LineBreakpoint.create(project, document, breakpoint.getLine());
protected LineBreakpoint doCreateInstance(Project project, Document document, XLineBreakpoint<XBreakpointProperties> xBreakpoint) {
return LineBreakpoint.create(project, document, xBreakpoint.getLine(), xBreakpoint);
}
}
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.java.debugger.breakpoints.JavaBreakpointPropertiesPanel">
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.java.debugger.breakpoints.JavaBreakpointFiltersPanel">
<grid id="27dc6" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
@@ -26,11 +26,11 @@ import com.intellij.ui.FieldPanel;
import com.intellij.ui.MultiLineTooltipUI;
import com.intellij.ui.classFilter.ClassFilter;
import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.breakpoints.XBreakpointProperties;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties;
import javax.swing.*;
import java.awt.*;
@@ -44,7 +44,7 @@ import java.util.List;
/**
* @author egor
*/
public class JavaBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPanel<XLineBreakpoint<XBreakpointProperties>> {
public class JavaBreakpointFiltersPanel<T extends JavaBreakpointProperties, B extends XBreakpoint<T>> extends XBreakpointCustomPropertiesPanel<B> {
private JPanel myConditionsPanel;
private JPanel myInstanceFiltersPanel;
private JCheckBox myInstanceFiltersCheckBox;
@@ -66,7 +66,7 @@ public class JavaBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPa
private PsiClass myBreakpointPsiClass;
public JavaBreakpointPropertiesPanel(Project project) {
public JavaBreakpointFiltersPanel(Project project) {
myProject = project;
myInstanceFiltersField = new FieldPanel(new MyTextField(), "", null,
new ActionListener() {
@@ -135,8 +135,8 @@ public class JavaBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPa
}
@Override
public boolean isVisibleOnPopup(@NotNull XLineBreakpoint<XBreakpointProperties> breakpoint) {
JavaBreakpointProperties properties = (JavaBreakpointProperties)breakpoint.getProperties();
public boolean isVisibleOnPopup(@NotNull B breakpoint) {
JavaBreakpointProperties properties = breakpoint.getProperties();
if (properties != null) {
return properties.COUNT_FILTER_ENABLED || properties.CLASS_FILTERS_ENABLED || properties.INSTANCE_FILTERS_ENABLED;
}
@@ -144,8 +144,8 @@ public class JavaBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPa
}
@Override
public void saveTo(@NotNull XLineBreakpoint<XBreakpointProperties> breakpoint) {
JavaBreakpointProperties properties = (JavaBreakpointProperties)breakpoint.getProperties();
public void saveTo(@NotNull B breakpoint) {
JavaBreakpointProperties properties = breakpoint.getProperties();
if (properties == null) {
return;
}
@@ -179,8 +179,8 @@ public class JavaBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPa
}
@Override
public void loadFrom(@NotNull XLineBreakpoint<XBreakpointProperties> breakpoint) {
JavaBreakpointProperties properties = (JavaBreakpointProperties)breakpoint.getProperties();
public void loadFrom(@NotNull B breakpoint) {
JavaBreakpointProperties properties = breakpoint.getProperties();
if (properties != null) {
if (properties.COUNT_FILTER > 0) {
myPassCountField.setText(Integer.toString(properties.COUNT_FILTER));
@@ -1,76 +0,0 @@
package org.jetbrains.java.debugger.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.engine.DebuggerUtils;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.util.SystemProperties;
import com.intellij.xdebugger.XDebuggerUtil;
import com.intellij.xdebugger.breakpoints.XBreakpointProperties;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.intellij.xdebugger.breakpoints.XLineBreakpointTypeBase;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.java.debugger.JavaDebuggerEditorsProvider;
import java.util.List;
public class JavaBreakpointType extends XLineBreakpointTypeBase {
public JavaBreakpointType() {
super("java", DebuggerBundle.message("java.breakpoint.title"), new JavaDebuggerEditorsProvider());
}
@Override
public boolean canPutAt(@NotNull final VirtualFile file, final int line, @NotNull Project project) {
return SystemProperties.getBooleanProperty("java.debugger.xBreakpoint", false) &&
doCanPutAt(PsiManager.getInstance(project).findFile(file));
}
@Override
public boolean isSuspendThreadSupported() {
return true;
}
@Override
public List<XBreakpointGroupingRule<XLineBreakpoint<XBreakpointProperties>, ?>> getGroupingRules() {
return XDebuggerUtil.getInstance().getGroupingByFileRuleAsList();
}
@Contract("null -> false")
public static boolean doCanPutAt(@Nullable PsiFile psiFile) {
// JSPX supports jvm debugging, but not in XHTML files
if (psiFile == null || psiFile.getVirtualFile().getFileType() == StdFileTypes.XHTML) {
return false;
}
FileType fileType = psiFile.getFileType();
return StdFileTypes.CLASS.equals(fileType) || DebuggerUtils.supportsJVMDebugging(fileType) || DebuggerUtils.supportsJVMDebugging(psiFile);
}
@Nullable
@Override
public XBreakpointProperties createProperties() {
return new JavaBreakpointProperties();
}
@Nullable
@Override
public XBreakpointProperties createBreakpointProperties(@NotNull VirtualFile file, int line) {
return new JavaBreakpointProperties();
}
@Nullable
@Override
public XBreakpointCustomPropertiesPanel<XLineBreakpoint<XBreakpointProperties>> createCustomRightPropertiesPanel(@NotNull Project project) {
return new JavaBreakpointPropertiesPanel(project);
}
}
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.java.debugger.breakpoints;
package org.jetbrains.java.debugger.breakpoints.properties;
import com.intellij.debugger.InstanceFilter;
import com.intellij.ui.classFilter.ClassFilter;
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.Nullable;
/**
* @author egor
*/
public class JavaBreakpointProperties extends XBreakpointProperties<JavaBreakpointProperties> {
public class JavaBreakpointProperties<T extends JavaBreakpointProperties> extends XBreakpointProperties<T> {
public boolean COUNT_FILTER_ENABLED = false;
public int COUNT_FILTER = 0;
@@ -42,7 +42,7 @@ public class JavaBreakpointProperties extends XBreakpointProperties<JavaBreakpoi
myInstanceFilters = instanceFilters;
}
protected void addInstanceFilter(long l) {
public 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));
@@ -67,20 +67,20 @@ public class JavaBreakpointProperties extends XBreakpointProperties<JavaBreakpoi
@Nullable
@Override
public JavaBreakpointProperties getState() {
return this;
public T getState() {
return (T)this;
}
@Override
public void loadState(JavaBreakpointProperties state) {
public void loadState(T state) {
COUNT_FILTER_ENABLED = state.COUNT_FILTER_ENABLED;
COUNT_FILTER = state.COUNT_FILTER;
CLASS_FILTERS_ENABLED = state.CLASS_FILTERS_ENABLED;
myClassFilters = state.myClassFilters;
myClassExclusionFilters = state.myClassExclusionFilters;
myClassFilters = state.getClassFilters();
myClassExclusionFilters = state.getClassExclusionFilters();
INSTANCE_FILTERS_ENABLED = state.INSTANCE_FILTERS_ENABLED;
myInstanceFilters = state.myInstanceFilters;
myInstanceFilters = state.getInstanceFilters();
}
}
@@ -0,0 +1,52 @@
/*
* 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 org.jetbrains.java.debugger.breakpoints.properties;
import org.jetbrains.annotations.Nullable;
/**
* @author egor
*/
public class JavaExceptionBreakpointProperties extends JavaBreakpointProperties<JavaExceptionBreakpointProperties> {
public boolean NOTIFY_CAUGHT = true;
public boolean NOTIFY_UNCAUGHT = true;
public String myQualifiedName;
public String myPackageName;
public JavaExceptionBreakpointProperties(String qualifiedName, String packageName) {
myQualifiedName = qualifiedName;
myPackageName = packageName;
}
public JavaExceptionBreakpointProperties() {
}
@Nullable
@Override
public JavaExceptionBreakpointProperties getState() {
return this;
}
@Override
public void loadState(JavaExceptionBreakpointProperties state) {
super.loadState(state);
NOTIFY_CAUGHT = state.NOTIFY_CAUGHT;
NOTIFY_UNCAUGHT = state.NOTIFY_UNCAUGHT;
myQualifiedName = state.myQualifiedName;
myPackageName = state.myPackageName;
}
}
@@ -0,0 +1,49 @@
/*
* 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 org.jetbrains.java.debugger.breakpoints.properties;
import org.jetbrains.annotations.Nullable;
/**
* @author egor
*/
public class JavaFieldBreakpointProperties extends JavaBreakpointProperties<JavaFieldBreakpointProperties> {
public boolean WATCH_MODIFICATION = true;
public boolean WATCH_ACCESS = false;
public String myFieldName;
public JavaFieldBreakpointProperties(String fieldName) {
myFieldName = fieldName;
}
public JavaFieldBreakpointProperties() {
}
@Nullable
@Override
public JavaFieldBreakpointProperties getState() {
return this;
}
@Override
public void loadState(JavaFieldBreakpointProperties state) {
super.loadState(state);
WATCH_MODIFICATION = state.WATCH_MODIFICATION;
WATCH_ACCESS = state.WATCH_ACCESS;
myFieldName = state.myFieldName;
}
}
@@ -0,0 +1,54 @@
/*
* 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 org.jetbrains.java.debugger.breakpoints.properties;
import org.jetbrains.annotations.Nullable;
/**
* @author egor
*/
public class JavaMethodBreakpointProperties extends JavaBreakpointProperties<JavaMethodBreakpointProperties> {
public String myClassPattern;
public String myMethodName;
public boolean WATCH_ENTRY = true;
public boolean WATCH_EXIT = true;
public JavaMethodBreakpointProperties(String classPattern, String methodName) {
myClassPattern = classPattern;
myMethodName = methodName;
}
public JavaMethodBreakpointProperties() {
}
@Nullable
@Override
public JavaMethodBreakpointProperties getState() {
return this;
}
@Override
public void loadState(JavaMethodBreakpointProperties state) {
super.loadState(state);
myClassPattern = state.myClassPattern;
myMethodName = state.myMethodName;
WATCH_ENTRY = state.WATCH_ENTRY;
WATCH_EXIT = state.WATCH_EXIT;
}
}
@@ -311,26 +311,26 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa
String suspendPolicy = readValue(comment, "suspendPolicy");
if (suspendPolicy != null) {
breakpoint.SUSPEND = !DebuggerSettings.SUSPEND_NONE.equals(suspendPolicy);
breakpoint.SUSPEND_POLICY = suspendPolicy;
//breakpoint.setSuspend(!DebuggerSettings.SUSPEND_NONE.equals(suspendPolicy));
breakpoint.setSuspendPolicy(suspendPolicy);
println("SUSPEND_POLICY = " + suspendPolicy, ProcessOutputTypes.SYSTEM);
}
String condition = readValue(comment, "Condition");
if (condition != null) {
breakpoint.CONDITION_ENABLED = true;
breakpoint.setCondition(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, condition));
//breakpoint.CONDITION_ENABLED = true;
breakpoint.setCondition(/*new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, */condition/*)*/);
println("Condition = " + condition, ProcessOutputTypes.SYSTEM);
}
String passCount = readValue(comment, "Pass count");
if (passCount != null) {
breakpoint.COUNT_FILTER_ENABLED = true;
breakpoint.COUNT_FILTER = Integer.parseInt(passCount);
breakpoint.setCountFilterEnabled(true);
breakpoint.setCountFilter(Integer.parseInt(passCount));
println("Pass count = " + passCount, ProcessOutputTypes.SYSTEM);
}
String classFilters = readValue(comment, "Class filters");
if (classFilters != null) {
breakpoint.CLASS_FILTERS_ENABLED = true;
breakpoint.setClassFiltersEnabled(true);
StringTokenizer tokenizer = new StringTokenizer(classFilters, " ,");
ArrayList<ClassFilter> lst = new ArrayList<ClassFilter>();
@@ -320,10 +320,10 @@ class.filters.dialog.exclusion.filters.group=Class Exclusion Filters
instance.filters.dialog.title=Instance Filters
instance.filters.dialog.instance.filters.group=Instance Filters
breakpoint.exception.breakpoint.display.name=''{0}''
exception.breakpoints.tab.title=Exception Breakpoints
field.watchpoints.tab.title=Field Watchpoints
line.breakpoints.tab.title=Line Breakpoints
method.breakpoints.tab.title=Method Breakpoints
exception.breakpoints.tab.title=Java Exception Breakpoints
field.watchpoints.tab.title=Java Field Watchpoints
line.breakpoints.tab.title=Java Line Breakpoints
method.breakpoints.tab.title=Java Method Breakpoints
title.error.evaluating.breakpoint.condition=Breakpoint Condition Error
title.error.evaluating.breakpoint.action=Breakpoint Action Error
error.evaluating.breakpoint.condition.or.action=Problem processing VM event:\nBreakpoint: ''{0}''\nError: {1}\nWould you like to stop at the breakpoint?
@@ -446,5 +446,3 @@ error.corrupt.debug.info=Debug info might be corrupt: {0}
action.kill.process.text=Kill Process
action.kill.process.description=Forcibly terminate debugged application
evaluation.error.unknown.method.return.type=Cannot resolve method return type: {0}
java.breakpoint.title=Java Line Breakpoints
+5 -10
View File
@@ -86,9 +86,6 @@
<extensionPoint name="debugger.nodeRenderer"
interface="com.intellij.debugger.ui.tree.render.NodeRenderer"/>
<extensionPoint name="debugger.breakpointFactory"
interface="com.intellij.debugger.ui.breakpoints.BreakpointFactory"/>
<extensionPoint name="debugger.jvmDebugProvider"
interface="com.intellij.debugger.engine.JVMDebugProvider"/>
@@ -1378,11 +1375,11 @@
<resolveScopeEnlarger implementation="com.intellij.psi.NonClasspathResolveScopeEnlarger"/>
<xdebugger.debuggerSupport implementation="com.intellij.debugger.ui.JavaDebuggerSupport"/>
<debugger.breakpointFactory implementation="com.intellij.debugger.ui.breakpoints.LineBreakpointFactory"/>
<debugger.breakpointFactory implementation="com.intellij.debugger.ui.breakpoints.ExceptionBreakpointFactory"/>
<debugger.breakpointFactory implementation="com.intellij.debugger.ui.breakpoints.AnyExceptionBreakpointFactory"/>
<debugger.breakpointFactory implementation="com.intellij.debugger.ui.breakpoints.FieldBreakpointFactory"/>
<debugger.breakpointFactory implementation="com.intellij.debugger.ui.breakpoints.MethodBreakpointFactory"/>
<xdebugger.breakpointType implementation="com.intellij.debugger.ui.breakpoints.JavaMethodBreakpointType"/>
<xdebugger.breakpointType implementation="com.intellij.debugger.ui.breakpoints.JavaWildcardMethodBreakpointType"/>
<xdebugger.breakpointType implementation="com.intellij.debugger.ui.breakpoints.JavaFieldBreakpointType"/>
<xdebugger.breakpointType implementation="com.intellij.debugger.ui.breakpoints.JavaExceptionBreakpointType"/>
<xdebugger.breakpointType implementation="com.intellij.debugger.ui.breakpoints.JavaLineBreakpointType"/>
<debugger.jvmSmartStepIntoHandler implementation="com.intellij.debugger.actions.JavaSmartStepIntoHandler"/>
<applicationService serviceInterface="com.intellij.remoteServer.runtime.deployment.debug.JavaDebuggerLauncher"
@@ -1461,8 +1458,6 @@
<codeInsight.unresolvedReferenceQuickFixProvider implementation="com.intellij.jarFinder.FindJarQuickFixProvider"/>
<xdebugger.breakpointType implementation="org.jetbrains.java.debugger.breakpoints.JavaBreakpointType"/>
<refactoring.pullUpHelperFactory language="JAVA" implementationClass="com.intellij.refactoring.memberPullUp.JavaPullUpHelperFactory"/>
<hierarchy.referenceProcessor implementation="com.intellij.ide.hierarchy.call.JavaCallReferenceProcessor"/>
<projectTemplate projectType="JAVA_MODULE" templatePath="resources/projectTemplates/Java/Command_Line_App.zip"/>