diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/JavaEditBreakpointActionHandler.java b/java/debugger/impl/src/com/intellij/debugger/actions/JavaEditBreakpointActionHandler.java deleted file mode 100644 index 9ed769aee350..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/actions/JavaEditBreakpointActionHandler.java +++ /dev/null @@ -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 pair = XBreakpointUtil.findSelectedBreakpoint(project, editor); - return pair.first != null && pair.second instanceof BreakpointWithHighlighter; - } -} diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ToggleBreakpointEnabledAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/ToggleBreakpointEnabledAction.java index fda3e6128a3e..693b7f4917a5 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/ToggleBreakpointEnabledAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/ToggleBreakpointEnabledAction.java @@ -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()); } } diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ToggleFieldBreakpointAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/ToggleFieldBreakpointAction.java index 39a397755a5e..a7e00ee0dd72 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/ToggleFieldBreakpointAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/ToggleFieldBreakpointAction.java @@ -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); } } } diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ToggleLineBreakpointActionHandler.java b/java/debugger/impl/src/com/intellij/debugger/actions/ToggleLineBreakpointActionHandler.java deleted file mode 100644 index 650e7c37cf70..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/actions/ToggleLineBreakpointActionHandler.java +++ /dev/null @@ -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()); - } -} \ No newline at end of file diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java index a5b1be2ba733..56e8cd383ee6 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java @@ -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(); diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java index 832958759964..c35c971c5a76 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java @@ -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 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(); + //} } }); } diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java index c60a3b220906..1416dd3b05c3 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java @@ -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, diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/JavaDebuggerSupport.java b/java/debugger/impl/src/com/intellij/debugger/ui/JavaDebuggerSupport.java index e021d76b271b..af5202ccd260 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/JavaDebuggerSupport.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/JavaDebuggerSupport.java @@ -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 { - private final List myListeners = ContainerUtil.createLockFreeCopyOnWriteList(); + //private final List myListeners = ContainerUtil.createLockFreeCopyOnWriteList(); @Override public AnAction[] getAddBreakpointActions(@NotNull Project project) { - List result = new ArrayList(); - BreakpointFactory[] breakpointFactories = BreakpointFactory.getBreakpointFactories(); - for (BreakpointFactory breakpointFactory : breakpointFactories) { - result.add(new AddJavaBreakpointAction(breakpointFactory)); - } - return result.toArray(new AnAction[result.size()]); + //List result = new ArrayList(); + //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 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 items) { - for (BreakpointFactory breakpointFactory : BreakpointFactory.getBreakpointFactories()) { - Key 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 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; + } + }; } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/PositionHighlighter.java b/java/debugger/impl/src/com/intellij/debugger/ui/PositionHighlighter.java index e5bb8faafb61..dd0b0de43151 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/PositionHighlighter.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/PositionHighlighter.java @@ -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); } } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointCategoryGroup.java b/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointCategoryGroup.java deleted file mode 100644 index 032b480c5584..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointCategoryGroup.java +++ /dev/null @@ -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 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 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; - } -} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointGroupingByCategoryRule.java b/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointGroupingByCategoryRule.java deleted file mode 100644 index f9dc88af07ac..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointGroupingByCategoryRule.java +++ /dev/null @@ -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 extends XBreakpointGroupingRule { - 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 groups) { - if (b instanceof Breakpoint) { - final Breakpoint breakpoint = (Breakpoint)b; - Key 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; - } -} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AddFieldBreakpointDialog.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AddFieldBreakpointDialog.java index f325da10fcde..e3cd5229e0ab 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AddFieldBreakpointDialog.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AddFieldBreakpointDialog.java @@ -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; diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AddWildcardBreakpointDialog.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AddWildcardBreakpointDialog.java index c18acb715935..73c74a4eed0a 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AddWildcardBreakpointDialog.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AddWildcardBreakpointDialog.java @@ -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(); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AnyExceptionBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AnyExceptionBreakpoint.java index 3d1ff8507d10..25864de5d3af 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AnyExceptionBreakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AnyExceptionBreakpoint.java @@ -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 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 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; + // } + //} } \ No newline at end of file diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AnyExceptionBreakpointFactory.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AnyExceptionBreakpointFactory.java deleted file mode 100644 index f595c1d81c65..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/AnyExceptionBreakpointFactory.java +++ /dev/null @@ -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 getBreakpointCategory() { - return AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT; - } -} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java index 1b370ca47ded..8ea3fea6923d 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java @@ -30,45 +30,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

implements FilteredRequestor, ClassPrepareRequestor { + final XBreakpoint

myXBreakpoint; + protected final Project myProject; + + //private boolean ENABLED = true; + //private boolean LOG_ENABLED = false; + //private boolean LOG_EXPRESSION_ENABLED = false; + //private boolean REMOVE_AFTER_HIT = false; + //private TextWithImports myLogMessage; // an expression to be evaluated and printed + //@NonNls private static final String LOG_MESSAGE_OPTION_NAME = "LOG_MESSAGE"; public static final Breakpoint[] EMPTY_ARRAY = new Breakpoint[0]; protected boolean myCachedVerifiedState = false; + //private TextWithImportsImpl myLogMessage; - protected Breakpoint(@NotNull Project project) { - super(project); - myLogMessage = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, ""); + protected Breakpoint(@NotNull Project project, XBreakpoint

xBreakpoint) { + //super(project); + myProject = project; + myXBreakpoint = xBreakpoint; + //myLogMessage = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, ""); //noinspection AbstractMethodCallInConstructor - final BreakpointDefaults defaults = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().getBreakpointDefaults(getCategory()); - SUSPEND_POLICY = defaults.getSuspendPolicy(); - CONDITION_ENABLED = defaults.isConditionEnabled(); + //final BreakpointDefaults defaults = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().getBreakpointDefaults(getCategory()); + //SUSPEND_POLICY = defaults.getSuspendPolicy(); + //CONDITION_ENABLED = defaults.isConditionEnabled(); + } + + public Project getProject() { + return myProject; + } + + protected P getProperties() { + return myXBreakpoint.getProperties(); } public abstract PsiClass getPsiClass(); @@ -100,6 +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() { + 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); } } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointFactory.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointFactory.java deleted file mode 100644 index 67c32935849e..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointFactory.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.debugger.ui.breakpoints; - -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Key; -import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem; -import org.jdom.Element; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; - -/** - * Used to deexternalize breakpoints of certain category while reading saved configuration and for creating configuration UI - */ -public abstract class BreakpointFactory { - public static final ExtensionPointName EXTENSION_POINT_NAME = - ExtensionPointName.create("com.intellij.debugger.breakpointFactory"); - - public static BreakpointFactory[] getBreakpointFactories() { - return ApplicationManager.getApplication().getExtensions(EXTENSION_POINT_NAME); - } - - public abstract Breakpoint createBreakpoint(Project project, final Element element); - - public abstract Key getBreakpointCategory(); - - public abstract Icon getIcon(); - - public abstract Icon getDisabledIcon(); - - @Nullable - public static BreakpointFactory getInstance(Key category) { - final BreakpointFactory[] allFactories = getBreakpointFactories(); - for (final BreakpointFactory factory : allFactories) { - if (category.equals(factory.getBreakpointCategory())) { - return factory; - } - } - return null; - } - - protected abstract String getHelpID(); - - public abstract String getDisplayName(); - - @Nullable - public abstract BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact); - - @Nullable - public Breakpoint addBreakpoint(Project project) { - return null; - } - - public boolean canAddBreakpoints() { - return false; - } - - public boolean breakpointCanBeRemoved(Breakpoint breakpoint) { - return true; - } - - public BreakpointItem createBreakpointItem(final Breakpoint breakpoint) { - return new JavaBreakpointItem(this, breakpoint); - } -} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java index 1bcbf3e9954b..8e9282747729 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java @@ -20,14 +20,10 @@ */ package com.intellij.debugger.ui.breakpoints; -import com.intellij.codeInsight.folding.impl.actions.ExpandRegionAction; -import com.intellij.debugger.DebuggerBundle; import com.intellij.debugger.DebuggerInvocationUtil; import com.intellij.debugger.SourcePosition; import com.intellij.debugger.engine.BreakpointStepMethodFilter; import com.intellij.debugger.engine.DebugProcessImpl; -import com.intellij.debugger.engine.evaluation.CodeFragmentKind; -import com.intellij.debugger.engine.evaluation.TextWithImportsImpl; import com.intellij.debugger.engine.requests.RequestManagerImpl; import com.intellij.debugger.impl.DebuggerContextImpl; import com.intellij.debugger.impl.DebuggerContextListener; @@ -35,54 +31,43 @@ import com.intellij.debugger.impl.DebuggerManagerImpl; import com.intellij.debugger.impl.DebuggerSession; import com.intellij.debugger.ui.JavaDebuggerSupport; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.EditorFactory; -import com.intellij.openapi.editor.event.*; import com.intellij.openapi.editor.markup.GutterIconRenderer; -import com.intellij.openapi.editor.markup.MarkupEditorFilterFactory; import com.intellij.openapi.editor.markup.RangeHighlighter; import com.intellij.openapi.fileEditor.FileDocumentManager; -import com.intellij.openapi.fileEditor.FileEditor; -import com.intellij.openapi.fileEditor.FileEditorManager; -import com.intellij.openapi.fileEditor.TextEditor; -import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.project.Project; import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.ui.MessageType; -import com.intellij.openapi.util.*; -import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.Key; +import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiField; import com.intellij.psi.PsiFile; import com.intellij.util.Alarm; import com.intellij.util.EventDispatcher; -import com.intellij.util.IJSwingUtilities; -import com.intellij.util.SystemProperties; -import com.intellij.util.containers.MultiMap; import com.intellij.xdebugger.XDebuggerManager; -import com.intellij.xdebugger.XDebuggerUtil; -import com.intellij.xdebugger.breakpoints.XBreakpointType; +import com.intellij.xdebugger.breakpoints.XBreakpoint; +import com.intellij.xdebugger.breakpoints.XBreakpointListener; +import com.intellij.xdebugger.breakpoints.XBreakpointManager; import com.intellij.xdebugger.impl.DebuggerSupport; import com.intellij.xdebugger.impl.XDebugSessionImpl; +import com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl; +import com.intellij.xdebugger.impl.breakpoints.XDependentBreakpointManager; import com.sun.jdi.Field; import com.sun.jdi.InternalException; import com.sun.jdi.ObjectReference; import com.sun.jdi.ThreadReference; import com.sun.jdi.request.*; -import gnu.trove.THashMap; import gnu.trove.TIntHashSet; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.java.debugger.breakpoints.JavaBreakpointAdapter; -import org.jetbrains.java.debugger.breakpoints.JavaBreakpointType; import javax.swing.*; -import java.awt.event.MouseEvent; import java.util.*; public class BreakpointManager { @@ -96,11 +81,9 @@ public class BreakpointManager { @NonNls private static final String RULES_GROUP_NAME = "breakpoint_rules"; private final Project myProject; - private AnyExceptionBreakpoint myAnyExceptionBreakpoint; - private final List myBreakpoints = new ArrayList(); // breakpoints storage, access should be synchronized - private final List myBreakpointRules = new ArrayList(); // breakpoint rules + private XBreakpointManager myXBreakpointManager; + private final Map myBreakpoints = new HashMap(); // breakpoints storage, access should be synchronized @Nullable private List myBreakpointsListForIteration = null; // another list for breakpoints iteration, unsynchronized access ok - private final MultiMap myDocumentBreakpoints = MultiMap.createSmartList(); private final Map myUIProperties = new LinkedHashMap(); private final Map, BreakpointDefaults> myBreakpointDefaults = new LinkedHashMap, BreakpointDefaults>(); @@ -155,212 +138,35 @@ public class BreakpointManager { } } }); - - if (!project.isDefault()) { - XDebuggerManager.getInstance(project).getBreakpointManager().addBreakpointListener( - XBreakpointType.EXTENSION_POINT_NAME.findExtension(JavaBreakpointType.class), new JavaBreakpointAdapter(project), project); - } } public void init() { - EditorEventMulticaster eventMulticaster = EditorFactory.getInstance().getEventMulticaster(); - eventMulticaster.addEditorMouseListener(new EditorMouseAdapter() { - @Nullable private EditorMouseEvent myMousePressedEvent; - - @Nullable - private Breakpoint toggleBreakpoint(final boolean mostSuitingBreakpoint, final int line, boolean temporary) { - final Editor editor = FileEditorManager.getInstance(myProject).getSelectedTextEditor(); - if (editor == null) { - return null; + myXBreakpointManager = XDebuggerManager.getInstance(myProject).getBreakpointManager(); + myXBreakpointManager.addBreakpointListener(new XBreakpointListener() { + @Override + public void breakpointAdded(@NotNull XBreakpoint xBreakpoint) { + if (isJavaType(xBreakpoint)) { + onBreakpointAdded(xBreakpoint); } - final Document document = editor.getDocument(); - final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(document); - if (!JavaBreakpointType.doCanPutAt(psiFile)) { - return null; + } + + @Override + public void breakpointRemoved(@NotNull XBreakpoint xBreakpoint) { + if (isJavaType(xBreakpoint)) { + onBreakpointRemoved(xBreakpoint); } + } - if (SystemProperties.getBooleanProperty("java.debugger.xBreakpoint", false) && - XBreakpointType.EXTENSION_POINT_NAME.findExtension(JavaBreakpointType.class) - .canPutAt(psiFile.getVirtualFile(), line, myProject)) { - return null; - } - - PsiDocumentManager.getInstance(myProject).commitDocument(document); - - int offset = editor.getCaretModel().getOffset(); - int editorLine = editor.getDocument().getLineNumber(offset); - if (editorLine != line) { - if (line < 0 || line >= document.getLineCount()) { - return null; - } - offset = editor.getDocument().getLineStartOffset(line); - } - - ExpandRegionAction.expandRegionAtOffset(myProject, editor, offset); - - Breakpoint breakpoint = findBreakpoint(document, offset, null); - if (breakpoint == null) { - boolean isInsideCompiledClass = StdFileTypes.CLASS.equals(psiFile.getFileType()); - if (mostSuitingBreakpoint || isInsideCompiledClass) { - breakpoint = addFieldBreakpoint(document, offset); - if (breakpoint == null) { - breakpoint = addMethodBreakpoint(document, line); - } - if (breakpoint == null && !isInsideCompiledClass) { - breakpoint = addLineBreakpoint(document, line); - } - } - else { - breakpoint = addLineBreakpoint(document, line); - - if (breakpoint == null) { - breakpoint = addMethodBreakpoint(document, line); - } - } - + @Override + public void breakpointChanged(@NotNull XBreakpoint xBreakpoint) { + if (isJavaType(xBreakpoint)) { + Breakpoint breakpoint = myBreakpoints.get(xBreakpoint); if (breakpoint != null) { - breakpoint.REMOVE_AFTER_HIT = temporary; - RequestManagerImpl.createRequests(breakpoint); - } - return breakpoint; - } - else { - removeBreakpoint(breakpoint); - return null; - } - } - - private boolean isFromMyProject(Editor editor) { - FileEditor[] allEditors = FileEditorManager.getInstance(myProject).getAllEditors(); - for (FileEditor ed : allEditors) { - if (!(ed instanceof TextEditor)) { - continue; - } - if (((TextEditor)ed).getEditor().equals(editor)) { - return true; - } - } - return false; - } - - //mousePressed + mouseReleased is a hack to keep selection in editor when shift is pressed - @Override - public void mousePressed(@NotNull EditorMouseEvent e) { - if (MarkupEditorFilterFactory.createIsDiffFilter().avaliableIn(e.getEditor())) return; - - if (e.isConsumed()) return; - - if (e.getArea() == EditorMouseEventArea.LINE_MARKERS_AREA && e.getMouseEvent().isShiftDown()) { - myMousePressedEvent = e; - e.consume(); - } - } - - @Override - public void mouseReleased(@NotNull EditorMouseEvent e) { - if (myMousePressedEvent != null) { - mouseClicked(e); - } - myMousePressedEvent = null; - } - - @Override - public void mouseClicked(@NotNull final EditorMouseEvent e) { - if (MarkupEditorFilterFactory.createIsDiffFilter().avaliableIn(e.getEditor())) return; - - if (e.isConsumed()) return; - - if (e.getArea() == EditorMouseEventArea.LINE_MARKERS_AREA) { - PsiDocumentManager.getInstance(myProject).commitAndRunReadAction(new Runnable() { - @Override - public void run() { - final Editor editor = e.getEditor(); - if (!isFromMyProject(editor)) { - return; - } - final int line = editor.xyToLogicalPosition(e.getMouseEvent().getPoint()).line; - final Document document = editor.getDocument(); - if (line < 0 || line >= document.getLineCount()) { - return; - } - MouseEvent event = e.getMouseEvent(); - if (event.isPopupTrigger()) { - return; - } - if (event.getButton() != 1) { - return; - } - if (e.getMouseEvent().isControlDown() || e.getMouseEvent().isMetaDown()) { - return; - } - - VirtualFile file = FileDocumentManager.getInstance().getFile(document); - if (file != null && XDebuggerUtil.getInstance().canPutBreakpointAt(myProject, file, line)) { - return; - } - e.consume(); - - DebuggerInvocationUtil.invokeLater(myProject, new Runnable() { - @Override - public void run() { - final boolean suitingBreakpoint = e.getMouseEvent().isAltDown() && !e.getMouseEvent().isShiftDown(); - final boolean temporary = e.getMouseEvent().isAltDown() && e.getMouseEvent().isShiftDown(); - - final Breakpoint breakpoint = toggleBreakpoint(suitingBreakpoint, line, temporary); - - - if (!e.getMouseEvent().isAltDown() && e.getMouseEvent().isShiftDown() && breakpoint != null) { - breakpoint.LOG_EXPRESSION_ENABLED = true; - String selection = editor.getSelectionModel().getSelectedText(); - String text = selection != null ? selection : DebuggerBundle.message("breakpoint.log.message", - breakpoint.getDisplayName()); - breakpoint.setLogMessage(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, text)); - breakpoint.SUSPEND = false; - editBreakpoint(breakpoint, editor); - - - //DialogWrapper dialog = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager() - // .createConfigurationDialog(breakpoint, BreakpointPropertiesPanel.CONTROL_LOG_MESSAGE); - //dialog.show(); - // - //if (!dialog.isOK()) { - // removeBreakpoint(breakpoint); - //} - } - } - }); - } - }); - } - } - }, myProject); - - eventMulticaster.addDocumentListener(new DocumentAdapter() { - private final Alarm myUpdateAlarm = new Alarm(); - - @Override - public void documentChanged(@NotNull final DocumentEvent e) { - final Document document = e.getDocument(); - //noinspection SynchronizeOnThis - synchronized (BreakpointManager.this) { - Collection breakpoints = myDocumentBreakpoints.get(document); - if (!breakpoints.isEmpty()) { - myUpdateAlarm.cancelAllRequests(); - // must create new array in order to avoid "concurrent modification" errors - final List breakpointsToUpdate = new ArrayList(breakpoints); - myUpdateAlarm.addRequest(new Runnable() { - @Override - public void run() { - if (!myProject.isDisposed()) { - PsiDocumentManager.getInstance(myProject).commitDocument(document); - update(breakpointsToUpdate); - } - } - }, 300, ModalityState.NON_MODAL); + fireBreakpointChanged(breakpoint); } } } - }, myProject); + }); } public void editBreakpoint(final Breakpoint breakpoint, final Editor editor) { @@ -396,7 +202,7 @@ public class BreakpointManager { @Nullable public RunToCursorBreakpoint addRunToCursorBreakpoint(Document document, int lineIndex, final boolean ignoreBreakpoints) { - return RunToCursorBreakpoint.create(myProject, document, lineIndex, ignoreBreakpoints); + return RunToCursorBreakpoint.create(myProject, document, lineIndex, ignoreBreakpoints, null); } @Nullable @@ -411,7 +217,7 @@ public class BreakpointManager { return null; } - LineBreakpoint breakpoint = LineBreakpoint.create(myProject, document, lineIndex); + LineBreakpoint breakpoint = LineBreakpoint.create(myProject, document, lineIndex, null); if (breakpoint == null) { return null; } @@ -423,7 +229,7 @@ public class BreakpointManager { @Nullable public FieldBreakpoint addFieldBreakpoint(Field field, ObjectReference object) { ApplicationManager.getApplication().assertIsDispatchThread(); - final FieldBreakpoint fieldBreakpoint = FieldBreakpoint.create(myProject, field, object); + final FieldBreakpoint fieldBreakpoint = FieldBreakpoint.create(myProject, field, object, null); if (fieldBreakpoint != null) { addBreakpoint(fieldBreakpoint); } @@ -449,7 +255,7 @@ public class BreakpointManager { @Nullable public FieldBreakpoint addFieldBreakpoint(Document document, int lineIndex, String fieldName) { ApplicationManager.getApplication().assertIsDispatchThread(); - FieldBreakpoint fieldBreakpoint = FieldBreakpoint.create(myProject, document, lineIndex, fieldName); + FieldBreakpoint fieldBreakpoint = FieldBreakpoint.create(myProject, document, lineIndex, fieldName, null); if (fieldBreakpoint != null) { addBreakpoint(fieldBreakpoint); } @@ -459,7 +265,7 @@ public class BreakpointManager { @NotNull public ExceptionBreakpoint addExceptionBreakpoint(@NotNull String exceptionClassName, String packageName) { ApplicationManager.getApplication().assertIsDispatchThread(); - ExceptionBreakpoint breakpoint = new ExceptionBreakpoint(myProject, exceptionClassName, packageName); + ExceptionBreakpoint breakpoint = new ExceptionBreakpoint(myProject, exceptionClassName, packageName, null); addBreakpoint(breakpoint); if (LOG.isDebugEnabled()) { LOG.debug("ExceptionBreakpoint Added"); @@ -471,7 +277,7 @@ public class BreakpointManager { public MethodBreakpoint addMethodBreakpoint(Document document, int lineIndex) { ApplicationManager.getApplication().assertIsDispatchThread(); - MethodBreakpoint breakpoint = MethodBreakpoint.create(myProject, document, lineIndex); + MethodBreakpoint breakpoint = MethodBreakpoint.create(myProject, document, lineIndex, null); if (breakpoint == null) { return null; } @@ -485,7 +291,7 @@ public class BreakpointManager { @Nullable public WildcardMethodBreakpoint addMethodBreakpoint(String classPattern, String methodName) { ApplicationManager.getApplication().assertIsDispatchThread(); - WildcardMethodBreakpoint breakpoint = WildcardMethodBreakpoint.create(myProject, classPattern, methodName); + WildcardMethodBreakpoint breakpoint = WildcardMethodBreakpoint.create(myProject, classPattern, methodName, null); if (breakpoint == null) { return null; } @@ -531,14 +337,6 @@ public class BreakpointManager { */ @Nullable public T findBreakpoint(final Document document, final int offset, @Nullable final Key category) { - for (BreakpointWithHighlighter breakpointWithHighlighter : myDocumentBreakpoints.get(document)) { - if (breakpointWithHighlighter.isAt(document, offset) && - (category == null || category.equals(breakpointWithHighlighter.getCategory()))) { - //noinspection unchecked - return (T)breakpointWithHighlighter; - } - } - for (final Breakpoint breakpoint : getBreakpoints()) { if (breakpoint instanceof BreakpointWithHighlighter && ((BreakpointWithHighlighter)breakpoint).isAt(document, offset)) { if (category == null || category.equals(breakpoint.getCategory())) { @@ -550,224 +348,239 @@ public class BreakpointManager { return null; } - public void readExternal(@NotNull final Element parentNode) { - if (myProject.isOpen()) { - doRead(parentNode); - } - else { - myStartupManager.registerPostStartupActivity(new Runnable() { - @Override - public void run() { - doRead(parentNode); - } - }); - } - } - - private void doRead(@NotNull final Element parentNode) { - ApplicationManager.getApplication().runReadAction(new Runnable() { - @Override - @SuppressWarnings({"HardCodedStringLiteral"}) - public void run() { - final Map nameToBreakpointMap = new THashMap(); - try { - final List groups = parentNode.getChildren(); - for (final Object group1 : groups) { - final Element group = (Element)group1; - if (group.getName().equals(RULES_GROUP_NAME)) { - continue; - } - final String categoryName = group.getName(); - final Key breakpointCategory = BreakpointCategory.lookup(categoryName); - final String defaultPolicy = group.getAttributeValue(DEFAULT_SUSPEND_POLICY_ATTRIBUTE_NAME); - final boolean conditionEnabled = Boolean.parseBoolean(group.getAttributeValue(DEFAULT_CONDITION_STATE_ATTRIBUTE_NAME, "true")); - setBreakpointDefaults(breakpointCategory, new BreakpointDefaults(defaultPolicy, conditionEnabled)); - Element anyExceptionBreakpointGroup; - if (!AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT.equals(breakpointCategory)) { - // for compatibility with previous format - anyExceptionBreakpointGroup = group.getChild(AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT.toString()); - final BreakpointFactory factory = BreakpointFactory.getInstance(breakpointCategory); - if (factory != null) { - for (final Object o : group.getChildren("breakpoint")) { - Element breakpointNode = (Element)o; - Breakpoint breakpoint = factory.createBreakpoint(myProject, breakpointNode); - breakpoint.readExternal(breakpointNode); - addBreakpoint(breakpoint); - nameToBreakpointMap.put(breakpoint.getDisplayName(), breakpoint); - } - } - } - else { - anyExceptionBreakpointGroup = group; - } - - if (anyExceptionBreakpointGroup != null) { - final Element breakpointElement = group.getChild("breakpoint"); - if (breakpointElement != null) { - getAnyExceptionBreakpoint().readExternal(breakpointElement); - } - } - - } - } - catch (InvalidDataException ignored) { - } - - final Element rulesGroup = parentNode.getChild(RULES_GROUP_NAME); - if (rulesGroup != null) { - final List rules = rulesGroup.getChildren("rule"); - for (final Object rule1 : rules) { - final Element rule = (Element)rule1; - final Element master = rule.getChild(MASTER_BREAKPOINT_TAGNAME); - if (master == null) { - continue; - } - final Element slave = rule.getChild(SLAVE_BREAKPOINT_TAGNAME); - if (slave == null) { - continue; - } - final Breakpoint masterBreakpoint = nameToBreakpointMap.get(master.getAttributeValue("name")); - if (masterBreakpoint == null) { - continue; - } - final Breakpoint slaveBreakpoint = nameToBreakpointMap.get(slave.getAttributeValue("name")); - if (slaveBreakpoint == null) { - continue; - } - addBreakpointRule(new EnableBreakpointRule(BreakpointManager.this, masterBreakpoint, slaveBreakpoint, "true".equalsIgnoreCase(rule.getAttributeValue("leaveEnabled")))); - } - } - - DebuggerInvocationUtil.invokeLater(myProject, new Runnable() { - @Override - public void run() { - updateBreakpointsUI(); - } - }); - } - }); - - myUIProperties.clear(); - final Element props = parentNode.getChild("ui_properties"); - if (props != null) { - final List children = props.getChildren("property"); - for (Object child : children) { - Element property = (Element)child; - final String name = property.getAttributeValue("name"); - final String value = property.getAttributeValue("value"); - if (name != null && value != null) { - myUIProperties.put(name, value); - } + private XBreakpoint findXBreakpoint(Breakpoint breakpoint) { + for (Map.Entry entry : myBreakpoints.entrySet()) { + if (entry.getValue().equals(breakpoint)) { + return entry.getKey(); } } + return null; } + //public void readExternal(@NotNull final Element parentNode) { + // if (true) return; + // if (myProject.isOpen()) { + // doRead(parentNode); + // } + // else { + // myStartupManager.registerPostStartupActivity(new Runnable() { + // @Override + // public void run() { + // doRead(parentNode); + // } + // }); + // } + //} + + //private void doRead(@NotNull final Element parentNode) { + // ApplicationManager.getApplication().runReadAction(new Runnable() { + // @Override + // @SuppressWarnings({"HardCodedStringLiteral"}) + // public void run() { + // final Map nameToBreakpointMap = new THashMap(); + // try { + // final List groups = parentNode.getChildren(); + // for (final Object group1 : groups) { + // final Element group = (Element)group1; + // if (group.getName().equals(RULES_GROUP_NAME)) { + // continue; + // } + // final String categoryName = group.getName(); + // final Key breakpointCategory = BreakpointCategory.lookup(categoryName); + // final String defaultPolicy = group.getAttributeValue(DEFAULT_SUSPEND_POLICY_ATTRIBUTE_NAME); + // final boolean conditionEnabled = Boolean.parseBoolean(group.getAttributeValue(DEFAULT_CONDITION_STATE_ATTRIBUTE_NAME, "true")); + // setBreakpointDefaults(breakpointCategory, new BreakpointDefaults(defaultPolicy, conditionEnabled)); + // Element anyExceptionBreakpointGroup; + // if (!AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT.equals(breakpointCategory)) { + // // for compatibility with previous format + // anyExceptionBreakpointGroup = group.getChild(AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT.toString()); + // final BreakpointFactory factory = BreakpointFactory.getInstance(breakpointCategory); + // if (factory != null) { + // for (final Object o : group.getChildren("breakpoint")) { + // Element breakpointNode = (Element)o; + // Breakpoint breakpoint = factory.createBreakpoint(myProject, breakpointNode); + // breakpoint.readExternal(breakpointNode); + // addBreakpoint(breakpoint); + // nameToBreakpointMap.put(breakpoint.getDisplayName(), breakpoint); + // } + // } + // } + // else { + // anyExceptionBreakpointGroup = group; + // } + // + // if (anyExceptionBreakpointGroup != null) { + // final Element breakpointElement = group.getChild("breakpoint"); + // if (breakpointElement != null) { + // getAnyExceptionBreakpoint().readExternal(breakpointElement); + // } + // } + // + // } + // } + // catch (InvalidDataException ignored) { + // } + // + // final Element rulesGroup = parentNode.getChild(RULES_GROUP_NAME); + // if (rulesGroup != null) { + // final List rules = rulesGroup.getChildren("rule"); + // for (final Object rule1 : rules) { + // final Element rule = (Element)rule1; + // final Element master = rule.getChild(MASTER_BREAKPOINT_TAGNAME); + // if (master == null) { + // continue; + // } + // final Element slave = rule.getChild(SLAVE_BREAKPOINT_TAGNAME); + // if (slave == null) { + // continue; + // } + // final Breakpoint masterBreakpoint = nameToBreakpointMap.get(master.getAttributeValue("name")); + // if (masterBreakpoint == null) { + // continue; + // } + // final Breakpoint slaveBreakpoint = nameToBreakpointMap.get(slave.getAttributeValue("name")); + // if (slaveBreakpoint == null) { + // continue; + // } + // addBreakpointRule(new EnableBreakpointRule(BreakpointManager.this, masterBreakpoint, slaveBreakpoint, "true".equalsIgnoreCase(rule.getAttributeValue("leaveEnabled")))); + // } + // } + // + // DebuggerInvocationUtil.invokeLater(myProject, new Runnable() { + // @Override + // public void run() { + // updateBreakpointsUI(); + // } + // }); + // } + // }); + // + // myUIProperties.clear(); + // final Element props = parentNode.getChild("ui_properties"); + // if (props != null) { + // final List children = props.getChildren("property"); + // for (Object child : children) { + // Element property = (Element)child; + // final String name = property.getAttributeValue("name"); + // final String value = property.getAttributeValue("value"); + // if (name != null && value != null) { + // myUIProperties.put(name, value); + // } + // } + // } + //} + //used in Fabrique public synchronized void addBreakpoint(Breakpoint breakpoint) { - myBreakpoints.add(breakpoint); + myBreakpoints.put(breakpoint.myXBreakpoint, breakpoint); myBreakpointsListForIteration = null; - if (breakpoint instanceof BreakpointWithHighlighter) { - BreakpointWithHighlighter breakpointWithHighlighter = (BreakpointWithHighlighter)breakpoint; - final Document document = breakpointWithHighlighter.getDocument(); - if (document != null) { - myDocumentBreakpoints.putValue(document, breakpointWithHighlighter); - } - } myDispatcher.getMulticaster().breakpointsChanged(); } - public synchronized void removeBreakpoint(@Nullable final Breakpoint breakpoint) { - ApplicationManager.getApplication().assertIsDispatchThread(); + private synchronized void onBreakpointAdded(XBreakpoint xBreakpoint) { + Breakpoint breakpoint = createJavaBreakpoint(xBreakpoint); + myBreakpoints.put(xBreakpoint, breakpoint); + myBreakpointsListForIteration = null; + RequestManagerImpl.createRequests(breakpoint); + myDispatcher.getMulticaster().breakpointsChanged(); + } + + public void removeBreakpoint(@Nullable final Breakpoint breakpoint) { if (breakpoint == null) { return; } - if (myBreakpoints.remove(breakpoint)) { - updateBreakpointRules(breakpoint); + myXBreakpointManager.removeBreakpoint(breakpoint.myXBreakpoint); + } + + private synchronized void onBreakpointRemoved(@Nullable final XBreakpoint xBreakpoint) { + ApplicationManager.getApplication().assertIsDispatchThread(); + if (xBreakpoint == null) { + return; + } + + Breakpoint breakpoint = myBreakpoints.remove(xBreakpoint); + if (breakpoint != null) { + //updateBreakpointRules(breakpoint); myBreakpointsListForIteration = null; - if (breakpoint instanceof BreakpointWithHighlighter) { - for (Document document : myDocumentBreakpoints.keySet()) { - if (myDocumentBreakpoints.remove(document, (BreakpointWithHighlighter)breakpoint)) { - break; - } - } - } //we delete breakpoints inside release, so gutter will not fire events to deleted breakpoints breakpoint.delete(); + RequestManagerImpl.deleteRequests(breakpoint); myDispatcher.getMulticaster().breakpointsChanged(); } } public void writeExternal(@NotNull final Element parentNode) { - ApplicationManager.getApplication().runReadAction(new Runnable() { - @Override - public void run() { - removeInvalidBreakpoints(); - final Map, Element> categoryToElementMap = new THashMap, Element>(); - for (Key category : myBreakpointDefaults.keySet()) { - final Element group = getCategoryGroupElement(categoryToElementMap, category, parentNode); - final BreakpointDefaults defaults = getBreakpointDefaults(category); - group.setAttribute(DEFAULT_SUSPEND_POLICY_ATTRIBUTE_NAME, String.valueOf(defaults.getSuspendPolicy())); - group.setAttribute(DEFAULT_CONDITION_STATE_ATTRIBUTE_NAME, String.valueOf(defaults.isConditionEnabled())); - } - // don't store invisible breakpoints - for (Breakpoint breakpoint : getBreakpoints()) { - if (breakpoint.isValid() && - (!(breakpoint instanceof BreakpointWithHighlighter) || ((BreakpointWithHighlighter)breakpoint).isVisible())) { - writeBreakpoint(getCategoryGroupElement(categoryToElementMap, breakpoint.getCategory(), parentNode), breakpoint); - } - } - final AnyExceptionBreakpoint anyExceptionBreakpoint = getAnyExceptionBreakpoint(); - final Element group = getCategoryGroupElement(categoryToElementMap, anyExceptionBreakpoint.getCategory(), parentNode); - writeBreakpoint(group, anyExceptionBreakpoint); - - final Element rules = new Element(RULES_GROUP_NAME); - parentNode.addContent(rules); - for (EnableBreakpointRule myBreakpointRule : myBreakpointRules) { - writeRule(myBreakpointRule, rules); - } - } - }); - - final Element uiProperties = new Element("ui_properties"); - parentNode.addContent(uiProperties); - for (final String name : myUIProperties.keySet()) { - Element property = new Element("property"); - uiProperties.addContent(property); - property.setAttribute("name", name); - property.setAttribute("value", myUIProperties.get(name)); - } + // if (true) return; + // ApplicationManager.getApplication().runReadAction(new Runnable() { + // @Override + // public void run() { + // removeInvalidBreakpoints(); + // final Map, Element> categoryToElementMap = new THashMap, Element>(); + // for (Key category : myBreakpointDefaults.keySet()) { + // final Element group = getCategoryGroupElement(categoryToElementMap, category, parentNode); + // final BreakpointDefaults defaults = getBreakpointDefaults(category); + // group.setAttribute(DEFAULT_SUSPEND_POLICY_ATTRIBUTE_NAME, String.valueOf(defaults.getSuspendPolicy())); + // group.setAttribute(DEFAULT_CONDITION_STATE_ATTRIBUTE_NAME, String.valueOf(defaults.isConditionEnabled())); + // } + // // don't store invisible breakpoints + // for (Breakpoint breakpoint : getBreakpoints()) { + // if (breakpoint.isValid() && + // (!(breakpoint instanceof BreakpointWithHighlighter) || ((BreakpointWithHighlighter)breakpoint).isVisible())) { + // writeBreakpoint(getCategoryGroupElement(categoryToElementMap, breakpoint.getCategory(), parentNode), breakpoint); + // } + // } + // final AnyExceptionBreakpoint anyExceptionBreakpoint = getAnyExceptionBreakpoint(); + // final Element group = getCategoryGroupElement(categoryToElementMap, anyExceptionBreakpoint.getCategory(), parentNode); + // writeBreakpoint(group, anyExceptionBreakpoint); + // + // final Element rules = new Element(RULES_GROUP_NAME); + // parentNode.addContent(rules); + // //for (EnableBreakpointRule myBreakpointRule : myBreakpointRules) { + // // writeRule(myBreakpointRule, rules); + // //} + // } + // }); + // + // final Element uiProperties = new Element("ui_properties"); + // parentNode.addContent(uiProperties); + // for (final String name : myUIProperties.keySet()) { + // Element property = new Element("property"); + // uiProperties.addContent(property); + // property.setAttribute("name", name); + // property.setAttribute("value", myUIProperties.get(name)); + // } } - @SuppressWarnings({"HardCodedStringLiteral"}) - private static void writeRule(@NotNull final EnableBreakpointRule enableBreakpointRule, @NotNull Element element) { - Element rule = new Element("rule"); - if (enableBreakpointRule.isLeaveEnabled()) { - rule.setAttribute("leaveEnabled", Boolean.toString(true)); - } - element.addContent(rule); - writeRuleBreakpoint(rule, MASTER_BREAKPOINT_TAGNAME, enableBreakpointRule.getMasterBreakpoint()); - writeRuleBreakpoint(rule, SLAVE_BREAKPOINT_TAGNAME, enableBreakpointRule.getSlaveBreakpoint()); - } + //@SuppressWarnings({"HardCodedStringLiteral"}) + //private static void writeRule(@NotNull final EnableBreakpointRule enableBreakpointRule, @NotNull Element element) { + // Element rule = new Element("rule"); + // if (enableBreakpointRule.isLeaveEnabled()) { + // rule.setAttribute("leaveEnabled", Boolean.toString(true)); + // } + // element.addContent(rule); + // writeRuleBreakpoint(rule, MASTER_BREAKPOINT_TAGNAME, enableBreakpointRule.getMasterBreakpoint()); + // writeRuleBreakpoint(rule, SLAVE_BREAKPOINT_TAGNAME, enableBreakpointRule.getSlaveBreakpoint()); + //} - @SuppressWarnings({"HardCodedStringLiteral"}) private static void writeRuleBreakpoint(@NotNull final Element element, final String tagName, @NotNull final Breakpoint breakpoint) { - Element master = new Element(tagName); - element.addContent(master); - master.setAttribute("name", breakpoint.getDisplayName()); - } + //@SuppressWarnings({"HardCodedStringLiteral"}) private static void writeRuleBreakpoint(@NotNull final Element element, final String tagName, @NotNull final Breakpoint breakpoint) { + // Element master = new Element(tagName); + // element.addContent(master); + // master.setAttribute("name", breakpoint.getDisplayName()); + //} - @SuppressWarnings({"HardCodedStringLiteral"}) - private static void writeBreakpoint(@NotNull final Element group, @NotNull final Breakpoint breakpoint) { - Element breakpointNode = new Element("breakpoint"); - group.addContent(breakpointNode); - try { - breakpoint.writeExternal(breakpointNode); - } - catch (WriteExternalException e) { - LOG.error(e); - } - } + //@SuppressWarnings({"HardCodedStringLiteral"}) + //private static void writeBreakpoint(@NotNull final Element group, @NotNull final Breakpoint breakpoint) { + // Element breakpointNode = new Element("breakpoint"); + // group.addContent(breakpointNode); + // try { + // breakpoint.writeExternal(breakpointNode); + // } + // catch (WriteExternalException e) { + // LOG.error(e); + // } + //} private static Element getCategoryGroupElement(@NotNull final Map, Element> categoryToElementMap, @NotNull final Key category, @NotNull final Element parentNode) { Element group = categoryToElementMap.get(category); @@ -814,18 +627,31 @@ public class BreakpointManager { @NotNull public synchronized List getBreakpoints() { if (myBreakpointsListForIteration == null) { - myBreakpointsListForIteration = new ArrayList(myBreakpoints.size() + 1); - myBreakpointsListForIteration.addAll(myBreakpoints); - myBreakpointsListForIteration.add(getAnyExceptionBreakpoint()); + myBreakpointsListForIteration = new ArrayList(myBreakpoints.size()); + + for (XBreakpoint xBreakpoint : myXBreakpointManager.getAllBreakpoints()) { + if (isJavaType(xBreakpoint)) { + Breakpoint breakpoint = myBreakpoints.get(xBreakpoint); + if (breakpoint == null) { + breakpoint = createJavaBreakpoint(xBreakpoint); + myBreakpoints.put(xBreakpoint, breakpoint); + } + myBreakpointsListForIteration.add(breakpoint); + } + } } return myBreakpointsListForIteration; } - public AnyExceptionBreakpoint getAnyExceptionBreakpoint() { - if (myAnyExceptionBreakpoint == null) { - myAnyExceptionBreakpoint = new AnyExceptionBreakpoint(myProject); + private boolean isJavaType(XBreakpoint xBreakpoint) { + return xBreakpoint.getType() instanceof JavaBreakpointType; + } + + private Breakpoint createJavaBreakpoint(XBreakpoint xBreakpoint) { + if (xBreakpoint.getType() instanceof JavaBreakpointType) { + return ((JavaBreakpointType)xBreakpoint.getType()).createJavaBreakpoint(myProject, xBreakpoint); } - return myAnyExceptionBreakpoint; + throw new IllegalStateException("Unsupported breakpoint type:" + xBreakpoint.getType()); } //interaction with RequestManagerImpl @@ -963,6 +789,7 @@ public class BreakpointManager { private boolean myAllowMulticasting = true; private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD); public void fireBreakpointChanged(Breakpoint breakpoint) { + breakpoint.reload(); RequestManagerImpl.updateRequests(breakpoint); if (myAllowMulticasting) { // can be invoked from non-AWT thread @@ -988,84 +815,104 @@ public class BreakpointManager { } public void setBreakpointEnabled(@NotNull final Breakpoint breakpoint, final boolean enabled) { - if (breakpoint.ENABLED != enabled) { - breakpoint.ENABLED = enabled; - fireBreakpointChanged(breakpoint); - breakpoint.updateUI(); + if (breakpoint.isEnabled() != enabled) { + breakpoint.setEnabled(enabled); + //fireBreakpointChanged(breakpoint); + //breakpoint.updateUI(); } } public void addBreakpointRule(@NotNull EnableBreakpointRule rule) { - rule.init(); - myBreakpointRules.add(rule); + //rule.init(); + //myBreakpointRules.add(rule); } public boolean removeBreakpointRule(@NotNull EnableBreakpointRule rule) { - final boolean removed = myBreakpointRules.remove(rule); - if (removed) { - rule.dispose(); - } - return removed; + //final boolean removed = myBreakpointRules.remove(rule); + //if (removed) { + // rule.dispose(); + //} + //return removed; + return false; } public boolean removeBreakpointRule(@NotNull Breakpoint slaveBreakpoint) { - for (final EnableBreakpointRule rule : myBreakpointRules) { - if (slaveBreakpoint.equals(rule.getSlaveBreakpoint())) { - removeBreakpointRule(rule); - return true; - } - } + //for (final EnableBreakpointRule rule : myBreakpointRules) { + // if (slaveBreakpoint.equals(rule.getSlaveBreakpoint())) { + // removeBreakpointRule(rule); + // return true; + // } + //} return false; } - private void updateBreakpointRules(@NotNull Breakpoint removedBreakpoint) { - for (Iterator it = myBreakpointRules.iterator(); it.hasNext();) { - final EnableBreakpointRule rule = it.next(); - if (removedBreakpoint.equals(rule.getMasterBreakpoint()) || removedBreakpoint.equals(rule.getSlaveBreakpoint())) { - it.remove(); - } - } - } + //private void updateBreakpointRules(@NotNull Breakpoint removedBreakpoint) { + // for (Iterator it = myBreakpointRules.iterator(); it.hasNext();) { + // final EnableBreakpointRule rule = it.next(); + // if (removedBreakpoint.equals(rule.getMasterBreakpoint()) || removedBreakpoint.equals(rule.getSlaveBreakpoint())) { + // it.remove(); + // } + // } + //} + // copied from XDebugSessionImpl processDependencies public void processBreakpointHit(@NotNull final Breakpoint breakpoint) { - for (final EnableBreakpointRule rule : myBreakpointRules) { - rule.processBreakpointHit(breakpoint); + XDependentBreakpointManager dependentBreakpointManager = ((XBreakpointManagerImpl)myXBreakpointManager).getDependentBreakpointManager(); + XBreakpoint xBreakpoint = findXBreakpoint(breakpoint); + if (!dependentBreakpointManager.isMasterOrSlave(xBreakpoint)) { + return; + } + List> breakpoints = dependentBreakpointManager.getSlaveBreakpoints(xBreakpoint); + for (final XBreakpoint slaveBreakpoint : breakpoints) { + DebuggerInvocationUtil.invokeLater(myProject, new Runnable() { + @Override + public void run() { + slaveBreakpoint.setEnabled(true); + } + }); + } + + if (dependentBreakpointManager.getMasterBreakpoint(xBreakpoint) != null && !dependentBreakpointManager.isLeaveEnabled(xBreakpoint)) { + DebuggerInvocationUtil.invokeLater(myProject, new Runnable() { + @Override + public void run() { + breakpoint.setEnabled(false); + } + }); + //myDebuggerManager.getBreakpointManager().getLineBreakpointManager().queueBreakpointUpdate(breakpoint); } } public void setInitialBreakpointsState() { - myAllowMulticasting = false; - for (final EnableBreakpointRule myBreakpointRule : myBreakpointRules) { - myBreakpointRule.init(); - } - myAllowMulticasting = true; - if (!myBreakpointRules.isEmpty()) { - IJSwingUtilities.invoke(new Runnable() { - @Override - public void run() { - myDispatcher.getMulticaster().breakpointsChanged(); - } - }); - } + //myAllowMulticasting = false; + //for (final EnableBreakpointRule myBreakpointRule : myBreakpointRules) { + // myBreakpointRule.init(); + //} + //myAllowMulticasting = true; + //if (!myBreakpointRules.isEmpty()) { + // IJSwingUtilities.invoke(new Runnable() { + // @Override + // public void run() { + // myDispatcher.getMulticaster().breakpointsChanged(); + // } + // }); + //} } @Nullable public Breakpoint findMasterBreakpoint(@NotNull Breakpoint dependentBreakpoint) { - for (final EnableBreakpointRule rule : myBreakpointRules) { - if (dependentBreakpoint.equals(rule.getSlaveBreakpoint())) { - return rule.getMasterBreakpoint(); - } - } - return null; + XDependentBreakpointManager dependentBreakpointManager = ((XBreakpointManagerImpl)myXBreakpointManager).getDependentBreakpointManager(); + XBreakpoint xBreakpoint = findXBreakpoint(dependentBreakpoint); + return myBreakpoints.get(dependentBreakpointManager.getMasterBreakpoint(xBreakpoint)); } @Nullable public EnableBreakpointRule findBreakpointRule(@NotNull Breakpoint dependentBreakpoint) { - for (final EnableBreakpointRule rule : myBreakpointRules) { - if (dependentBreakpoint.equals(rule.getSlaveBreakpoint())) { - return rule; - } - } + //for (final EnableBreakpointRule rule : myBreakpointRules) { + // if (dependentBreakpoint.equals(rule.getSlaveBreakpoint())) { + // return rule; + // } + //} return null; } @@ -1076,4 +923,14 @@ public class BreakpointManager { public String setProperty(String name, String value) { return myUIProperties.put(name, value); } + + public static PsiFile getPsiFile(XBreakpoint xBreakpoint, Project project) { + try { + final Document document = FileDocumentManager.getInstance().getDocument(xBreakpoint.getSourcePosition().getFile()); + return PsiDocumentManager.getInstance(project).getPsiFile(document); + } catch (Exception e) { + LOG.error(e); + } + return null; + } } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java index d52044bbeb71..38031d4735a6 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java @@ -59,6 +59,9 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +/* + * Not used any more, since move to xBreakpoints + */ public abstract class BreakpointPropertiesPanel { private BreakpointChooser myMasterBreakpointChooser; @@ -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); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java index 16b75279099e..200e377b87f8 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java @@ -25,49 +25,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

extends Breakpoint

{ @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() { @Override public Boolean compute() { @@ -238,34 +242,34 @@ public abstract class BreakpointWithHighlighter extends Breakpoint { } buf.append(" 
 "); buf.append(DebuggerBundle.message("breakpoint.property.name.suspend.policy")).append(" : "); - if (DebuggerSettings.SUSPEND_NONE.equals(SUSPEND_POLICY) || !SUSPEND) { + if (DebuggerSettings.SUSPEND_NONE.equals(getSuspendPolicy()) || !isSuspend()) { buf.append(DebuggerBundle.message("breakpoint.properties.panel.option.suspend.none")); } - else if (DebuggerSettings.SUSPEND_ALL.equals(SUSPEND_POLICY)) { + else if (DebuggerSettings.SUSPEND_ALL.equals(getSuspendPolicy())) { buf.append(DebuggerBundle.message("breakpoint.properties.panel.option.suspend.all")); } - else if (DebuggerSettings.SUSPEND_THREAD.equals(SUSPEND_POLICY)) { + else if (DebuggerSettings.SUSPEND_THREAD.equals(getSuspendPolicy())) { buf.append(DebuggerBundle.message("breakpoint.properties.panel.option.suspend.thread")); } buf.append(" 
 "); buf.append(DebuggerBundle.message("breakpoint.property.name.log.message")).append(": "); - buf.append(LOG_ENABLED ? CommonBundle.getYesButtonText() : CommonBundle.getNoButtonText()); - if (LOG_EXPRESSION_ENABLED) { + buf.append(isLogEnabled() ? CommonBundle.getYesButtonText() : CommonBundle.getNoButtonText()); + if (isLogExpressionEnabled()) { buf.append(" 
 "); buf.append(DebuggerBundle.message("breakpoint.property.name.log.expression")).append(": "); buf.append(XmlStringUtil.escapeString(getLogMessage().getText())); } - if (CONDITION_ENABLED && getCondition() != null && getCondition().getText() != null && !getCondition().getText().isEmpty()) { + if (isConditionEnabled() && getCondition() != null && getCondition().getText() != null && !getCondition().getText().isEmpty()) { buf.append(" 
 "); buf.append(DebuggerBundle.message("breakpoint.property.name.condition")).append(": "); buf.append(XmlStringUtil.escapeString(getCondition().getText())); } - if (COUNT_FILTER_ENABLED) { + if (isCountFilterEnabled()) { buf.append(" 
 "); buf.append(DebuggerBundle.message("breakpoint.property.name.pass.count")).append(": "); - buf.append(COUNT_FILTER); + buf.append(getCountFilter()); } - if (CLASS_FILTERS_ENABLED) { + if (isClassFiltersEnabled()) { buf.append(" 
 "); buf.append(DebuggerBundle.message("breakpoint.property.name.class.filters")).append(": "); ClassFilter[] classFilters = getClassFilters(); @@ -273,7 +277,7 @@ public abstract class BreakpointWithHighlighter extends Breakpoint { buf.append(classFilter.getPattern()).append(" "); } } - if (INSTANCE_FILTERS_ENABLED) { + if (isInstanceFiltersEnabled()) { buf.append(" 
 "); buf.append(DebuggerBundle.message("breakpoint.property.name.instance.filters")); InstanceFilter[] instanceFilters = getInstanceFilters(); @@ -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 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(); + // } + //} } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpoint.java index c6a19557f4e8..88a9a6ff329e 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpoint.java @@ -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 { private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.breakpoints.ExceptionBreakpoint"); - public boolean NOTIFY_CAUGHT = true; - public boolean NOTIFY_UNCAUGHT = true; - private String myQualifiedName; - private String myPackageName; - protected final static String READ_NO_CLASS_NAME = DebuggerBundle.message("error.absent.exception.breakpoint.class.name"); public static final @NonNls Key CATEGORY = BreakpointCategory.lookup("exception_breakpoints"); - public ExceptionBreakpoint(Project project) { - super(project); + public ExceptionBreakpoint(Project project, XBreakpoint xBreakpoint) { + super(project, xBreakpoint); } public Key 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() { 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() { 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; + } } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointFactory.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointFactory.java deleted file mode 100644 index 40b75c4ffc71..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointFactory.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.debugger.ui.breakpoints; - -import com.intellij.debugger.DebuggerBundle; -import com.intellij.debugger.DebuggerManagerEx; -import com.intellij.debugger.HelpID; -import com.intellij.debugger.engine.JVMNameUtil; -import com.intellij.icons.AllIcons; -import com.intellij.ide.util.TreeClassChooser; -import com.intellij.ide.util.TreeClassChooserFactory; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Key; -import com.intellij.psi.JavaPsiFacade; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiClassOwner; -import com.intellij.psi.search.GlobalSearchScope; -import org.jdom.Element; - -import javax.swing.*; - -/** - * @author Eugene Zhuravlev - * Date: Apr 26, 2005 - */ -public class ExceptionBreakpointFactory extends BreakpointFactory { - public Breakpoint createBreakpoint(Project project, final Element element) { - return new ExceptionBreakpoint(project); - } - - public Icon getIcon() { - return AllIcons.Debugger.Db_exception_breakpoint; - } - - public Icon getDisabledIcon() { - return AllIcons.Debugger.Db_disabled_exception_breakpoint; - } - - @Override - protected String getHelpID() { - return HelpID.EXCEPTION_BREAKPOINTS; - } - - @Override - public String getDisplayName() { - return DebuggerBundle.message("exception.breakpoints.tab.title"); - } - - @Override - public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) { - return new ExceptionBreakpointPropertiesPanel(project, compact); - } - - public Key getBreakpointCategory() { - return ExceptionBreakpoint.CATEGORY; - } - - @Override - public boolean canAddBreakpoints() { - return true; - } - - @Override - public Breakpoint addBreakpoint(Project project) { - ExceptionBreakpoint breakpoint = null; - final PsiClass throwableClass = - JavaPsiFacade.getInstance(project).findClass("java.lang.Throwable", GlobalSearchScope.allScope(project)); - TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project) - .createInheritanceClassChooser(DebuggerBundle.message("add.exception.breakpoint.classchooser.title"), - GlobalSearchScope.allScope(project), throwableClass, true, true, null); - chooser.showDialog(); - PsiClass selectedClass = chooser.getSelected(); - String qName = selectedClass == null ? null : JVMNameUtil.getNonAnonymousClassName(selectedClass); - - if (qName != null && qName.length() > 0) { - breakpoint = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager() - .addExceptionBreakpoint(qName, ((PsiClassOwner)selectedClass.getContainingFile()).getPackageName()); - } - return breakpoint; - } -} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointPropertiesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointPropertiesPanel.java index 6d02499f227c..4af7275d1258 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointPropertiesPanel.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpointPropertiesPanel.java @@ -21,31 +21,34 @@ package com.intellij.debugger.ui.breakpoints; import com.intellij.debugger.DebuggerBundle; -import com.intellij.ide.util.ClassFilter; -import com.intellij.openapi.project.Project; import com.intellij.ui.IdeBorderFactory; import com.intellij.util.ui.DialogUtil; +import com.intellij.xdebugger.breakpoints.XBreakpoint; +import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpointProperties; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -public class ExceptionBreakpointPropertiesPanel extends BreakpointPropertiesPanel { +public class ExceptionBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPanel> { private JCheckBox myNotifyCaughtCheckBox; private JCheckBox myNotifyUncaughtCheckBox; - private ExceptionBreakpoint myExceptionBreakpoint; + //private ExceptionBreakpoint myExceptionBreakpoint; - public ExceptionBreakpointPropertiesPanel(Project project, boolean compact) { - super(project, ExceptionBreakpoint.CATEGORY, compact); - } + //public ExceptionBreakpointPropertiesPanel(Project project, boolean compact) { + // super(project, ExceptionBreakpoint.CATEGORY, compact); + //} - protected ClassFilter createClassConditionFilter() { - return null; - } - - protected JComponent createSpecialBox() { + //protected ClassFilter createClassConditionFilter() { + // return null; + //} + @NotNull + @Override + public JComponent getComponent() { myNotifyCaughtCheckBox = new JCheckBox(DebuggerBundle.message("label.exception.breakpoint.properties.panel.caught.exception")); myNotifyUncaughtCheckBox = new JCheckBox(DebuggerBundle.message("label.exception.breakpoint.properties.panel.uncaught.exception")); DialogUtil.registerMnemonic(myNotifyCaughtCheckBox); @@ -91,25 +94,20 @@ public class ExceptionBreakpointPropertiesPanel extends BreakpointPropertiesPane return _panel; } - protected void updateCheckboxes() { - super.updateCheckboxes(); - myPassCountCheckbox.setEnabled(!(myExceptionBreakpoint instanceof AnyExceptionBreakpoint)); + //protected void updateCheckboxes() { + // super.updateCheckboxes(); + // myPassCountCheckbox.setEnabled(!(myExceptionBreakpoint instanceof AnyExceptionBreakpoint)); + //} + + @Override + public void loadFrom(@NotNull XBreakpoint breakpoint) { + myNotifyCaughtCheckBox.setSelected(breakpoint.getProperties().NOTIFY_CAUGHT); + myNotifyUncaughtCheckBox.setSelected(breakpoint.getProperties().NOTIFY_UNCAUGHT); } - public void initFrom(Breakpoint breakpoint, boolean moreOptionsVisible) { - ExceptionBreakpoint exceptionBreakpoint = (ExceptionBreakpoint)breakpoint; - myExceptionBreakpoint = exceptionBreakpoint; - super.initFrom(breakpoint, moreOptionsVisible); - - myNotifyCaughtCheckBox.setSelected(exceptionBreakpoint.NOTIFY_CAUGHT); - myNotifyUncaughtCheckBox.setSelected(exceptionBreakpoint.NOTIFY_UNCAUGHT); - } - - public void saveTo(Breakpoint breakpoint) { - ExceptionBreakpoint exceptionBreakpoint = (ExceptionBreakpoint)breakpoint; - exceptionBreakpoint.NOTIFY_CAUGHT = myNotifyCaughtCheckBox.isSelected(); - exceptionBreakpoint.NOTIFY_UNCAUGHT = myNotifyUncaughtCheckBox.isSelected(); - - super.saveTo(breakpoint); + @Override + public void saveTo(@NotNull XBreakpoint breakpoint) { + breakpoint.getProperties().NOTIFY_CAUGHT = myNotifyCaughtCheckBox.isSelected(); + breakpoint.getProperties().NOTIFY_UNCAUGHT = myNotifyUncaughtCheckBox.isSelected(); } } \ No newline at end of file diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpoint.java index 365ae242b36d..ada59099a2db 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpoint.java @@ -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 { private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.breakpoints.FieldBreakpoint"); - public boolean WATCH_MODIFICATION = true; - public boolean WATCH_ACCESS = false; private boolean myIsStatic; - private String myFieldName; @NonNls public static final Key CATEGORY = BreakpointCategory.lookup("field_breakpoints"); - protected FieldBreakpoint(Project project) { - super(project); + protected FieldBreakpoint(Project project, XBreakpoint breakpoint) { + super(project, breakpoint); } - private FieldBreakpoint(Project project, RangeHighlighter highlighter, @NotNull String fieldName) { - super(project, highlighter); - myFieldName = fieldName; + private FieldBreakpoint(Project project, 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; + } } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointFactory.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointFactory.java deleted file mode 100644 index 1bdef0c862e7..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointFactory.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.debugger.ui.breakpoints; - -import com.intellij.CommonBundle; -import com.intellij.debugger.DebuggerBundle; -import com.intellij.debugger.DebuggerManagerEx; -import com.intellij.debugger.HelpID; -import com.intellij.icons.AllIcons; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.Ref; -import com.intellij.psi.*; -import com.intellij.psi.search.GlobalSearchScope; -import org.jdom.Element; - -import javax.swing.*; - -/** - * @author Eugene Zhuravlev - * Date: Apr 26, 2005 - */ -public class FieldBreakpointFactory extends BreakpointFactory{ - public Breakpoint createBreakpoint(Project project, final Element element) { - return new FieldBreakpoint(project); - } - - public Icon getIcon() { - return AllIcons.Debugger.Db_field_breakpoint; - } - - public Icon getDisabledIcon() { - return AllIcons.Debugger.Db_disabled_field_breakpoint; - } - - @Override - protected String getHelpID() { - return HelpID.FIELD_WATCHPOINTS; - } - - @Override - public String getDisplayName() { - return DebuggerBundle.message("field.watchpoints.tab.title"); - } - - @Override - public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) { - return new FieldBreakpointPropertiesPanel(project, compact); - } - - public Key getBreakpointCategory() { - return FieldBreakpoint.CATEGORY; - } - - @Override - public Breakpoint addBreakpoint(final Project project) { - final Ref result = Ref.create(null); - AddFieldBreakpointDialog dialog = new AddFieldBreakpointDialog(project) { - protected boolean validateData() { - String className = getClassName(); - if (className.length() == 0) { - Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.class.name.not.specified"), - DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon()); - return false; - } - String fieldName = getFieldName(); - if (fieldName.length() == 0) { - Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.field.name.not.specified"), - DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon()); - return false; - } - PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(className, GlobalSearchScope.allScope(project)); - if (psiClass != null) { - PsiFile psiFile = psiClass.getContainingFile(); - Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile); - if(document != null) { - PsiField field = psiClass.findFieldByName(fieldName, true); - if(field != null) { - int line = document.getLineNumber(field.getTextOffset()); - FieldBreakpoint fieldBreakpoint = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().addFieldBreakpoint(document, line, fieldName); - if (fieldBreakpoint != null) { - result.set(fieldBreakpoint); - return true; - } - } - else { - Messages.showMessageDialog(project, - DebuggerBundle.message("error.field.breakpoint.field.not.found", className, fieldName, fieldName), - CommonBundle.getErrorTitle(), - Messages.getErrorIcon() - ); - } - } - } else { - Messages.showMessageDialog(project, - DebuggerBundle.message("error.field.breakpoint.class.sources.not.found", className, fieldName, className), - CommonBundle.getErrorTitle(), - Messages.getErrorIcon() - ); - } - return false; - } - }; - dialog.show(); - return result.get(); - } - - @Override - public boolean canAddBreakpoints() { - return true; - } -} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointPropertiesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointPropertiesPanel.java index bec12645dd80..4d0bec2e165b 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointPropertiesPanel.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpointPropertiesPanel.java @@ -21,24 +21,30 @@ package com.intellij.debugger.ui.breakpoints; import com.intellij.debugger.DebuggerBundle; -import com.intellij.openapi.project.Project; import com.intellij.ui.IdeBorderFactory; import com.intellij.util.ui.DialogUtil; +import com.intellij.xdebugger.breakpoints.XLineBreakpoint; +import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.java.debugger.breakpoints.properties.JavaFieldBreakpointProperties; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -public class FieldBreakpointPropertiesPanel extends BreakpointPropertiesPanel { +public class FieldBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPanel> { private JCheckBox myWatchAccessCheckBox; private JCheckBox myWatchModificationCheckBox; - public FieldBreakpointPropertiesPanel(final Project project, boolean compact) { - super(project, FieldBreakpoint.CATEGORY, compact); - } + //public FieldBreakpointPropertiesPanel(final Project project, boolean compact) { + // super(project, FieldBreakpoint.CATEGORY, compact); + //} - protected JComponent createSpecialBox() { + + @NotNull + @Override + public JComponent getComponent() { JPanel _panel; JPanel _panel0; myWatchAccessCheckBox = new JCheckBox(DebuggerBundle.message("label.filed.breakpoint.properties.panel.field.access")); @@ -86,20 +92,15 @@ public class FieldBreakpointPropertiesPanel extends BreakpointPropertiesPanel { return _panel; } - public void initFrom(Breakpoint breakpoint, boolean moreOptionsVisible) { - super.initFrom(breakpoint, moreOptionsVisible); - FieldBreakpoint fieldBreakpoint = (FieldBreakpoint)breakpoint; - - myWatchAccessCheckBox.setSelected(fieldBreakpoint.WATCH_ACCESS); - myWatchModificationCheckBox.setSelected(fieldBreakpoint.WATCH_MODIFICATION); + @Override + public void loadFrom(@NotNull XLineBreakpoint breakpoint) { + myWatchAccessCheckBox.setSelected(breakpoint.getProperties().WATCH_ACCESS); + myWatchModificationCheckBox.setSelected(breakpoint.getProperties().WATCH_MODIFICATION); } - public void saveTo(Breakpoint breakpoint) { - FieldBreakpoint fieldBreakpoint = (FieldBreakpoint)breakpoint; - - fieldBreakpoint.WATCH_ACCESS = myWatchAccessCheckBox.isSelected(); - fieldBreakpoint.WATCH_MODIFICATION = myWatchModificationCheckBox.isSelected(); - - super.saveTo(breakpoint); + @Override + public void saveTo(@NotNull XLineBreakpoint breakpoint) { + breakpoint.getProperties().WATCH_ACCESS = myWatchAccessCheckBox.isSelected(); + breakpoint.getProperties().WATCH_MODIFICATION = myWatchModificationCheckBox.isSelected(); } } \ No newline at end of file diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestor.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestor.java index 8aa57bd351d8..6a628f189bc5 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestor.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,250 +13,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/** - * class FilteredRequestor - * @author Jeka - */ package com.intellij.debugger.ui.breakpoints; -import com.intellij.debugger.*; -import com.intellij.debugger.engine.ContextUtil; -import com.intellij.debugger.engine.DebugProcessImpl; -import com.intellij.debugger.engine.evaluation.*; -import com.intellij.debugger.engine.evaluation.expression.EvaluatorBuilderImpl; -import com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator; +import com.intellij.debugger.InstanceFilter; import com.intellij.debugger.engine.requests.LocatableEventRequestor; -import com.intellij.debugger.impl.DebuggerUtilsEx; -import com.intellij.debugger.settings.DebuggerSettings; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.*; -import com.intellij.psi.PsiElement; import com.intellij.ui.classFilter.ClassFilter; -import com.sun.jdi.BooleanValue; -import com.sun.jdi.ObjectReference; -import com.sun.jdi.VMDisconnectedException; -import com.sun.jdi.Value; -import com.sun.jdi.event.LocatableEvent; -import org.jdom.Element; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.List; +/** + * @author egor + */ +public interface FilteredRequestor extends LocatableEventRequestor { + String getSuspendPolicy(); -public abstract class FilteredRequestor implements LocatableEventRequestor, JDOMExternalizable { + boolean isInstanceFiltersEnabled(); + InstanceFilter[] getInstanceFilters(); - public String SUSPEND_POLICY = DebuggerSettings.SUSPEND_ALL; - public boolean SUSPEND = true; + boolean isCountFilterEnabled(); + int getCountFilter(); - public boolean COUNT_FILTER_ENABLED = false; - public int COUNT_FILTER = 0; - - public boolean CONDITION_ENABLED = false; - private TextWithImports myCondition; - - public boolean CLASS_FILTERS_ENABLED = false; - private ClassFilter[] myClassFilters = ClassFilter.EMPTY_ARRAY; - private ClassFilter[] myClassExclusionFilters = ClassFilter.EMPTY_ARRAY; - - public boolean INSTANCE_FILTERS_ENABLED = false; - private InstanceFilter[] myInstanceFilters = InstanceFilter.EMPTY_ARRAY; - - @NonNls private static final String FILTER_OPTION_NAME = "filter"; - @NonNls private static final String EXCLUSION_FILTER_OPTION_NAME = "exclusion_filter"; - @NonNls private static final String INSTANCE_ID_OPTION_NAME = "instance_id"; - @NonNls private static final String CONDITION_OPTION_NAME = "CONDITION"; - protected final Project myProject; - - public FilteredRequestor(@NotNull Project project) { - myProject = project; - myCondition = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, ""); - } - - public InstanceFilter[] getInstanceFilters() { - return myInstanceFilters; - } - - public void setInstanceFilters(InstanceFilter[] instanceFilters) { - myInstanceFilters = instanceFilters != null? instanceFilters : InstanceFilter.EMPTY_ARRAY; - } - - public String getSuspendPolicy() { - return SUSPEND? SUSPEND_POLICY : DebuggerSettings.SUSPEND_NONE; - } - - /** - * @return true if the ID was added or false otherwise - */ - private boolean hasObjectID(long id) { - for (InstanceFilter instanceFilter : myInstanceFilters) { - if (instanceFilter.getId() == id) { - return true; - } - } - return false; - } - - protected void addInstanceFilter(long l) { - final InstanceFilter[] filters = new InstanceFilter[myInstanceFilters.length + 1]; - System.arraycopy(myInstanceFilters, 0, filters, 0, myInstanceFilters.length); - filters[myInstanceFilters.length] = InstanceFilter.create(String.valueOf(l)); - myInstanceFilters = filters; - } - - public final ClassFilter[] getClassFilters() { - return myClassFilters; - } - - public final void setClassFilters(ClassFilter[] classFilters) { - myClassFilters = classFilters != null? classFilters : ClassFilter.EMPTY_ARRAY; - } - - public ClassFilter[] getClassExclusionFilters() { - return myClassExclusionFilters; - } - - public void setClassExclusionFilters(ClassFilter[] classExclusionFilters) { - myClassExclusionFilters = classExclusionFilters != null? classExclusionFilters : ClassFilter.EMPTY_ARRAY; - } - - public void readExternal(Element parentNode) throws InvalidDataException { - DefaultJDOMExternalizer.readExternal(this, parentNode); - if (DebuggerSettings.SUSPEND_NONE.equals(SUSPEND_POLICY)) { // compatibility with older format - SUSPEND = false; - SUSPEND_POLICY = DebuggerSettings.SUSPEND_ALL; - } - String condition = JDOMExternalizerUtil.readField(parentNode, CONDITION_OPTION_NAME); - if (condition != null) { - setCondition(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, condition)); - } - - myClassFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(FILTER_OPTION_NAME)); - myClassExclusionFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(EXCLUSION_FILTER_OPTION_NAME)); - - final ClassFilter [] instanceFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(INSTANCE_ID_OPTION_NAME)); - final List iFilters = new ArrayList(instanceFilters.length); - - for (ClassFilter instanceFilter : instanceFilters) { - try { - iFilters.add(InstanceFilter.create(instanceFilter)); - } - catch (Exception e) { - } - } - myInstanceFilters = iFilters.isEmpty() ? InstanceFilter.EMPTY_ARRAY : iFilters.toArray(new InstanceFilter[iFilters.size()]); - } - - public void writeExternal(Element parentNode) throws WriteExternalException { - DefaultJDOMExternalizer.writeExternal(this, parentNode); - JDOMExternalizerUtil.writeField(parentNode, CONDITION_OPTION_NAME, getCondition().toExternalForm()); - DebuggerUtilsEx.writeFilters(parentNode, FILTER_OPTION_NAME, myClassFilters); - DebuggerUtilsEx.writeFilters(parentNode, EXCLUSION_FILTER_OPTION_NAME, myClassExclusionFilters); - DebuggerUtilsEx.writeFilters(parentNode, INSTANCE_ID_OPTION_NAME, InstanceFilter.createClassFilters(myInstanceFilters)); - } - - public boolean evaluateCondition(final EvaluationContextImpl context, LocatableEvent event) throws EvaluateException { - if(COUNT_FILTER_ENABLED) { - final DebugProcessImpl debugProcess = context.getDebugProcess(); - debugProcess.getVirtualMachineProxy().suspend(); - debugProcess.getRequestsManager().deleteRequest(this); - ((Breakpoint)this).createRequest(debugProcess); - debugProcess.getVirtualMachineProxy().resume(); - } - if (INSTANCE_FILTERS_ENABLED) { - Value value = context.getThisObject(); - if (value != null) { // non-static - ObjectReference reference = (ObjectReference)value; - if(!hasObjectID(reference.uniqueID())) { - return false; - } - } - } - - if (CLASS_FILTERS_ENABLED) { - String typeName = calculateEventClass(context, event); - if (!typeMatchesClassFilters(typeName)) return false; - } - - if (CONDITION_ENABLED && getCondition() != null && !"".equals(getCondition().getText())) { - try { - ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(context.getProject(), new EvaluatingComputable() { - public ExpressionEvaluator compute() throws EvaluateException { - final SourcePosition contextSourcePosition = ContextUtil.getSourcePosition(context); - // IMPORTANT: calculate context psi element basing on the location where the exception - // has been hit, not on the location where it was set. (For line breakpoints these locations are the same, however, - // for method, exception and field breakpoints these locations differ) - PsiElement contextPsiElement = ContextUtil.getContextElement(contextSourcePosition); - if (contextPsiElement == null) { - contextPsiElement = getEvaluationElement(); // as a last resort - } - return EvaluatorBuilderImpl.build(getCondition(), contextPsiElement, contextSourcePosition); - } - }); - final Value value = evaluator.evaluate(context); - if (!(value instanceof BooleanValue)) { - throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.boolean.expected")); - } - if(!((BooleanValue)value).booleanValue()) { - return false; - } - } - catch (EvaluateException ex) { - if(ex.getCause() instanceof VMDisconnectedException) { - return false; - } - throw EvaluateExceptionUtil.createEvaluateException( - DebuggerBundle.message("error.failed.evaluating.breakpoint.condition", getCondition(), ex.getMessage()) - ); - } - return true; - } - - return true; - } - - protected String calculateEventClass(EvaluationContextImpl context, LocatableEvent event) throws EvaluateException { - return event.location().declaringType().name(); - } - - private boolean typeMatchesClassFilters(@Nullable String typeName) { - if (typeName == null) { - return true; - } - boolean matches = false, hasEnabled = false; - for (ClassFilter classFilter : getClassFilters()) { - if (classFilter.isEnabled()) { - hasEnabled = true; - if (classFilter.matches(typeName)) { - matches = true; - break; - } - } - } - if(hasEnabled && !matches) { - return false; - } - for (ClassFilter classFilter : getClassExclusionFilters()) { - if (classFilter.isEnabled() && classFilter.matches(typeName)) { - return false; - } - } - return true; - } - - public abstract PsiElement getEvaluationElement(); - - public TextWithImports getCondition() { - return myCondition; - } - - public void setCondition(TextWithImports condition) { - myCondition = condition; - } - - public Project getProject() { - return myProject; - } + boolean isClassFiltersEnabled(); + ClassFilter[] getClassFilters(); + ClassFilter[] getClassExclusionFilters(); } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestorImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestorImpl.java new file mode 100644 index 000000000000..2364d9c71ccd --- /dev/null +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestorImpl.java @@ -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 iFilters = new ArrayList(instanceFilters.length); + + for (ClassFilter instanceFilter : instanceFilters) { + try { + iFilters.add(InstanceFilter.create(instanceFilter)); + } + catch (Exception e) { + } + } + myInstanceFilters = iFilters.isEmpty() ? InstanceFilter.EMPTY_ARRAY : iFilters.toArray(new InstanceFilter[iFilters.size()]); + } + + public void writeExternal(Element parentNode) throws WriteExternalException { + DefaultJDOMExternalizer.writeExternal(this, parentNode); + JDOMExternalizerUtil.writeField(parentNode, CONDITION_OPTION_NAME, getCondition().toExternalForm()); + DebuggerUtilsEx.writeFilters(parentNode, FILTER_OPTION_NAME, myClassFilters); + DebuggerUtilsEx.writeFilters(parentNode, EXCLUSION_FILTER_OPTION_NAME, myClassExclusionFilters); + DebuggerUtilsEx.writeFilters(parentNode, INSTANCE_ID_OPTION_NAME, InstanceFilter.createClassFilters(myInstanceFilters)); + } + + protected String calculateEventClass(EvaluationContextImpl context, LocatableEvent event) throws EvaluateException { + return event.location().declaringType().name(); + } + + private boolean typeMatchesClassFilters(@Nullable String typeName) { + if (typeName == null) { + return true; + } + boolean matches = false, hasEnabled = false; + for (ClassFilter classFilter : getClassFilters()) { + if (classFilter.isEnabled()) { + hasEnabled = true; + if (classFilter.matches(typeName)) { + matches = true; + break; + } + } + } + if(hasEnabled && !matches) { + return false; + } + for (ClassFilter classFilter : getClassExclusionFilters()) { + if (classFilter.isEnabled() && classFilter.matches(typeName)) { + return false; + } + } + return true; + } + + public 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; + } +} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointItem.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointItem.java deleted file mode 100644 index ec3577cbae0a..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointItem.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.debugger.ui.breakpoints; - -import com.intellij.debugger.DebuggerManagerEx; -import com.intellij.debugger.SourcePosition; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.ui.SimpleColoredComponent; -import com.intellij.ui.SimpleTextAttributes; -import com.intellij.ui.popup.util.DetailView; -import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; - -class JavaBreakpointItem extends BreakpointItem { - private final Breakpoint myBreakpoint; - private BreakpointFactory myBreakpointFactory; - private BreakpointPropertiesPanel myBreakpointPropertiesPanel; - - public JavaBreakpointItem(@Nullable BreakpointFactory breakpointFactory, Breakpoint breakpoint) { - myBreakpointFactory = breakpointFactory; - myBreakpoint = breakpoint; - } - - @Override - public void setupGenericRenderer(SimpleColoredComponent renderer, boolean plainView) { - if (plainView) { - renderer.setIcon(myBreakpoint.getIcon()); - } - renderer.append(plainView ? StringUtil.shortenTextWithEllipsis(myBreakpoint.getShortName(), 60, 0) : myBreakpoint.getDisplayName(), - isEnabled() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES); - } - - @Override - public Icon getIcon() { - return myBreakpoint.getIcon(); - } - - @Override - public String getDisplayText() { - return myBreakpoint.getDisplayName(); - } - - @Override - public String speedSearchText() { - return myBreakpoint.getDisplayName(); - } - - @Override - public String footerText() { - return myBreakpoint.getDisplayName(); - } - - @Override - protected void doUpdateDetailView(DetailView panel, boolean editorOnly) { - //saveState(); - if (myBreakpointPropertiesPanel != null) { - myBreakpointPropertiesPanel.dispose(); - myBreakpointPropertiesPanel = null; - } - - if (!editorOnly) { - myBreakpointPropertiesPanel = myBreakpointFactory != null ? myBreakpointFactory - .createBreakpointPropertiesPanel(myBreakpoint.getProject(), false) : null; - - if (myBreakpointPropertiesPanel != null) { - myBreakpointPropertiesPanel.initFrom(myBreakpoint, true); - - final JPanel mainPanel = myBreakpointPropertiesPanel.getPanel(); - panel.setPropertiesPanel(mainPanel); - } - else { - panel.setPropertiesPanel(null); - } - } - - if (myBreakpoint instanceof BreakpointWithHighlighter) { - SourcePosition sourcePosition = ((BreakpointWithHighlighter)myBreakpoint).getSourcePosition(); - VirtualFile virtualFile = sourcePosition.getFile().getVirtualFile(); - showInEditor(panel, virtualFile, sourcePosition.getLine()); - } else { - panel.clearEditor(); - } - if (myBreakpointPropertiesPanel != null) { - myBreakpointPropertiesPanel.setDetailView(panel); - } - } - - @Override - public void navigate(boolean requestFocus) { - if (myBreakpoint instanceof BreakpointWithHighlighter) { - ((BreakpointWithHighlighter)myBreakpoint).getSourcePosition().navigate(requestFocus); - } - } - - @Override - public boolean canNavigate() { - return myBreakpoint instanceof BreakpointWithHighlighter && ((BreakpointWithHighlighter)myBreakpoint).getSourcePosition().canNavigate(); - } - - @Override - public boolean canNavigateToSource() { - return myBreakpoint instanceof BreakpointWithHighlighter && - ((BreakpointWithHighlighter)myBreakpoint).getSourcePosition().canNavigateToSource(); - } - - @Override - public boolean allowedToRemove() { - return myBreakpointFactory != null && myBreakpointFactory.breakpointCanBeRemoved(myBreakpoint); - } - - @Override - public void removed(Project project) { - dispose(); - DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().removeBreakpoint(myBreakpoint); - } - - @Override - public void saveState() { - if (myBreakpointPropertiesPanel != null) { - myBreakpointPropertiesPanel.saveTo(myBreakpoint); - } - } - - @Override - public Object getBreakpoint() { - return myBreakpoint; - } - - @Override - public boolean isEnabled() { - return myBreakpoint.ENABLED; - } - - @Override - public void setEnabled(boolean state) { - myBreakpoint.ENABLED = state; - myBreakpoint.updateUI(); - DebuggerManagerEx.getInstanceEx(myBreakpoint.getProject()).getBreakpointManager().fireBreakpointChanged(myBreakpoint); - } - - @Override - public boolean isDefaultBreakpoint() { - return myBreakpoint.getCategory().equals(ExceptionBreakpoint.CATEGORY); - } - - @Override - protected void dispose() { - if (myBreakpointPropertiesPanel != null) { - myBreakpointPropertiesPanel.dispose(); - myBreakpointPropertiesPanel = null; - } - } - - @Override - public int compareTo(@NotNull BreakpointItem breakpointItem) { - final Object breakpoint = breakpointItem.getBreakpoint(); - if (breakpoint instanceof Breakpoint) { - return -getIndexOf(myBreakpoint) + getIndexOf((Breakpoint)breakpoint); - } - return getDisplayText().compareTo(breakpointItem.getDisplayText()); - } - - private int getIndexOf(Breakpoint breakpoint) { - return DebuggerManagerEx.getInstanceEx(myBreakpoint.getProject()).getBreakpointManager().getBreakpoints().indexOf(breakpoint); - } -} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpointPropertiesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointType.java similarity index 62% rename from java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpointPropertiesPanel.java rename to java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointType.java index 802657b44fd9..2776032a2f4f 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpointPropertiesPanel.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointType.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,17 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * Class LineBreakpointPropertiesPanel - * @author Jeka - */ package com.intellij.debugger.ui.breakpoints; import com.intellij.openapi.project.Project; +import com.intellij.xdebugger.breakpoints.XBreakpoint; +import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties; -public class LineBreakpointPropertiesPanel extends BreakpointPropertiesPanel { - public LineBreakpointPropertiesPanel(Project project, boolean compact) { - super(project, LineBreakpoint.CATEGORY, compact); - } -} \ No newline at end of file +/** + * Base class for all Java breakpoint types + * @author egor + */ +public interface JavaBreakpointType

{ + Breakpoint createJavaBreakpoint(Project project, XBreakpoint

breakpoint); +} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointTypeBase.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointTypeBase.java new file mode 100644 index 000000000000..69a5dbb32455 --- /dev/null +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaBreakpointTypeBase.java @@ -0,0 +1,56 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.debugger.ui.breakpoints; + +import com.intellij.openapi.project.Project; +import com.intellij.xdebugger.breakpoints.XBreakpoint; +import com.intellij.xdebugger.breakpoints.XBreakpointType; +import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel; +import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider; +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.java.debugger.JavaDebuggerEditorsProvider; +import org.jetbrains.java.debugger.breakpoints.JavaBreakpointFiltersPanel; +import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties; + +/** + * Base class for non-line java breakpoint + * @author egor + */ +public abstract class JavaBreakpointTypeBase extends XBreakpointType, T> { + protected JavaBreakpointTypeBase(@NonNls @NotNull String id, @Nls @NotNull String title) { + super(id, title, true); + } + + @Override + public final boolean isAddBreakpointButtonVisible() { + return true; + } + + @Nullable + @Override + public final XBreakpointCustomPropertiesPanel> createCustomRightPropertiesPanel(@NotNull Project project) { + return new JavaBreakpointFiltersPanel>(project); + } + + @Nullable + @Override + public final XDebuggerEditorsProvider getEditorsProvider(@NotNull XBreakpoint breakpoint, @NotNull Project project) { + return new JavaDebuggerEditorsProvider(); + } +} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaExceptionBreakpointType.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaExceptionBreakpointType.java new file mode 100644 index 000000000000..89f6e432b3d3 --- /dev/null +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaExceptionBreakpointType.java @@ -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 + implements JavaBreakpointType { + 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 breakpoint) { + String name = breakpoint.getProperties().myQualifiedName; + if (name != null) { + return DebuggerBundle.message("breakpoint.exception.breakpoint.display.name", name); + } + else { + return DebuggerBundle.message("breakpoint.any.exception.display.name"); + } + } + + @Nullable + @Override + public JavaExceptionBreakpointProperties createProperties() { + return new JavaExceptionBreakpointProperties(); + } + + @Nullable + @Override + public XBreakpointCustomPropertiesPanel> createCustomPropertiesPanel() { + return new ExceptionBreakpointPropertiesPanel(); + } + + @Nullable + @Override + public XBreakpoint createDefaultBreakpoint(@NotNull XBreakpointCreator creator) { + return creator.createBreakpoint(new JavaExceptionBreakpointProperties()); + } + + //public Key getBreakpointCategory() { + // return ExceptionBreakpoint.CATEGORY; + //} + + @Nullable + @Override + public XBreakpoint addBreakpoint(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 breakpoint) { + if (breakpoint.getProperties().myQualifiedName != null) { + return new ExceptionBreakpoint(project, breakpoint); + } + else { + return new AnyExceptionBreakpoint(project, breakpoint); + } + } +} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaFieldBreakpointType.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaFieldBreakpointType.java new file mode 100644 index 000000000000..43860054bd8a --- /dev/null +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaFieldBreakpointType.java @@ -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 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 breakpoint) { + return getDisplayText(breakpoint); + } + + @Override + public String getDisplayText(XLineBreakpoint breakpoint) { + //if(!isValid()) { + // return DebuggerBundle.message("status.breakpoint.invalid"); + //} + JavaFieldBreakpointProperties properties = breakpoint.getProperties(); + final String className = "Class";//properties.getClassName(); + return className != null && !className.isEmpty() ? className + "." + properties.myFieldName : properties.myFieldName; + } + + @Nullable + @Override + public XBreakpointCustomPropertiesPanel> createCustomPropertiesPanel() { + return new FieldBreakpointPropertiesPanel(); + } + + @Nullable + @Override + public JavaFieldBreakpointProperties createProperties() { + return new JavaFieldBreakpointProperties(); + } + + @Nullable + @Override + public JavaFieldBreakpointProperties createBreakpointProperties(@NotNull VirtualFile file, int line) { + return new JavaFieldBreakpointProperties(); + } + + @Nullable + @Override + public XLineBreakpoint addBreakpoint(final Project project, JComponent parentComponent) { + final Ref result = Ref.create(null); + AddFieldBreakpointDialog dialog = new AddFieldBreakpointDialog(project) { + protected boolean validateData() { + 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 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); + } +} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointType.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointType.java new file mode 100644 index 000000000000..455d90dd38b6 --- /dev/null +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointType.java @@ -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 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, ?>> 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); + } +} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointTypeBase.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointTypeBase.java new file mode 100644 index 000000000000..b9d68e3b56a8 --- /dev/null +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointTypeBase.java @@ -0,0 +1,140 @@ +/* + * Copyright 2000-2009 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.debugger.ui.breakpoints; + +import com.intellij.debugger.engine.DebuggerUtils; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.fileEditor.FileDocumentManager; +import com.intellij.openapi.fileTypes.FileType; +import com.intellij.openapi.fileTypes.StdFileTypes; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Ref; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.*; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.util.Processor; +import com.intellij.xdebugger.XDebuggerUtil; +import com.intellij.xdebugger.breakpoints.XLineBreakpoint; +import com.intellij.xdebugger.breakpoints.XLineBreakpointType; +import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel; +import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider; +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.java.debugger.JavaDebuggerEditorsProvider; +import org.jetbrains.java.debugger.breakpoints.JavaBreakpointFiltersPanel; +import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties; + +/** + * Base class for java line-connected exceptions (line, method, field) + * @author egor + */ +public abstract class JavaLineBreakpointTypeBase

extends XLineBreakpointType

{ + public JavaLineBreakpointTypeBase(@NonNls @NotNull String id, @Nls @NotNull String title) { + super(id, title); + } + + @Override + public boolean isAddBreakpointButtonVisible() { + return true; + } + + @Override + public final boolean isSuspendThreadSupported() { + return true; + } + + @Nullable + @Override + public final XBreakpointCustomPropertiesPanel> createCustomRightPropertiesPanel(@NotNull Project project) { + return new JavaBreakpointFiltersPanel>(project); + } + + @Nullable + @Override + public final XDebuggerEditorsProvider getEditorsProvider(@NotNull XLineBreakpoint

breakpoint, @NotNull Project project) { + return new JavaDebuggerEditorsProvider(); + } + + @Override + public final boolean canPutAt(@NotNull VirtualFile file, final int line, @NotNull Project project) { + PsiFile psiFile = PsiManager.getInstance(project).findFile(file); + // JSPX supports jvm debugging, but not in XHTML files + if (psiFile == null || psiFile.getVirtualFile().getFileType() == StdFileTypes.XHTML) { + return false; + } + + FileType fileType = psiFile.getFileType(); + if (!StdFileTypes.CLASS.equals(fileType) && + !DebuggerUtils.supportsJVMDebugging(fileType) && + !DebuggerUtils.supportsJVMDebugging(psiFile)) { + return false; + } + + final Document document = FileDocumentManager.getInstance().getDocument(file); + final Ref> result = Ref.create(); + XDebuggerUtil.getInstance().iterateLine(project, document, line, new Processor() { + @Override + public boolean process(PsiElement element) { + // avoid comments + if ((element instanceof PsiWhiteSpace) || (PsiTreeUtil.getParentOfType(element, PsiComment.class, false) != null)) { + return true; + } + // first check fields + PsiField field = PsiTreeUtil.getParentOfType(element, PsiField.class, false); + if(field != null) { + result.set(JavaFieldBreakpointType.class); + return false; + } + // then methods + PsiMethod method = PsiTreeUtil.getParentOfType(element, PsiMethod.class, false); + if(method != null && document.getLineNumber(method.getTextOffset()) == line) { + result.set(JavaMethodBreakpointType.class); + return false; + } + // then regular statements + PsiElement child = element; + while(element != null) { + + final int offset = element.getTextOffset(); + if (offset >= 0) { + if (document.getLineNumber(offset) != line) { + break; + } + } + child = element; + element = element.getParent(); + } + + if(child instanceof PsiMethod && child.getTextRange().getEndOffset() >= document.getLineEndOffset(line)) { + PsiCodeBlock body = ((PsiMethod)child).getBody(); + if(body != null) { + PsiStatement[] statements = body.getStatements(); + if (statements.length > 0 && document.getLineNumber(statements[0].getTextOffset()) == line) { + result.set(JavaLineBreakpointType.class); + } + } + } + else { + result.set(JavaLineBreakpointType.class); + } + return true; + } + }); + return result.get() == getClass(); + } +} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaMethodBreakpointType.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaMethodBreakpointType.java new file mode 100644 index 000000000000..d35983f03d2a --- /dev/null +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaMethodBreakpointType.java @@ -0,0 +1,127 @@ +/* + * Copyright 2000-2009 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.debugger.ui.breakpoints; + +import com.intellij.debugger.DebuggerBundle; +import com.intellij.debugger.HelpID; +import com.intellij.icons.AllIcons; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.StringBuilderSpinAllocator; +import com.intellij.xdebugger.breakpoints.XBreakpoint; +import com.intellij.xdebugger.breakpoints.XLineBreakpoint; +import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties; + +import javax.swing.*; + +/** + * @author Eugene Zhuravlev + * Date: Apr 26, 2005 + */ +public class JavaMethodBreakpointType extends JavaLineBreakpointTypeBase implements JavaBreakpointType { + public JavaMethodBreakpointType() { + super("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 breakpoint) { + return getDisplayText(breakpoint); + } + + @Override + public String getDisplayText(XLineBreakpoint breakpoint) { + return getText(breakpoint); + } + + static String getText(XBreakpoint breakpoint) { + final StringBuilder buffer = StringBuilderSpinAllocator.alloc(); + try { + //if(isValid()) { + final String className = breakpoint.getProperties().myClassPattern; + final boolean classNameExists = className != null && className.length() > 0; + if (classNameExists) { + buffer.append(className); + } + if(breakpoint.getProperties().myMethodName != null) { + if (classNameExists) { + buffer.append("."); + } + buffer.append(breakpoint.getProperties().myMethodName); + } + //} + //else { + // buffer.append(DebuggerBundle.message("status.breakpoint.invalid")); + //} + return buffer.toString(); + } + finally { + StringBuilderSpinAllocator.dispose(buffer); + } + } + + @Nullable + @Override + public XBreakpointCustomPropertiesPanel createCustomPropertiesPanel() { + return new MethodBreakpointPropertiesPanel(); + } + + @Nullable + @Override + public JavaMethodBreakpointProperties createProperties() { + return new JavaMethodBreakpointProperties(); + } + + @Nullable + @Override + public JavaMethodBreakpointProperties createBreakpointProperties(@NotNull VirtualFile file, int line) { + return new JavaMethodBreakpointProperties(); + } + + @Override + public Breakpoint createJavaBreakpoint(Project project, XBreakpoint breakpoint) { + return new MethodBreakpoint(project, breakpoint); + } +} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaWildcardMethodBreakpointType.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaWildcardMethodBreakpointType.java new file mode 100644 index 000000000000..3d19e35fea0b --- /dev/null +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaWildcardMethodBreakpointType.java @@ -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 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 breakpoint) { + return JavaMethodBreakpointType.getText(breakpoint); + } + + @Nullable + @Override + public XBreakpointCustomPropertiesPanel> createCustomPropertiesPanel() { + return new MethodBreakpointPropertiesPanel(); + } + + //@Override + //public Key getBreakpointCategory() { + // return MethodBreakpoint.CATEGORY; + //} + + @Nullable + @Override + public JavaMethodBreakpointProperties createProperties() { + return new JavaMethodBreakpointProperties(); + } + + @Nullable + @Override + public XBreakpoint addBreakpoint(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); + } +} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java index 307b9629b99f..e9e78df92bdc 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java @@ -54,6 +54,7 @@ import com.intellij.util.Processor; import com.intellij.util.StringBuilderSpinAllocator; import com.intellij.util.containers.ContainerUtil; import com.intellij.xdebugger.XDebuggerUtil; +import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.sun.jdi.*; import com.sun.jdi.event.LocatableEvent; import com.sun.jdi.request.BreakpointRequest; @@ -74,12 +75,12 @@ public class LineBreakpoint extends BreakpointWithHighlighter { private String myOwnerMethodName; public static final @NonNls Key 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()) { diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpointFactory.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpointFactory.java deleted file mode 100644 index 0042074dc798..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpointFactory.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.debugger.ui.breakpoints; - -import com.intellij.debugger.DebuggerBundle; -import com.intellij.debugger.HelpID; -import com.intellij.icons.AllIcons; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Key; -import org.jdom.Element; - -import javax.swing.*; - -/** - * @author Eugene Zhuravlev - * Date: Apr 26, 2005 - */ -public class LineBreakpointFactory extends BreakpointFactory { - @Override - public Breakpoint createBreakpoint(Project project, final Element element) { - return new LineBreakpoint(project); - } - - @Override - public Icon getIcon() { - return AllIcons.Debugger.Db_set_breakpoint; - } - - @Override - public Icon getDisabledIcon() { - return AllIcons.Debugger.Db_disabled_breakpoint; - } - - @Override - protected String getHelpID() { - return HelpID.LINE_BREAKPOINTS; - } - - @Override - public String getDisplayName() { - return DebuggerBundle.message("line.breakpoints.tab.title"); - } - - @Override - public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) { - return new LineBreakpointPropertiesPanel(project, compact); - } - - @Override - public Key getBreakpointCategory() { - return LineBreakpoint.CATEGORY; - } -} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java index 90a839d425d4..3d7f1ff019a0 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java @@ -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 { private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.breakpoints.MethodBreakpoint"); - public boolean WATCH_ENTRY = true; - public boolean WATCH_EXIT = true; - - @Nullable private String myMethodName; @Nullable private JVMName mySignature; private boolean myIsStatic; public static final @NonNls Key CATEGORY = BreakpointCategory.lookup("method_breakpoints"); - protected MethodBreakpoint(@NotNull Project project) { - super(project); + protected MethodBreakpoint(@NotNull Project project, XBreakpoint breakpoint) { + super(project, breakpoint); } private MethodBreakpoint(@NotNull Project project, @NotNull RangeHighlighter highlighter) { - super(project, highlighter); + super(project, highlighter, null); } public boolean isStatic() { @@ -104,21 +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; diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointFactory.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointFactory.java deleted file mode 100644 index a08e2a123ae6..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointFactory.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.debugger.ui.breakpoints; - -import com.intellij.debugger.DebuggerBundle; -import com.intellij.debugger.DebuggerManagerEx; -import com.intellij.debugger.HelpID; -import com.intellij.icons.AllIcons; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Key; -import org.jdom.Element; - -import javax.swing.*; - -/** - * @author Eugene Zhuravlev - * Date: Apr 26, 2005 - */ -public class MethodBreakpointFactory extends BreakpointFactory{ - @Override - public Breakpoint createBreakpoint(Project project, final Element element) { - return element.getAttributeValue(WildcardMethodBreakpoint.JDOM_LABEL) != null? new WildcardMethodBreakpoint(project) : new MethodBreakpoint(project); - } - - @Override - public Icon getIcon() { - return AllIcons.Debugger.Db_method_breakpoint; - } - - @Override - public Icon getDisabledIcon() { - return AllIcons.Debugger.Db_disabled_method_breakpoint; - } - - @Override - protected String getHelpID() { - return HelpID.METHOD_BREAKPOINTS; - } - - @Override - public String getDisplayName() { - return DebuggerBundle.message("method.breakpoints.tab.title"); - } - - @Override - public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) { - return new MethodBreakpointPropertiesPanel(project, compact); - } - - @Override - public Key getBreakpointCategory() { - return MethodBreakpoint.CATEGORY; - } - - @Override - public boolean canAddBreakpoints() { - return true; - } - - @Override - public WildcardMethodBreakpoint addBreakpoint(Project project) { - AddWildcardBreakpointDialog dialog = new AddWildcardBreakpointDialog(project); - dialog.show(); - WildcardMethodBreakpoint methodBreakpoint; - methodBreakpoint = !dialog.isOK() - ? null - : DebuggerManagerEx.getInstanceEx(project).getBreakpointManager() - .addMethodBreakpoint(dialog.getClassPattern(), dialog.getMethodName()); - return methodBreakpoint; - } -} diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointPropertiesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointPropertiesPanel.java index c50b6995d038..bf7419264105 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointPropertiesPanel.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpointPropertiesPanel.java @@ -21,24 +21,30 @@ package com.intellij.debugger.ui.breakpoints; import com.intellij.debugger.DebuggerBundle; -import com.intellij.openapi.project.Project; import com.intellij.ui.IdeBorderFactory; import com.intellij.util.ui.DialogUtil; +import com.intellij.xdebugger.breakpoints.XBreakpoint; +import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -public class MethodBreakpointPropertiesPanel extends BreakpointPropertiesPanel { +public class MethodBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPanel> { private JCheckBox myWatchEntryCheckBox; private JCheckBox myWatchExitCheckBox; - public MethodBreakpointPropertiesPanel(final Project project, boolean compact) { - super(project, MethodBreakpoint.CATEGORY, compact); - } + //public MethodBreakpointPropertiesPanel(final Project project, boolean compact) { + // super(project, MethodBreakpoint.CATEGORY, compact); + //} - protected JComponent createSpecialBox() { + + @NotNull + @Override + public JComponent getComponent() { JPanel _panel, _panel0; myWatchEntryCheckBox = new JCheckBox(DebuggerBundle.message("label.method.breakpoint.properties.panel.method.entry")); @@ -86,31 +92,15 @@ public class MethodBreakpointPropertiesPanel extends BreakpointPropertiesPanel { return _panel; } - public void initFrom(Breakpoint breakpoint, boolean moreOptionsVisible) { - super.initFrom(breakpoint, moreOptionsVisible); - if (breakpoint instanceof MethodBreakpoint) { - MethodBreakpoint methodBreakpoint = (MethodBreakpoint)breakpoint; - myWatchEntryCheckBox.setSelected(methodBreakpoint.WATCH_ENTRY); - myWatchExitCheckBox.setSelected(methodBreakpoint.WATCH_EXIT); - } - else if (breakpoint instanceof WildcardMethodBreakpoint){ - final WildcardMethodBreakpoint methodBreakpoint = ((WildcardMethodBreakpoint)breakpoint); - myWatchEntryCheckBox.setSelected(methodBreakpoint.WATCH_ENTRY); - myWatchExitCheckBox.setSelected(methodBreakpoint.WATCH_EXIT); - } + @Override + public void loadFrom(@NotNull XBreakpoint breakpoint) { + myWatchEntryCheckBox.setSelected(breakpoint.getProperties().WATCH_ENTRY); + myWatchExitCheckBox.setSelected(breakpoint.getProperties().WATCH_EXIT); } - public void saveTo(Breakpoint breakpoint) { - if (breakpoint instanceof MethodBreakpoint) { - MethodBreakpoint methodBreakpoint = (MethodBreakpoint)breakpoint; - methodBreakpoint.WATCH_ENTRY = myWatchEntryCheckBox.isSelected(); - methodBreakpoint.WATCH_EXIT = myWatchExitCheckBox.isSelected(); - } - else if (breakpoint instanceof WildcardMethodBreakpoint){ - final WildcardMethodBreakpoint methodBreakpoint = ((WildcardMethodBreakpoint)breakpoint); - methodBreakpoint.WATCH_ENTRY = myWatchEntryCheckBox.isSelected(); - methodBreakpoint.WATCH_EXIT = myWatchExitCheckBox.isSelected(); - } - super.saveTo(breakpoint); + @Override + public void saveTo(@NotNull XBreakpoint breakpoint) { + breakpoint.getProperties().WATCH_ENTRY = myWatchEntryCheckBox.isSelected(); + breakpoint.getProperties().WATCH_EXIT = myWatchExitCheckBox.isSelected(); } } \ No newline at end of file diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/RunToCursorBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/RunToCursorBreakpoint.java index 82f617a14f6b..a103ddcc2709 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/RunToCursorBreakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/RunToCursorBreakpoint.java @@ -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(); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StepIntoBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StepIntoBreakpoint.java index 6e39e5ac1d29..fd575177d273 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StepIntoBreakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StepIntoBreakpoint.java @@ -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; diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/WildcardMethodBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/WildcardMethodBreakpoint.java index f6c0dc3c3ab2..3e3553520193 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/WildcardMethodBreakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/WildcardMethodBreakpoint.java @@ -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 { private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.breakpoints.ExceptionBreakpoint"); - public boolean WATCH_ENTRY = true; - public boolean WATCH_EXIT = true; - private String myClassPattern; - private String myMethodName; - public static final String JDOM_LABEL = "wildcard_breakpoint"; - public WildcardMethodBreakpoint(Project project) { - super(project); + public WildcardMethodBreakpoint(Project project, XBreakpoint breakpoint) { + super(project, breakpoint); } public Key getCategory() { return MethodBreakpoint.CATEGORY; } - protected WildcardMethodBreakpoint(Project project, @NotNull String classPattern, @NotNull String methodName) { - super(project); - myClassPattern = classPattern; - myMethodName = methodName; + protected WildcardMethodBreakpoint(Project project, @NotNull String classPattern, @NotNull String methodName, XBreakpoint breakpoint) { + super(project, breakpoint); + setClassPattern(classPattern); + setMethodName(methodName); } public String getClassName() { - return myClassPattern; + return getClassPattern(); } public @Nullable String getShortClassName() { @@ -83,7 +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; } } diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointAdapter.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointAdapter.java deleted file mode 100644 index a6705848a44d..000000000000 --- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointAdapter.java +++ /dev/null @@ -1,157 +0,0 @@ -package org.jetbrains.java.debugger.breakpoints; - -import com.intellij.debugger.engine.evaluation.CodeFragmentKind; -import com.intellij.debugger.engine.evaluation.TextWithImportsImpl; -import com.intellij.debugger.engine.requests.RequestManagerImpl; -import com.intellij.debugger.settings.DebuggerSettings; -import com.intellij.debugger.ui.breakpoints.LineBreakpoint; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.markup.RangeHighlighter; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.xdebugger.breakpoints.XBreakpointProperties; -import com.intellij.xdebugger.breakpoints.XLineBreakpoint; -import com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; - -public class JavaBreakpointAdapter extends JavaBreakpointAdapterBase { - private static final Key OLD_JAVA_BREAKPOINT_KEY = Key.create("oldJavaBreakpoint"); - - public JavaBreakpointAdapter(Project project) { - super(project); - } - - @Override - protected void configureCreatedBreakpoint(LineBreakpoint oldBreakpoint, XLineBreakpoint breakpoint) { - oldBreakpoint.SUSPEND_POLICY = transformSuspendPolicy(breakpoint); - applyCondition(oldBreakpoint, breakpoint); - applyFilters(oldBreakpoint, breakpoint); - } - - private boolean applyFilters(LineBreakpoint oldBreakpoint, XLineBreakpoint breakpoint) { - boolean changed = false; - JavaBreakpointProperties properties = (JavaBreakpointProperties)breakpoint.getProperties(); - - changed |= oldBreakpoint.COUNT_FILTER_ENABLED != properties.COUNT_FILTER_ENABLED; - oldBreakpoint.COUNT_FILTER_ENABLED = properties.COUNT_FILTER_ENABLED; - - changed |= oldBreakpoint.COUNT_FILTER != properties.COUNT_FILTER; - oldBreakpoint.COUNT_FILTER = properties.COUNT_FILTER; - - changed |= oldBreakpoint.CLASS_FILTERS_ENABLED != properties.CLASS_FILTERS_ENABLED; - oldBreakpoint.CLASS_FILTERS_ENABLED = properties.CLASS_FILTERS_ENABLED; - - changed |= !Arrays.equals(oldBreakpoint.getClassFilters(), properties.getClassFilters()); - oldBreakpoint.setClassFilters(properties.getClassFilters()); - - changed |= !Arrays.equals(oldBreakpoint.getClassExclusionFilters(), properties.getClassExclusionFilters()); - oldBreakpoint.setClassExclusionFilters(properties.getClassExclusionFilters()); - - changed |= oldBreakpoint.INSTANCE_FILTERS_ENABLED != properties.INSTANCE_FILTERS_ENABLED; - oldBreakpoint.INSTANCE_FILTERS_ENABLED = properties.INSTANCE_FILTERS_ENABLED; - - changed |= !Arrays.equals(oldBreakpoint.getInstanceFilters(), properties.getInstanceFilters()); - oldBreakpoint.setInstanceFilters(properties.getInstanceFilters()); - - return changed; - } - - private static void applyCondition(LineBreakpoint oldBreakpoint, XLineBreakpoint breakpoint) { - if (breakpoint.getCondition() != null) { - oldBreakpoint.CONDITION_ENABLED = true; - oldBreakpoint.setCondition(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, breakpoint.getCondition())); - } - else { - oldBreakpoint.CONDITION_ENABLED = false; - if (!StringUtil.isEmptyOrSpaces(oldBreakpoint.getCondition().getText())) { - oldBreakpoint.setCondition(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, "")); - } - } - } - - @Override - protected void updateBreakpoint(LineBreakpoint jBreakpoint, XLineBreakpoint breakpoint) { - boolean changed = false; - if (jBreakpoint.ENABLED != breakpoint.isEnabled()) { - jBreakpoint.ENABLED = breakpoint.isEnabled(); - changed = true; - } - - String suspendPolicy = transformSuspendPolicy(breakpoint); - if (jBreakpoint.SUSPEND_POLICY != suspendPolicy) { - jBreakpoint.SUSPEND_POLICY = suspendPolicy; - changed = true; - } - - if (StringUtil.compare(breakpoint.getCondition(), jBreakpoint.getCondition().getText(), false) != 0) { - applyCondition(jBreakpoint, breakpoint); - changed = true; - } - - if (applyFilters(jBreakpoint, breakpoint)) { - changed = true; - } - - if (jBreakpoint.getSourcePosition().getLine() != breakpoint.getLine()) { - jBreakpoint.reload(); - changed = true; - } - - if (changed) { - RequestManagerImpl.updateRequests(jBreakpoint); - jBreakpoint.updateUI(); - } - } - - @Override - protected LineBreakpoint findBreakpoint(XLineBreakpoint breakpoint) { - return OLD_JAVA_BREAKPOINT_KEY.get(breakpoint); - } - - public LineBreakpoint getOrCreate(XLineBreakpoint breakpoint) { - LineBreakpoint oldBreakpoint = findBreakpoint(breakpoint); - if (oldBreakpoint == null) { - oldBreakpoint = createBreakpoint(breakpoint); - OLD_JAVA_BREAKPOINT_KEY.set(breakpoint, oldBreakpoint); - } - return oldBreakpoint; - } - - @Override - public void breakpointRemoved(@NotNull XLineBreakpoint breakpoint) { - LineBreakpoint jBreakpoint = findBreakpoint(breakpoint); - if (jBreakpoint != null) { - jBreakpoint.delete(); - } - } - - @Override - protected LineBreakpoint doCreateInstance(Project project, Document document, XLineBreakpoint breakpoint) { - LineBreakpoint lineBreakpoint = new LineBreakpoint(project, ((XLineBreakpointImpl)breakpoint).getHighlighter()) { - @Override - protected void setEditorFilter(RangeHighlighter highlighter) { - } - }; - - lineBreakpoint.setVisible(false); - lineBreakpoint.init(); - return lineBreakpoint; - } - - private static String transformSuspendPolicy(XLineBreakpoint breakpoint) { - switch (breakpoint.getSuspendPolicy()) { - case ALL: - return DebuggerSettings.SUSPEND_ALL; - case THREAD: - return DebuggerSettings.SUSPEND_THREAD; - case NONE: - return DebuggerSettings.SUSPEND_NONE; - - default: - throw new IllegalArgumentException("unknown suspend policy"); - } - } -} diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointAdapterBase.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointAdapterBase.java index 6b249356d340..2f92c7c12428 100644 --- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointAdapterBase.java +++ b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointAdapterBase.java @@ -56,11 +56,11 @@ public abstract class JavaBreakpointAdapterBase extends XBreakpointAdapter breakpoint) { - return LineBreakpoint.create(project, document, breakpoint.getLine()); + protected LineBreakpoint doCreateInstance(Project project, Document document, XLineBreakpoint xBreakpoint) { + return LineBreakpoint.create(project, document, xBreakpoint.getLine(), xBreakpoint); } } diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointPropertiesPanel.form b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.form similarity index 99% rename from java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointPropertiesPanel.form rename to java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.form index db560b3feaeb..39507678f8ff 100644 --- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointPropertiesPanel.form +++ b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.form @@ -1,5 +1,5 @@ -

+ diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointPropertiesPanel.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.java similarity index 94% rename from java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointPropertiesPanel.java rename to java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.java index e575973ea0ba..2afcf0fd339f 100644 --- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointPropertiesPanel.java +++ b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel.java @@ -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> { +public class JavaBreakpointFiltersPanel> extends XBreakpointCustomPropertiesPanel { 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 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 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 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)); diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointType.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointType.java deleted file mode 100644 index 5e55a49658f8..000000000000 --- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointType.java +++ /dev/null @@ -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, ?>> 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> createCustomRightPropertiesPanel(@NotNull Project project) { - return new JavaBreakpointPropertiesPanel(project); - } - - -} \ No newline at end of file diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointProperties.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java similarity index 84% rename from java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointProperties.java rename to java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java index e2f3202a0d46..47e35bb86c15 100644 --- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/JavaBreakpointProperties.java +++ b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java @@ -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 { +public class JavaBreakpointProperties extends XBreakpointProperties { public boolean COUNT_FILTER_ENABLED = false; public int COUNT_FILTER = 0; @@ -42,7 +42,7 @@ public class JavaBreakpointProperties extends XBreakpointProperties { + 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; + } +} diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaFieldBreakpointProperties.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaFieldBreakpointProperties.java new file mode 100644 index 000000000000..4d91a2a44a6e --- /dev/null +++ b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaFieldBreakpointProperties.java @@ -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 { + 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; + } +} diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaMethodBreakpointProperties.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaMethodBreakpointProperties.java new file mode 100644 index 000000000000..a4750dbdd845 --- /dev/null +++ b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaMethodBreakpointProperties.java @@ -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 { + 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; + } +} diff --git a/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java b/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java index 26e0eb52d34a..e136812fd657 100644 --- a/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java +++ b/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java @@ -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 lst = new ArrayList(); diff --git a/resources-en/src/messages/DebuggerBundle.properties b/resources-en/src/messages/DebuggerBundle.properties index 57e0ec144aec..1a08b7c57386 100644 --- a/resources-en/src/messages/DebuggerBundle.properties +++ b/resources-en/src/messages/DebuggerBundle.properties @@ -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 diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index d04e05907fa8..dbd4105722bb 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -86,9 +86,6 @@ - - @@ -1378,11 +1375,11 @@ - - - - - + + + + + - -