Merge remote-tracking branch 'origin/master'

This commit is contained in:
Ekaterina Tuzova
2014-02-28 17:00:36 +04:00
268 changed files with 5256 additions and 4648 deletions
+2
View File
@@ -98,6 +98,8 @@
<module fileurl="file://$PROJECT_DIR$/jps/model-api/jps-model-api.iml" filepath="$PROJECT_DIR$/jps/model-api/jps-model-api.iml" group="jps" />
<module fileurl="file://$PROJECT_DIR$/jps/model-impl/jps-model-impl.iml" filepath="$PROJECT_DIR$/jps/model-impl/jps-model-impl.iml" group="jps" />
<module fileurl="file://$PROJECT_DIR$/jps/model-serialization/jps-model-serialization.iml" filepath="$PROJECT_DIR$/jps/model-serialization/jps-model-serialization.iml" group="jps" />
<module fileurl="file://$PROJECT_DIR$/jps/model-impl/jps-model-tests.iml" filepath="$PROJECT_DIR$/jps/model-impl/jps-model-tests.iml"/>
<module fileurl="file://$PROJECT_DIR$/jps/model-serialization/jps-serialization-tests.iml" filepath="$PROJECT_DIR$/jps/model-serialization/jps-serialization-tests.iml" group="jps"/>
<module fileurl="file://$PROJECT_DIR$/jps/standalone-builder/jps-standalone-builder.iml" filepath="$PROJECT_DIR$/jps/standalone-builder/jps-standalone-builder.iml" group="jps" />
<module fileurl="file://$PROJECT_DIR$/java/jsp-base-openapi/jsp-base-openapi.iml" filepath="$PROJECT_DIR$/java/jsp-base-openapi/jsp-base-openapi.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/java/jsp-openapi/jsp-openapi.iml" filepath="$PROJECT_DIR$/java/jsp-openapi/jsp-openapi.iml" group="java" />
+2 -2
View File
@@ -749,8 +749,8 @@ def layoutCommunityJps(String home, String target) {
dir("test") {
jar("jps-build-test.jar") {
moduleTests("jps-builders")
moduleTests("jps-model-impl")
moduleTests("jps-model-serialization")
moduleTests("jps-model-tests")
moduleTests("jps-serialization-tests")
}
}
jar("ant-jps-plugin.jar") { module("ant-jps-plugin") }
+1 -1
View File
@@ -353,7 +353,7 @@ binding.setVariable("layoutMacApp", { String path, String ch, Map args ->
String archs = """
<key>LSArchitecturePriority</key>
<array>"""
(args.archs != null ? args.archs : ["64_x86", "i386"]).each {
(args.archs != null ? args.archs : ["x86_64", "i386"]).each {
archs += "<string>${it}</string>"
}
archs +="</array>\n"
+3
View File
@@ -93,6 +93,9 @@
<orderEntry type="module" module-name="manifest" />
<orderEntry type="module" module-name="xml-tests" scope="TEST" />
<orderEntry type="module" module-name="devkit-jps-plugin" scope="TEST" />
<orderEntry type="module" module-name="jps-model-tests" scope="TEST" />
<orderEntry type="module" module-name="jps-serialization-tests" scope="TEST" />
<orderEntry type="module" module-name="ui-designer-jps-plugin" scope="TEST" />
<orderEntry type="module" module-name="ui-designer-jps-plugin" scope="TEST" />
<orderEntry type="module" module-name="java-tests" scope="TEST" />
<orderEntry type="module" module-name="community-tests" scope="TEST" />
@@ -80,7 +80,7 @@ import java.util.concurrent.atomic.AtomicInteger;
*/
public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.TranslatingCompilerFilesMonitor");
private static final boolean ourDebugMode = false;
public static boolean ourDebugMode = false;
private static final FileAttribute ourSourceFileAttribute = new FileAttribute("_make_source_file_info_", 3);
private static final FileAttribute ourOutputFileAttribute = new FileAttribute("_make_output_file_info_", 3);
@@ -197,6 +197,9 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
}
FileUtil.createIfDoesntExist(CompilerPaths.getRebuildMarkerFile(project));
--myWatchedProjectsCount;
if (ourDebugMode) {
System.out.println("After suspend for project:"+projectId + "," + myWatchedProjectsCount);
}
// cleanup internal structures to free memory
mySourcesToRecompile.remove(projectId);
myOutputsToDelete.remove(projectId);
@@ -217,8 +220,12 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
public void watchProject(Project project) {
synchronized (myDataLock) {
mySuspendedProjects.remove(getProjectId(project));
int projectId = getProjectId(project);
mySuspendedProjects.remove(projectId);
++myWatchedProjectsCount;
if (ourDebugMode) {
System.out.println("After watch for project:"+projectId + "," + myWatchedProjectsCount);
}
}
}
@@ -1616,6 +1623,11 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
}
private void processNewFile(final VirtualFile file, final boolean notifyServer) {
if (ourDebugMode) {
System.out.println("MyVfsListener.processNewFile");
System.out.println("file = [" + file + "], notifyServer = [" + notifyServer + "]");
System.out.println("myWatchedProjectsCount = " + myWatchedProjectsCount);
}
if (myWatchedProjectsCount == 0) return;
final Ref<Boolean> isInContent = Ref.create(false);
ApplicationManager.getApplication().runReadAction(new Runnable() {
@@ -20,6 +20,9 @@ import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizable;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.ui.classFilter.ClassFilter;
import com.intellij.util.xmlb.annotations.Attribute;
import com.intellij.util.xmlb.annotations.Tag;
import com.intellij.util.xmlb.annotations.Transient;
import org.jdom.Element;
/**
@@ -27,10 +30,13 @@ import org.jdom.Element;
* Date: Aug 29, 2003
* Time: 2:49:27 PM
*/
@Tag("instance-filter")
public class InstanceFilter implements JDOMExternalizable{
public static final InstanceFilter[] EMPTY_ARRAY = new InstanceFilter[0];
@Attribute("id")
public long ID = 0;
@Attribute("enabled")
public boolean ENABLED = true;
public InstanceFilter() {
@@ -41,10 +47,12 @@ public class InstanceFilter implements JDOMExternalizable{
this.ENABLED = ENABLED;
}
@Transient
public long getId() {
return ID;
}
@Transient
public boolean isEnabled() {
return ENABLED;
}
@@ -1,116 +0,0 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.actions;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.ui.breakpoints.BreakpointFactory;
import com.intellij.debugger.ui.breakpoints.BreakpointPropertiesPanel;
import com.intellij.debugger.ui.breakpoints.BreakpointWithHighlighter;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.markup.GutterIconRenderer;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.Balloon;
import com.intellij.openapi.ui.popup.JBPopupListener;
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.util.ui.UIUtil;
import com.intellij.xdebugger.impl.actions.EditBreakpointActionHandler;
import com.intellij.xdebugger.impl.breakpoints.XBreakpointUtil;
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialogFactory;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
public class JavaEditBreakpointActionHandler extends EditBreakpointActionHandler {
@Override
protected void doShowPopup(final Project project, final JComponent component, final Point whereToShow, final Object breakpoint) {
if (!(breakpoint instanceof BreakpointWithHighlighter)) {
return;
}
final BreakpointWithHighlighter javaBreakpoint = (BreakpointWithHighlighter)breakpoint;
BreakpointFactory breakpointFactory = null;
for (BreakpointFactory factory : BreakpointFactory.EXTENSION_POINT_NAME.getExtensions()) {
if (factory.getBreakpointCategory().equals(javaBreakpoint.getCategory())) {
breakpointFactory = factory;
}
}
assert breakpointFactory != null : "can't find factory for breakpoint " + javaBreakpoint;
final BreakpointPropertiesPanel propertiesPanel = breakpointFactory.createBreakpointPropertiesPanel(project, true);
assert propertiesPanel != null;
propertiesPanel.initFrom(javaBreakpoint, false);
final JComponent mainPanel = propertiesPanel.getPanel();
final JBPopupListener saveOnClose = new JBPopupListener.Adapter() {
@Override
public void onClosed(LightweightWindowEvent event) {
propertiesPanel.saveTo(javaBreakpoint);
propertiesPanel.dispose();
DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().fireBreakpointChanged(javaBreakpoint);
}
};
final Runnable showMoreOptions = new Runnable() {
@Override
public void run() {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
BreakpointsDialogFactory.getInstance(project).showDialog(javaBreakpoint);
}
});
}
};
final Balloon balloon = DebuggerUIUtil.showBreakpointEditor(project, mainPanel, whereToShow, component, showMoreOptions, breakpoint);
balloon.addListener(saveOnClose);
propertiesPanel.setDelegate(new BreakpointPropertiesPanel.Delegate() {
@Override
public void showActionsPanel() {
propertiesPanel.setActionsPanelVisible(true);
balloon.hide();
DebuggerUIUtil.showBreakpointEditor(project, mainPanel, whereToShow, component, showMoreOptions, breakpoint).addListener(saveOnClose);
}
});
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
IdeFocusManager.findInstance().requestFocus(mainPanel, true);
}
});
}
@Override
public boolean isEnabled(@NotNull Project project, AnActionEvent event) {
DataContext dataContext = event.getDataContext();
Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
if (editor == null) {
return false;
}
final Pair<GutterIconRenderer,Object> pair = XBreakpointUtil.findSelectedBreakpoint(project, editor);
return pair.first != null && pair.second instanceof BreakpointWithHighlighter;
}
}
@@ -22,7 +22,6 @@ import com.intellij.debugger.ui.breakpoints.BreakpointManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.FileEditorManager;
@@ -41,7 +40,7 @@ public class ToggleBreakpointEnabledAction extends AnAction {
Breakpoint breakpoint = findBreakpoint(project);
if (breakpoint != null) {
final BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
breakpointManager.setBreakpointEnabled(breakpoint, !breakpoint.ENABLED);
breakpointManager.setBreakpointEnabled(breakpoint, !breakpoint.isEnabled());
}
}
@@ -81,7 +81,7 @@ public class ToggleFieldBreakpointAction extends AnAction {
long id = object.uniqueID();
InstanceFilter[] instanceFilters = new InstanceFilter[] { InstanceFilter.create(Long.toString(id))};
fieldBreakpoint.setInstanceFilters(instanceFilters);
fieldBreakpoint.INSTANCE_FILTERS_ENABLED = true;
fieldBreakpoint.setInstanceFiltersEnabled(true);
}
}
}
@@ -1,163 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.actions;
import com.intellij.codeInsight.folding.impl.actions.ExpandRegionAction;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.engine.DebuggerUtils;
import com.intellij.debugger.engine.requests.RequestManagerImpl;
import com.intellij.debugger.ui.breakpoints.Breakpoint;
import com.intellij.debugger.ui.breakpoints.BreakpointManager;
import com.intellij.debugger.ui.breakpoints.LineBreakpoint;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.FoldRegion;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.xdebugger.impl.actions.DebuggerActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class ToggleLineBreakpointActionHandler extends DebuggerActionHandler {
private final boolean myTemporary;
public ToggleLineBreakpointActionHandler(boolean temporary) {
myTemporary = temporary;
}
public boolean isEnabled(@NotNull final Project project, final AnActionEvent event) {
PlaceInDocument place = getPlace(project, event);
if (place != null) {
final Document document = place.getDocument();
final int offset = place.getOffset();
int line = document.getLineNumber(offset);
VirtualFile file = FileDocumentManager.getInstance().getFile(document);
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (DebuggerUtils.supportsJVMDebugging(file.getFileType()) || DebuggerUtils.supportsJVMDebugging(psiFile)) {
final BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
return breakpointManager.findBreakpoint(document, offset, LineBreakpoint.CATEGORY) != null ||
LineBreakpoint.canAddLineBreakpoint(project, document, line);
}
}
return false;
}
public void perform(@NotNull final Project project, final AnActionEvent event) {
PlaceInDocument place = getPlace(project, event);
if(place == null) {
return;
}
Editor editor = event.getData(CommonDataKeys.EDITOR);
ExpandRegionAction.expandRegionAtCaret(project, editor);
Document document = place.getDocument();
int line = document.getLineNumber(place.getOffset());
if (editor != null && editor.getCaretModel().getVisualPosition().line != line) {
editor.getCaretModel().moveToOffset(place.getOffset());
}
DebuggerManagerEx debugManager = DebuggerManagerEx.getInstanceEx(project);
if (debugManager == null) {
return;
}
BreakpointManager manager = debugManager.getBreakpointManager();
final Breakpoint breakpoint = manager.findBreakpoint(document, place.getOffset(), LineBreakpoint.CATEGORY);
if(breakpoint == null) {
LineBreakpoint lineBreakpoint = manager.addLineBreakpoint(document, line);
if(lineBreakpoint != null) {
lineBreakpoint.REMOVE_AFTER_HIT = myTemporary;
RequestManagerImpl.createRequests(lineBreakpoint);
}
}
else {
if (!breakpoint.REMOVE_AFTER_HIT && myTemporary) {
breakpoint.REMOVE_AFTER_HIT = true;
breakpoint.updateUI();
}
else {
manager.removeBreakpoint(breakpoint);
}
}
}
private static boolean containsOnlyDeclarations(int line, Document document, PsiFile file) {
int lineStart = document.getLineStartOffset(line);
int lineEnd = document.getLineEndOffset(line);
PsiElement start = file.findElementAt(lineStart);
PsiElement end = file.findElementAt(lineEnd - 1);
if (start == null || end == null) return false;
PsiElement commonParent = PsiTreeUtil.findCommonParent(start, end);
for (PsiElement element : PsiTreeUtil.findChildrenOfAnyType(commonParent, PsiStatement.class, PsiExpression.class)) {
if (new TextRange(lineStart, lineEnd).contains(element.getTextRange().getStartOffset())) {
return false;
}
}
return true;
}
@Nullable
private static PlaceInDocument getPlace(@NotNull final Project project, AnActionEvent event) {
Editor editor = event.getData(CommonDataKeys.EDITOR);
if(editor == null) {
editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
}
if (editor == null) {
return null;
}
final Document document = editor.getDocument();
PsiDocumentManager.getInstance(project).commitDocument(document);
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
if (file == null) {
return null;
}
// if several lines are merged into one visual line (using folding), try to find the most appropriate of those lines
int visualLine = editor.getCaretModel().getVisualPosition().getLine();
int visibleOffset = editor.getCaretModel().getOffset();
while (editor.offsetToVisualPosition(visibleOffset).line == visualLine) {
int line = document.getLineNumber(visibleOffset);
if (!containsOnlyDeclarations(line, document, file)) {
return new PlaceInDocument(document, visibleOffset);
}
int lineEndOffset = document.getLineEndOffset(line);
FoldRegion region = editor.getFoldingModel().getCollapsedRegionAtOffset(lineEndOffset);
if (region != null) {
int foldEnd = region.getEndOffset();
if (foldEnd > lineEndOffset) {
visibleOffset = foldEnd;
continue;
}
}
visibleOffset = lineEndOffset + 1;
}
return new PlaceInDocument(document, editor.getCaretModel().getOffset());
}
}
@@ -1409,7 +1409,7 @@ public abstract class DebugProcessImpl implements DebugProcess {
hint.setIgnoreFilters(myForcedIgnoreFilters || mySession.shouldIgnoreSteppingFilters());
applyThreadFilter(stepThread);
if (myBreakpoint != null) {
myBreakpoint.SUSPEND_POLICY = suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD? DebuggerSettings.SUSPEND_THREAD : DebuggerSettings.SUSPEND_ALL;
myBreakpoint.setSuspendPolicy(suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD? DebuggerSettings.SUSPEND_THREAD : DebuggerSettings.SUSPEND_ALL);
myBreakpoint.createRequest(suspendContext.getDebugProcess());
myRunToCursorBreakpoint = myBreakpoint;
}
@@ -1476,8 +1476,7 @@ 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.createRequest(context.getDebugProcess());
DebugProcessImpl.this.myRunToCursorBreakpoint = myRunToCursorBreakpoint;
super.contextAction();
@@ -69,7 +69,10 @@ public final class TextWithImportsImpl implements TextWithImports{
}
private static Trinity<String, String, FileType> parseExternalForm(String s) {
String[] split = s.split(String.valueOf(DebuggerEditorImpl.SEPARATOR));
// when serialized into a tag special symbols are now kept as is
// so our separator \r may be converted to \n or \r\n
s = StringUtil.convertLineSeparators(s);
String[] split = s.split("\n");
return Trinity.create(split[0], split.length > 1 ? split[1] : "", split.length > 2 ? FileTypeManager.getInstance().getStdFileType(split[2]) : null);
}
@@ -30,9 +30,7 @@ import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.debugger.ui.breakpoints.Breakpoint;
import com.intellij.debugger.ui.breakpoints.BreakpointManager;
import com.intellij.debugger.ui.breakpoints.FilteredRequestor;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
@@ -40,15 +38,10 @@ import com.intellij.openapi.util.Key;
import com.intellij.psi.PsiClass;
import com.intellij.ui.classFilter.ClassFilter;
import com.intellij.util.containers.HashMap;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.breakpoints.XBreakpointProperties;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.sun.jdi.*;
import com.sun.jdi.event.ClassPrepareEvent;
import com.sun.jdi.request.*;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.java.debugger.breakpoints.JavaBreakpointAdapter;
import org.jetbrains.java.debugger.breakpoints.JavaBreakpointType;
import java.util.Collections;
import java.util.HashSet;
@@ -158,11 +151,11 @@ public class RequestManagerImpl extends DebugProcessAdapterImpl implements Reque
request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
}
if (requestor.COUNT_FILTER_ENABLED && requestor.COUNT_FILTER > 0) {
request.addCountFilter(requestor.COUNT_FILTER);
if (requestor.isCountFilterEnabled() && requestor.getCountFilter() > 0) {
request.addCountFilter(requestor.getCountFilter());
}
if (requestor.CLASS_FILTERS_ENABLED && !(request instanceof BreakpointRequest) /*no built-in class filters support for breakpoint requests*/ ) {
if (requestor.isClassFiltersEnabled() && !(request instanceof BreakpointRequest) /*no built-in class filters support for breakpoint requests*/ ) {
ClassFilter[] classFilters = requestor.getClassFilters();
if (DebuggerUtilsEx.getEnabledNumber(classFilters) == 1) {
for (final ClassFilter filter : classFilters) {
@@ -408,17 +401,18 @@ public class RequestManagerImpl extends DebugProcessAdapterImpl implements Reque
breakpoint.createRequest(myDebugProcess);
}
AccessToken token = ReadAction.start();
try {
JavaBreakpointAdapter adapter = new JavaBreakpointAdapter(project);
for (XLineBreakpoint<XBreakpointProperties> breakpoint : XDebuggerManager.getInstance(project).getBreakpointManager()
.getBreakpoints(JavaBreakpointType.class)) {
adapter.getOrCreate(breakpoint).createRequest(myDebugProcess);
}
}
finally {
token.finish();
}
//AccessToken token = ReadAction.start();
//try {
// JavaBreakpointAdapter adapter = new JavaBreakpointAdapter(project);
// for (XLineBreakpoint breakpoint : XDebuggerManager.getInstance(project).getBreakpointManager()
// .getBreakpoints(JavaLineBreakpointType.class)) {
// //new JavaLineBreakpointRequestor(breakpoint).createRequest(myDebugProcess);
// //adapter.getOrCreate(breakpoint).createRequest(myDebugProcess);
// }
//}
//finally {
// token.finish();
//}
}
});
}
@@ -19,19 +19,17 @@ import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.actions.*;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.settings.*;
import com.intellij.debugger.ui.breakpoints.*;
import com.intellij.debugger.ui.breakpoints.Breakpoint;
import com.intellij.ide.DataManager;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.markup.GutterIconRenderer;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xdebugger.AbstractDebuggerSession;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
import com.intellij.xdebugger.impl.DebuggerSupport;
@@ -45,9 +43,10 @@ import com.intellij.xdebugger.impl.evaluate.quick.common.QuickEvaluateHandler;
import com.intellij.xdebugger.impl.settings.DebuggerSettingsPanelProvider;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* @author nik
@@ -63,8 +62,6 @@ public class JavaDebuggerSupport extends DebuggerSupport {
private final ForceRunToCursorActionHandler myForceRunToCursorActionHandler = new ForceRunToCursorActionHandler();
private final ResumeActionHandler myResumeActionHandler = new ResumeActionHandler();
private final PauseActionHandler myPauseActionHandler = new PauseActionHandler();
private final ToggleLineBreakpointActionHandler myToggleLineBreakpointActionHandler = new ToggleLineBreakpointActionHandler(false);
private final ToggleLineBreakpointActionHandler myToggleTemporaryLineBreakpointActionHandler = new ToggleLineBreakpointActionHandler(true);
private final ShowExecutionPointActionHandler myShowExecutionPointActionHandler = new ShowExecutionPointActionHandler();
private final EvaluateActionHandler myEvaluateActionHandler = new EvaluateActionHandler();
private final QuickEvaluateActionHandler myQuickEvaluateHandler = new QuickEvaluateActionHandler();
@@ -73,7 +70,6 @@ public class JavaDebuggerSupport extends DebuggerSupport {
private final DebuggerActionHandler mySmartStepIntoHandler = new JvmSmartStepIntoActionHandler();
private final DebuggerActionHandler myAddToWatchedActionHandler = new AddToWatchActionHandler();
private final JavaMarkObjectActionHandler myMarkObjectActionHandler = new JavaMarkObjectActionHandler();
private final JavaEditBreakpointActionHandler myEditBreakpointActionHandler = new JavaEditBreakpointActionHandler();
@NotNull
public BreakpointPanelProvider<?> getBreakpointPanelProvider() {
@@ -132,13 +128,13 @@ public class JavaDebuggerSupport extends DebuggerSupport {
@NotNull
public DebuggerActionHandler getToggleLineBreakpointHandler() {
return myToggleLineBreakpointActionHandler;
return DISABLED;
}
@NotNull
@Override
public DebuggerActionHandler getToggleTemporaryLineBreakpointHandler() {
return myToggleTemporaryLineBreakpointActionHandler;
return DISABLED;
}
@NotNull
@@ -182,7 +178,7 @@ public class JavaDebuggerSupport extends DebuggerSupport {
@NotNull
@Override
public EditBreakpointActionHandler getEditBreakpointAction() {
return myEditBreakpointActionHandler;
return DISABLED_EDIT;
}
@NotNull
@@ -191,122 +187,124 @@ public class JavaDebuggerSupport extends DebuggerSupport {
}
private static class JavaBreakpointPanelProvider extends BreakpointPanelProvider<Breakpoint> {
private final List<MyBreakpointManagerListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
//private final List<MyBreakpointManagerListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
@Override
public AnAction[] getAddBreakpointActions(@NotNull Project project) {
List<AnAction> result = new ArrayList<AnAction>();
BreakpointFactory[] breakpointFactories = BreakpointFactory.getBreakpointFactories();
for (BreakpointFactory breakpointFactory : breakpointFactories) {
result.add(new AddJavaBreakpointAction(breakpointFactory));
}
return result.toArray(new AnAction[result.size()]);
//List<AnAction> result = new ArrayList<AnAction>();
//BreakpointFactory[] breakpointFactories = BreakpointFactory.getBreakpointFactories();
//for (BreakpointFactory breakpointFactory : breakpointFactories) {
// result.add(new AddJavaBreakpointAction(breakpointFactory));
//}
//return result.toArray(new AnAction[result.size()]);
return AnAction.EMPTY_ARRAY;
}
@Override
public void createBreakpointsGroupingRules(Collection<XBreakpointGroupingRule> rules) {
rules.add(new XBreakpointGroupingByCategoryRule());
//rules.add(new XBreakpointGroupingByCategoryRule());
rules.add(new XBreakpointGroupingByPackageRule());
rules.add(new XBreakpointGroupingByClassRule());
}
@Override
public void addListener(final BreakpointsListener listener, Project project, Disposable disposable) {
BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
final MyBreakpointManagerListener listener1 = new MyBreakpointManagerListener(listener, breakpointManager);
breakpointManager.addBreakpointManagerListener(listener1);
myListeners.add(listener1);
Disposer.register(disposable, new Disposable() {
@Override
public void dispose() {
removeListener(listener);
}
});
//BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
//final MyBreakpointManagerListener listener1 = new MyBreakpointManagerListener(listener, breakpointManager);
//breakpointManager.addBreakpointManagerListener(listener1);
//myListeners.add(listener1);
//Disposer.register(disposable, new Disposable() {
// @Override
// public void dispose() {
// removeListener(listener);
// }
//});
}
@Override
protected void removeListener(BreakpointsListener listener) {
for (MyBreakpointManagerListener managerListener : myListeners) {
if (managerListener.myListener == listener) {
BreakpointManager manager = managerListener.myBreakpointManager;
manager.removeBreakpointManagerListener(managerListener);
myListeners.remove(managerListener);
break;
}
}
//for (MyBreakpointManagerListener managerListener : myListeners) {
// if (managerListener.myListener == listener) {
// BreakpointManager manager = managerListener.myBreakpointManager;
// manager.removeBreakpointManagerListener(managerListener);
// myListeners.remove(managerListener);
// break;
// }
//}
}
public int getPriority() {
return 1;
return 100;
}
public Breakpoint findBreakpoint(@NotNull final Project project, @NotNull final Document document, final int offset) {
return DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().findBreakpoint(document, offset, null);
return null;
//return DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().findBreakpoint(document, offset, null);
}
@Override
public GutterIconRenderer getBreakpointGutterIconRenderer(Object breakpoint) {
if (breakpoint instanceof BreakpointWithHighlighter) {
final RangeHighlighter highlighter = ((BreakpointWithHighlighter)breakpoint).getHighlighter();
if (highlighter != null) {
return (GutterIconRenderer)highlighter.getGutterIconRenderer();
}
}
//if (breakpoint instanceof BreakpointWithHighlighter) {
// final RangeHighlighter highlighter = ((BreakpointWithHighlighter)breakpoint).getHighlighter();
// if (highlighter != null) {
// return (GutterIconRenderer)highlighter.getGutterIconRenderer();
// }
//}
return null;
}
public void onDialogClosed(final Project project) {
DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().updateAllRequests();
//DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().updateAllRequests();
}
@Override
public void provideBreakpointItems(Project project, Collection<BreakpointItem> items) {
for (BreakpointFactory breakpointFactory : BreakpointFactory.getBreakpointFactories()) {
Key<? extends Breakpoint> category = breakpointFactory.getBreakpointCategory();
Breakpoint[] breakpoints = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().getBreakpoints(category);
for (Breakpoint breakpoint : breakpoints) {
items.add(breakpointFactory.createBreakpointItem(breakpoint));
}
}
//for (BreakpointFactory breakpointFactory : BreakpointFactory.getBreakpointFactories()) {
// Key<? extends Breakpoint> category = breakpointFactory.getBreakpointCategory();
// Breakpoint[] breakpoints = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().getBreakpoints(category);
// for (Breakpoint breakpoint : breakpoints) {
// items.add(breakpointFactory.createBreakpointItem(breakpoint));
// }
//}
}
private static class AddJavaBreakpointAction extends AnAction {
private BreakpointFactory myBreakpointFactory;
//private static class AddJavaBreakpointAction extends AnAction {
// private BreakpointFactory myBreakpointFactory;
//
// public AddJavaBreakpointAction(BreakpointFactory breakpointFactory) {
// myBreakpointFactory = breakpointFactory;
// Presentation p = getTemplatePresentation();
// p.setIcon(myBreakpointFactory.getIcon());
// p.setText(breakpointFactory.getDisplayName());
// }
//
// @Override
// public void update(AnActionEvent e) {
// e.getPresentation().setVisible(myBreakpointFactory.canAddBreakpoints());
// }
//
// @Override
// public void actionPerformed(AnActionEvent e) {
// myBreakpointFactory.addBreakpoint(getEventProject(e));
// }
//}
public AddJavaBreakpointAction(BreakpointFactory breakpointFactory) {
myBreakpointFactory = breakpointFactory;
Presentation p = getTemplatePresentation();
p.setIcon(myBreakpointFactory.getIcon());
p.setText(breakpointFactory.getDisplayName());
}
@Override
public void update(AnActionEvent e) {
e.getPresentation().setVisible(myBreakpointFactory.canAddBreakpoints());
}
@Override
public void actionPerformed(AnActionEvent e) {
myBreakpointFactory.addBreakpoint(getEventProject(e));
}
}
private static class MyBreakpointManagerListener implements BreakpointManagerListener {
private final BreakpointsListener myListener;
public BreakpointManager myBreakpointManager;
public MyBreakpointManagerListener(BreakpointsListener listener, BreakpointManager breakpointManager) {
myListener = listener;
myBreakpointManager = breakpointManager;
}
@Override
public void breakpointsChanged() {
myListener.breakpointsChanged();
}
}
//private static class MyBreakpointManagerListener implements BreakpointManagerListener {
//
// private final BreakpointsListener myListener;
// public BreakpointManager myBreakpointManager;
//
//
// public MyBreakpointManagerListener(BreakpointsListener listener, BreakpointManager breakpointManager) {
// myListener = listener;
// myBreakpointManager = breakpointManager;
// }
//
// @Override
// public void breakpointsChanged() {
// myListener.breakpointsChanged();
// }
//}
}
public static class JavaDebuggerSettingsPanelProvider extends DebuggerSettingsPanelProvider {
@@ -341,4 +339,27 @@ public class JavaDebuggerSupport extends DebuggerSupport {
}
return ProjectManager.getInstance().getDefaultProject();
}
private static final DebuggerActionHandler DISABLED = new DebuggerActionHandler() {
@Override
public void perform(@NotNull Project project, AnActionEvent event) {
}
@Override
public boolean isEnabled(@NotNull Project project, AnActionEvent event) {
return false;
}
};
private static final EditBreakpointActionHandler DISABLED_EDIT = new EditBreakpointActionHandler() {
@Override
protected void doShowPopup(Project project, JComponent component, Point whereToShow, Object breakpoint) {
}
@Override
public boolean isEnabled(@NotNull Project project, AnActionEvent event) {
return false;
}
};
}
@@ -437,7 +437,7 @@ public class PositionHighlighter {
public void actionPerformed(AnActionEvent e) {
if (myEventsOutOfLine.size() == 1) {
Breakpoint breakpoint = myEventsOutOfLine.get(0).getFirst();
breakpoint.ENABLED = !breakpoint.ENABLED;
breakpoint.setEnabled(!breakpoint.isEnabled());
DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().fireBreakpointChanged(breakpoint);
}
}
@@ -1,81 +0,0 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.ui;
import com.intellij.debugger.ui.breakpoints.Breakpoint;
import com.intellij.debugger.ui.breakpoints.BreakpointFactory;
import com.intellij.openapi.util.Key;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroup;
import com.intellij.xdebugger.impl.breakpoints.ui.grouping.XBreakpointTypeGroup;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* Created with IntelliJ IDEA.
* User: zajac
* Date: 23.05.12
* Time: 16:22
* To change this template use File | Settings | File Templates.
*/
public class XBreakpointCategoryGroup extends XBreakpointGroup {
private Key<? extends Breakpoint> myCategory;
private Icon myIcon;
private final String myName;
public XBreakpointCategoryGroup(BreakpointFactory factory) {
myCategory = factory.getBreakpointCategory();
myIcon = factory.getIcon();
final String name = factory.getDisplayName();
myName = name != null ? name : "UNKNOWN";
}
public Key<? extends Breakpoint> getCategory() {
return myCategory;
}
@Override
public Icon getIcon(boolean isOpen) {
return myIcon;
}
@NotNull
@Override
public String getName() {
return myName;
}
@Override
public int compareTo(XBreakpointGroup o) {
if (o instanceof XBreakpointTypeGroup) {
return -1;
}
if (o instanceof XBreakpointCategoryGroup) {
return getFactoryIndex() - ((XBreakpointCategoryGroup)o).getFactoryIndex();
}
return super.compareTo(o);
}
private int getFactoryIndex() {
BreakpointFactory[] breakpointFactories = BreakpointFactory.getBreakpointFactories();
for (int i = 0; i < breakpointFactories.length; ++i) {
if (breakpointFactories[i].getBreakpointCategory().equals(myCategory)) {
return i;
}
}
return -1;
}
}
@@ -1,64 +0,0 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.ui;
import com.intellij.debugger.ui.breakpoints.AnyExceptionBreakpoint;
import com.intellij.debugger.ui.breakpoints.Breakpoint;
import com.intellij.debugger.ui.breakpoints.BreakpointFactory;
import com.intellij.debugger.ui.breakpoints.ExceptionBreakpoint;
import com.intellij.openapi.util.Key;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointsGroupingPriorities;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
class XBreakpointGroupingByCategoryRule<B> extends XBreakpointGroupingRule<B, XBreakpointCategoryGroup> {
XBreakpointGroupingByCategoryRule() {
super("XBreakpointGroupingByCategoryRule", "Type");
}
@Override
public boolean isAlwaysEnabled() {
return true;
}
@Override
public int getPriority() {
return XBreakpointsGroupingPriorities.BY_TYPE;
}
@Override
public XBreakpointCategoryGroup getGroup(@NotNull B b, @NotNull Collection<XBreakpointCategoryGroup> groups) {
if (b instanceof Breakpoint) {
final Breakpoint breakpoint = (Breakpoint)b;
Key<? extends Breakpoint> category = breakpoint.getCategory();
if (category.equals(AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT)) {
category = ExceptionBreakpoint.CATEGORY;
}
for (XBreakpointCategoryGroup group : groups) {
if (group.getCategory().equals(category)) {
return group;
}
}
final BreakpointFactory factory = BreakpointFactory.getInstance(category);
if (factory != null) {
return new XBreakpointCategoryGroup(factory);
}
}
return null;
}
}
@@ -15,8 +15,11 @@
*/
package com.intellij.debugger.ui;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.ui.breakpoints.Breakpoint;
import com.intellij.debugger.ui.breakpoints.BreakpointManager;
import com.intellij.icons.AllIcons;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointsGroupingPriorities;
import org.jetbrains.annotations.NotNull;
@@ -42,10 +45,14 @@ class XBreakpointGroupingByClassRule<B> extends XBreakpointGroupingRule<B, XBrea
@Override
public XBreakpointClassGroup getGroup(@NotNull B b, @NotNull Collection<XBreakpointClassGroup> groups) {
if (b instanceof Breakpoint) {
final Breakpoint breakpoint = (Breakpoint)b;
String className = breakpoint.getShortClassName();
String packageName = breakpoint.getPackageName();
if (b instanceof XBreakpoint) {
BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(JavaDebuggerSupport.getCurrentProject()).getBreakpointManager();
Breakpoint javaBreakpoint = breakpointManager.findBreakpoint((XBreakpoint)b);
if (javaBreakpoint == null) {
return null;
}
String className = javaBreakpoint.getShortClassName();
String packageName = javaBreakpoint.getPackageName();
if (className == null) {
return null;
}
@@ -15,10 +15,12 @@
*/
package com.intellij.debugger.ui;
import com.intellij.debugger.ui.breakpoints.BreakpointWithHighlighter;
import com.intellij.debugger.ui.breakpoints.ExceptionBreakpoint;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.ui.breakpoints.Breakpoint;
import com.intellij.debugger.ui.breakpoints.BreakpointManager;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointsGroupingPriorities;
import org.jetbrains.annotations.NotNull;
@@ -41,11 +43,12 @@ public class XBreakpointGroupingByPackageRule<B> extends XBreakpointGroupingRule
@Override
public XBreakpointPackageGroup getGroup(@NotNull B breakpoint, @NotNull Collection<XBreakpointPackageGroup> groups) {
String packageName = null;
if (breakpoint instanceof BreakpointWithHighlighter) {
packageName = ((BreakpointWithHighlighter)breakpoint).getPackageName();
}
else if (breakpoint instanceof ExceptionBreakpoint) {
packageName = ((ExceptionBreakpoint)breakpoint).getPackageName();
if (breakpoint instanceof XBreakpoint) {
BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(JavaDebuggerSupport.getCurrentProject()).getBreakpointManager();
Breakpoint javaBreakpoint = breakpointManager.findBreakpoint((XBreakpoint)breakpoint);
if (javaBreakpoint != null) {
packageName = javaBreakpoint.getPackageName();
}
}
if (packageName == null) {
return null;
@@ -41,7 +41,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
abstract class AddFieldBreakpointDialog extends DialogWrapper {
public abstract class AddFieldBreakpointDialog extends DialogWrapper {
private final Project myProject;
private JPanel myPanel;
private TextFieldWithBrowseButton myFieldChooser;
@@ -30,7 +30,7 @@ public class AddWildcardBreakpointDialog extends DialogWrapper {
private JTextField myClassPatternField;
private JTextField myMethodNameField;
protected AddWildcardBreakpointDialog(Project project) {
public AddWildcardBreakpointDialog(Project project) {
super(project, true);
setTitle("Add Method Breakpoint");
init();
@@ -27,6 +27,7 @@ import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.Key;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.sun.jdi.ReferenceType;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
@@ -34,9 +35,9 @@ import org.jetbrains.annotations.NonNls;
public class AnyExceptionBreakpoint extends ExceptionBreakpoint {
public static final @NonNls Key<AnyExceptionBreakpoint> ANY_EXCEPTION_BREAKPOINT = BreakpointCategory.lookup("breakpoint_any");
protected AnyExceptionBreakpoint(Project project) {
super(project, null, null);
ENABLED = false;
protected AnyExceptionBreakpoint(Project project, XBreakpoint xBreakpoint) {
super(project, null, null, xBreakpoint);
//setEnabled(false);
}
public Key<AnyExceptionBreakpoint> getCategory() {
@@ -49,7 +50,7 @@ public class AnyExceptionBreakpoint extends ExceptionBreakpoint {
public void createRequest(DebugProcessImpl debugProcess) {
DebuggerManagerThreadImpl.assertIsManagerThread();
if (!ENABLED || !debugProcess.isAttached() || debugProcess.areBreakpointsMuted() || !debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
if (!isEnabled() || !debugProcess.isAttached() || debugProcess.areBreakpointsMuted() || !debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
return;
}
super.processClassPrepare(debugProcess, null);
@@ -1,65 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import org.jdom.Element;
import javax.swing.*;
/**
* @author Eugene Zhuravlev
* Date: Apr 26, 2005
*/
public class AnyExceptionBreakpointFactory extends BreakpointFactory{
public Breakpoint createBreakpoint(Project project, final Element element) {
return new AnyExceptionBreakpoint(project);
}
public Icon getIcon() {
return AllIcons.Debugger.Db_exception_breakpoint;
}
public Icon getDisabledIcon() {
return AllIcons.Debugger.Db_disabled_exception_breakpoint;
}
@Override
protected String getHelpID() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public String getDisplayName() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) {
return new ExceptionBreakpointPropertiesPanel(project, compact);
}
@Override
public boolean breakpointCanBeRemoved(Breakpoint breakpoint) {
return false;
}
public Key<AnyExceptionBreakpoint> getBreakpointCategory() {
return AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT;
}
}
@@ -30,45 +30,62 @@ import com.intellij.debugger.engine.requests.RequestManagerImpl;
import com.intellij.debugger.jdi.StackFrameProxyImpl;
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
import com.intellij.debugger.requests.ClassPrepareRequestor;
import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizerUtil;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.ui.AppUIUtil;
import com.intellij.ui.classFilter.ClassFilter;
import com.intellij.util.StringBuilderSpinAllocator;
import com.sun.jdi.ObjectReference;
import com.sun.jdi.ReferenceType;
import com.sun.jdi.Value;
import com.sun.jdi.VoidValue;
import com.intellij.xdebugger.breakpoints.SuspendPolicy;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.sun.jdi.*;
import com.sun.jdi.event.LocatableEvent;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties;
import javax.swing.*;
import java.util.List;
public abstract class Breakpoint extends FilteredRequestor implements ClassPrepareRequestor {
public boolean ENABLED = true;
public boolean LOG_ENABLED = false;
public boolean LOG_EXPRESSION_ENABLED = false;
public boolean REMOVE_AFTER_HIT = false;
private TextWithImports myLogMessage; // an expression to be evaluated and printed
public abstract class Breakpoint<P extends JavaBreakpointProperties> implements FilteredRequestor, ClassPrepareRequestor {
final XBreakpoint<P> myXBreakpoint;
protected final Project myProject;
//private boolean ENABLED = true;
//private boolean LOG_ENABLED = false;
//private boolean LOG_EXPRESSION_ENABLED = false;
//private boolean REMOVE_AFTER_HIT = false;
//private TextWithImports myLogMessage; // an expression to be evaluated and printed
@NonNls private static final String LOG_MESSAGE_OPTION_NAME = "LOG_MESSAGE";
public static final Breakpoint[] EMPTY_ARRAY = new Breakpoint[0];
protected boolean myCachedVerifiedState = false;
//private TextWithImportsImpl myLogMessage;
protected Breakpoint(@NotNull Project project) {
super(project);
myLogMessage = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, "");
protected Breakpoint(@NotNull Project project, XBreakpoint<P> xBreakpoint) {
//super(project);
myProject = project;
myXBreakpoint = xBreakpoint;
//myLogMessage = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, "");
//noinspection AbstractMethodCallInConstructor
final BreakpointDefaults defaults = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().getBreakpointDefaults(getCategory());
SUSPEND_POLICY = defaults.getSuspendPolicy();
CONDITION_ENABLED = defaults.isConditionEnabled();
//final BreakpointDefaults defaults = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().getBreakpointDefaults(getCategory());
//SUSPEND_POLICY = defaults.getSuspendPolicy();
//CONDITION_ENABLED = defaults.isConditionEnabled();
}
public Project getProject() {
return myProject;
}
protected P getProperties() {
return myXBreakpoint.getProperties();
}
public abstract PsiClass getPsiClass();
@@ -100,6 +117,16 @@ public abstract class Breakpoint extends FilteredRequestor implements ClassPrepa
myCachedVerifiedState = isVerified;
}
public boolean isRemoveAfterHit() {
return myXBreakpoint instanceof XLineBreakpoint && ((XLineBreakpoint)myXBreakpoint).isTemporary();
}
public void setRemoveAfterHit(boolean value) {
if (myXBreakpoint instanceof XLineBreakpoint) {
((XLineBreakpoint)myXBreakpoint).setTemporary(value);
}
}
@Nullable
public String getShortClassName() {
final String className = getClassName();
@@ -210,19 +237,19 @@ public abstract class Breakpoint extends FilteredRequestor implements ClassPrepa
private void runAction(final EvaluationContextImpl context, LocatableEvent event) {
final DebugProcessImpl debugProcess = context.getDebugProcess();
if (LOG_ENABLED || LOG_EXPRESSION_ENABLED) {
if (isLogEnabled() || isLogExpressionEnabled()) {
final StringBuilder buf = StringBuilderSpinAllocator.alloc();
try {
if (LOG_ENABLED) {
if (myXBreakpoint.isLogMessage()) {
buf.append(getEventMessage(event));
buf.append("\n");
}
final TextWithImports expressionToEvaluate = getLogMessage();
if (LOG_EXPRESSION_ENABLED && expressionToEvaluate != null && !"".equals(expressionToEvaluate.getText())) {
if (isLogExpressionEnabled()) {
if(!debugProcess.isAttached()) {
return;
}
final TextWithImports expressionToEvaluate = getLogMessage();
try {
ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(getProject(), new EvaluatingComputable<ExpressionEvaluator>() {
@Override
@@ -252,11 +279,112 @@ public abstract class Breakpoint extends FilteredRequestor implements ClassPrepa
StringBuilderSpinAllocator.dispose(buf);
}
}
if (REMOVE_AFTER_HIT) {
if (isRemoveAfterHit()) {
handleTemporaryBreakpointHit(debugProcess);
}
}
/**
* @return true if the ID was added or false otherwise
*/
private boolean hasObjectID(long id) {
for (InstanceFilter instanceFilter : getInstanceFilters()) {
if (instanceFilter.getId() == id) {
return true;
}
}
return false;
}
public boolean evaluateCondition(final EvaluationContextImpl context, LocatableEvent event) throws EvaluateException {
if(isCountFilterEnabled()) {
final DebugProcessImpl debugProcess = context.getDebugProcess();
debugProcess.getVirtualMachineProxy().suspend();
debugProcess.getRequestsManager().deleteRequest(this);
((Breakpoint)this).createRequest(debugProcess);
debugProcess.getVirtualMachineProxy().resume();
}
if (isInstanceFiltersEnabled()) {
Value value = context.getThisObject();
if (value != null) { // non-static
ObjectReference reference = (ObjectReference)value;
if(!hasObjectID(reference.uniqueID())) {
return false;
}
}
}
if (isClassFiltersEnabled()) {
String typeName = calculateEventClass(context, event);
if (!typeMatchesClassFilters(typeName)) return false;
}
if (isConditionEnabled() && !getCondition().getText().isEmpty()) {
try {
ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(context.getProject(), new EvaluatingComputable<ExpressionEvaluator>() {
public ExpressionEvaluator compute() throws EvaluateException {
final SourcePosition contextSourcePosition = ContextUtil.getSourcePosition(context);
// IMPORTANT: calculate context psi element basing on the location where the exception
// has been hit, not on the location where it was set. (For line breakpoints these locations are the same, however,
// for method, exception and field breakpoints these locations differ)
PsiElement contextPsiElement = ContextUtil.getContextElement(contextSourcePosition);
if (contextPsiElement == null) {
contextPsiElement = getEvaluationElement(); // as a last resort
}
return EvaluatorBuilderImpl.build(getCondition(), contextPsiElement, contextSourcePosition);
}
});
final Value value = evaluator.evaluate(context);
if (!(value instanceof BooleanValue)) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.boolean.expected"));
}
if(!((BooleanValue)value).booleanValue()) {
return false;
}
}
catch (EvaluateException ex) {
if(ex.getCause() instanceof VMDisconnectedException) {
return false;
}
throw EvaluateExceptionUtil.createEvaluateException(
DebuggerBundle.message("error.failed.evaluating.breakpoint.condition", getCondition(), ex.getMessage())
);
}
return true;
}
return true;
}
protected String calculateEventClass(EvaluationContextImpl context, LocatableEvent event) throws EvaluateException {
return event.location().declaringType().name();
}
private boolean typeMatchesClassFilters(@Nullable String typeName) {
if (typeName == null) {
return true;
}
boolean matches = false, hasEnabled = false;
for (ClassFilter classFilter : getClassFilters()) {
if (classFilter.isEnabled()) {
hasEnabled = true;
if (classFilter.matches(typeName)) {
matches = true;
break;
}
}
}
if(hasEnabled && !matches) {
return false;
}
for (ClassFilter classFilter : getClassExclusionFilters()) {
if (classFilter.isEnabled() && classFilter.matches(typeName)) {
return false;
}
}
return true;
}
private void handleTemporaryBreakpointHit(final DebugProcessImpl debugProcess) {
debugProcess.addDebugProcessListener(new DebugProcessAdapter() {
@Override
@@ -288,26 +416,208 @@ public abstract class Breakpoint extends FilteredRequestor implements ClassPrepa
RequestManagerImpl.deleteRequests(this);
}
@Override
public void readExternal(Element parentNode) throws InvalidDataException {
super.readExternal(parentNode);
String logMessage = JDOMExternalizerUtil.readField(parentNode, LOG_MESSAGE_OPTION_NAME);
if (logMessage != null) {
setLogMessage(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, logMessage));
FilteredRequestorImpl requestor = new FilteredRequestorImpl(myProject);
requestor.readTo(parentNode, this);
try {
setEnabled(Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "ENABLED")));
} catch (Exception e) {
}
try {
setLogEnabled(Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "LOG_ENABLED")));
} catch (Exception e) {
}
try {
if (Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "LOG_EXPRESSION_ENABLED"))) {
String logMessage = JDOMExternalizerUtil.readField(parentNode, LOG_MESSAGE_OPTION_NAME);
if (logMessage != null) {
setLogMessage(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, logMessage));
}
}
} catch (Exception e) {
}
try {
setRemoveAfterHit(Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "REMOVE_AFTER_HIT")));
} catch (Exception e) {
}
}
//@Override
//public void writeExternal(Element parentNode) throws WriteExternalException {
//super.writeExternal(parentNode);
//JDOMExternalizerUtil.writeField(parentNode, LOG_MESSAGE_OPTION_NAME, getLogMessage().toExternalForm());
//}
//public void setLogMessage(TextWithImports logMessage) {
// myLogMessage = logMessage;
//}
public abstract PsiElement getEvaluationElement();
protected TextWithImports getLogMessage() {
return new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, myXBreakpoint.getLogExpression());
}
protected TextWithImports getCondition() {
return new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, myXBreakpoint.getCondition());
}
public boolean isEnabled() {
return myXBreakpoint.isEnabled();
}
public void setEnabled(boolean enabled) {
myXBreakpoint.setEnabled(enabled);
}
protected boolean isLogEnabled() {
return myXBreakpoint.isLogMessage();
}
public void setLogEnabled(boolean logEnabled) {
myXBreakpoint.setLogMessage(logEnabled);
}
protected boolean isLogExpressionEnabled() {
String expression = myXBreakpoint.getLogExpression();
if (expression == null || expression.isEmpty()) {
return false;
}
return !getLogMessage().isEmpty();
}
@Override
public void writeExternal(Element parentNode) throws WriteExternalException {
super.writeExternal(parentNode);
JDOMExternalizerUtil.writeField(parentNode, LOG_MESSAGE_OPTION_NAME, getLogMessage().toExternalForm());
public boolean isCountFilterEnabled() {
if (getProperties() == null) {
return false;
}
return getProperties().COUNT_FILTER_ENABLED;
}
public void setCountFilterEnabled(boolean enabled) {
getProperties().COUNT_FILTER_ENABLED = enabled;
}
public TextWithImports getLogMessage() {
return myLogMessage;
@Override
public int getCountFilter() {
return getProperties().COUNT_FILTER;
}
public void setLogMessage(TextWithImports logMessage) {
myLogMessage = logMessage;
public void setCountFilter(int filter) {
getProperties().COUNT_FILTER = filter;
}
@Override
public boolean isClassFiltersEnabled() {
if (getProperties() == null) {
return false;
}
return getProperties().CLASS_FILTERS_ENABLED;
}
public void setClassFiltersEnabled(boolean enabled) {
getProperties().CLASS_FILTERS_ENABLED = enabled;
}
@Override
public ClassFilter[] getClassFilters() {
return getProperties().getClassFilters();
}
public void setClassFilters(ClassFilter[] filters) {
getProperties().setClassFilters(filters);
}
@Override
public ClassFilter[] getClassExclusionFilters() {
return getProperties().getClassExclusionFilters();
}
protected void setClassExclusionFilters(ClassFilter[] filters) {
getProperties().setClassExclusionFilters(filters);
}
@Override
public boolean isInstanceFiltersEnabled() {
if (getProperties() == null) {
return false;
}
return getProperties().INSTANCE_FILTERS_ENABLED;
}
public void setInstanceFiltersEnabled(boolean enabled) {
getProperties().INSTANCE_FILTERS_ENABLED = enabled;
}
@Override
public InstanceFilter[] getInstanceFilters() {
return getProperties().getInstanceFilters();
}
public void setInstanceFilters(InstanceFilter[] filters) {
getProperties().setInstanceFilters(filters);
}
private static String getSuspendPolicy(XBreakpoint breakpoint) {
switch (breakpoint.getSuspendPolicy()) {
case ALL:
return DebuggerSettings.SUSPEND_ALL;
case THREAD:
return DebuggerSettings.SUSPEND_THREAD;
case NONE:
return DebuggerSettings.SUSPEND_NONE;
default:
throw new IllegalArgumentException("unknown suspend policy");
}
}
static SuspendPolicy transformSuspendPolicy(String policy) {
if (DebuggerSettings.SUSPEND_ALL.equals(policy)) {
return SuspendPolicy.ALL;
} else if (DebuggerSettings.SUSPEND_THREAD.equals(policy)) {
return SuspendPolicy.THREAD;
} else if (DebuggerSettings.SUSPEND_NONE.equals(policy)) {
return SuspendPolicy.NONE;
} else {
throw new IllegalArgumentException("unknown suspend policy");
}
}
protected boolean isSuspend() {
return myXBreakpoint.getSuspendPolicy() != SuspendPolicy.NONE;
}
@Override
public String getSuspendPolicy() {
return getSuspendPolicy(myXBreakpoint);
}
public void setSuspendPolicy(String policy) {
myXBreakpoint.setSuspendPolicy(transformSuspendPolicy(policy));
}
protected void setLogMessage(TextWithImports logMessage) {
if (!logMessage.getText().isEmpty()) {
myXBreakpoint.setLogExpression(logMessage.getText());
}
else {
myXBreakpoint.setLogExpression(null);
}
}
protected boolean isConditionEnabled() {
String condition = myXBreakpoint.getCondition();
if (condition == null || condition.isEmpty()) {
return false;
}
return !getCondition().isEmpty();
}
public void setCondition(String condition) {
myXBreakpoint.setCondition(condition);
}
protected void addInstanceFilter(long l) {
getProperties().addInstanceFilter(l);
}
}
@@ -1,81 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
import org.jdom.Element;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
/**
* Used to deexternalize breakpoints of certain category while reading saved configuration and for creating configuration UI
*/
public abstract class BreakpointFactory {
public static final ExtensionPointName<BreakpointFactory> EXTENSION_POINT_NAME =
ExtensionPointName.create("com.intellij.debugger.breakpointFactory");
public static BreakpointFactory[] getBreakpointFactories() {
return ApplicationManager.getApplication().getExtensions(EXTENSION_POINT_NAME);
}
public abstract Breakpoint createBreakpoint(Project project, final Element element);
public abstract Key<? extends Breakpoint> getBreakpointCategory();
public abstract Icon getIcon();
public abstract Icon getDisabledIcon();
@Nullable
public static BreakpointFactory getInstance(Key<? extends Breakpoint> category) {
final BreakpointFactory[] allFactories = getBreakpointFactories();
for (final BreakpointFactory factory : allFactories) {
if (category.equals(factory.getBreakpointCategory())) {
return factory;
}
}
return null;
}
protected abstract String getHelpID();
public abstract String getDisplayName();
@Nullable
public abstract BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact);
@Nullable
public Breakpoint addBreakpoint(Project project) {
return null;
}
public boolean canAddBreakpoints() {
return false;
}
public boolean breakpointCanBeRemoved(Breakpoint breakpoint) {
return true;
}
public BreakpointItem createBreakpointItem(final Breakpoint breakpoint) {
return new JavaBreakpointItem(this, breakpoint);
}
}
File diff suppressed because it is too large Load Diff
@@ -59,6 +59,9 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/*
* Not used any more, since move to xBreakpoints
*/
public abstract class BreakpointPropertiesPanel {
private BreakpointChooser myMasterBreakpointChooser;
@@ -208,8 +211,8 @@ public abstract class BreakpointPropertiesPanel {
final ItemListener suspendPolicyChangeListener = new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
final BreakpointDefaults defaults = getBreakpointManager(myProject).getBreakpointDefaults(breakpointCategory);
myMakeDefaultButton.setEnabled(!defaults.getSuspendPolicy().equals(getSelectedSuspendPolicy()) || defaults.isConditionEnabled() != myConditionCheckbox.isSelected());
//final BreakpointDefaults defaults = getBreakpointManager(myProject).getBreakpointDefaults(breakpointCategory);
//myMakeDefaultButton.setEnabled(!defaults.getSuspendPolicy().equals(getSelectedSuspendPolicy()) || defaults.isConditionEnabled() != myConditionCheckbox.isSelected());
}
};
@@ -426,13 +429,13 @@ public abstract class BreakpointPropertiesPanel {
}
private void updateSuspendPolicyRbFont() {
final String defPolicy = getBreakpointManager(myProject).getBreakpointDefaults(myBreakpointCategory).getSuspendPolicy();
//final String defPolicy = getBreakpointManager(myProject).getBreakpointDefaults(myBreakpointCategory).getSuspendPolicy();
final Font font = myRbSuspendAll.getFont().deriveFont(Font.PLAIN);
final Font boldFont = font.deriveFont(Font.BOLD);
myRbSuspendAll.setFont(DebuggerSettings.SUSPEND_ALL.equals(defPolicy)? boldFont : font);
myRbSuspendThread.setFont(DebuggerSettings.SUSPEND_THREAD.equals(defPolicy)? boldFont : font);
//myRbSuspendAll.setFont(DebuggerSettings.SUSPEND_ALL.equals(defPolicy)? boldFont : font);
//myRbSuspendThread.setFont(DebuggerSettings.SUSPEND_THREAD.equals(defPolicy)? boldFont : font);
}
protected ClassFilter createClassConditionFilter() {
@@ -459,125 +462,126 @@ public abstract class BreakpointPropertiesPanel {
* Init UI components with the values from Breakpoint
*/
public void initFrom(Breakpoint breakpoint, boolean moreOptionsVisible1) {
myBreakpoint = breakpoint;
boolean moreOptionsVisible = moreOptionsVisible1;
boolean actionsPanelVisible = moreOptionsVisible1;
initMasterBreakpointPanel();
if (breakpoint.COUNT_FILTER > 0) {
myPassCountField.setText(Integer.toString(breakpoint.COUNT_FILTER));
moreOptionsVisible = true;
}
else {
myPassCountField.setText("");
}
PsiElement context = breakpoint.getEvaluationElement();
myPassCountCheckbox.setSelected(breakpoint.COUNT_FILTER_ENABLED);
myConditionCheckbox.setSelected(breakpoint.CONDITION_ENABLED);
myConditionCombo.setEnabled(breakpoint.CONDITION_ENABLED);
myConditionCombo.setContext(context);
myConditionCombo.setText(breakpoint.getCondition() != null ? breakpoint.getCondition() : emptyText());
myCbSuspend.setSelected(breakpoint.SUSPEND);
myRbSuspendThread.setEnabled(myCbSuspend.isSelected());
myRbSuspendAll.setEnabled(myCbSuspend.isSelected());
if(!breakpoint.SUSPEND) {
actionsPanelVisible = true;
}
if(DebuggerSettings.SUSPEND_THREAD.equals(breakpoint.SUSPEND_POLICY)){
myRbSuspendThread.setSelected(true);
}
else {
myRbSuspendAll.setSelected(true);
}
myCbSuspend.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
if (!myActionsPanel.isVisible()) {
if (!myCbSuspend.isSelected()) {
if (myDelegate != null) {
myDelegate.showActionsPanel();
}
}
}
myRbSuspendThread.setEnabled(myCbSuspend.isSelected());
myRbSuspendAll.setEnabled(myCbSuspend.isSelected());
}
});
myLogMessageCheckBox.setSelected(breakpoint.LOG_ENABLED);
myTemporaryCheckBox.setSelected(breakpoint.REMOVE_AFTER_HIT);
myEnabledCheckbox.setSelected(breakpoint.ENABLED);
myEnabledCheckbox.setText(breakpoint.getShortName() + " enabled");
DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().addBreakpointManagerListener(new BreakpointManagerListener() {
@Override
public void breakpointsChanged() {
myEnabledCheckbox.setSelected(myBreakpoint.ENABLED);
}
});
myEnabledCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
if (myBreakpoint.ENABLED != myEnabledCheckbox.isSelected()) {
myBreakpoint.ENABLED = myEnabledCheckbox.isSelected();
getBreakpointManager(myProject).fireBreakpointChanged(myBreakpoint);
myBreakpoint.updateUI();
}
}
});
myTemporaryCheckBox.setVisible(breakpoint instanceof LineBreakpoint);
myLogExpressionCheckBox.setSelected(breakpoint.LOG_EXPRESSION_ENABLED);
if (breakpoint.LOG_ENABLED || breakpoint.LOG_EXPRESSION_ENABLED || (breakpoint instanceof LineBreakpoint && breakpoint.REMOVE_AFTER_HIT)) {
actionsPanelVisible = true;
}
myLogExpressionCombo.setContext(context);
if (breakpoint.getLogMessage() != null) {
myLogExpressionCombo.setText(breakpoint.getLogMessage());
}
else {
myLogExpressionCombo.setText(emptyText());
}
myLogExpressionCombo.setEnabled(breakpoint.LOG_EXPRESSION_ENABLED);
if (breakpoint.LOG_EXPRESSION_ENABLED) {
actionsPanelVisible = true;
}
myInstanceFiltersCheckBox.setSelected(breakpoint.INSTANCE_FILTERS_ENABLED);
myInstanceFiltersField.setEnabled(breakpoint.INSTANCE_FILTERS_ENABLED);
myInstanceFiltersField.getTextField().setEditable(breakpoint.INSTANCE_FILTERS_ENABLED);
myInstanceFilters = breakpoint.getInstanceFilters();
updateInstanceFilterEditor(true);
if (breakpoint.INSTANCE_FILTERS_ENABLED) {
moreOptionsVisible = true;
}
myClassFiltersCheckBox.setSelected(breakpoint.CLASS_FILTERS_ENABLED);
myClassFiltersField.setEnabled(breakpoint.CLASS_FILTERS_ENABLED);
myClassFiltersField.getTextField().setEditable(breakpoint.CLASS_FILTERS_ENABLED);
myClassFilters = breakpoint.getClassFilters();
myClassExclusionFilters = breakpoint.getClassExclusionFilters();
updateClassFilterEditor(true);
if (breakpoint.CLASS_FILTERS_ENABLED) {
moreOptionsVisible = true;
}
myBreakpointPsiClass = breakpoint.getPsiClass();
updateCheckboxes();
setActionsPanelVisible(actionsPanelVisible && !moreOptionsVisible1);
setMoreOptionsVisible(moreOptionsVisible);
//myBreakpoint = breakpoint;
//boolean moreOptionsVisible = moreOptionsVisible1;
//boolean actionsPanelVisible = moreOptionsVisible1;
//
//initMasterBreakpointPanel();
//
//if (breakpoint.getCountFilter() > 0) {
// myPassCountField.setText(Integer.toString(breakpoint.getCountFilter()));
// moreOptionsVisible = true;
//}
//else {
// myPassCountField.setText("");
//}
//
//PsiElement context = breakpoint.getEvaluationElement();
//myPassCountCheckbox.setSelected(breakpoint.isCountFilterEnabled());
//
//myConditionCheckbox.setSelected(breakpoint.isConditionEnabled());
//
//myConditionCombo.setEnabled(breakpoint.isConditionEnabled());
//
//myConditionCombo.setContext(context);
//myConditionCombo.setText(breakpoint.getCondition() != null ? breakpoint.getCondition() : emptyText());
//
//myCbSuspend.setSelected(breakpoint.isSuspend());
//myRbSuspendThread.setEnabled(myCbSuspend.isSelected());
//myRbSuspendAll.setEnabled(myCbSuspend.isSelected());
//
//if(!breakpoint.isSuspend()) {
// actionsPanelVisible = true;
//}
//if(DebuggerSettings.SUSPEND_THREAD.equals(breakpoint.getSuspendPolicy())){
// myRbSuspendThread.setSelected(true);
//}
//else {
// myRbSuspendAll.setSelected(true);
//}
//
//myCbSuspend.addActionListener(new ActionListener() {
// @Override
// public void actionPerformed(ActionEvent event) {
// if (!myActionsPanel.isVisible()) {
// if (!myCbSuspend.isSelected()) {
// if (myDelegate != null) {
// myDelegate.showActionsPanel();
// }
// }
// }
// myRbSuspendThread.setEnabled(myCbSuspend.isSelected());
// myRbSuspendAll.setEnabled(myCbSuspend.isSelected());
// }
//});
//myLogMessageCheckBox.setSelected(breakpoint.isLogEnabled());
//myTemporaryCheckBox.setSelected(breakpoint.isRemoveAfterHit());
//myEnabledCheckbox.setSelected(breakpoint.isEnabled());
//myEnabledCheckbox.setText(breakpoint.getShortName() + " enabled");
//
//DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().addBreakpointManagerListener(new BreakpointManagerListener() {
// @Override
// public void breakpointsChanged() {
// myEnabledCheckbox.setSelected(myBreakpoint.isEnabled());
// }
//});
//
//myEnabledCheckbox.addActionListener(new ActionListener() {
// @Override
// public void actionPerformed(ActionEvent event) {
// if (myBreakpoint.isEnabled() != myEnabledCheckbox.isSelected()) {
// myBreakpoint.setEnabled(myEnabledCheckbox.isSelected());
// getBreakpointManager(myProject).fireBreakpointChanged(myBreakpoint);
// myBreakpoint.updateUI();
// }
// }
//});
//myTemporaryCheckBox.setVisible(breakpoint instanceof LineBreakpoint);
//myLogExpressionCheckBox.setSelected(breakpoint.isLogExpressionEnabled());
//if (breakpoint.isLogEnabled() ||
// breakpoint.isLogExpressionEnabled() || (breakpoint instanceof LineBreakpoint && breakpoint.isRemoveAfterHit())) {
// actionsPanelVisible = true;
//}
//
//myLogExpressionCombo.setContext(context);
//
//if (breakpoint.getLogMessage() != null) {
// myLogExpressionCombo.setText(breakpoint.getLogMessage());
//}
//else {
// myLogExpressionCombo.setText(emptyText());
//}
//
//myLogExpressionCombo.setEnabled(breakpoint.isLogExpressionEnabled());
//if (breakpoint.isLogExpressionEnabled()) {
// actionsPanelVisible = true;
//}
//
//myInstanceFiltersCheckBox.setSelected(breakpoint.isInstanceFiltersEnabled());
//myInstanceFiltersField.setEnabled(breakpoint.isInstanceFiltersEnabled());
//myInstanceFiltersField.getTextField().setEditable(breakpoint.isInstanceFiltersEnabled());
//myInstanceFilters = breakpoint.getInstanceFilters();
//updateInstanceFilterEditor(true);
//if (breakpoint.isInstanceFiltersEnabled()) {
// moreOptionsVisible = true;
//}
//
//myClassFiltersCheckBox.setSelected(breakpoint.isClassFiltersEnabled());
//myClassFiltersField.setEnabled(breakpoint.isClassFiltersEnabled());
//myClassFiltersField.getTextField().setEditable(breakpoint.isClassFiltersEnabled());
//myClassFilters = breakpoint.getClassFilters();
//myClassExclusionFilters = breakpoint.getClassExclusionFilters();
//updateClassFilterEditor(true);
//if (breakpoint.isClassFiltersEnabled()) {
// moreOptionsVisible = true;
//}
//
//myBreakpointPsiClass = breakpoint.getPsiClass();
//
//updateCheckboxes();
//
//setActionsPanelVisible(actionsPanelVisible && !moreOptionsVisible1);
//setMoreOptionsVisible(moreOptionsVisible);
}
private void initMasterBreakpointPanel() {
@@ -632,41 +636,41 @@ public abstract class BreakpointPropertiesPanel {
*/
public void saveTo(Breakpoint breakpoint) {
saveMasterBreakpoint();
try {
String text = myPassCountField.getText().trim();
breakpoint.COUNT_FILTER = !text.isEmpty() ? Integer.parseInt(text) : 0;
if (breakpoint.COUNT_FILTER < 0) {
breakpoint.COUNT_FILTER = 0;
}
}
catch (Exception ignored) {
}
breakpoint.COUNT_FILTER_ENABLED = breakpoint.COUNT_FILTER > 0 && myPassCountCheckbox.isSelected();
breakpoint.setCondition(myConditionCombo.getText());
breakpoint.CONDITION_ENABLED = myConditionCheckbox.isSelected();
breakpoint.setLogMessage(myLogExpressionCombo.getText());
breakpoint.LOG_EXPRESSION_ENABLED = !breakpoint.getLogMessage().isEmpty() && myLogExpressionCheckBox.isSelected();
breakpoint.LOG_ENABLED = myLogMessageCheckBox.isSelected();
breakpoint.ENABLED = myEnabledCheckbox.isSelected();
breakpoint.REMOVE_AFTER_HIT = myTemporaryCheckBox.isSelected();
breakpoint.SUSPEND = myCbSuspend.isSelected();
breakpoint.SUSPEND_POLICY = getSelectedSuspendPolicy();
reloadInstanceFilters();
reloadClassFilters();
updateInstanceFilterEditor(true);
updateClassFilterEditor(true);
breakpoint.INSTANCE_FILTERS_ENABLED = myInstanceFiltersField.getText().length() > 0 && myInstanceFiltersCheckBox.isSelected();
breakpoint.CLASS_FILTERS_ENABLED = myClassFiltersField.getText().length() > 0 && myClassFiltersCheckBox.isSelected();
breakpoint.setClassFilters(myClassFilters);
breakpoint.setClassExclusionFilters(myClassExclusionFilters);
breakpoint.setInstanceFilters(myInstanceFilters);
myConditionCombo.addRecent(myConditionCombo.getText());
myLogExpressionCombo.addRecent(myLogExpressionCombo.getText());
breakpoint.updateUI();
//saveMasterBreakpoint();
//try {
// String text = myPassCountField.getText().trim();
// breakpoint.setCountFilter(!text.isEmpty() ? Integer.parseInt(text) : 0);
// if (breakpoint.getCountFilter() < 0) {
// breakpoint.setCountFilter(0);
// }
//}
//catch (Exception ignored) {
//}
//
//breakpoint.setCountFilterEnabled(breakpoint.getCountFilter() > 0 && myPassCountCheckbox.isSelected());
//breakpoint.setCondition(myConditionCombo.getText().getText());
////breakpoint.setConditionEnabled(myConditionCheckbox.isSelected());
//breakpoint.setLogMessage(myLogExpressionCombo.getText());
//breakpoint.setLogExpressionEnabled(!breakpoint.getLogMessage().isEmpty() && myLogExpressionCheckBox.isSelected());
//breakpoint.setLogEnabled(myLogMessageCheckBox.isSelected());
//breakpoint.setEnabled(myEnabledCheckbox.isSelected());
//breakpoint.setRemoveAfterHit(myTemporaryCheckBox.isSelected());
////breakpoint.setSuspend(myCbSuspend.isSelected());
//breakpoint.setSuspendPolicy(getSelectedSuspendPolicy());
//reloadInstanceFilters();
//reloadClassFilters();
//updateInstanceFilterEditor(true);
//updateClassFilterEditor(true);
//
//breakpoint.setInstanceFiltersEnabled(myInstanceFiltersField.getText().length() > 0 && myInstanceFiltersCheckBox.isSelected());
//breakpoint.setClassFiltersEnabled(myClassFiltersField.getText().length() > 0 && myClassFiltersCheckBox.isSelected());
//breakpoint.setClassFilters(myClassFilters);
//breakpoint.setClassExclusionFilters(myClassExclusionFilters);
//breakpoint.setInstanceFilters(myInstanceFilters);
//
//myConditionCombo.addRecent(myConditionCombo.getText());
//myLogExpressionCombo.addRecent(myLogExpressionCombo.getText());
//breakpoint.updateUI();
}
private static String concatWithEx(List<String> s, String concator, int N, String NthConcator) {
@@ -25,49 +25,48 @@ import com.intellij.debugger.engine.events.DebuggerCommandImpl;
import com.intellij.debugger.engine.requests.RequestManagerImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.debugger.ui.JavaDebuggerSupport;
import com.intellij.openapi.actionSystem.ActionGroup;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.ex.MarkupModelEx;
import com.intellij.openapi.editor.impl.DocumentMarkupModel;
import com.intellij.openapi.editor.markup.*;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.editor.markup.MarkupEditorFilterFactory;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.*;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.Key;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.jsp.JspFile;
import com.intellij.ui.AppUIUtil;
import com.intellij.ui.classFilter.ClassFilter;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.xdebugger.impl.DebuggerSupport;
import com.intellij.xdebugger.impl.actions.EditBreakpointAction;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.XDebuggerUtil;
import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.XBreakpointManager;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.intellij.xdebugger.ui.DebuggerColors;
import com.intellij.xml.util.XmlStringUtil;
import com.sun.jdi.ReferenceType;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties;
import javax.swing.*;
import java.awt.*;
import java.awt.dnd.DragSource;
/**
* User: lex
* Date: Sep 2, 2003
* Time: 3:22:55 PM
*/
public abstract class BreakpointWithHighlighter extends Breakpoint {
public abstract class BreakpointWithHighlighter<P extends JavaBreakpointProperties> extends Breakpoint<P> {
@Nullable
private RangeHighlighter myHighlighter;
@@ -150,7 +149,7 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
private Icon calcIcon(@Nullable DebugProcessImpl debugProcess) {
final boolean muted = debugProcess != null && isMuted(debugProcess);
if (!ENABLED) {
if (!isEnabled()) {
return getDisabledIcon(muted);
}
@@ -184,13 +183,14 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
return getSetIcon(muted);
}
protected BreakpointWithHighlighter(@NotNull Project project) {
protected BreakpointWithHighlighter(@NotNull Project project, XBreakpoint xBreakpoint) {
//for persistency
super(project);
super(project, xBreakpoint);
reload();
}
public BreakpointWithHighlighter(@NotNull final Project project, @NotNull final RangeHighlighter highlighter) {
super(project);
public BreakpointWithHighlighter(@NotNull final Project project, @NotNull final RangeHighlighter highlighter, XBreakpoint breakpoint) {
super(project, breakpoint);
myHighlighter = highlighter;
setEditorFilter(highlighter);
reload();
@@ -208,10 +208,10 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
@Override
public boolean isValid() {
return isPositionValid(getSourcePosition());
return isPositionValid(myXBreakpoint.getSourcePosition());
}
private static boolean isPositionValid(@Nullable final SourcePosition sourcePosition) {
protected static boolean isPositionValid(@Nullable final XSourcePosition sourcePosition) {
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
@@ -238,34 +238,34 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
}
buf.append("&nbsp;<br>&nbsp;");
buf.append(DebuggerBundle.message("breakpoint.property.name.suspend.policy")).append(" : ");
if (DebuggerSettings.SUSPEND_NONE.equals(SUSPEND_POLICY) || !SUSPEND) {
if (DebuggerSettings.SUSPEND_NONE.equals(getSuspendPolicy()) || !isSuspend()) {
buf.append(DebuggerBundle.message("breakpoint.properties.panel.option.suspend.none"));
}
else if (DebuggerSettings.SUSPEND_ALL.equals(SUSPEND_POLICY)) {
else if (DebuggerSettings.SUSPEND_ALL.equals(getSuspendPolicy())) {
buf.append(DebuggerBundle.message("breakpoint.properties.panel.option.suspend.all"));
}
else if (DebuggerSettings.SUSPEND_THREAD.equals(SUSPEND_POLICY)) {
else if (DebuggerSettings.SUSPEND_THREAD.equals(getSuspendPolicy())) {
buf.append(DebuggerBundle.message("breakpoint.properties.panel.option.suspend.thread"));
}
buf.append("&nbsp;<br>&nbsp;");
buf.append(DebuggerBundle.message("breakpoint.property.name.log.message")).append(": ");
buf.append(LOG_ENABLED ? CommonBundle.getYesButtonText() : CommonBundle.getNoButtonText());
if (LOG_EXPRESSION_ENABLED) {
buf.append(isLogEnabled() ? CommonBundle.getYesButtonText() : CommonBundle.getNoButtonText());
if (isLogExpressionEnabled()) {
buf.append("&nbsp;<br>&nbsp;");
buf.append(DebuggerBundle.message("breakpoint.property.name.log.expression")).append(": ");
buf.append(XmlStringUtil.escapeString(getLogMessage().getText()));
}
if (CONDITION_ENABLED && getCondition() != null && getCondition().getText() != null && !getCondition().getText().isEmpty()) {
if (isConditionEnabled() && getCondition() != null && getCondition().getText() != null && !getCondition().getText().isEmpty()) {
buf.append("&nbsp;<br>&nbsp;");
buf.append(DebuggerBundle.message("breakpoint.property.name.condition")).append(": ");
buf.append(XmlStringUtil.escapeString(getCondition().getText()));
}
if (COUNT_FILTER_ENABLED) {
if (isCountFilterEnabled()) {
buf.append("&nbsp;<br>&nbsp;");
buf.append(DebuggerBundle.message("breakpoint.property.name.pass.count")).append(": ");
buf.append(COUNT_FILTER);
buf.append(getCountFilter());
}
if (CLASS_FILTERS_ENABLED) {
if (isClassFiltersEnabled()) {
buf.append("&nbsp;<br>&nbsp;");
buf.append(DebuggerBundle.message("breakpoint.property.name.class.filters")).append(": ");
ClassFilter[] classFilters = getClassFilters();
@@ -273,7 +273,7 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
buf.append(classFilter.getPattern()).append(" ");
}
}
if (INSTANCE_FILTERS_ENABLED) {
if (isInstanceFiltersEnabled()) {
buf.append("&nbsp;<br>&nbsp;");
buf.append(DebuggerBundle.message("breakpoint.property.name.instance.filters"));
InstanceFilter[] instanceFilters = getInstanceFilters();
@@ -290,25 +290,23 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
}
@Override
public final void reload() {
public void reload() {
ApplicationManager.getApplication().assertReadAccessAllowed();
RangeHighlighter highlighter = myHighlighter;
if (highlighter != null && highlighter.isValid()) {
PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(highlighter.getDocument());
if (psiFile != null) {
mySourcePosition = SourcePosition.createFromOffset(psiFile, highlighter.getStartOffset());
reload(psiFile);
return;
}
final XSourcePosition position = myXBreakpoint.getSourcePosition();
try {
PsiElement element = XDebuggerUtil.getInstance().findContextElement(position.getFile(), position.getOffset(), myProject, false);
mySourcePosition = SourcePosition.createFromOffset(element.getContainingFile(), position.getOffset());
} catch (Exception e) {
mySourcePosition = null;
}
mySourcePosition = null;
reload(BreakpointManager.getPsiFile(myXBreakpoint, myProject));
}
@Override
public void createRequest(@NotNull DebugProcessImpl debugProcess) {
DebuggerManagerThreadImpl.assertIsManagerThread();
// check is this breakpoint is enabled, vm reference is valid and there're no requests created yet
if (!ENABLED ||
if (!isEnabled() ||
!debugProcess.isAttached() ||
isMuted(debugProcess) ||
!debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
@@ -329,7 +327,7 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
@Override
public void processClassPrepare(final DebugProcess debugProcess, final ReferenceType classType) {
if (!ENABLED || !isValid()) {
if (!isEnabled() || !isValid()) {
return;
}
createRequestForPreparedClass((DebugProcessImpl)debugProcess, classType);
@@ -383,20 +381,24 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
private void updateGutter() {
if (myVisible) {
RangeHighlighter highlighter = myHighlighter;
if (highlighter != null && highlighter.isValid() && isValid()) {
AppUIUtil.invokeLaterIfProjectAlive(myProject, new Runnable() {
@Override
public void run() {
if (isValid()) {
setupGutterRenderer(myHighlighter);
}
}
});
}
else {
DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().removeBreakpoint(this);
if (isValid()) {
final XBreakpointManager breakpointManager = XDebuggerManager.getInstance(myProject).getBreakpointManager();
breakpointManager.updateBreakpointPresentation((XLineBreakpoint)myXBreakpoint, getIcon(), getDescription());
}
//RangeHighlighter highlighter = myHighlighter;
//if (highlighter != null && highlighter.isValid() && isValid()) {
// AppUIUtil.invokeLaterIfProjectAlive(myProject, new Runnable() {
// @Override
// public void run() {
// if (isValid()) {
// setupGutterRenderer(myHighlighter);
// }
// }
// });
//}
//else {
// DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().removeBreakpoint(this);
//}
}
}
@@ -448,9 +450,9 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
});
}
private void setupGutterRenderer(@NotNull RangeHighlighter highlighter) {
highlighter.setGutterIconRenderer(new MyGutterIconRenderer(getIcon(), getDescription()));
}
//private void setupGutterRenderer(@NotNull RangeHighlighter highlighter) {
// highlighter.setGutterIconRenderer(new MyGutterIconRenderer(getIcon(), getDescription()));
//}
@Override
public abstract Key<? extends BreakpointWithHighlighter> getCategory();
@@ -559,7 +561,7 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
public void readExternal(@NotNull Element breakpointNode) throws InvalidDataException {
super.readExternal(breakpointNode);
//noinspection HardCodedStringLiteral
final String url = breakpointNode.getAttributeValue("url");
//final String url = breakpointNode.getAttributeValue("url");
//noinspection HardCodedStringLiteral
final String className = breakpointNode.getAttributeValue("class");
@@ -573,146 +575,146 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
myPackageName = packageName;
}
VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(url);
if (vFile == null) {
throw new InvalidDataException(DebuggerBundle.message("error.breakpoint.file.not.found", url));
}
final Document doc = FileDocumentManager.getInstance().getDocument(vFile);
if (doc == null) {
throw new InvalidDataException(DebuggerBundle.message("error.cannot.load.breakpoint.file", url));
}
// line number
final int line;
try {
//noinspection HardCodedStringLiteral
line = Integer.parseInt(breakpointNode.getAttributeValue("line"));
}
catch (Exception e) {
throw new InvalidDataException("Line number is invalid for breakpoint");
}
if (line < 0) {
throw new InvalidDataException("Line number is invalid for breakpoint");
}
RangeHighlighter highlighter = createHighlighter(myProject, doc, line);
if (highlighter == null) {
throw new InvalidDataException("");
}
myHighlighter = highlighter;
reload();
//VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(url);
//if (vFile == null) {
// throw new InvalidDataException(DebuggerBundle.message("error.breakpoint.file.not.found", url));
//}
//final Document doc = FileDocumentManager.getInstance().getDocument(vFile);
//if (doc == null) {
// throw new InvalidDataException(DebuggerBundle.message("error.cannot.load.breakpoint.file", url));
//}
//
//// line number
//final int line;
//try {
// //noinspection HardCodedStringLiteral
// line = Integer.parseInt(breakpointNode.getAttributeValue("line"));
//}
//catch (Exception e) {
// throw new InvalidDataException("Line number is invalid for breakpoint");
//}
//if (line < 0) {
// throw new InvalidDataException("Line number is invalid for breakpoint");
//}
//
//RangeHighlighter highlighter = createHighlighter(myProject, doc, line);
//
//if (highlighter == null) {
// throw new InvalidDataException("");
//}
//
//myHighlighter = highlighter;
//reload();
}
//
//@Override
//@SuppressWarnings({"HardCodedStringLiteral"})
//public void writeExternal(@NotNull Element parentNode) throws WriteExternalException {
// super.writeExternal(parentNode);
// PsiFile psiFile = getSourcePosition().getFile();
// final VirtualFile virtualFile = psiFile.getVirtualFile();
// final String url = virtualFile != null ? virtualFile.getUrl() : "";
// parentNode.setAttribute("url", url);
// parentNode.setAttribute("line", Integer.toString(getSourcePosition().getLine()));
// if (myClassName != null) {
// parentNode.setAttribute("class", myClassName);
// }
// if (myPackageName != null) {
// parentNode.setAttribute("package", myPackageName);
// }
//}
@Override
@SuppressWarnings({"HardCodedStringLiteral"})
public void writeExternal(@NotNull Element parentNode) throws WriteExternalException {
super.writeExternal(parentNode);
PsiFile psiFile = getSourcePosition().getFile();
final VirtualFile virtualFile = psiFile.getVirtualFile();
final String url = virtualFile != null ? virtualFile.getUrl() : "";
parentNode.setAttribute("url", url);
parentNode.setAttribute("line", Integer.toString(getSourcePosition().getLine()));
if (myClassName != null) {
parentNode.setAttribute("class", myClassName);
}
if (myPackageName != null) {
parentNode.setAttribute("package", myPackageName);
}
}
private class MyGutterIconRenderer extends GutterIconRenderer {
private final Icon myIcon;
private final String myDescription;
public MyGutterIconRenderer(@NotNull Icon icon, @NotNull String description) {
myIcon = icon;
myDescription = description;
}
@Override
@NotNull
public Icon getIcon() {
return myIcon;
}
@Override
public String getTooltipText() {
return myDescription;
}
@Override
public Alignment getAlignment() {
return Alignment.RIGHT;
}
@Override
public AnAction getClickAction() {
return new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().removeBreakpoint(BreakpointWithHighlighter.this);
}
};
}
@Override
public AnAction getMiddleButtonClickAction() {
return new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
ENABLED = !ENABLED;
DebuggerManagerEx.getInstanceEx(getProject()).getBreakpointManager().fireBreakpointChanged(BreakpointWithHighlighter.this);
updateUI();
}
};
}
@Override
public ActionGroup getPopupMenuActions() {
return null;
}
@Nullable
@Override
public AnAction getRightButtonClickAction() {
return new EditBreakpointAction.ContextAction(this, BreakpointWithHighlighter.this, DebuggerSupport.getDebuggerSupport(JavaDebuggerSupport.class));
}
@Override
public GutterDraggableObject getDraggableObject() {
return new GutterDraggableObject() {
@Override
public boolean copy(int line, @NotNull VirtualFile file) {
final PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file);
return psiFile != null && moveTo(SourcePosition.createFromLine(psiFile, line));
}
@Override
public Cursor getCursor(int line) {
final SourcePosition newPosition = SourcePosition.createFromLine(getSourcePosition().getFile(), line);
return canMoveTo(newPosition) ? DragSource.DefaultMoveDrop : DragSource.DefaultMoveNoDrop;
}
};
}
@Override
public boolean equals(@NotNull Object obj) {
return obj instanceof MyGutterIconRenderer &&
Comparing.equal(getTooltipText(), ((MyGutterIconRenderer)obj).getTooltipText()) &&
Comparing.equal(getIcon(), ((MyGutterIconRenderer)obj).getIcon());
}
@Override
public int hashCode() {
return getIcon().hashCode();
}
@Override
public String toString() {
return "LB " + getDisplayName();
}
}
//private class MyGutterIconRenderer extends GutterIconRenderer {
// private final Icon myIcon;
// private final String myDescription;
//
// public MyGutterIconRenderer(@NotNull Icon icon, @NotNull String description) {
// myIcon = icon;
// myDescription = description;
// }
//
// @Override
// @NotNull
// public Icon getIcon() {
// return myIcon;
// }
//
// @Override
// public String getTooltipText() {
// return myDescription;
// }
//
// @Override
// public Alignment getAlignment() {
// return Alignment.RIGHT;
// }
//
// @Override
// public AnAction getClickAction() {
// return new AnAction() {
// @Override
// public void actionPerformed(AnActionEvent e) {
// DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().removeBreakpoint(BreakpointWithHighlighter.this);
// }
// };
// }
//
// @Override
// public AnAction getMiddleButtonClickAction() {
// return new AnAction() {
// @Override
// public void actionPerformed(AnActionEvent e) {
// setEnabled(!isEnabled());
// DebuggerManagerEx.getInstanceEx(getProject()).getBreakpointManager().fireBreakpointChanged(BreakpointWithHighlighter.this);
// updateUI();
// }
// };
// }
//
// @Override
// public ActionGroup getPopupMenuActions() {
// return null;
// }
//
// @Nullable
// @Override
// public AnAction getRightButtonClickAction() {
// return new EditBreakpointAction.ContextAction(this, BreakpointWithHighlighter.this, DebuggerSupport.getDebuggerSupport(JavaDebuggerSupport.class));
// }
//
// @Override
// public GutterDraggableObject getDraggableObject() {
// return new GutterDraggableObject() {
// @Override
// public boolean copy(int line, @NotNull VirtualFile file) {
// final PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file);
// return psiFile != null && moveTo(SourcePosition.createFromLine(psiFile, line));
// }
//
// @Override
// public Cursor getCursor(int line) {
// final SourcePosition newPosition = SourcePosition.createFromLine(getSourcePosition().getFile(), line);
// return canMoveTo(newPosition) ? DragSource.DefaultMoveDrop : DragSource.DefaultMoveNoDrop;
// }
// };
// }
//
// @Override
// public boolean equals(@NotNull Object obj) {
// return obj instanceof MyGutterIconRenderer &&
// Comparing.equal(getTooltipText(), ((MyGutterIconRenderer)obj).getTooltipText()) &&
// Comparing.equal(getIcon(), ((MyGutterIconRenderer)obj).getIcon());
// }
//
// @Override
// public int hashCode() {
// return getIcon().hashCode();
// }
//
// @Override
// public String toString() {
// return "LB " + getDisplayName();
// }
//}
}
@@ -34,13 +34,14 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizerUtil;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.sun.jdi.AbsentInformationException;
import com.sun.jdi.Location;
import com.sun.jdi.ObjectReference;
@@ -50,36 +51,32 @@ import com.sun.jdi.event.LocatableEvent;
import com.sun.jdi.request.ExceptionRequest;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpointProperties;
import javax.swing.*;
public class ExceptionBreakpoint extends Breakpoint {
public class ExceptionBreakpoint extends Breakpoint<JavaExceptionBreakpointProperties> {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.breakpoints.ExceptionBreakpoint");
public boolean NOTIFY_CAUGHT = true;
public boolean NOTIFY_UNCAUGHT = true;
private String myQualifiedName;
private String myPackageName;
protected final static String READ_NO_CLASS_NAME = DebuggerBundle.message("error.absent.exception.breakpoint.class.name");
public static final @NonNls Key<ExceptionBreakpoint> CATEGORY = BreakpointCategory.lookup("exception_breakpoints");
public ExceptionBreakpoint(Project project) {
super(project);
public ExceptionBreakpoint(Project project, XBreakpoint xBreakpoint) {
super(project, xBreakpoint);
}
public Key<? extends ExceptionBreakpoint> getCategory() {
return CATEGORY;
}
protected ExceptionBreakpoint(Project project, String qualifiedName, String packageName) {
super(project);
myQualifiedName = qualifiedName;
protected ExceptionBreakpoint(Project project, String qualifiedName, String packageName, XBreakpoint xBreakpoint) {
super(project, xBreakpoint);
setQualifiedName(qualifiedName);
if (packageName == null) {
myPackageName = calcPackageName(qualifiedName);
setPackageName(calcPackageName(qualifiedName));
}
else {
myPackageName = packageName;
setPackageName(packageName);
}
}
@@ -92,27 +89,27 @@ public class ExceptionBreakpoint extends Breakpoint {
}
public String getClassName() {
return myQualifiedName;
return getQualifiedName();
}
public String getPackageName() {
return myPackageName;
return getProperties().myPackageName;
}
public PsiClass getPsiClass() {
return PsiDocumentManager.getInstance(myProject).commitAndRunReadAction(new Computable<PsiClass>() {
public PsiClass compute() {
return myQualifiedName != null ? DebuggerUtilsEx.findClass(myQualifiedName, myProject, GlobalSearchScope.allScope(myProject)) : null;
return getQualifiedName() != null ? DebuggerUtilsEx.findClass(getQualifiedName(), myProject, GlobalSearchScope.allScope(myProject)) : null;
}
});
}
public String getDisplayName() {
return DebuggerBundle.message("breakpoint.exception.breakpoint.display.name", myQualifiedName);
return DebuggerBundle.message("breakpoint.exception.breakpoint.display.name", getQualifiedName());
}
public Icon getIcon() {
if (!ENABLED) {
if (!isEnabled()) {
final Breakpoint master = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().findMasterBreakpoint(this);
return master == null? AllIcons.Debugger.Db_disabled_exception_breakpoint : AllIcons.Debugger.Db_dep_exception_breakpoint;
}
@@ -124,20 +121,20 @@ public class ExceptionBreakpoint extends Breakpoint {
public void createRequest(final DebugProcessImpl debugProcess) {
DebuggerManagerThreadImpl.assertIsManagerThread();
if (!ENABLED || !debugProcess.isAttached() || debugProcess.areBreakpointsMuted() || !debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
if (!isEnabled() || !debugProcess.isAttached() || debugProcess.areBreakpointsMuted() || !debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
return;
}
SourcePosition classPosition = PsiDocumentManager.getInstance(myProject).commitAndRunReadAction(new Computable<SourcePosition>() {
public SourcePosition compute() {
PsiClass psiClass = DebuggerUtilsEx.findClass(myQualifiedName, myProject, debugProcess.getSearchScope());
PsiClass psiClass = DebuggerUtilsEx.findClass(getQualifiedName(), myProject, debugProcess.getSearchScope());
return psiClass != null ? SourcePosition.createFromElement(psiClass) : null;
}
});
if(classPosition == null) {
createOrWaitPrepare(debugProcess, myQualifiedName);
createOrWaitPrepare(debugProcess, getQualifiedName());
}
else {
createOrWaitPrepare(debugProcess, classPosition);
@@ -146,11 +143,12 @@ public class ExceptionBreakpoint extends Breakpoint {
public void processClassPrepare(DebugProcess process, ReferenceType refType) {
DebugProcessImpl debugProcess = (DebugProcessImpl)process;
if (!ENABLED) {
if (!isEnabled()) {
return;
}
// trying to create a request
ExceptionRequest request = debugProcess.getRequestsManager().createExceptionRequest(this, refType, NOTIFY_CAUGHT, NOTIFY_UNCAUGHT);
ExceptionRequest request = debugProcess.getRequestsManager().createExceptionRequest(this, refType, isNotifyCaught(),
isNotifyUncaught());
debugProcess.getRequestsManager().enableRequest(request);
if (LOG.isDebugEnabled()) {
if (refType != null) {
@@ -170,7 +168,7 @@ public class ExceptionBreakpoint extends Breakpoint {
}
public String getEventMessage(LocatableEvent event) {
String exceptionName = (myQualifiedName != null)? myQualifiedName : "java.lang.Throwable";
String exceptionName = (getQualifiedName() != null)? getQualifiedName() : "java.lang.Throwable";
String threadName = null;
if (event instanceof ExceptionEvent) {
ExceptionEvent exceptionEvent = (ExceptionEvent)event;
@@ -216,15 +214,15 @@ public class ExceptionBreakpoint extends Breakpoint {
return true;
}
@SuppressWarnings({"HardCodedStringLiteral"}) public void writeExternal(Element parentNode) throws WriteExternalException {
super.writeExternal(parentNode);
if(myQualifiedName != null) {
parentNode.setAttribute("class_name", myQualifiedName);
}
if(myPackageName != null) {
parentNode.setAttribute("package_name", myPackageName);
}
}
//@SuppressWarnings({"HardCodedStringLiteral"}) public void writeExternal(Element parentNode) throws WriteExternalException {
// super.writeExternal(parentNode);
// if(getQualifiedName() != null) {
// parentNode.setAttribute("class_name", getQualifiedName());
// }
// if(getPackageName() != null) {
// parentNode.setAttribute("package_name", getPackageName());
// }
//}
public PsiElement getEvaluationElement() {
if (getClassName() == null) {
@@ -235,16 +233,45 @@ public class ExceptionBreakpoint extends Breakpoint {
public void readExternal(Element parentNode) throws InvalidDataException {
super.readExternal(parentNode);
//noinspection HardCodedStringLiteral
String className = parentNode.getAttributeValue("class_name");
myQualifiedName = className;
if(className == null) {
throw new InvalidDataException(READ_NO_CLASS_NAME);
}
//noinspection HardCodedStringLiteral
String packageName = parentNode.getAttributeValue("package_name");
myPackageName = packageName != null? packageName : calcPackageName(packageName);
setPackageName(packageName != null? packageName : calcPackageName(packageName));
try {
getProperties().NOTIFY_CAUGHT = Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "NOTIFY_CAUGHT"));
} catch (Exception e) {
}
try {
getProperties().NOTIFY_UNCAUGHT = Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "NOTIFY_UNCAUGHT"));
} catch (Exception e) {
}
//noinspection HardCodedStringLiteral
String className = parentNode.getAttributeValue("class_name");
setQualifiedName(className);
if(className == null) {
throw new InvalidDataException(READ_NO_CLASS_NAME);
}
}
private boolean isNotifyCaught() {
return getProperties().NOTIFY_CAUGHT;
}
private boolean isNotifyUncaught() {
return getProperties().NOTIFY_UNCAUGHT;
}
private String getQualifiedName() {
return getProperties().myQualifiedName;
}
private void setQualifiedName(String qualifiedName) {
getProperties().myQualifiedName = qualifiedName;
}
private void setPackageName(String packageName) {
getProperties().myPackageName = packageName;
}
}
@@ -1,94 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.HelpID;
import com.intellij.debugger.engine.JVMNameUtil;
import com.intellij.icons.AllIcons;
import com.intellij.ide.util.TreeClassChooser;
import com.intellij.ide.util.TreeClassChooserFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiClassOwner;
import com.intellij.psi.search.GlobalSearchScope;
import org.jdom.Element;
import javax.swing.*;
/**
* @author Eugene Zhuravlev
* Date: Apr 26, 2005
*/
public class ExceptionBreakpointFactory extends BreakpointFactory {
public Breakpoint createBreakpoint(Project project, final Element element) {
return new ExceptionBreakpoint(project);
}
public Icon getIcon() {
return AllIcons.Debugger.Db_exception_breakpoint;
}
public Icon getDisabledIcon() {
return AllIcons.Debugger.Db_disabled_exception_breakpoint;
}
@Override
protected String getHelpID() {
return HelpID.EXCEPTION_BREAKPOINTS;
}
@Override
public String getDisplayName() {
return DebuggerBundle.message("exception.breakpoints.tab.title");
}
@Override
public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) {
return new ExceptionBreakpointPropertiesPanel(project, compact);
}
public Key<ExceptionBreakpoint> getBreakpointCategory() {
return ExceptionBreakpoint.CATEGORY;
}
@Override
public boolean canAddBreakpoints() {
return true;
}
@Override
public Breakpoint addBreakpoint(Project project) {
ExceptionBreakpoint breakpoint = null;
final PsiClass throwableClass =
JavaPsiFacade.getInstance(project).findClass("java.lang.Throwable", GlobalSearchScope.allScope(project));
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project)
.createInheritanceClassChooser(DebuggerBundle.message("add.exception.breakpoint.classchooser.title"),
GlobalSearchScope.allScope(project), throwableClass, true, true, null);
chooser.showDialog();
PsiClass selectedClass = chooser.getSelected();
String qName = selectedClass == null ? null : JVMNameUtil.getNonAnonymousClassName(selectedClass);
if (qName != null && qName.length() > 0) {
breakpoint = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager()
.addExceptionBreakpoint(qName, ((PsiClassOwner)selectedClass.getContainingFile()).getPackageName());
}
return breakpoint;
}
}
@@ -21,31 +21,34 @@
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.ide.util.ClassFilter;
import com.intellij.openapi.project.Project;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.util.ui.DialogUtil;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpointProperties;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ExceptionBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
public class ExceptionBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPanel<XBreakpoint<JavaExceptionBreakpointProperties>> {
private JCheckBox myNotifyCaughtCheckBox;
private JCheckBox myNotifyUncaughtCheckBox;
private ExceptionBreakpoint myExceptionBreakpoint;
//private ExceptionBreakpoint myExceptionBreakpoint;
public ExceptionBreakpointPropertiesPanel(Project project, boolean compact) {
super(project, ExceptionBreakpoint.CATEGORY, compact);
}
//public ExceptionBreakpointPropertiesPanel(Project project, boolean compact) {
// super(project, ExceptionBreakpoint.CATEGORY, compact);
//}
protected ClassFilter createClassConditionFilter() {
return null;
}
protected JComponent createSpecialBox() {
//protected ClassFilter createClassConditionFilter() {
// return null;
//}
@NotNull
@Override
public JComponent getComponent() {
myNotifyCaughtCheckBox = new JCheckBox(DebuggerBundle.message("label.exception.breakpoint.properties.panel.caught.exception"));
myNotifyUncaughtCheckBox = new JCheckBox(DebuggerBundle.message("label.exception.breakpoint.properties.panel.uncaught.exception"));
DialogUtil.registerMnemonic(myNotifyCaughtCheckBox);
@@ -91,25 +94,20 @@ public class ExceptionBreakpointPropertiesPanel extends BreakpointPropertiesPane
return _panel;
}
protected void updateCheckboxes() {
super.updateCheckboxes();
myPassCountCheckbox.setEnabled(!(myExceptionBreakpoint instanceof AnyExceptionBreakpoint));
//protected void updateCheckboxes() {
// super.updateCheckboxes();
// myPassCountCheckbox.setEnabled(!(myExceptionBreakpoint instanceof AnyExceptionBreakpoint));
//}
@Override
public void loadFrom(@NotNull XBreakpoint<JavaExceptionBreakpointProperties> breakpoint) {
myNotifyCaughtCheckBox.setSelected(breakpoint.getProperties().NOTIFY_CAUGHT);
myNotifyUncaughtCheckBox.setSelected(breakpoint.getProperties().NOTIFY_UNCAUGHT);
}
public void initFrom(Breakpoint breakpoint, boolean moreOptionsVisible) {
ExceptionBreakpoint exceptionBreakpoint = (ExceptionBreakpoint)breakpoint;
myExceptionBreakpoint = exceptionBreakpoint;
super.initFrom(breakpoint, moreOptionsVisible);
myNotifyCaughtCheckBox.setSelected(exceptionBreakpoint.NOTIFY_CAUGHT);
myNotifyUncaughtCheckBox.setSelected(exceptionBreakpoint.NOTIFY_UNCAUGHT);
}
public void saveTo(Breakpoint breakpoint) {
ExceptionBreakpoint exceptionBreakpoint = (ExceptionBreakpoint)breakpoint;
exceptionBreakpoint.NOTIFY_CAUGHT = myNotifyCaughtCheckBox.isSelected();
exceptionBreakpoint.NOTIFY_UNCAUGHT = myNotifyUncaughtCheckBox.isSelected();
super.saveTo(breakpoint);
@Override
public void saveTo(@NotNull XBreakpoint<JavaExceptionBreakpointProperties> breakpoint) {
breakpoint.getProperties().NOTIFY_CAUGHT = myNotifyCaughtCheckBox.isSelected();
breakpoint.getProperties().NOTIFY_UNCAUGHT = myNotifyUncaughtCheckBox.isSelected();
}
}
@@ -33,19 +33,17 @@ import com.intellij.icons.AllIcons;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizerUtil;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.Processor;
import com.intellij.util.text.CharArrayUtil;
import com.intellij.xdebugger.XDebuggerUtil;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.sun.jdi.*;
import com.sun.jdi.event.AccessWatchpointEvent;
import com.sun.jdi.event.LocatableEvent;
@@ -55,26 +53,23 @@ import com.sun.jdi.request.ModificationWatchpointRequest;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.java.debugger.breakpoints.properties.JavaFieldBreakpointProperties;
import javax.swing.*;
import java.util.List;
public class FieldBreakpoint extends BreakpointWithHighlighter {
public class FieldBreakpoint extends BreakpointWithHighlighter<JavaFieldBreakpointProperties> {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.breakpoints.FieldBreakpoint");
public boolean WATCH_MODIFICATION = true;
public boolean WATCH_ACCESS = false;
private boolean myIsStatic;
private String myFieldName;
@NonNls public static final Key<FieldBreakpoint> CATEGORY = BreakpointCategory.lookup("field_breakpoints");
protected FieldBreakpoint(Project project) {
super(project);
protected FieldBreakpoint(Project project, XBreakpoint breakpoint) {
super(project, breakpoint);
}
private FieldBreakpoint(Project project, RangeHighlighter highlighter, @NotNull String fieldName) {
super(project, highlighter);
myFieldName = fieldName;
private FieldBreakpoint(Project project, @NotNull String fieldName, XBreakpoint breakpoint) {
super(project, breakpoint);
setFieldName(fieldName);
}
public boolean isStatic() {
@@ -82,10 +77,9 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
}
public String getFieldName() {
return myFieldName;
return getProperties().myFieldName;
}
@Override
protected Icon getDisabledIcon(boolean isMuted) {
final Breakpoint master = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().findMasterBreakpoint(this);
@@ -128,7 +122,7 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
@Override
public PsiField compute() {
final PsiClass psiClass = getPsiClassAt(sourcePosition);
return psiClass != null ? psiClass.findFieldByName(myFieldName, true) : null;
return psiClass != null ? psiClass.findFieldByName(getFieldName(), true) : null;
}
});
if (field != null) {
@@ -142,11 +136,15 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
super.reload(psiFile);
PsiField field = PositionUtil.getPsiElementAt(getProject(), PsiField.class, getSourcePosition());
if(field != null) {
myFieldName = field.getName();
setFieldName(field.getName());
PsiClass psiClass = field.getContainingClass();
if (psiClass != null) {
getProperties().myClassName = psiClass.getQualifiedName();
}
myIsStatic = field.hasModifierProperty(PsiModifier.STATIC);
}
if (myIsStatic) {
INSTANCE_FILTERS_ENABLED = false;
setInstanceFiltersEnabled(false);
}
}
@@ -181,20 +179,21 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
ReferenceType refType) {
VirtualMachineProxy vm = debugProcess.getVirtualMachineProxy();
try {
Field field = refType.fieldByName(myFieldName);
Field field = refType.fieldByName(getFieldName());
if (field == null) {
debugProcess.getRequestsManager().setInvalid(this, DebuggerBundle.message("error.invalid.breakpoint.missing.field.in.class", myFieldName, refType.name()));
debugProcess.getRequestsManager().setInvalid(this, DebuggerBundle.message("error.invalid.breakpoint.missing.field.in.class",
getFieldName(), refType.name()));
return;
}
RequestManagerImpl manager = debugProcess.getRequestsManager();
if (WATCH_MODIFICATION && vm.canWatchFieldModification()) {
if (isWatchModification() && vm.canWatchFieldModification()) {
ModificationWatchpointRequest request = manager.createModificationWatchpointRequest(this, field);
debugProcess.getRequestsManager().enableRequest(request);
if (LOG.isDebugEnabled()) {
LOG.debug("Modification request added");
}
}
if (WATCH_ACCESS && vm.canWatchFieldAccess()) {
if (isWatchAccess() && vm.canWatchFieldAccess()) {
AccessWatchpointRequest request = manager.createAccessWatchpointRequest(this, field);
debugProcess.getRequestsManager().enableRequest(request);
if (LOG.isDebugEnabled()) {
@@ -284,11 +283,11 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
return DebuggerBundle.message("status.breakpoint.invalid");
}
final String className = getClassName();
return className != null && !className.isEmpty() ? className + "." + myFieldName : myFieldName;
return className != null && !className.isEmpty() ? className + "." + getFieldName() : getFieldName();
}
public static FieldBreakpoint create(@NotNull Project project, @NotNull Document document, int lineIndex, String fieldName) {
FieldBreakpoint breakpoint = new FieldBreakpoint(project, createHighlighter(project, document, lineIndex), fieldName);
public static FieldBreakpoint create(@NotNull Project project, String fieldName, XBreakpoint xBreakpoint) {
FieldBreakpoint breakpoint = new FieldBreakpoint(project, fieldName, xBreakpoint);
return (FieldBreakpoint)breakpoint.init();
}
@@ -308,39 +307,39 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
return field == getPsiField();
}
protected static FieldBreakpoint create(@NotNull Project project, @NotNull Field field, ObjectReference object) {
String fieldName = field.name();
int line = 0;
Document document = null;
try {
List locations = field.declaringType().allLineLocations();
if(!locations.isEmpty()) {
Location location = (Location)locations.get(0);
line = location.lineNumber();
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(location.sourcePath());
if(file != null) {
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if(psiFile != null) {
document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
}
}
}
}
catch (AbsentInformationException e) {
LOG.debug(e);
}
catch (InternalError e) {
LOG.debug(e);
}
if(document == null) return null;
FieldBreakpoint fieldBreakpoint = new FieldBreakpoint(project, createHighlighter(project, document, line), fieldName);
if (!fieldBreakpoint.isStatic()) {
fieldBreakpoint.addInstanceFilter(object.uniqueID());
}
return (FieldBreakpoint)fieldBreakpoint.init();
}
//protected static FieldBreakpoint create(@NotNull Project project, @NotNull Field field, ObjectReference object, XBreakpoint xBreakpoint) {
// String fieldName = field.name();
// int line = 0;
// Document document = null;
// try {
// List locations = field.declaringType().allLineLocations();
// if(!locations.isEmpty()) {
// Location location = (Location)locations.get(0);
// line = location.lineNumber();
// VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(location.sourcePath());
// if(file != null) {
// PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
// if(psiFile != null) {
// document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
// }
// }
// }
// }
// catch (AbsentInformationException e) {
// LOG.debug(e);
// }
// catch (InternalError e) {
// LOG.debug(e);
// }
//
// if(document == null) return null;
//
// FieldBreakpoint fieldBreakpoint = new FieldBreakpoint(project, createHighlighter(project, document, line), fieldName, xBreakpoint);
// if (!fieldBreakpoint.isStatic()) {
// fieldBreakpoint.addInstanceFilter(object.uniqueID());
// }
// return (FieldBreakpoint)fieldBreakpoint.init();
//}
public static PsiField findField(Project project, Document document, int offset) {
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
@@ -373,21 +372,41 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
public void readExternal(@NotNull Element breakpointNode) throws InvalidDataException {
super.readExternal(breakpointNode);
//noinspection HardCodedStringLiteral
myFieldName = breakpointNode.getAttributeValue("field_name");
if(myFieldName == null) {
setFieldName(breakpointNode.getAttributeValue("field_name"));
if(getFieldName() == null) {
throw new InvalidDataException("No field name for field breakpoint");
}
try {
getProperties().WATCH_MODIFICATION = Boolean.valueOf(JDOMExternalizerUtil.readField(breakpointNode, "WATCH_MODIFICATION"));
} catch (Exception e) {
}
try {
getProperties().WATCH_ACCESS = Boolean.valueOf(JDOMExternalizerUtil.readField(breakpointNode, "WATCH_ACCESS"));
} catch (Exception e) {
}
}
@Override
@SuppressWarnings({"HardCodedStringLiteral"})
public void writeExternal(@NotNull Element parentNode) throws WriteExternalException {
super.writeExternal(parentNode);
parentNode.setAttribute("field_name", getFieldName());
}
//
//@Override
//@SuppressWarnings({"HardCodedStringLiteral"})
//public void writeExternal(@NotNull Element parentNode) throws WriteExternalException {
// super.writeExternal(parentNode);
// parentNode.setAttribute("field_name", getFieldName());
//}
@Override
public PsiElement getEvaluationElement() {
return getPsiClass();
}
private boolean isWatchModification() {
return getProperties().WATCH_MODIFICATION;
}
private boolean isWatchAccess() {
return getProperties().WATCH_ACCESS;
}
private void setFieldName(String fieldName) {
getProperties().myFieldName = fieldName;
}
}
@@ -1,127 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.CommonBundle;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.HelpID;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Ref;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import org.jdom.Element;
import javax.swing.*;
/**
* @author Eugene Zhuravlev
* Date: Apr 26, 2005
*/
public class FieldBreakpointFactory extends BreakpointFactory{
public Breakpoint createBreakpoint(Project project, final Element element) {
return new FieldBreakpoint(project);
}
public Icon getIcon() {
return AllIcons.Debugger.Db_field_breakpoint;
}
public Icon getDisabledIcon() {
return AllIcons.Debugger.Db_disabled_field_breakpoint;
}
@Override
protected String getHelpID() {
return HelpID.FIELD_WATCHPOINTS;
}
@Override
public String getDisplayName() {
return DebuggerBundle.message("field.watchpoints.tab.title");
}
@Override
public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) {
return new FieldBreakpointPropertiesPanel(project, compact);
}
public Key<FieldBreakpoint> getBreakpointCategory() {
return FieldBreakpoint.CATEGORY;
}
@Override
public Breakpoint addBreakpoint(final Project project) {
final Ref<Breakpoint> result = Ref.create(null);
AddFieldBreakpointDialog dialog = new AddFieldBreakpointDialog(project) {
protected boolean validateData() {
String className = getClassName();
if (className.length() == 0) {
Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.class.name.not.specified"),
DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon());
return false;
}
String fieldName = getFieldName();
if (fieldName.length() == 0) {
Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.field.name.not.specified"),
DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon());
return false;
}
PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(className, GlobalSearchScope.allScope(project));
if (psiClass != null) {
PsiFile psiFile = psiClass.getContainingFile();
Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
if(document != null) {
PsiField field = psiClass.findFieldByName(fieldName, true);
if(field != null) {
int line = document.getLineNumber(field.getTextOffset());
FieldBreakpoint fieldBreakpoint = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().addFieldBreakpoint(document, line, fieldName);
if (fieldBreakpoint != null) {
result.set(fieldBreakpoint);
return true;
}
}
else {
Messages.showMessageDialog(project,
DebuggerBundle.message("error.field.breakpoint.field.not.found", className, fieldName, fieldName),
CommonBundle.getErrorTitle(),
Messages.getErrorIcon()
);
}
}
} else {
Messages.showMessageDialog(project,
DebuggerBundle.message("error.field.breakpoint.class.sources.not.found", className, fieldName, className),
CommonBundle.getErrorTitle(),
Messages.getErrorIcon()
);
}
return false;
}
};
dialog.show();
return result.get();
}
@Override
public boolean canAddBreakpoints() {
return true;
}
}
@@ -21,24 +21,30 @@
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.openapi.project.Project;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.util.ui.DialogUtil;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.java.debugger.breakpoints.properties.JavaFieldBreakpointProperties;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class FieldBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
public class FieldBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPanel<XLineBreakpoint<JavaFieldBreakpointProperties>> {
private JCheckBox myWatchAccessCheckBox;
private JCheckBox myWatchModificationCheckBox;
public FieldBreakpointPropertiesPanel(final Project project, boolean compact) {
super(project, FieldBreakpoint.CATEGORY, compact);
}
//public FieldBreakpointPropertiesPanel(final Project project, boolean compact) {
// super(project, FieldBreakpoint.CATEGORY, compact);
//}
protected JComponent createSpecialBox() {
@NotNull
@Override
public JComponent getComponent() {
JPanel _panel;
JPanel _panel0;
myWatchAccessCheckBox = new JCheckBox(DebuggerBundle.message("label.filed.breakpoint.properties.panel.field.access"));
@@ -86,20 +92,15 @@ public class FieldBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
return _panel;
}
public void initFrom(Breakpoint breakpoint, boolean moreOptionsVisible) {
super.initFrom(breakpoint, moreOptionsVisible);
FieldBreakpoint fieldBreakpoint = (FieldBreakpoint)breakpoint;
myWatchAccessCheckBox.setSelected(fieldBreakpoint.WATCH_ACCESS);
myWatchModificationCheckBox.setSelected(fieldBreakpoint.WATCH_MODIFICATION);
@Override
public void loadFrom(@NotNull XLineBreakpoint<JavaFieldBreakpointProperties> breakpoint) {
myWatchAccessCheckBox.setSelected(breakpoint.getProperties().WATCH_ACCESS);
myWatchModificationCheckBox.setSelected(breakpoint.getProperties().WATCH_MODIFICATION);
}
public void saveTo(Breakpoint breakpoint) {
FieldBreakpoint fieldBreakpoint = (FieldBreakpoint)breakpoint;
fieldBreakpoint.WATCH_ACCESS = myWatchAccessCheckBox.isSelected();
fieldBreakpoint.WATCH_MODIFICATION = myWatchModificationCheckBox.isSelected();
super.saveTo(breakpoint);
@Override
public void saveTo(@NotNull XLineBreakpoint<JavaFieldBreakpointProperties> breakpoint) {
breakpoint.getProperties().WATCH_ACCESS = myWatchAccessCheckBox.isSelected();
breakpoint.getProperties().WATCH_MODIFICATION = myWatchModificationCheckBox.isSelected();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,250 +13,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* class FilteredRequestor
* @author Jeka
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.*;
import com.intellij.debugger.engine.ContextUtil;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.evaluation.*;
import com.intellij.debugger.engine.evaluation.expression.EvaluatorBuilderImpl;
import com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator;
import com.intellij.debugger.InstanceFilter;
import com.intellij.debugger.engine.requests.LocatableEventRequestor;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.*;
import com.intellij.psi.PsiElement;
import com.intellij.ui.classFilter.ClassFilter;
import com.sun.jdi.BooleanValue;
import com.sun.jdi.ObjectReference;
import com.sun.jdi.VMDisconnectedException;
import com.sun.jdi.Value;
import com.sun.jdi.event.LocatableEvent;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
/**
* @author egor
*/
public interface FilteredRequestor extends LocatableEventRequestor {
String getSuspendPolicy();
public abstract class FilteredRequestor implements LocatableEventRequestor, JDOMExternalizable {
boolean isInstanceFiltersEnabled();
InstanceFilter[] getInstanceFilters();
public String SUSPEND_POLICY = DebuggerSettings.SUSPEND_ALL;
public boolean SUSPEND = true;
boolean isCountFilterEnabled();
int getCountFilter();
public boolean COUNT_FILTER_ENABLED = false;
public int COUNT_FILTER = 0;
public boolean CONDITION_ENABLED = false;
private TextWithImports myCondition;
public boolean CLASS_FILTERS_ENABLED = false;
private ClassFilter[] myClassFilters = ClassFilter.EMPTY_ARRAY;
private ClassFilter[] myClassExclusionFilters = ClassFilter.EMPTY_ARRAY;
public boolean INSTANCE_FILTERS_ENABLED = false;
private InstanceFilter[] myInstanceFilters = InstanceFilter.EMPTY_ARRAY;
@NonNls private static final String FILTER_OPTION_NAME = "filter";
@NonNls private static final String EXCLUSION_FILTER_OPTION_NAME = "exclusion_filter";
@NonNls private static final String INSTANCE_ID_OPTION_NAME = "instance_id";
@NonNls private static final String CONDITION_OPTION_NAME = "CONDITION";
protected final Project myProject;
public FilteredRequestor(@NotNull Project project) {
myProject = project;
myCondition = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, "");
}
public InstanceFilter[] getInstanceFilters() {
return myInstanceFilters;
}
public void setInstanceFilters(InstanceFilter[] instanceFilters) {
myInstanceFilters = instanceFilters != null? instanceFilters : InstanceFilter.EMPTY_ARRAY;
}
public String getSuspendPolicy() {
return SUSPEND? SUSPEND_POLICY : DebuggerSettings.SUSPEND_NONE;
}
/**
* @return true if the ID was added or false otherwise
*/
private boolean hasObjectID(long id) {
for (InstanceFilter instanceFilter : myInstanceFilters) {
if (instanceFilter.getId() == id) {
return true;
}
}
return false;
}
protected void addInstanceFilter(long l) {
final InstanceFilter[] filters = new InstanceFilter[myInstanceFilters.length + 1];
System.arraycopy(myInstanceFilters, 0, filters, 0, myInstanceFilters.length);
filters[myInstanceFilters.length] = InstanceFilter.create(String.valueOf(l));
myInstanceFilters = filters;
}
public final ClassFilter[] getClassFilters() {
return myClassFilters;
}
public final void setClassFilters(ClassFilter[] classFilters) {
myClassFilters = classFilters != null? classFilters : ClassFilter.EMPTY_ARRAY;
}
public ClassFilter[] getClassExclusionFilters() {
return myClassExclusionFilters;
}
public void setClassExclusionFilters(ClassFilter[] classExclusionFilters) {
myClassExclusionFilters = classExclusionFilters != null? classExclusionFilters : ClassFilter.EMPTY_ARRAY;
}
public void readExternal(Element parentNode) throws InvalidDataException {
DefaultJDOMExternalizer.readExternal(this, parentNode);
if (DebuggerSettings.SUSPEND_NONE.equals(SUSPEND_POLICY)) { // compatibility with older format
SUSPEND = false;
SUSPEND_POLICY = DebuggerSettings.SUSPEND_ALL;
}
String condition = JDOMExternalizerUtil.readField(parentNode, CONDITION_OPTION_NAME);
if (condition != null) {
setCondition(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, condition));
}
myClassFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(FILTER_OPTION_NAME));
myClassExclusionFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(EXCLUSION_FILTER_OPTION_NAME));
final ClassFilter [] instanceFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(INSTANCE_ID_OPTION_NAME));
final List<InstanceFilter> iFilters = new ArrayList<InstanceFilter>(instanceFilters.length);
for (ClassFilter instanceFilter : instanceFilters) {
try {
iFilters.add(InstanceFilter.create(instanceFilter));
}
catch (Exception e) {
}
}
myInstanceFilters = iFilters.isEmpty() ? InstanceFilter.EMPTY_ARRAY : iFilters.toArray(new InstanceFilter[iFilters.size()]);
}
public void writeExternal(Element parentNode) throws WriteExternalException {
DefaultJDOMExternalizer.writeExternal(this, parentNode);
JDOMExternalizerUtil.writeField(parentNode, CONDITION_OPTION_NAME, getCondition().toExternalForm());
DebuggerUtilsEx.writeFilters(parentNode, FILTER_OPTION_NAME, myClassFilters);
DebuggerUtilsEx.writeFilters(parentNode, EXCLUSION_FILTER_OPTION_NAME, myClassExclusionFilters);
DebuggerUtilsEx.writeFilters(parentNode, INSTANCE_ID_OPTION_NAME, InstanceFilter.createClassFilters(myInstanceFilters));
}
public boolean evaluateCondition(final EvaluationContextImpl context, LocatableEvent event) throws EvaluateException {
if(COUNT_FILTER_ENABLED) {
final DebugProcessImpl debugProcess = context.getDebugProcess();
debugProcess.getVirtualMachineProxy().suspend();
debugProcess.getRequestsManager().deleteRequest(this);
((Breakpoint)this).createRequest(debugProcess);
debugProcess.getVirtualMachineProxy().resume();
}
if (INSTANCE_FILTERS_ENABLED) {
Value value = context.getThisObject();
if (value != null) { // non-static
ObjectReference reference = (ObjectReference)value;
if(!hasObjectID(reference.uniqueID())) {
return false;
}
}
}
if (CLASS_FILTERS_ENABLED) {
String typeName = calculateEventClass(context, event);
if (!typeMatchesClassFilters(typeName)) return false;
}
if (CONDITION_ENABLED && getCondition() != null && !"".equals(getCondition().getText())) {
try {
ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(context.getProject(), new EvaluatingComputable<ExpressionEvaluator>() {
public ExpressionEvaluator compute() throws EvaluateException {
final SourcePosition contextSourcePosition = ContextUtil.getSourcePosition(context);
// IMPORTANT: calculate context psi element basing on the location where the exception
// has been hit, not on the location where it was set. (For line breakpoints these locations are the same, however,
// for method, exception and field breakpoints these locations differ)
PsiElement contextPsiElement = ContextUtil.getContextElement(contextSourcePosition);
if (contextPsiElement == null) {
contextPsiElement = getEvaluationElement(); // as a last resort
}
return EvaluatorBuilderImpl.build(getCondition(), contextPsiElement, contextSourcePosition);
}
});
final Value value = evaluator.evaluate(context);
if (!(value instanceof BooleanValue)) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.boolean.expected"));
}
if(!((BooleanValue)value).booleanValue()) {
return false;
}
}
catch (EvaluateException ex) {
if(ex.getCause() instanceof VMDisconnectedException) {
return false;
}
throw EvaluateExceptionUtil.createEvaluateException(
DebuggerBundle.message("error.failed.evaluating.breakpoint.condition", getCondition(), ex.getMessage())
);
}
return true;
}
return true;
}
protected String calculateEventClass(EvaluationContextImpl context, LocatableEvent event) throws EvaluateException {
return event.location().declaringType().name();
}
private boolean typeMatchesClassFilters(@Nullable String typeName) {
if (typeName == null) {
return true;
}
boolean matches = false, hasEnabled = false;
for (ClassFilter classFilter : getClassFilters()) {
if (classFilter.isEnabled()) {
hasEnabled = true;
if (classFilter.matches(typeName)) {
matches = true;
break;
}
}
}
if(hasEnabled && !matches) {
return false;
}
for (ClassFilter classFilter : getClassExclusionFilters()) {
if (classFilter.isEnabled() && classFilter.matches(typeName)) {
return false;
}
}
return true;
}
public abstract PsiElement getEvaluationElement();
public TextWithImports getCondition() {
return myCondition;
}
public void setCondition(TextWithImports condition) {
myCondition = condition;
}
public Project getProject() {
return myProject;
}
boolean isClassFiltersEnabled();
ClassFilter[] getClassFilters();
ClassFilter[] getClassExclusionFilters();
}
@@ -0,0 +1,243 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* class FilteredRequestorImpl
* @author Jeka
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.InstanceFilter;
import com.intellij.debugger.engine.evaluation.*;
import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.*;
import com.intellij.psi.PsiElement;
import com.intellij.ui.classFilter.ClassFilter;
import com.sun.jdi.event.LocatableEvent;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
/*
* Not used any more, since move to xBreakpoints
*/
public class FilteredRequestorImpl implements JDOMExternalizable, FilteredRequestor {
public String SUSPEND_POLICY = DebuggerSettings.SUSPEND_ALL;
public boolean SUSPEND = true;
public boolean COUNT_FILTER_ENABLED = false;
public int COUNT_FILTER = 0;
public boolean CONDITION_ENABLED = false;
private TextWithImports myCondition;
public boolean CLASS_FILTERS_ENABLED = false;
private ClassFilter[] myClassFilters = ClassFilter.EMPTY_ARRAY;
private ClassFilter[] myClassExclusionFilters = ClassFilter.EMPTY_ARRAY;
public boolean INSTANCE_FILTERS_ENABLED = false;
private InstanceFilter[] myInstanceFilters = InstanceFilter.EMPTY_ARRAY;
@NonNls private static final String FILTER_OPTION_NAME = "filter";
@NonNls private static final String EXCLUSION_FILTER_OPTION_NAME = "exclusion_filter";
@NonNls private static final String INSTANCE_ID_OPTION_NAME = "instance_id";
@NonNls private static final String CONDITION_OPTION_NAME = "CONDITION";
protected final Project myProject;
public FilteredRequestorImpl(@NotNull Project project) {
myProject = project;
myCondition = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, "");
}
public InstanceFilter[] getInstanceFilters() {
return myInstanceFilters;
}
public void setInstanceFilters(InstanceFilter[] instanceFilters) {
myInstanceFilters = instanceFilters != null? instanceFilters : InstanceFilter.EMPTY_ARRAY;
}
public String getSuspendPolicy() {
return SUSPEND? SUSPEND_POLICY : DebuggerSettings.SUSPEND_NONE;
}
/**
* @return true if the ID was added or false otherwise
*/
private boolean hasObjectID(long id) {
for (InstanceFilter instanceFilter : myInstanceFilters) {
if (instanceFilter.getId() == id) {
return true;
}
}
return false;
}
protected void addInstanceFilter(long l) {
final InstanceFilter[] filters = new InstanceFilter[myInstanceFilters.length + 1];
System.arraycopy(myInstanceFilters, 0, filters, 0, myInstanceFilters.length);
filters[myInstanceFilters.length] = InstanceFilter.create(String.valueOf(l));
myInstanceFilters = filters;
}
public final ClassFilter[] getClassFilters() {
return myClassFilters;
}
public final void setClassFilters(ClassFilter[] classFilters) {
myClassFilters = classFilters != null? classFilters : ClassFilter.EMPTY_ARRAY;
}
public ClassFilter[] getClassExclusionFilters() {
return myClassExclusionFilters;
}
public void setClassExclusionFilters(ClassFilter[] classExclusionFilters) {
myClassExclusionFilters = classExclusionFilters != null? classExclusionFilters : ClassFilter.EMPTY_ARRAY;
}
public void readTo(Element parentNode, Breakpoint breakpoint) throws InvalidDataException {
readExternal(parentNode);
if (SUSPEND) {
breakpoint.setSuspendPolicy(SUSPEND_POLICY);
}
else {
breakpoint.setSuspendPolicy(DebuggerSettings.SUSPEND_NONE);
}
breakpoint.setCountFilterEnabled(COUNT_FILTER_ENABLED);
breakpoint.setCountFilter(COUNT_FILTER);
breakpoint.setCondition(CONDITION_ENABLED && myCondition != null && !myCondition.getText().isEmpty() ? myCondition.getText() : null);
breakpoint.setClassFiltersEnabled(CLASS_FILTERS_ENABLED);
breakpoint.setClassFilters(getClassFilters());
breakpoint.setClassExclusionFilters(getClassExclusionFilters());
breakpoint.setInstanceFiltersEnabled(INSTANCE_FILTERS_ENABLED);
breakpoint.setInstanceFilters(getInstanceFilters());
}
public void readExternal(Element parentNode) throws InvalidDataException {
DefaultJDOMExternalizer.readExternal(this, parentNode);
if (DebuggerSettings.SUSPEND_NONE.equals(SUSPEND_POLICY)) { // compatibility with older format
SUSPEND = false;
SUSPEND_POLICY = DebuggerSettings.SUSPEND_ALL;
}
String condition = JDOMExternalizerUtil.readField(parentNode, CONDITION_OPTION_NAME);
if (condition != null) {
setCondition(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, condition));
}
myClassFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(FILTER_OPTION_NAME));
myClassExclusionFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(EXCLUSION_FILTER_OPTION_NAME));
final ClassFilter [] instanceFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(INSTANCE_ID_OPTION_NAME));
final List<InstanceFilter> iFilters = new ArrayList<InstanceFilter>(instanceFilters.length);
for (ClassFilter instanceFilter : instanceFilters) {
try {
iFilters.add(InstanceFilter.create(instanceFilter));
}
catch (Exception e) {
}
}
myInstanceFilters = iFilters.isEmpty() ? InstanceFilter.EMPTY_ARRAY : iFilters.toArray(new InstanceFilter[iFilters.size()]);
}
public void writeExternal(Element parentNode) throws WriteExternalException {
DefaultJDOMExternalizer.writeExternal(this, parentNode);
JDOMExternalizerUtil.writeField(parentNode, CONDITION_OPTION_NAME, getCondition().toExternalForm());
DebuggerUtilsEx.writeFilters(parentNode, FILTER_OPTION_NAME, myClassFilters);
DebuggerUtilsEx.writeFilters(parentNode, EXCLUSION_FILTER_OPTION_NAME, myClassExclusionFilters);
DebuggerUtilsEx.writeFilters(parentNode, INSTANCE_ID_OPTION_NAME, InstanceFilter.createClassFilters(myInstanceFilters));
}
protected String calculateEventClass(EvaluationContextImpl context, LocatableEvent event) throws EvaluateException {
return event.location().declaringType().name();
}
private boolean typeMatchesClassFilters(@Nullable String typeName) {
if (typeName == null) {
return true;
}
boolean matches = false, hasEnabled = false;
for (ClassFilter classFilter : getClassFilters()) {
if (classFilter.isEnabled()) {
hasEnabled = true;
if (classFilter.matches(typeName)) {
matches = true;
break;
}
}
}
if(hasEnabled && !matches) {
return false;
}
for (ClassFilter classFilter : getClassExclusionFilters()) {
if (classFilter.isEnabled() && classFilter.matches(typeName)) {
return false;
}
}
return true;
}
public PsiElement getEvaluationElement() {
return null;
}
public TextWithImports getCondition() {
return myCondition;
}
public void setCondition(TextWithImports condition) {
myCondition = condition;
}
public Project getProject() {
return myProject;
}
public boolean isCountFilterEnabled() {
return COUNT_FILTER_ENABLED;
}
public int getCountFilter() {
return COUNT_FILTER;
}
public boolean isClassFiltersEnabled() {
return CLASS_FILTERS_ENABLED;
}
public boolean isInstanceFiltersEnabled() {
return INSTANCE_FILTERS_ENABLED;
}
@Override
public boolean processLocatableEvent(SuspendContextCommandImpl action, LocatableEvent event)
throws EventProcessingException {
return false;
}
}
@@ -1,184 +0,0 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.SourcePosition;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.SimpleColoredComponent;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.popup.util.DetailView;
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
class JavaBreakpointItem extends BreakpointItem {
private final Breakpoint myBreakpoint;
private BreakpointFactory myBreakpointFactory;
private BreakpointPropertiesPanel myBreakpointPropertiesPanel;
public JavaBreakpointItem(@Nullable BreakpointFactory breakpointFactory, Breakpoint breakpoint) {
myBreakpointFactory = breakpointFactory;
myBreakpoint = breakpoint;
}
@Override
public void setupGenericRenderer(SimpleColoredComponent renderer, boolean plainView) {
if (plainView) {
renderer.setIcon(myBreakpoint.getIcon());
}
renderer.append(plainView ? StringUtil.shortenTextWithEllipsis(myBreakpoint.getShortName(), 60, 0) : myBreakpoint.getDisplayName(),
isEnabled() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES);
}
@Override
public Icon getIcon() {
return myBreakpoint.getIcon();
}
@Override
public String getDisplayText() {
return myBreakpoint.getDisplayName();
}
@Override
public String speedSearchText() {
return myBreakpoint.getDisplayName();
}
@Override
public String footerText() {
return myBreakpoint.getDisplayName();
}
@Override
protected void doUpdateDetailView(DetailView panel, boolean editorOnly) {
//saveState();
if (myBreakpointPropertiesPanel != null) {
myBreakpointPropertiesPanel.dispose();
myBreakpointPropertiesPanel = null;
}
if (!editorOnly) {
myBreakpointPropertiesPanel = myBreakpointFactory != null ? myBreakpointFactory
.createBreakpointPropertiesPanel(myBreakpoint.getProject(), false) : null;
if (myBreakpointPropertiesPanel != null) {
myBreakpointPropertiesPanel.initFrom(myBreakpoint, true);
final JPanel mainPanel = myBreakpointPropertiesPanel.getPanel();
panel.setPropertiesPanel(mainPanel);
}
else {
panel.setPropertiesPanel(null);
}
}
if (myBreakpoint instanceof BreakpointWithHighlighter) {
SourcePosition sourcePosition = ((BreakpointWithHighlighter)myBreakpoint).getSourcePosition();
VirtualFile virtualFile = sourcePosition.getFile().getVirtualFile();
showInEditor(panel, virtualFile, sourcePosition.getLine());
} else {
panel.clearEditor();
}
if (myBreakpointPropertiesPanel != null) {
myBreakpointPropertiesPanel.setDetailView(panel);
}
}
@Override
public void navigate(boolean requestFocus) {
if (myBreakpoint instanceof BreakpointWithHighlighter) {
((BreakpointWithHighlighter)myBreakpoint).getSourcePosition().navigate(requestFocus);
}
}
@Override
public boolean canNavigate() {
return myBreakpoint instanceof BreakpointWithHighlighter && ((BreakpointWithHighlighter)myBreakpoint).getSourcePosition().canNavigate();
}
@Override
public boolean canNavigateToSource() {
return myBreakpoint instanceof BreakpointWithHighlighter &&
((BreakpointWithHighlighter)myBreakpoint).getSourcePosition().canNavigateToSource();
}
@Override
public boolean allowedToRemove() {
return myBreakpointFactory != null && myBreakpointFactory.breakpointCanBeRemoved(myBreakpoint);
}
@Override
public void removed(Project project) {
dispose();
DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().removeBreakpoint(myBreakpoint);
}
@Override
public void saveState() {
if (myBreakpointPropertiesPanel != null) {
myBreakpointPropertiesPanel.saveTo(myBreakpoint);
}
}
@Override
public Object getBreakpoint() {
return myBreakpoint;
}
@Override
public boolean isEnabled() {
return myBreakpoint.ENABLED;
}
@Override
public void setEnabled(boolean state) {
myBreakpoint.ENABLED = state;
myBreakpoint.updateUI();
DebuggerManagerEx.getInstanceEx(myBreakpoint.getProject()).getBreakpointManager().fireBreakpointChanged(myBreakpoint);
}
@Override
public boolean isDefaultBreakpoint() {
return myBreakpoint.getCategory().equals(ExceptionBreakpoint.CATEGORY);
}
@Override
protected void dispose() {
if (myBreakpointPropertiesPanel != null) {
myBreakpointPropertiesPanel.dispose();
myBreakpointPropertiesPanel = null;
}
}
@Override
public int compareTo(@NotNull BreakpointItem breakpointItem) {
final Object breakpoint = breakpointItem.getBreakpoint();
if (breakpoint instanceof Breakpoint) {
return -getIndexOf(myBreakpoint) + getIndexOf((Breakpoint)breakpoint);
}
return getDisplayText().compareTo(breakpointItem.getDisplayText());
}
private int getIndexOf(Breakpoint breakpoint) {
return DebuggerManagerEx.getInstanceEx(myBreakpoint.getProject()).getBreakpointManager().getBreakpoints().indexOf(breakpoint);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,17 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Class LineBreakpointPropertiesPanel
* @author Jeka
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.openapi.project.Project;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties;
public class LineBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
public LineBreakpointPropertiesPanel(Project project, boolean compact) {
super(project, LineBreakpoint.CATEGORY, compact);
}
}
/**
* Base class for all Java breakpoint types
* @author egor
*/
public interface JavaBreakpointType<P extends JavaBreakpointProperties> {
Breakpoint createJavaBreakpoint(Project project, XBreakpoint<P> breakpoint);
}
@@ -0,0 +1,56 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.openapi.project.Project;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.XBreakpointType;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.java.debugger.JavaDebuggerEditorsProvider;
import org.jetbrains.java.debugger.breakpoints.JavaBreakpointFiltersPanel;
import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties;
/**
* Base class for non-line java breakpoint
* @author egor
*/
public abstract class JavaBreakpointTypeBase<T extends JavaBreakpointProperties> extends XBreakpointType<XBreakpoint<T>, T> {
protected JavaBreakpointTypeBase(@NonNls @NotNull String id, @Nls @NotNull String title) {
super(id, title, true);
}
@Override
public final boolean isAddBreakpointButtonVisible() {
return true;
}
@Nullable
@Override
public final XBreakpointCustomPropertiesPanel<XBreakpoint<T>> createCustomRightPropertiesPanel(@NotNull Project project) {
return new JavaBreakpointFiltersPanel<T, XBreakpoint<T>>(project);
}
@Nullable
@Override
public final XDebuggerEditorsProvider getEditorsProvider(@NotNull XBreakpoint<T> breakpoint, @NotNull Project project) {
return new JavaDebuggerEditorsProvider();
}
}
@@ -0,0 +1,138 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.HelpID;
import com.intellij.debugger.engine.JVMNameUtil;
import com.intellij.icons.AllIcons;
import com.intellij.ide.util.TreeClassChooser;
import com.intellij.ide.util.TreeClassChooserFactory;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiClassOwner;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpointProperties;
import javax.swing.*;
/**
* @author Eugene Zhuravlev
* Date: Apr 26, 2005
*/
public class JavaExceptionBreakpointType extends JavaBreakpointTypeBase<JavaExceptionBreakpointProperties>
implements JavaBreakpointType<JavaExceptionBreakpointProperties> {
public JavaExceptionBreakpointType() {
super("java-exception", DebuggerBundle.message("exception.breakpoints.tab.title"));
}
@NotNull
@Override
public Icon getEnabledIcon() {
return AllIcons.Debugger.Db_exception_breakpoint;
}
@NotNull
@Override
public Icon getDisabledIcon() {
return AllIcons.Debugger.Db_disabled_exception_breakpoint;
}
//@Override
protected String getHelpID() {
return HelpID.EXCEPTION_BREAKPOINTS;
}
//@Override
public String getDisplayName() {
return DebuggerBundle.message("exception.breakpoints.tab.title");
}
@Override
public String getDisplayText(XBreakpoint<JavaExceptionBreakpointProperties> breakpoint) {
String name = breakpoint.getProperties().myQualifiedName;
if (name != null) {
return DebuggerBundle.message("breakpoint.exception.breakpoint.display.name", name);
}
else {
return DebuggerBundle.message("breakpoint.any.exception.display.name");
}
}
@Nullable
@Override
public JavaExceptionBreakpointProperties createProperties() {
return new JavaExceptionBreakpointProperties();
}
@Nullable
@Override
public XBreakpointCustomPropertiesPanel<XBreakpoint<JavaExceptionBreakpointProperties>> createCustomPropertiesPanel() {
return new ExceptionBreakpointPropertiesPanel();
}
@Nullable
@Override
public XBreakpoint<JavaExceptionBreakpointProperties> createDefaultBreakpoint(@NotNull XBreakpointCreator<JavaExceptionBreakpointProperties> creator) {
return creator.createBreakpoint(new JavaExceptionBreakpointProperties());
}
//public Key<ExceptionBreakpoint> getBreakpointCategory() {
// return ExceptionBreakpoint.CATEGORY;
//}
@Nullable
@Override
public XBreakpoint<JavaExceptionBreakpointProperties> addBreakpoint(final Project project, JComponent parentComponent) {
final PsiClass throwableClass =
JavaPsiFacade.getInstance(project).findClass("java.lang.Throwable", GlobalSearchScope.allScope(project));
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project)
.createInheritanceClassChooser(DebuggerBundle.message("add.exception.breakpoint.classchooser.title"),
GlobalSearchScope.allScope(project), throwableClass, true, true, null);
chooser.showDialog();
final PsiClass selectedClass = chooser.getSelected();
final String qName = selectedClass == null ? null : JVMNameUtil.getNonAnonymousClassName(selectedClass);
if (qName != null && qName.length() > 0) {
return ApplicationManager.getApplication().runWriteAction(new Computable<XBreakpoint<JavaExceptionBreakpointProperties>>() {
@Override
public XBreakpoint<JavaExceptionBreakpointProperties> compute() {
return XDebuggerManager.getInstance(project).getBreakpointManager().addBreakpoint(
JavaExceptionBreakpointType.this, new JavaExceptionBreakpointProperties(qName, ((PsiClassOwner)selectedClass.getContainingFile()).getPackageName()));
}
});
}
return null;
}
@Override
public Breakpoint createJavaBreakpoint(Project project, XBreakpoint<JavaExceptionBreakpointProperties> breakpoint) {
if (breakpoint.getProperties().myQualifiedName != null) {
return new ExceptionBreakpoint(project, breakpoint);
}
else {
return new AnyExceptionBreakpoint(project, breakpoint);
}
}
}
@@ -0,0 +1,167 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.CommonBundle;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.HelpID;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.java.debugger.breakpoints.properties.JavaFieldBreakpointProperties;
import javax.swing.*;
/**
* @author Eugene Zhuravlev
* Date: Apr 26, 2005
*/
public class JavaFieldBreakpointType extends JavaLineBreakpointTypeBase<JavaFieldBreakpointProperties> implements JavaBreakpointType {
public JavaFieldBreakpointType() {
super("java-field", DebuggerBundle.message("field.watchpoints.tab.title"));
}
@NotNull
@Override
public Icon getEnabledIcon() {
return AllIcons.Debugger.Db_field_breakpoint;
}
@NotNull
@Override
public Icon getDisabledIcon() {
return AllIcons.Debugger.Db_disabled_field_breakpoint;
}
//@Override
protected String getHelpID() {
return HelpID.FIELD_WATCHPOINTS;
}
//@Override
public String getDisplayName() {
return DebuggerBundle.message("field.watchpoints.tab.title");
}
@Override
public String getShortText(XLineBreakpoint<JavaFieldBreakpointProperties> breakpoint) {
return getDisplayText(breakpoint);
}
@Override
public String getDisplayText(XLineBreakpoint<JavaFieldBreakpointProperties> breakpoint) {
//if(!isValid()) {
// return DebuggerBundle.message("status.breakpoint.invalid");
//}
JavaFieldBreakpointProperties properties = breakpoint.getProperties();
final String className = properties.myClassName;
return className != null && !className.isEmpty() ? className + "." + properties.myFieldName : properties.myFieldName;
}
@Nullable
@Override
public XBreakpointCustomPropertiesPanel<XLineBreakpoint<JavaFieldBreakpointProperties>> createCustomPropertiesPanel() {
return new FieldBreakpointPropertiesPanel();
}
@Nullable
@Override
public JavaFieldBreakpointProperties createProperties() {
return new JavaFieldBreakpointProperties();
}
@Nullable
@Override
public JavaFieldBreakpointProperties createBreakpointProperties(@NotNull VirtualFile file, int line) {
return new JavaFieldBreakpointProperties();
}
@Nullable
@Override
public XLineBreakpoint<JavaFieldBreakpointProperties> addBreakpoint(final Project project, JComponent parentComponent) {
final Ref<XLineBreakpoint> result = Ref.create(null);
AddFieldBreakpointDialog dialog = new AddFieldBreakpointDialog(project) {
protected boolean validateData() {
final String className = getClassName();
if (className.length() == 0) {
Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.class.name.not.specified"),
DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon());
return false;
}
final String fieldName = getFieldName();
if (fieldName.length() == 0) {
Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.field.name.not.specified"),
DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon());
return false;
}
PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(className, GlobalSearchScope.allScope(project));
if (psiClass != null) {
final PsiFile psiFile = psiClass.getContainingFile();
Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
if(document != null) {
PsiField field = psiClass.findFieldByName(fieldName, true);
if(field != null) {
final int line = document.getLineNumber(field.getTextOffset());
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
XLineBreakpoint<JavaFieldBreakpointProperties> fieldBreakpoint = XDebuggerManager.getInstance(project).getBreakpointManager()
.addLineBreakpoint(JavaFieldBreakpointType.this, psiFile.getVirtualFile().getUrl(), line, new JavaFieldBreakpointProperties(fieldName, className));
result.set(fieldBreakpoint);
}
});
return true;
}
else {
Messages.showMessageDialog(project,
DebuggerBundle.message("error.field.breakpoint.field.not.found", className, fieldName, fieldName),
CommonBundle.getErrorTitle(),
Messages.getErrorIcon()
);
}
}
} else {
Messages.showMessageDialog(project,
DebuggerBundle.message("error.field.breakpoint.class.sources.not.found", className, fieldName, className),
CommonBundle.getErrorTitle(),
Messages.getErrorIcon()
);
}
return false;
}
};
dialog.show();
return result.get();
}
@Override
public Breakpoint createJavaBreakpoint(Project project, XBreakpoint breakpoint) {
return new FieldBreakpoint(project, breakpoint);
}
}
@@ -0,0 +1,87 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.HelpID;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.xdebugger.XDebuggerUtil;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties;
import org.jetbrains.java.debugger.breakpoints.properties.JavaLineBreakpointProperties;
import javax.swing.*;
import java.util.List;
/**
* Base class for java line-connected exceptions (line, method, field)
* @author egor
*/
public class JavaLineBreakpointType extends JavaLineBreakpointTypeBase<JavaBreakpointProperties> implements JavaBreakpointType {
public JavaLineBreakpointType() {
super("java-line", DebuggerBundle.message("line.breakpoints.tab.title"));
}
@NotNull
@Override
public Icon getEnabledIcon() {
return AllIcons.Debugger.Db_set_breakpoint;
}
@NotNull
@Override
public Icon getDisabledIcon() {
return AllIcons.Debugger.Db_disabled_breakpoint;
}
//@Override
protected String getHelpID() {
return HelpID.LINE_BREAKPOINTS;
}
//@Override
public String getDisplayName() {
return DebuggerBundle.message("line.breakpoints.tab.title");
}
@Override
public List<XBreakpointGroupingRule<XLineBreakpoint<JavaBreakpointProperties>, ?>> getGroupingRules() {
return XDebuggerUtil.getInstance().getGroupingByFileRuleAsList();
}
@Nullable
@Override
public JavaBreakpointProperties createProperties() {
return new JavaLineBreakpointProperties();
}
@Nullable
@Override
public JavaBreakpointProperties createBreakpointProperties(@NotNull VirtualFile file, int line) {
return new JavaLineBreakpointProperties();
}
@Override
public Breakpoint createJavaBreakpoint(Project project, XBreakpoint breakpoint) {
return new LineBreakpoint(project, breakpoint);
}
}
@@ -0,0 +1,140 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.engine.DebuggerUtils;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.Processor;
import com.intellij.xdebugger.XDebuggerUtil;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.intellij.xdebugger.breakpoints.XLineBreakpointType;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.java.debugger.JavaDebuggerEditorsProvider;
import org.jetbrains.java.debugger.breakpoints.JavaBreakpointFiltersPanel;
import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties;
/**
* Base class for java line-connected exceptions (line, method, field)
* @author egor
*/
public abstract class JavaLineBreakpointTypeBase<P extends JavaBreakpointProperties> extends XLineBreakpointType<P> {
public JavaLineBreakpointTypeBase(@NonNls @NotNull String id, @Nls @NotNull String title) {
super(id, title);
}
@Override
public boolean isAddBreakpointButtonVisible() {
return true;
}
@Override
public final boolean isSuspendThreadSupported() {
return true;
}
@Nullable
@Override
public final XBreakpointCustomPropertiesPanel<XLineBreakpoint<P>> createCustomRightPropertiesPanel(@NotNull Project project) {
return new JavaBreakpointFiltersPanel<P, XLineBreakpoint<P>>(project);
}
@Nullable
@Override
public final XDebuggerEditorsProvider getEditorsProvider(@NotNull XLineBreakpoint<P> breakpoint, @NotNull Project project) {
return new JavaDebuggerEditorsProvider();
}
@Override
public final boolean canPutAt(@NotNull VirtualFile file, final int line, @NotNull Project project) {
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
// JSPX supports jvm debugging, but not in XHTML files
if (psiFile == null || psiFile.getVirtualFile().getFileType() == StdFileTypes.XHTML) {
return false;
}
FileType fileType = psiFile.getFileType();
if (!StdFileTypes.CLASS.equals(fileType) &&
!DebuggerUtils.supportsJVMDebugging(fileType) &&
!DebuggerUtils.supportsJVMDebugging(psiFile)) {
return false;
}
final Document document = FileDocumentManager.getInstance().getDocument(file);
final Ref<Class<? extends JavaLineBreakpointTypeBase>> result = Ref.create();
XDebuggerUtil.getInstance().iterateLine(project, document, line, new Processor<PsiElement>() {
@Override
public boolean process(PsiElement element) {
// avoid comments
if ((element instanceof PsiWhiteSpace) || (PsiTreeUtil.getParentOfType(element, PsiComment.class, false) != null)) {
return true;
}
// first check fields
PsiField field = PsiTreeUtil.getParentOfType(element, PsiField.class, false);
if(field != null) {
result.set(JavaFieldBreakpointType.class);
return false;
}
// then methods
PsiMethod method = PsiTreeUtil.getParentOfType(element, PsiMethod.class, false);
if(method != null && document.getLineNumber(method.getTextOffset()) == line) {
result.set(JavaMethodBreakpointType.class);
return false;
}
// then regular statements
PsiElement child = element;
while(element != null) {
final int offset = element.getTextOffset();
if (offset >= 0) {
if (document.getLineNumber(offset) != line) {
break;
}
}
child = element;
element = element.getParent();
}
if(child instanceof PsiMethod && child.getTextRange().getEndOffset() >= document.getLineEndOffset(line)) {
PsiCodeBlock body = ((PsiMethod)child).getBody();
if(body != null) {
PsiStatement[] statements = body.getStatements();
if (statements.length > 0 && document.getLineNumber(statements[0].getTextOffset()) == line) {
result.set(JavaLineBreakpointType.class);
}
}
}
else {
result.set(JavaLineBreakpointType.class);
}
return true;
}
});
return result.get() == getClass();
}
}
@@ -0,0 +1,127 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.HelpID;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties;
import javax.swing.*;
/**
* @author Eugene Zhuravlev
* Date: Apr 26, 2005
*/
public class JavaMethodBreakpointType extends JavaLineBreakpointTypeBase<JavaMethodBreakpointProperties> implements JavaBreakpointType {
public JavaMethodBreakpointType() {
super("java-method", DebuggerBundle.message("method.breakpoints.tab.title"));
}
@NotNull
@Override
public Icon getEnabledIcon() {
return AllIcons.Debugger.Db_method_breakpoint;
}
@NotNull
@Override
public Icon getDisabledIcon() {
return AllIcons.Debugger.Db_disabled_method_breakpoint;
}
//@Override
protected String getHelpID() {
return HelpID.METHOD_BREAKPOINTS;
}
@Override
public boolean isAddBreakpointButtonVisible() {
return false;
}
//@Override
public String getDisplayName() {
return DebuggerBundle.message("method.breakpoints.tab.title");
}
@Override
public String getShortText(XLineBreakpoint<JavaMethodBreakpointProperties> breakpoint) {
return getDisplayText(breakpoint);
}
@Override
public String getDisplayText(XLineBreakpoint<JavaMethodBreakpointProperties> breakpoint) {
return getText(breakpoint);
}
static String getText(XBreakpoint<JavaMethodBreakpointProperties> breakpoint) {
final StringBuilder buffer = StringBuilderSpinAllocator.alloc();
try {
//if(isValid()) {
final String className = breakpoint.getProperties().myClassPattern;
final boolean classNameExists = className != null && className.length() > 0;
if (classNameExists) {
buffer.append(className);
}
if(breakpoint.getProperties().myMethodName != null) {
if (classNameExists) {
buffer.append(".");
}
buffer.append(breakpoint.getProperties().myMethodName);
}
//}
//else {
// buffer.append(DebuggerBundle.message("status.breakpoint.invalid"));
//}
return buffer.toString();
}
finally {
StringBuilderSpinAllocator.dispose(buffer);
}
}
@Nullable
@Override
public XBreakpointCustomPropertiesPanel createCustomPropertiesPanel() {
return new MethodBreakpointPropertiesPanel();
}
@Nullable
@Override
public JavaMethodBreakpointProperties createProperties() {
return new JavaMethodBreakpointProperties();
}
@Nullable
@Override
public JavaMethodBreakpointProperties createBreakpointProperties(@NotNull VirtualFile file, int line) {
return new JavaMethodBreakpointProperties();
}
@Override
public Breakpoint createJavaBreakpoint(Project project, XBreakpoint breakpoint) {
return new MethodBreakpoint(project, breakpoint);
}
}
@@ -0,0 +1,107 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.HelpID;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties;
import javax.swing.*;
/**
* @author Egor
*/
public class JavaWildcardMethodBreakpointType extends JavaBreakpointTypeBase<JavaMethodBreakpointProperties> implements JavaBreakpointType {
public JavaWildcardMethodBreakpointType() {
super("java-wildcard-method", DebuggerBundle.message("method.breakpoints.tab.title"));
}
@NotNull
@Override
public Icon getEnabledIcon() {
return AllIcons.Debugger.Db_method_breakpoint;
}
@NotNull
@Override
public Icon getDisabledIcon() {
return AllIcons.Debugger.Db_disabled_method_breakpoint;
}
//@Override
protected String getHelpID() {
return HelpID.METHOD_BREAKPOINTS;
}
//@Override
public String getDisplayName() {
return DebuggerBundle.message("method.breakpoints.tab.title");
}
@Override
public String getDisplayText(XBreakpoint<JavaMethodBreakpointProperties> breakpoint) {
return JavaMethodBreakpointType.getText(breakpoint);
}
@Nullable
@Override
public XBreakpointCustomPropertiesPanel<XBreakpoint<JavaMethodBreakpointProperties>> createCustomPropertiesPanel() {
return new MethodBreakpointPropertiesPanel();
}
//@Override
//public Key<MethodBreakpoint> getBreakpointCategory() {
// return MethodBreakpoint.CATEGORY;
//}
@Nullable
@Override
public JavaMethodBreakpointProperties createProperties() {
return new JavaMethodBreakpointProperties();
}
@Nullable
@Override
public XBreakpoint<JavaMethodBreakpointProperties> addBreakpoint(final Project project, JComponent parentComponent) {
final AddWildcardBreakpointDialog dialog = new AddWildcardBreakpointDialog(project);
dialog.show();
if (!dialog.isOK()) {
return null;
}
return ApplicationManager.getApplication().runWriteAction(new Computable<XBreakpoint<JavaMethodBreakpointProperties>>() {
@Override
public XBreakpoint<JavaMethodBreakpointProperties> compute() {
return XDebuggerManager.getInstance(project).getBreakpointManager().addBreakpoint(JavaWildcardMethodBreakpointType.this, new JavaMethodBreakpointProperties(
dialog.getClassPattern(),
dialog.getMethodName()));
}
});
}
@Override
public Breakpoint createJavaBreakpoint(Project project, XBreakpoint breakpoint) {
return new WildcardMethodBreakpoint(project, breakpoint);
}
}
@@ -54,6 +54,7 @@ import com.intellij.util.Processor;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xdebugger.XDebuggerUtil;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.sun.jdi.*;
import com.sun.jdi.event.LocatableEvent;
import com.sun.jdi.request.BreakpointRequest;
@@ -74,12 +75,8 @@ public class LineBreakpoint extends BreakpointWithHighlighter {
private String myOwnerMethodName;
public static final @NonNls Key<LineBreakpoint> CATEGORY = BreakpointCategory.lookup("line_breakpoints");
protected LineBreakpoint(Project project) {
super(project);
}
public LineBreakpoint(Project project, RangeHighlighter highlighter) {
super(project, highlighter);
protected LineBreakpoint(Project project, XBreakpoint xBreakpoint) {
super(project, xBreakpoint);
}
@Override
@@ -95,7 +92,7 @@ public class LineBreakpoint extends BreakpointWithHighlighter {
@Override
protected Icon getSetIcon(boolean isMuted) {
if (REMOVE_AFTER_HIT) {
if (isRemoveAfterHit()) {
return isMuted ? AllIcons.Debugger.Db_muted_temporary_breakpoint : AllIcons.Debugger.Db_temporary_breakpoint;
}
return isMuted? AllIcons.Debugger.Db_muted_breakpoint : AllIcons.Debugger.Db_set_breakpoint;
@@ -108,7 +105,7 @@ public class LineBreakpoint extends BreakpointWithHighlighter {
@Override
protected Icon getVerifiedIcon(boolean isMuted) {
if (REMOVE_AFTER_HIT) {
if (isRemoveAfterHit()) {
return isMuted ? AllIcons.Debugger.Db_muted_temporary_breakpoint : AllIcons.Debugger.Db_temporary_breakpoint;
}
return isMuted? AllIcons.Debugger.Db_muted_verified_breakpoint : AllIcons.Debugger.Db_verified_breakpoint;
@@ -349,9 +346,8 @@ public class LineBreakpoint extends BreakpointWithHighlighter {
}
private String getDisplayInfoInternal(boolean showPackageInfo, int totalTextLength) {
final RangeHighlighter highlighter = getHighlighter();
if(highlighter != null && highlighter.isValid() && isValid()) {
final int lineNumber = (highlighter.getDocument().getLineNumber(highlighter.getStartOffset()) + 1);
if(isValid()) {
final int lineNumber = getSourcePosition().getLine() + 1;
String className = getClassName();
final boolean hasClassInfo = className != null && className.length() > 0;
final String methodName = getMethodName();
@@ -471,24 +467,19 @@ public class LineBreakpoint extends BreakpointWithHighlighter {
return ContextUtil.getContextElement(getSourcePosition());
}
public static LineBreakpoint create(@NotNull Project project, @NotNull Document document, int lineIndex) {
final RangeHighlighter highlighter = createHighlighter(project, document, lineIndex);
if (highlighter == null) {
return null;
}
LineBreakpoint breakpoint = new LineBreakpoint(project, highlighter);
public static LineBreakpoint create(@NotNull Project project, XBreakpoint xBreakpoint) {
LineBreakpoint breakpoint = new LineBreakpoint(project, xBreakpoint);
return (LineBreakpoint)breakpoint.init();
}
@Override
public boolean canMoveTo(SourcePosition position) {
if (!super.canMoveTo(position)) {
return false;
}
final Document document = PsiDocumentManager.getInstance(getProject()).getDocument(position.getFile());
return canAddLineBreakpoint(myProject, document, position.getLine());
}
//@Override
//public boolean canMoveTo(SourcePosition position) {
// if (!super.canMoveTo(position)) {
// return false;
// }
// final Document document = PsiDocumentManager.getInstance(getProject()).getDocument(position.getFile());
// return canAddLineBreakpoint(myProject, document, position.getLine());
//}
public static boolean canAddLineBreakpoint(Project project, final Document document, final int lineIndex) {
if (lineIndex < 0 || lineIndex >= document.getLineCount()) {
@@ -1,66 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.HelpID;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import org.jdom.Element;
import javax.swing.*;
/**
* @author Eugene Zhuravlev
* Date: Apr 26, 2005
*/
public class LineBreakpointFactory extends BreakpointFactory {
@Override
public Breakpoint createBreakpoint(Project project, final Element element) {
return new LineBreakpoint(project);
}
@Override
public Icon getIcon() {
return AllIcons.Debugger.Db_set_breakpoint;
}
@Override
public Icon getDisabledIcon() {
return AllIcons.Debugger.Db_disabled_breakpoint;
}
@Override
protected String getHelpID() {
return HelpID.LINE_BREAKPOINTS;
}
@Override
public String getDisplayName() {
return DebuggerBundle.message("line.breakpoints.tab.title");
}
@Override
public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) {
return new LineBreakpointPropertiesPanel(project, compact);
}
@Override
public Key<LineBreakpoint> getBreakpointCategory() {
return LineBreakpoint.CATEGORY;
}
}
@@ -38,10 +38,13 @@ import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizerUtil;
import com.intellij.openapi.util.Key;
import com.intellij.psi.*;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.text.CharArrayUtil;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.sun.jdi.AbsentInformationException;
import com.sun.jdi.Location;
import com.sun.jdi.Method;
@@ -52,31 +55,29 @@ import com.sun.jdi.event.MethodExitEvent;
import com.sun.jdi.request.EventRequest;
import com.sun.jdi.request.MethodEntryRequest;
import com.sun.jdi.request.MethodExitRequest;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties;
import javax.swing.*;
import java.util.Iterator;
import java.util.Set;
public class MethodBreakpoint extends BreakpointWithHighlighter {
public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakpointProperties> {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.breakpoints.MethodBreakpoint");
public boolean WATCH_ENTRY = true;
public boolean WATCH_EXIT = true;
@Nullable private String myMethodName;
@Nullable private JVMName mySignature;
private boolean myIsStatic;
public static final @NonNls Key<MethodBreakpoint> CATEGORY = BreakpointCategory.lookup("method_breakpoints");
protected MethodBreakpoint(@NotNull Project project) {
super(project);
protected MethodBreakpoint(@NotNull Project project, XBreakpoint breakpoint) {
super(project, breakpoint);
}
private MethodBreakpoint(@NotNull Project project, @NotNull RangeHighlighter highlighter) {
super(project, highlighter);
super(project, highlighter, null);
}
public boolean isStatic() {
@@ -104,21 +105,25 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
}
public boolean isValid() {
return super.isValid() && myMethodName != null;
return super.isValid() && getMethodName() != null;
}
protected void reload(@NotNull PsiFile psiFile) {
myMethodName = null;
setMethodName(null);
mySignature = null;
MethodDescriptor descriptor = getMethodDescriptor(myProject, psiFile, getSourcePosition());
if (descriptor != null) {
myMethodName = descriptor.methodName;
setMethodName(descriptor.methodName);
mySignature = descriptor.methodSignature;
myIsStatic = descriptor.isStatic;
}
PsiClass psiClass = getPsiClass();
if (psiClass != null) {
getProperties().myClassPattern = psiClass.getQualifiedName();
}
if (myIsStatic) {
INSTANCE_FILTERS_ENABLED = false;
setInstanceFiltersEnabled(false);
}
}
@@ -130,7 +135,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
String signature = method.signature();
String name = method.name();
if (myMethodName.equals(name) && mySignature.getName(debugProcess).equals(signature)) {
if (getMethodName().equals(name) && mySignature.getName(debugProcess).equals(signature)) {
hasMethod = true;
break;
}
@@ -144,7 +149,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
}
RequestManagerImpl requestManager = debugProcess.getRequestsManager();
if (WATCH_ENTRY) {
if (isWatchEntry()) {
MethodEntryRequest entryRequest = (MethodEntryRequest)findRequest(debugProcess, MethodEntryRequest.class);
if (entryRequest == null) {
entryRequest = requestManager.createMethodEntryRequest(this);
@@ -157,7 +162,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
entryRequest.addClassFilter(classType);
debugProcess.getRequestsManager().enableRequest(entryRequest);
}
if (WATCH_EXIT) {
if (isWatchExit()) {
MethodExitRequest exitRequest = (MethodExitRequest)findRequest(debugProcess, MethodExitRequest.class);
if (exitRequest == null) {
exitRequest = requestManager.createMethodExitRequest(this);
@@ -256,11 +261,11 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
if (classNameExists) {
buffer.append(className);
}
if(myMethodName != null) {
if(getMethodName() != null) {
if (classNameExists) {
buffer.append(".");
}
buffer.append(myMethodName);
buffer.append(getMethodName());
}
}
else {
@@ -281,16 +286,16 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
}
public boolean matchesEvent(@NotNull final LocatableEvent event, final DebugProcessImpl process) throws EvaluateException {
if (myMethodName == null || mySignature == null) {
if (getMethodName() == null || mySignature == null) {
return false;
}
final Method method = event.location().method();
return method != null && method.name().equals(myMethodName) && method.signature().equals(mySignature.getName(process));
return method != null && method.name().equals(getMethodName()) && method.signature().equals(mySignature.getName(process));
}
@Nullable
public static MethodBreakpoint create(@NotNull Project project, @NotNull Document document, int lineIndex) {
final MethodBreakpoint breakpoint = new MethodBreakpoint(project, createHighlighter(project, document, lineIndex));
public static MethodBreakpoint create(@NotNull Project project, XBreakpoint xBreakpoint) {
final MethodBreakpoint breakpoint = new MethodBreakpoint(project, xBreakpoint);
return (MethodBreakpoint)breakpoint.init();
}
@@ -362,6 +367,19 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
return null;
}
@Override
public void readExternal(@NotNull Element breakpointNode) throws InvalidDataException {
super.readExternal(breakpointNode);
try {
getProperties().WATCH_ENTRY = Boolean.valueOf(JDOMExternalizerUtil.readField(breakpointNode, "WATCH_ENTRY"));
} catch (Exception e) {
}
try {
getProperties().WATCH_EXIT = Boolean.valueOf(JDOMExternalizerUtil.readField(breakpointNode, "WATCH_EXIT"));
} catch (Exception e) {
}
}
public String toString() {
return getDescription();
}
@@ -376,6 +394,23 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
return false;
}
private boolean isWatchEntry() {
return getProperties().WATCH_ENTRY;
}
private boolean isWatchExit() {
return getProperties().WATCH_EXIT;
}
@Nullable
private String getMethodName() {
return getProperties().myMethodName;
}
private void setMethodName(@Nullable String methodName) {
getProperties().myMethodName = methodName;
}
private static final class MethodDescriptor {
String methodName;
JVMName methodSignature;
@@ -1,84 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.HelpID;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import org.jdom.Element;
import javax.swing.*;
/**
* @author Eugene Zhuravlev
* Date: Apr 26, 2005
*/
public class MethodBreakpointFactory extends BreakpointFactory{
@Override
public Breakpoint createBreakpoint(Project project, final Element element) {
return element.getAttributeValue(WildcardMethodBreakpoint.JDOM_LABEL) != null? new WildcardMethodBreakpoint(project) : new MethodBreakpoint(project);
}
@Override
public Icon getIcon() {
return AllIcons.Debugger.Db_method_breakpoint;
}
@Override
public Icon getDisabledIcon() {
return AllIcons.Debugger.Db_disabled_method_breakpoint;
}
@Override
protected String getHelpID() {
return HelpID.METHOD_BREAKPOINTS;
}
@Override
public String getDisplayName() {
return DebuggerBundle.message("method.breakpoints.tab.title");
}
@Override
public BreakpointPropertiesPanel createBreakpointPropertiesPanel(Project project, boolean compact) {
return new MethodBreakpointPropertiesPanel(project, compact);
}
@Override
public Key<MethodBreakpoint> getBreakpointCategory() {
return MethodBreakpoint.CATEGORY;
}
@Override
public boolean canAddBreakpoints() {
return true;
}
@Override
public WildcardMethodBreakpoint addBreakpoint(Project project) {
AddWildcardBreakpointDialog dialog = new AddWildcardBreakpointDialog(project);
dialog.show();
WildcardMethodBreakpoint methodBreakpoint;
methodBreakpoint = !dialog.isOK()
? null
: DebuggerManagerEx.getInstanceEx(project).getBreakpointManager()
.addMethodBreakpoint(dialog.getClassPattern(), dialog.getMethodName());
return methodBreakpoint;
}
}
@@ -21,24 +21,30 @@
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.openapi.project.Project;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.util.ui.DialogUtil;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MethodBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
public class MethodBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPanel<XBreakpoint<JavaMethodBreakpointProperties>> {
private JCheckBox myWatchEntryCheckBox;
private JCheckBox myWatchExitCheckBox;
public MethodBreakpointPropertiesPanel(final Project project, boolean compact) {
super(project, MethodBreakpoint.CATEGORY, compact);
}
//public MethodBreakpointPropertiesPanel(final Project project, boolean compact) {
// super(project, MethodBreakpoint.CATEGORY, compact);
//}
protected JComponent createSpecialBox() {
@NotNull
@Override
public JComponent getComponent() {
JPanel _panel, _panel0;
myWatchEntryCheckBox = new JCheckBox(DebuggerBundle.message("label.method.breakpoint.properties.panel.method.entry"));
@@ -86,31 +92,15 @@ public class MethodBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
return _panel;
}
public void initFrom(Breakpoint breakpoint, boolean moreOptionsVisible) {
super.initFrom(breakpoint, moreOptionsVisible);
if (breakpoint instanceof MethodBreakpoint) {
MethodBreakpoint methodBreakpoint = (MethodBreakpoint)breakpoint;
myWatchEntryCheckBox.setSelected(methodBreakpoint.WATCH_ENTRY);
myWatchExitCheckBox.setSelected(methodBreakpoint.WATCH_EXIT);
}
else if (breakpoint instanceof WildcardMethodBreakpoint){
final WildcardMethodBreakpoint methodBreakpoint = ((WildcardMethodBreakpoint)breakpoint);
myWatchEntryCheckBox.setSelected(methodBreakpoint.WATCH_ENTRY);
myWatchExitCheckBox.setSelected(methodBreakpoint.WATCH_EXIT);
}
@Override
public void loadFrom(@NotNull XBreakpoint<JavaMethodBreakpointProperties> breakpoint) {
myWatchEntryCheckBox.setSelected(breakpoint.getProperties().WATCH_ENTRY);
myWatchExitCheckBox.setSelected(breakpoint.getProperties().WATCH_EXIT);
}
public void saveTo(Breakpoint breakpoint) {
if (breakpoint instanceof MethodBreakpoint) {
MethodBreakpoint methodBreakpoint = (MethodBreakpoint)breakpoint;
methodBreakpoint.WATCH_ENTRY = myWatchEntryCheckBox.isSelected();
methodBreakpoint.WATCH_EXIT = myWatchExitCheckBox.isSelected();
}
else if (breakpoint instanceof WildcardMethodBreakpoint){
final WildcardMethodBreakpoint methodBreakpoint = ((WildcardMethodBreakpoint)breakpoint);
methodBreakpoint.WATCH_ENTRY = myWatchEntryCheckBox.isSelected();
methodBreakpoint.WATCH_EXIT = myWatchExitCheckBox.isSelected();
}
super.saveTo(breakpoint);
@Override
public void saveTo(@NotNull XBreakpoint<JavaMethodBreakpointProperties> breakpoint) {
breakpoint.getProperties().WATCH_ENTRY = myWatchEntryCheckBox.isSelected();
breakpoint.getProperties().WATCH_EXIT = myWatchExitCheckBox.isSelected();
}
}
@@ -18,10 +18,11 @@ package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.SourcePosition;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -31,18 +32,11 @@ import org.jetbrains.annotations.Nullable;
*/
public class RunToCursorBreakpoint extends LineBreakpoint {
private final boolean myRestoreBreakpoints;
@Nullable
private final SourcePosition myCustomPosition;
protected RunToCursorBreakpoint(@NotNull Project project, @NotNull RangeHighlighter highlighter, boolean restoreBreakpoints) {
super(project, highlighter);
setVisible(false);
myRestoreBreakpoints = restoreBreakpoints;
myCustomPosition = null;
}
private String mySuspendPolicy;
protected RunToCursorBreakpoint(@NotNull Project project, @NotNull SourcePosition pos, boolean restoreBreakpoints) {
super(project);
super(project, null);
myCustomPosition = pos;
setVisible(false);
myRestoreBreakpoints = restoreBreakpoints;
@@ -50,7 +44,51 @@ public class RunToCursorBreakpoint extends LineBreakpoint {
@Override
public SourcePosition getSourcePosition() {
return myCustomPosition != null ? myCustomPosition : super.getSourcePosition();
return myCustomPosition;
}
@Override
public void reload() {
}
@Override
public String getSuspendPolicy() {
return mySuspendPolicy;
}
public void setSuspendPolicy(String policy) {
mySuspendPolicy = policy;
}
protected boolean isLogEnabled() {
return false;
}
@Override
protected boolean isLogExpressionEnabled() {
return false;
}
@Override
public boolean isEnabled() {
return true;
}
public boolean isCountFilterEnabled() {
return false;
}
public boolean isClassFiltersEnabled() {
return false;
}
public boolean isInstanceFiltersEnabled() {
return false;
}
@Override
protected boolean isConditionEnabled() {
return false;
}
public boolean isRestoreBreakpoints() {
@@ -62,6 +100,11 @@ public class RunToCursorBreakpoint extends LineBreakpoint {
return false;
}
@Override
public boolean isValid() {
return true;
}
@Override
protected boolean isMuted(@NotNull final DebugProcessImpl debugProcess) {
return false; // always enabled
@@ -74,17 +117,9 @@ public class RunToCursorBreakpoint extends LineBreakpoint {
return null;
}
final RangeHighlighter highlighter = createHighlighter(project, document, lineIndex);
if (highlighter == null) {
return null;
}
PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
SourcePosition pos = SourcePosition.createFromLine(psiFile, lineIndex);
final RunToCursorBreakpoint breakpoint = new RunToCursorBreakpoint(project, highlighter, restoreBreakpoints);
final RangeHighlighter h = breakpoint.getHighlighter();
if (h != null) {
h.dispose();
}
return (RunToCursorBreakpoint)breakpoint.init();
return new RunToCursorBreakpoint(project, pos, restoreBreakpoints);
}
}
@@ -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;
@@ -26,12 +26,11 @@ import com.intellij.debugger.engine.requests.RequestManagerImpl;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.sun.jdi.AbsentInformationException;
import com.sun.jdi.Location;
import com.sun.jdi.Method;
@@ -42,40 +41,35 @@ import com.sun.jdi.event.MethodExitEvent;
import com.sun.jdi.request.EventRequest;
import com.sun.jdi.request.MethodEntryRequest;
import com.sun.jdi.request.MethodExitRequest;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties;
import javax.swing.*;
import java.util.Iterator;
import java.util.Set;
public class WildcardMethodBreakpoint extends Breakpoint {
public class WildcardMethodBreakpoint extends Breakpoint<JavaMethodBreakpointProperties> {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.breakpoints.ExceptionBreakpoint");
public boolean WATCH_ENTRY = true;
public boolean WATCH_EXIT = true;
private String myClassPattern;
private String myMethodName;
public static final String JDOM_LABEL = "wildcard_breakpoint";
public WildcardMethodBreakpoint(Project project) {
super(project);
public WildcardMethodBreakpoint(Project project, XBreakpoint breakpoint) {
super(project, breakpoint);
}
public Key<MethodBreakpoint> getCategory() {
return MethodBreakpoint.CATEGORY;
}
protected WildcardMethodBreakpoint(Project project, @NotNull String classPattern, @NotNull String methodName) {
super(project);
myClassPattern = classPattern;
myMethodName = methodName;
protected WildcardMethodBreakpoint(Project project, @NotNull String classPattern, @NotNull String methodName, XBreakpoint breakpoint) {
super(project, breakpoint);
setClassPattern(classPattern);
setMethodName(methodName);
}
public String getClassName() {
return myClassPattern;
return getClassPattern();
}
public @Nullable String getShortClassName() {
@@ -83,7 +77,7 @@ public class WildcardMethodBreakpoint extends Breakpoint {
}
public String getMethodName() {
return myMethodName;
return getProperties().myMethodName;
}
public PsiClass getPsiClass() {
@@ -96,9 +90,9 @@ public class WildcardMethodBreakpoint extends Breakpoint {
}
final StringBuilder buffer = StringBuilderSpinAllocator.alloc();
try {
buffer.append(myClassPattern);
buffer.append(getClassPattern());
buffer.append(".");
buffer.append(myMethodName);
buffer.append(getMethodName());
buffer.append("()");
return buffer.toString();
}
@@ -108,7 +102,7 @@ public class WildcardMethodBreakpoint extends Breakpoint {
}
public Icon getIcon() {
if (!ENABLED) {
if (!isEnabled()) {
final Breakpoint master = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().findMasterBreakpoint(this);
return master == null? AllIcons.Debugger.Db_disabled_method_breakpoint : AllIcons.Debugger.Db_dep_method_breakpoint;
}
@@ -124,12 +118,12 @@ public class WildcardMethodBreakpoint extends Breakpoint {
public void createRequest(DebugProcessImpl debugProcess) {
DebuggerManagerThreadImpl.assertIsManagerThread();
if (!ENABLED || !debugProcess.isAttached() || debugProcess.areBreakpointsMuted() || !debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
if (!isEnabled() || !debugProcess.isAttached() || debugProcess.areBreakpointsMuted() || !debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
return;
}
try {
RequestManagerImpl requestManager = debugProcess.getRequestsManager();
if (WATCH_ENTRY) {
if (isWatchEntry()) {
MethodEntryRequest entryRequest = (MethodEntryRequest)findRequest(debugProcess, MethodEntryRequest.class);
if (entryRequest == null) {
entryRequest = requestManager.createMethodEntryRequest(this);
@@ -137,10 +131,10 @@ public class WildcardMethodBreakpoint extends Breakpoint {
else {
entryRequest.disable();
}
entryRequest.addClassFilter(myClassPattern);
entryRequest.addClassFilter(getClassPattern());
debugProcess.getRequestsManager().enableRequest(entryRequest);
}
if (WATCH_EXIT) {
if (isWatchExit()) {
MethodExitRequest exitRequest = (MethodExitRequest)findRequest(debugProcess, MethodExitRequest.class);
if (exitRequest == null) {
exitRequest = requestManager.createMethodExitRequest(this);
@@ -148,7 +142,7 @@ public class WildcardMethodBreakpoint extends Breakpoint {
else {
exitRequest.disable();
}
exitRequest.addClassFilter(myClassPattern);
exitRequest.addClassFilter(getClassPattern());
debugProcess.getRequestsManager().enableRequest(exitRequest);
}
}
@@ -212,46 +206,74 @@ public class WildcardMethodBreakpoint extends Breakpoint {
}
public boolean isValid() {
return myClassPattern != null && myMethodName != null;
return getClassPattern() != null && getMethodName() != null;
}
@SuppressWarnings({"HardCodedStringLiteral"}) public void writeExternal(Element parentNode) throws WriteExternalException {
super.writeExternal(parentNode);
parentNode.setAttribute(JDOM_LABEL, "true");
if (myClassPattern != null) {
parentNode.setAttribute("class_name", myClassPattern);
}
if (myMethodName != null) {
parentNode.setAttribute("method_name", myMethodName);
}
}
//@SuppressWarnings({"HardCodedStringLiteral"}) public void writeExternal(Element parentNode) throws WriteExternalException {
// super.writeExternal(parentNode);
// parentNode.setAttribute(JDOM_LABEL, "true");
// if (getClassPattern() != null) {
// parentNode.setAttribute("class_name", getClassPattern());
// }
// if (getMethodName() != null) {
// parentNode.setAttribute("method_name", getMethodName());
// }
//}
public PsiElement getEvaluationElement() {
return null;
}
public void readExternal(Element parentNode) throws InvalidDataException {
super.readExternal(parentNode);
//noinspection HardCodedStringLiteral
String className = parentNode.getAttributeValue("class_name");
myClassPattern = className;
//noinspection HardCodedStringLiteral
String methodName = parentNode.getAttributeValue("method_name");
myMethodName = methodName;
if(className == null || methodName == null) {
throw new InvalidDataException();
}
}
//public void readExternal(Element parentNode) throws InvalidDataException {
// super.readExternal(parentNode);
//
// //noinspection HardCodedStringLiteral
// String className = parentNode.getAttributeValue("class_name");
// setClassPattern(className);
//
// //noinspection HardCodedStringLiteral
// String methodName = parentNode.getAttributeValue("method_name");
// setMethodName(methodName);
//
// if(className == null || methodName == null) {
// throw new InvalidDataException();
// }
//}
public boolean matchesEvent(final LocatableEvent event){
final Method method = event.location().method();
return method != null && myMethodName.equals(method.name());
return method != null && getMethodName().equals(method.name());
}
public static WildcardMethodBreakpoint create(Project project, final String classPattern, final String methodName) {
return new WildcardMethodBreakpoint(project, classPattern, methodName);
public static WildcardMethodBreakpoint create(Project project, final String classPattern, final String methodName, XBreakpoint xBreakpoint) {
return new WildcardMethodBreakpoint(project, classPattern, methodName, xBreakpoint);
}
private boolean isWatchEntry() {
return getProperties().WATCH_ENTRY;
}
private void setWatchEntry(boolean WATCH_ENTRY) {
getProperties().WATCH_ENTRY = WATCH_ENTRY;
}
private boolean isWatchExit() {
return getProperties().WATCH_EXIT;
}
private void setWatchExit(boolean WATCH_EXIT) {
getProperties().WATCH_EXIT = WATCH_EXIT;
}
private String getClassPattern() {
return getProperties().myClassPattern;
}
private void setClassPattern(String classPattern) {
getProperties().myClassPattern = classPattern;
}
private void setMethodName(String methodName) {
getProperties().myMethodName = methodName;
}
}
@@ -1,16 +1,28 @@
package org.jetbrains.java.debugger;
import com.intellij.debugger.engine.evaluation.CodeFragmentKind;
import com.intellij.debugger.engine.evaluation.TextWithImports;
import com.intellij.debugger.engine.evaluation.TextWithImportsImpl;
import com.intellij.debugger.ui.DebuggerExpressionComboBox;
import com.intellij.ide.highlighter.JavaFileType;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.JavaCodeFragmentFactory;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProviderBase;
import com.intellij.xdebugger.impl.breakpoints.ui.XDebuggerComboBoxProvider;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class JavaDebuggerEditorsProvider extends XDebuggerEditorsProviderBase {
import javax.swing.*;
public class JavaDebuggerEditorsProvider extends XDebuggerEditorsProviderBase implements XDebuggerComboBoxProvider {
@NotNull
@Override
public FileType getFileType() {
@@ -21,4 +33,72 @@ public class JavaDebuggerEditorsProvider extends XDebuggerEditorsProviderBase {
protected PsiFile createExpressionCodeFragment(@NotNull Project project, @NotNull String text, @Nullable PsiElement context, boolean isPhysical) {
return JavaCodeFragmentFactory.getInstance(project).createExpressionCodeFragment(text, context, null, isPhysical);
}
@Override
public XBreakpointCustomPropertiesPanel<XBreakpoint<?>> createConditionComboBoxPanel(Project project,
XDebuggerEditorsProvider debuggerEditorsProvider,
String historyId,
XSourcePosition sourcePosition) {
return new ExpressionComboBoxPanel(project, historyId, sourcePosition) {
@Override
public void saveTo(@NotNull XBreakpoint<?> breakpoint) {
TextWithImports text = myComboBox.getText();
final String condition = !text.getText().isEmpty() ? text.toExternalForm() : null;
breakpoint.setCondition(condition);
if (condition != null) {
myComboBox.addRecent(text);
}
}
@Override
public void loadFrom(@NotNull XBreakpoint<?> breakpoint) {
myComboBox.setText(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, StringUtil.notNullize(breakpoint.getCondition())));
}
};
}
@Override
public XBreakpointCustomPropertiesPanel<XBreakpoint<?>> createLogExpressionComboBoxPanel(Project project,
XDebuggerEditorsProvider debuggerEditorsProvider,
String historyId,
XSourcePosition sourcePosition) {
return new ExpressionComboBoxPanel(project, historyId, sourcePosition) {
@Override
public void saveTo(@NotNull XBreakpoint<?> breakpoint) {
TextWithImports text = myComboBox.getText();
breakpoint.setLogExpression(myComboBox.isEnabled() && !text.getText().isEmpty() ? text.toExternalForm() : null);
if (text != null) {
myComboBox.addRecent(text);
}
}
@Override
public void loadFrom(@NotNull XBreakpoint<?> breakpoint) {
myComboBox.setText(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, StringUtil.notNullize(breakpoint.getLogExpression())));
}
};
}
private abstract class ExpressionComboBoxPanel extends XBreakpointCustomPropertiesPanel<XBreakpoint<?>> {
protected final DebuggerExpressionComboBox myComboBox;
private ExpressionComboBoxPanel(Project project,
String historyId,
XSourcePosition sourcePosition) {
myComboBox = new DebuggerExpressionComboBox(project, historyId);
if (sourcePosition != null) {
PsiElement element = getContextElement(sourcePosition.getFile(), sourcePosition.getOffset(), project);
myComboBox.setContext(element);
}
else {
myComboBox.setContext(null);
}
}
@NotNull
@Override
public JComponent getComponent() {
return myComboBox;
}
}
}
@@ -1,157 +0,0 @@
package org.jetbrains.java.debugger.breakpoints;
import com.intellij.debugger.engine.evaluation.CodeFragmentKind;
import com.intellij.debugger.engine.evaluation.TextWithImportsImpl;
import com.intellij.debugger.engine.requests.RequestManagerImpl;
import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.debugger.ui.breakpoints.LineBreakpoint;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.xdebugger.breakpoints.XBreakpointProperties;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
public class JavaBreakpointAdapter extends JavaBreakpointAdapterBase {
private static final Key<LineBreakpoint> OLD_JAVA_BREAKPOINT_KEY = Key.create("oldJavaBreakpoint");
public JavaBreakpointAdapter(Project project) {
super(project);
}
@Override
protected void configureCreatedBreakpoint(LineBreakpoint oldBreakpoint, XLineBreakpoint<XBreakpointProperties> breakpoint) {
oldBreakpoint.SUSPEND_POLICY = transformSuspendPolicy(breakpoint);
applyCondition(oldBreakpoint, breakpoint);
applyFilters(oldBreakpoint, breakpoint);
}
private boolean applyFilters(LineBreakpoint oldBreakpoint, XLineBreakpoint<XBreakpointProperties> breakpoint) {
boolean changed = false;
JavaBreakpointProperties properties = (JavaBreakpointProperties)breakpoint.getProperties();
changed |= oldBreakpoint.COUNT_FILTER_ENABLED != properties.COUNT_FILTER_ENABLED;
oldBreakpoint.COUNT_FILTER_ENABLED = properties.COUNT_FILTER_ENABLED;
changed |= oldBreakpoint.COUNT_FILTER != properties.COUNT_FILTER;
oldBreakpoint.COUNT_FILTER = properties.COUNT_FILTER;
changed |= oldBreakpoint.CLASS_FILTERS_ENABLED != properties.CLASS_FILTERS_ENABLED;
oldBreakpoint.CLASS_FILTERS_ENABLED = properties.CLASS_FILTERS_ENABLED;
changed |= !Arrays.equals(oldBreakpoint.getClassFilters(), properties.getClassFilters());
oldBreakpoint.setClassFilters(properties.getClassFilters());
changed |= !Arrays.equals(oldBreakpoint.getClassExclusionFilters(), properties.getClassExclusionFilters());
oldBreakpoint.setClassExclusionFilters(properties.getClassExclusionFilters());
changed |= oldBreakpoint.INSTANCE_FILTERS_ENABLED != properties.INSTANCE_FILTERS_ENABLED;
oldBreakpoint.INSTANCE_FILTERS_ENABLED = properties.INSTANCE_FILTERS_ENABLED;
changed |= !Arrays.equals(oldBreakpoint.getInstanceFilters(), properties.getInstanceFilters());
oldBreakpoint.setInstanceFilters(properties.getInstanceFilters());
return changed;
}
private static void applyCondition(LineBreakpoint oldBreakpoint, XLineBreakpoint<XBreakpointProperties> breakpoint) {
if (breakpoint.getCondition() != null) {
oldBreakpoint.CONDITION_ENABLED = true;
oldBreakpoint.setCondition(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, breakpoint.getCondition()));
}
else {
oldBreakpoint.CONDITION_ENABLED = false;
if (!StringUtil.isEmptyOrSpaces(oldBreakpoint.getCondition().getText())) {
oldBreakpoint.setCondition(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, ""));
}
}
}
@Override
protected void updateBreakpoint(LineBreakpoint jBreakpoint, XLineBreakpoint<XBreakpointProperties> breakpoint) {
boolean changed = false;
if (jBreakpoint.ENABLED != breakpoint.isEnabled()) {
jBreakpoint.ENABLED = breakpoint.isEnabled();
changed = true;
}
String suspendPolicy = transformSuspendPolicy(breakpoint);
if (jBreakpoint.SUSPEND_POLICY != suspendPolicy) {
jBreakpoint.SUSPEND_POLICY = suspendPolicy;
changed = true;
}
if (StringUtil.compare(breakpoint.getCondition(), jBreakpoint.getCondition().getText(), false) != 0) {
applyCondition(jBreakpoint, breakpoint);
changed = true;
}
if (applyFilters(jBreakpoint, breakpoint)) {
changed = true;
}
if (jBreakpoint.getSourcePosition().getLine() != breakpoint.getLine()) {
jBreakpoint.reload();
changed = true;
}
if (changed) {
RequestManagerImpl.updateRequests(jBreakpoint);
jBreakpoint.updateUI();
}
}
@Override
protected LineBreakpoint findBreakpoint(XLineBreakpoint<XBreakpointProperties> breakpoint) {
return OLD_JAVA_BREAKPOINT_KEY.get(breakpoint);
}
public LineBreakpoint getOrCreate(XLineBreakpoint<XBreakpointProperties> breakpoint) {
LineBreakpoint oldBreakpoint = findBreakpoint(breakpoint);
if (oldBreakpoint == null) {
oldBreakpoint = createBreakpoint(breakpoint);
OLD_JAVA_BREAKPOINT_KEY.set(breakpoint, oldBreakpoint);
}
return oldBreakpoint;
}
@Override
public void breakpointRemoved(@NotNull XLineBreakpoint<XBreakpointProperties> breakpoint) {
LineBreakpoint jBreakpoint = findBreakpoint(breakpoint);
if (jBreakpoint != null) {
jBreakpoint.delete();
}
}
@Override
protected LineBreakpoint doCreateInstance(Project project, Document document, XLineBreakpoint<XBreakpointProperties> breakpoint) {
LineBreakpoint lineBreakpoint = new LineBreakpoint(project, ((XLineBreakpointImpl)breakpoint).getHighlighter()) {
@Override
protected void setEditorFilter(RangeHighlighter highlighter) {
}
};
lineBreakpoint.setVisible(false);
lineBreakpoint.init();
return lineBreakpoint;
}
private static String transformSuspendPolicy(XLineBreakpoint<XBreakpointProperties> breakpoint) {
switch (breakpoint.getSuspendPolicy()) {
case ALL:
return DebuggerSettings.SUSPEND_ALL;
case THREAD:
return DebuggerSettings.SUSPEND_THREAD;
case NONE:
return DebuggerSettings.SUSPEND_NONE;
default:
throw new IllegalArgumentException("unknown suspend policy");
}
}
}
@@ -56,11 +56,11 @@ public abstract class JavaBreakpointAdapterBase extends XBreakpointAdapter<XLine
LineBreakpoint oldBreakpoint = doCreateInstance(project, document, breakpoint);
oldBreakpoint.setVisible(false);
oldBreakpoint.updateUI();
oldBreakpoint.ENABLED = breakpoint.isEnabled();
oldBreakpoint.setEnabled(breakpoint.isEnabled());
return oldBreakpoint;
}
protected LineBreakpoint doCreateInstance(Project project, Document document, XLineBreakpoint<XBreakpointProperties> breakpoint) {
return LineBreakpoint.create(project, document, breakpoint.getLine());
protected LineBreakpoint doCreateInstance(Project project, Document document, XLineBreakpoint<XBreakpointProperties> xBreakpoint) {
return LineBreakpoint.create(project, xBreakpoint);
}
}
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.java.debugger.breakpoints.JavaBreakpointPropertiesPanel">
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.java.debugger.breakpoints.JavaBreakpointFiltersPanel">
<grid id="27dc6" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
@@ -26,11 +26,11 @@ import com.intellij.ui.FieldPanel;
import com.intellij.ui.MultiLineTooltipUI;
import com.intellij.ui.classFilter.ClassFilter;
import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.breakpoints.XBreakpointProperties;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties;
import javax.swing.*;
import java.awt.*;
@@ -44,7 +44,7 @@ import java.util.List;
/**
* @author egor
*/
public class JavaBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPanel<XLineBreakpoint<XBreakpointProperties>> {
public class JavaBreakpointFiltersPanel<T extends JavaBreakpointProperties, B extends XBreakpoint<T>> extends XBreakpointCustomPropertiesPanel<B> {
private JPanel myConditionsPanel;
private JPanel myInstanceFiltersPanel;
private JCheckBox myInstanceFiltersCheckBox;
@@ -66,7 +66,7 @@ public class JavaBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPa
private PsiClass myBreakpointPsiClass;
public JavaBreakpointPropertiesPanel(Project project) {
public JavaBreakpointFiltersPanel(Project project) {
myProject = project;
myInstanceFiltersField = new FieldPanel(new MyTextField(), "", null,
new ActionListener() {
@@ -135,8 +135,8 @@ public class JavaBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPa
}
@Override
public boolean isVisibleOnPopup(@NotNull XLineBreakpoint<XBreakpointProperties> breakpoint) {
JavaBreakpointProperties properties = (JavaBreakpointProperties)breakpoint.getProperties();
public boolean isVisibleOnPopup(@NotNull B breakpoint) {
JavaBreakpointProperties properties = breakpoint.getProperties();
if (properties != null) {
return properties.COUNT_FILTER_ENABLED || properties.CLASS_FILTERS_ENABLED || properties.INSTANCE_FILTERS_ENABLED;
}
@@ -144,8 +144,8 @@ public class JavaBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPa
}
@Override
public void saveTo(@NotNull XLineBreakpoint<XBreakpointProperties> breakpoint) {
JavaBreakpointProperties properties = (JavaBreakpointProperties)breakpoint.getProperties();
public void saveTo(@NotNull B breakpoint) {
JavaBreakpointProperties properties = breakpoint.getProperties();
if (properties == null) {
return;
}
@@ -179,8 +179,8 @@ public class JavaBreakpointPropertiesPanel extends XBreakpointCustomPropertiesPa
}
@Override
public void loadFrom(@NotNull XLineBreakpoint<XBreakpointProperties> breakpoint) {
JavaBreakpointProperties properties = (JavaBreakpointProperties)breakpoint.getProperties();
public void loadFrom(@NotNull B breakpoint) {
JavaBreakpointProperties properties = breakpoint.getProperties();
if (properties != null) {
if (properties.COUNT_FILTER > 0) {
myPassCountField.setText(Integer.toString(properties.COUNT_FILTER));
@@ -1,76 +0,0 @@
package org.jetbrains.java.debugger.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.engine.DebuggerUtils;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.util.SystemProperties;
import com.intellij.xdebugger.XDebuggerUtil;
import com.intellij.xdebugger.breakpoints.XBreakpointProperties;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.intellij.xdebugger.breakpoints.XLineBreakpointTypeBase;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.java.debugger.JavaDebuggerEditorsProvider;
import java.util.List;
public class JavaBreakpointType extends XLineBreakpointTypeBase {
public JavaBreakpointType() {
super("java", DebuggerBundle.message("java.breakpoint.title"), new JavaDebuggerEditorsProvider());
}
@Override
public boolean canPutAt(@NotNull final VirtualFile file, final int line, @NotNull Project project) {
return SystemProperties.getBooleanProperty("java.debugger.xBreakpoint", false) &&
doCanPutAt(PsiManager.getInstance(project).findFile(file));
}
@Override
public boolean isSuspendThreadSupported() {
return true;
}
@Override
public List<XBreakpointGroupingRule<XLineBreakpoint<XBreakpointProperties>, ?>> getGroupingRules() {
return XDebuggerUtil.getInstance().getGroupingByFileRuleAsList();
}
@Contract("null -> false")
public static boolean doCanPutAt(@Nullable PsiFile psiFile) {
// JSPX supports jvm debugging, but not in XHTML files
if (psiFile == null || psiFile.getVirtualFile().getFileType() == StdFileTypes.XHTML) {
return false;
}
FileType fileType = psiFile.getFileType();
return StdFileTypes.CLASS.equals(fileType) || DebuggerUtils.supportsJVMDebugging(fileType) || DebuggerUtils.supportsJVMDebugging(psiFile);
}
@Nullable
@Override
public XBreakpointProperties createProperties() {
return new JavaBreakpointProperties();
}
@Nullable
@Override
public XBreakpointProperties createBreakpointProperties(@NotNull VirtualFile file, int line) {
return new JavaBreakpointProperties();
}
@Nullable
@Override
public XBreakpointCustomPropertiesPanel<XLineBreakpoint<XBreakpointProperties>> createCustomRightPropertiesPanel(@NotNull Project project) {
return new JavaBreakpointPropertiesPanel(project);
}
}
@@ -13,27 +13,36 @@
* 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;
import com.intellij.util.xmlb.annotations.AbstractCollection;
import com.intellij.util.xmlb.annotations.OptionTag;
import com.intellij.util.xmlb.annotations.Tag;
import com.intellij.xdebugger.breakpoints.XBreakpointProperties;
import org.jetbrains.annotations.Nullable;
/**
* @author egor
*/
public class JavaBreakpointProperties extends XBreakpointProperties<JavaBreakpointProperties> {
public class JavaBreakpointProperties<T extends JavaBreakpointProperties> extends XBreakpointProperties<T> {
@OptionTag("count-filter-enabled")
public boolean COUNT_FILTER_ENABLED = false;
@OptionTag("count-filter")
public int COUNT_FILTER = 0;
@OptionTag("class-filters-enabled")
public boolean CLASS_FILTERS_ENABLED = false;
private ClassFilter[] myClassFilters;
private ClassFilter[] myClassExclusionFilters;
@OptionTag("instance-filters-enabled")
public boolean INSTANCE_FILTERS_ENABLED = false;
private InstanceFilter[] myInstanceFilters;
@Tag("instance-filters")
@AbstractCollection(surroundWithTag = false)
public InstanceFilter[] getInstanceFilters() {
return myInstanceFilters != null ? myInstanceFilters : InstanceFilter.EMPTY_ARRAY;
}
@@ -42,13 +51,15 @@ public class JavaBreakpointProperties extends XBreakpointProperties<JavaBreakpoi
myInstanceFilters = instanceFilters;
}
protected void addInstanceFilter(long l) {
public void addInstanceFilter(long l) {
final InstanceFilter[] filters = new InstanceFilter[myInstanceFilters.length + 1];
System.arraycopy(myInstanceFilters, 0, filters, 0, myInstanceFilters.length);
filters[myInstanceFilters.length] = InstanceFilter.create(String.valueOf(l));
myInstanceFilters = filters;
}
@Tag("class-filters")
@AbstractCollection(surroundWithTag = false)
public final ClassFilter[] getClassFilters() {
return myClassFilters != null ? myClassFilters : ClassFilter.EMPTY_ARRAY;
}
@@ -57,6 +68,8 @@ public class JavaBreakpointProperties extends XBreakpointProperties<JavaBreakpoi
myClassFilters = classFilters;
}
@Tag("class-exclusion-filters")
@AbstractCollection(surroundWithTag = false)
public ClassFilter[] getClassExclusionFilters() {
return myClassExclusionFilters != null ? myClassExclusionFilters : ClassFilter.EMPTY_ARRAY;
}
@@ -67,20 +80,20 @@ public class JavaBreakpointProperties extends XBreakpointProperties<JavaBreakpoi
@Nullable
@Override
public JavaBreakpointProperties getState() {
return this;
public T getState() {
return (T)this;
}
@Override
public void loadState(JavaBreakpointProperties state) {
public void loadState(T state) {
COUNT_FILTER_ENABLED = state.COUNT_FILTER_ENABLED;
COUNT_FILTER = state.COUNT_FILTER;
CLASS_FILTERS_ENABLED = state.CLASS_FILTERS_ENABLED;
myClassFilters = state.myClassFilters;
myClassExclusionFilters = state.myClassExclusionFilters;
myClassFilters = state.getClassFilters();
myClassExclusionFilters = state.getClassExclusionFilters();
INSTANCE_FILTERS_ENABLED = state.INSTANCE_FILTERS_ENABLED;
myInstanceFilters = state.myInstanceFilters;
myInstanceFilters = state.getInstanceFilters();
}
}
@@ -0,0 +1,57 @@
/*
* 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 com.intellij.util.xmlb.annotations.Attribute;
import org.jetbrains.annotations.Nullable;
/**
* @author egor
*/
public class JavaExceptionBreakpointProperties extends JavaBreakpointProperties<JavaExceptionBreakpointProperties> {
public boolean NOTIFY_CAUGHT = true;
public boolean NOTIFY_UNCAUGHT = true;
@Attribute("class")
public String myQualifiedName;
@Attribute("package")
public String myPackageName;
public JavaExceptionBreakpointProperties(String qualifiedName, String packageName) {
myQualifiedName = qualifiedName;
myPackageName = packageName;
}
public JavaExceptionBreakpointProperties() {
}
@Nullable
@Override
public JavaExceptionBreakpointProperties getState() {
return this;
}
@Override
public void loadState(JavaExceptionBreakpointProperties state) {
super.loadState(state);
NOTIFY_CAUGHT = state.NOTIFY_CAUGHT;
NOTIFY_UNCAUGHT = state.NOTIFY_UNCAUGHT;
myQualifiedName = state.myQualifiedName;
myPackageName = state.myPackageName;
}
}
@@ -0,0 +1,57 @@
/*
* 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 com.intellij.util.xmlb.annotations.Attribute;
import org.jetbrains.annotations.Nullable;
/**
* @author egor
*/
public class JavaFieldBreakpointProperties extends JavaBreakpointProperties<JavaFieldBreakpointProperties> {
public boolean WATCH_MODIFICATION = true;
public boolean WATCH_ACCESS = false;
@Attribute("field")
public String myFieldName;
@Attribute("class")
public String myClassName;
public JavaFieldBreakpointProperties(String fieldName, String className) {
myFieldName = fieldName;
myClassName = className;
}
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;
myClassName = state.myClassName;
}
}
@@ -0,0 +1,22 @@
/*
* 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;
/**
* @author egor
*/
public class JavaLineBreakpointProperties extends JavaBreakpointProperties<JavaLineBreakpointProperties> {
}
@@ -0,0 +1,58 @@
/*
* 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 com.intellij.util.xmlb.annotations.Attribute;
import org.jetbrains.annotations.Nullable;
/**
* @author egor
*/
public class JavaMethodBreakpointProperties extends JavaBreakpointProperties<JavaMethodBreakpointProperties> {
@Attribute("class")
public String myClassPattern;
@Attribute("method")
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;
}
}
@@ -18,6 +18,7 @@ package com.intellij.ide.impl;
import com.intellij.facet.*;
import com.intellij.ide.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.DumbAware;
@@ -48,7 +49,8 @@ public class ProjectStructureSelectInTarget extends SelectInTargetBase implement
final Object o = ((WrappingVirtualFile)file).getWrappedObject(context.getProject());
return o instanceof Facet;
}
return fileIndex.isInContent(file) || fileIndex.isInLibraryClasses(file) || fileIndex.isInLibrarySource(file);
return fileIndex.isInContent(file) || fileIndex.isInLibraryClasses(file) || fileIndex.isInLibrarySource(file)
|| StdFileTypes.IDEA_MODULE.equals(file.getFileType()) && findModuleByModuleFile(context.getProject(), file) != null;
}
@Override
@@ -64,8 +66,9 @@ public class ProjectStructureSelectInTarget extends SelectInTargetBase implement
module = facet == null? null : facet.getModule();
}
else {
Module moduleByIml = file.getFileType().equals(StdFileTypes.IDEA_MODULE) ? findModuleByModuleFile(project, file) : null;
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
module = fileIndex.getModuleForFile(file);
module = moduleByIml != null ? moduleByIml : fileIndex.getModuleForFile(file);
facet = fileIndex.isInSourceContent(file) ? null : findFacet(project, file);
}
if (module != null || facet != null) {
@@ -94,6 +97,16 @@ public class ProjectStructureSelectInTarget extends SelectInTargetBase implement
}
}
@Nullable
private static Module findModuleByModuleFile(@NotNull Project project, @NotNull VirtualFile file) {
for (Module module : ModuleManager.getInstance(project).getModules()) {
if (file.equals(module.getModuleFile())) {
return module;
}
}
return null;
}
@Nullable
private static Facet findFacet(final @NotNull Project project, final @NotNull VirtualFile file) {
for (FacetTypeId id : FacetTypeRegistry.getInstance().getFacetTypeIds()) {
@@ -406,8 +406,9 @@ public class GenericsHighlightUtil {
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && aClass.isInterface() && method.hasModifierProperty(PsiModifier.DEFAULT)) {
HierarchicalMethodSignature sig = method.getHierarchicalMethodSignature();
for (HierarchicalMethodSignature methodSignature : sig.getSuperSignatures()) {
final PsiClass containingClass = methodSignature.getMethod().getContainingClass();
if (containingClass != null && CommonClassNames.JAVA_LANG_OBJECT.equals(containingClass.getQualifiedName())) {
final PsiMethod objectMethod = methodSignature.getMethod();
final PsiClass containingClass = objectMethod.getContainingClass();
if (containingClass != null && CommonClassNames.JAVA_LANG_OBJECT.equals(containingClass.getQualifiedName()) && objectMethod.hasModifierProperty(PsiModifier.PUBLIC)) {
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
.descriptionAndTooltip("Default method '" + sig.getName() + "' overrides a member of 'java.lang.Object'")
.range(methodIdentifier)
@@ -308,7 +308,7 @@ public class LambdaUtil {
final int finalLambdaIdx = adjustLambdaIdx(lambdaIdx, (PsiMethod)resolve, parameters);
if (finalLambdaIdx < parameters.length) {
if (!tryToSubstitute) return getNormalizedType(parameters[finalLambdaIdx]);
return PsiResolveHelper.ourGuard.doPreventingRecursion(expression, true, new Computable<PsiType>() {
return PsiResolveHelper.ourGraphGuard.doPreventingRecursion(expression, true, new Computable<PsiType>() {
@Override
public PsiType compute() {
return resolveResult.getSubstitutor().substitute(getNormalizedType(parameters[finalLambdaIdx]));
@@ -225,15 +225,21 @@ public class JavaResolveUtil {
return true;
}
public static void substituteResults(@NotNull PsiJavaCodeReferenceElement ref, @NotNull JavaResolveResult[] result) {
public static void substituteResults(final @NotNull PsiJavaCodeReferenceElement ref, @NotNull JavaResolveResult[] result) {
if (result.length > 0 && result[0].getElement() instanceof PsiClass) {
PsiType[] parameters = ref.getTypeParameters();
for (int i = 0; i < result.length; i++) {
CandidateInfo resolveResult = (CandidateInfo)result[i];
PsiElement resultElement = resolveResult.getElement();
final CandidateInfo resolveResult = (CandidateInfo)result[i];
final PsiElement resultElement = resolveResult.getElement();
if (resultElement instanceof PsiClass && ((PsiClass)resultElement).hasTypeParameters()) {
PsiSubstitutor substitutor = resolveResult.getSubstitutor().putAll((PsiClass)resultElement, parameters);
result[i] = new CandidateInfo(resolveResult, substitutor);
PsiSubstitutor substitutor = resolveResult.getSubstitutor();
result[i] = new CandidateInfo(resolveResult, substitutor) {
@NotNull
@Override
public PsiSubstitutor getSubstitutor() {
final PsiType[] parameters = ref.getTypeParameters();
return super.getSubstitutor().putAll((PsiClass)resultElement, parameters);
}
};
}
}
}
@@ -389,21 +389,4 @@ public class InferenceIncorporationPhase {
}
}
}
public PsiSubstitutor checkIncorporated(PsiSubstitutor substitutor, Collection<InferenceVariable> variables) {
for (InferenceVariable variable : variables) { //todo equals bounds?
for (PsiType lowerBound : variable.getBounds(InferenceBound.LOWER)) {
lowerBound = substitutor.substitute(lowerBound);
if (mySession.isProperType(lowerBound)) {
for (PsiType upperBound : variable.getBounds(InferenceBound.UPPER)) {
upperBound = substitutor.substitute(upperBound);
if (mySession.isProperType(upperBound) && !TypeConversionUtil.isAssignable(upperBound, lowerBound)) {
return null;
}
}
}
}
}
return substitutor;
}
}
@@ -23,12 +23,6 @@ import com.intellij.psi.*;
import com.intellij.psi.impl.PsiImplUtil;
import com.intellij.psi.impl.source.resolve.graphInference.constraints.*;
import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.scope.MethodProcessorSetupFailedException;
import com.intellij.psi.scope.PsiConflictResolver;
import com.intellij.psi.scope.conflictResolvers.JavaMethodsConflictResolver;
import com.intellij.psi.scope.processor.MethodCandidatesProcessor;
import com.intellij.psi.scope.processor.MethodResolverProcessor;
import com.intellij.psi.scope.util.PsiScopesUtil;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiTypesUtil;
@@ -174,7 +168,8 @@ public class InferenceSession {
return true;
}
private static PsiType getParameterType(PsiParameter[] parameters, PsiExpression[] args, int i, PsiSubstitutor substitutor) {
private static PsiType getParameterType(PsiParameter[] parameters, PsiExpression[] args, int i, @Nullable PsiSubstitutor substitutor) {
if (substitutor == null) return null;
PsiType parameterType = substitutor.substitute(parameters[i < parameters.length ? i : parameters.length - 1].getType());
if (parameterType instanceof PsiEllipsisType) {
final PsiExpression arg = args[i];
@@ -213,7 +208,7 @@ public class InferenceSession {
PsiMethod parentMethod) {
if (!repeatInferencePhases(true)) {
//inferred result would be checked as candidate won't be applicable
return resolveSubset(myInferenceVariables.values(), mySiteSubstitutor, false);
return resolveSubset(myInferenceVariables.values(), mySiteSubstitutor);
}
if (parentMethod != null) {
@@ -299,7 +294,7 @@ public class InferenceSession {
}
}
} else {
return resolveSubset(myInferenceVariables.values(), mySiteSubstitutor, false);
return resolveSubset(myInferenceVariables.values(), mySiteSubstitutor);
}
return prepareSubstitution();
@@ -340,9 +335,13 @@ public class InferenceSession {
return false;
}
public void initBounds(PsiTypeParameter... typeParameters) {
public boolean initBounds(PsiTypeParameter... typeParameters) {
boolean sameMethodCall = false;
for (PsiTypeParameter parameter : typeParameters) {
if (myInferenceVariables.containsKey(parameter)) continue;
if (myInferenceVariables.containsKey(parameter)) {
sameMethodCall = true;
continue;
}
InferenceVariable variable = new InferenceVariable(parameter);
boolean added = false;
final PsiClassType[] extendsListTypes = parameter.getExtendsListTypes();
@@ -359,6 +358,7 @@ public class InferenceSession {
}
myInferenceVariables.put(parameter, variable);
}
return sameMethodCall;
}
public void addCapturedVariable(PsiTypeParameter param) {
@@ -366,19 +366,13 @@ public class InferenceSession {
}
private void initReturnTypeConstraint(PsiMethod method, final PsiCallExpression context) {
if (PsiPolyExpressionUtil.isMethodCallPolyExpression(context, method) ||
context instanceof PsiNewExpression && PsiDiamondType.ourDiamondGuard.currentStack().contains(context)) {
if (PsiPolyExpressionUtil.isMethodCallPolyExpression(context, method)) {
PsiType returnType = method.getReturnType();
if (!PsiType.VOID.equals(returnType) && returnType != null) {
returnType = PsiImplUtil.normalizeWildcardTypeByPosition(returnType, context);
PsiType targetType = PsiTypesUtil.getExpectedTypeByParent(context);
if (targetType == null) {
targetType = PsiResolveHelper.ourGraphGuard.doPreventingRecursion(context, false, new Computable<PsiType>() {
@Override
public PsiType compute() {
return getTargetType(context);
}
});
targetType = getTargetType(context);
}
if (targetType != null) {
registerConstraints(returnType, targetType);
@@ -397,7 +391,7 @@ public class InferenceSession {
public void registerConstraints(PsiType returnType, PsiType targetType) {
final InferenceVariable inferenceVariable = shouldResolveAndInstantiate(returnType, targetType);
if (inferenceVariable != null) {
final PsiSubstitutor substitutor = resolveSubset(Collections.singletonList(inferenceVariable), mySiteSubstitutor, true);
final PsiSubstitutor substitutor = resolveSubset(Collections.singletonList(inferenceVariable), mySiteSubstitutor);
myConstraints.add(new TypeCompatibilityConstraint(targetType, PsiUtil.captureToplevelWildcards(substitutor.substitute(inferenceVariable.getParameter()), myContext)));
}
else {
@@ -495,7 +489,7 @@ public class InferenceSession {
return false;
}
private PsiType getTargetType(final PsiExpression context) {
private static PsiType getTargetType(final PsiExpression context) {
final PsiElement parent = PsiUtil.skipParenthesizedExprUp(context.getParent());
if (parent instanceof PsiExpressionList) {
PsiElement gParent = parent.getParent();
@@ -505,28 +499,8 @@ public class InferenceSession {
if (gParent instanceof PsiCallExpression) {
final PsiExpressionList argumentList = ((PsiCallExpression)gParent).getArgumentList();
if (argumentList != null) {
final Pair<PsiMethod, PsiSubstitutor> pair = MethodCandidateInfo.getCurrentMethod(argumentList);
final PsiFile placeFile = context.getContainingFile();
final JavaMethodsConflictResolver conflictResolver = new JavaMethodsConflictResolver(argumentList, PsiUtil.getLanguageLevel(placeFile)){
@Override
protected PsiType[] getArgumentTypes() {
return InferenceSession.getArgumentTypes(argumentList, context);
}
};
final MethodCandidatesProcessor processor = new MethodResolverProcessor((PsiCallExpression)gParent, placeFile, new PsiConflictResolver[]{conflictResolver}) {
@Override
protected PsiType[] getExpressionTypes(PsiExpressionList argumentList) {
return getArgumentTypes(argumentList, context);
}
};
try {
PsiScopesUtil.setupAndRunProcessor(processor, (PsiCallExpression)gParent, false);
}
catch (MethodProcessorSetupFailedException e) {
return null;
}
final JavaResolveResult[] results = processor.getResult();
return results.length == 1 ? getTypeByMethod(context, argumentList, pair, results[0], results[0].getElement()) : null;
final JavaResolveResult result = ((PsiCallExpression)gParent).resolveMethodGenerics();
return getTypeByMethod(context, argumentList, result, result.getElement());
}
}
} else if (parent instanceof PsiConditionalExpression) {
@@ -546,30 +520,9 @@ public class InferenceSession {
return null;
}
private static PsiType[] getArgumentTypes(PsiExpressionList argumentList, PsiExpression context) {
if (argumentList != null) {
final PsiExpression[] expressions = argumentList.getExpressions();
final int idx = LambdaUtil.getLambdaIdx(argumentList, context);
final PsiType[] types = PsiType.createArray(expressions.length);
for (int i = 0; i < expressions.length; i++) {
if (i != idx) {
types[i] = expressions[i].getType();
}
else {
types[i] = PsiType.NULL;
}
}
return types;
}
else {
return null;
}
}
private PsiType getTypeByMethod(PsiExpression context,
PsiExpressionList argumentList,
Pair<PsiMethod, PsiSubstitutor> pair,
JavaResolveResult result, PsiElement parentMethod) {
private static PsiType getTypeByMethod(PsiExpression context,
PsiExpressionList argumentList,
final JavaResolveResult result, PsiElement parentMethod) {
if (parentMethod instanceof PsiMethod) {
final PsiParameter[] parameters = ((PsiMethod)parentMethod).getParameterList().getParameters();
if (parameters.length == 0) return null;
@@ -581,23 +534,13 @@ public class InferenceSession {
}
final int i = ArrayUtilRt.find(args, arg);
if (i < 0) return null;
final PsiCallExpression callExpression = PsiTreeUtil.getParentOfType(argumentList, PsiCallExpression.class);
if (callExpression != null && callExpression.getTypeArguments().length > 0) {
return getParameterType(parameters, args, i, ((MethodCandidateInfo)result).typeArgumentsSubstitutor());
}
final PsiType parameterType = getParameterType(parameters, args, i, pair != null ? pair.second : PsiSubstitutor.EMPTY);
args[i] = null;
final PsiTypeParameter[] typeParameters = ((PsiMethod)parentMethod).getTypeParameters();
final InferenceSession session = new InferenceSession(typeParameters, ((MethodCandidateInfo)result).getSiteSubstitutor(), myManager, argumentList);
session.initExpressionConstraints(parameters, args, argumentList, (PsiMethod)parentMethod);
if (session.tryToInfer(parameters, args, callExpression, (PsiMethod)parentMethod) != null) {
return null;
}
final Collection<PsiTypeParameter> params = session.getTypeParams();
initBounds(params.toArray(new PsiTypeParameter[params.size()]));
liftBounds(session.getInferenceVariables());
final PsiSubstitutor substitutor = ((MethodCandidateInfo)result).getSiteSubstitutor();
return substitutor.substitute(parameterType);
return getParameterType(parameters, args, i, PsiResolveHelper.ourGraphGuard.doPreventingRecursion(argumentList.getParent(), false,
new Computable<PsiSubstitutor>() {
@Override
public PsiSubstitutor compute() {
return result.getSubstitutor();
}
}));
}
return null;
}
@@ -720,7 +663,7 @@ public class InferenceSession {
while (!allVars.isEmpty()) {
final List<InferenceVariable> vars = InferenceVariablesOrder.resolveOrder(allVars, this);
if (!myIncorporationPhase.hasCaptureConstraints(vars)) {
final PsiSubstitutor firstSubstitutor = resolveSubset(vars, substitutor, true);
final PsiSubstitutor firstSubstitutor = resolveSubset(vars, substitutor);
if (firstSubstitutor != null) {
substitutor = firstSubstitutor;
allVars.removeAll(vars);
@@ -731,7 +674,7 @@ public class InferenceSession {
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(getManager().getProject());
for (InferenceVariable var : vars) {
final PsiTypeParameter parameter = var.getParameter();
final PsiTypeParameter copy = elementFactory.createTypeParameterFromText(parameter.getName(), null);
final PsiTypeParameter copy = elementFactory.createTypeParameterFromText("z" + parameter.getName(), null);
final PsiType lub = getLowerBound(var, substitutor);
final PsiType glb = getUpperBound(var, substitutor);
final InferenceVariable zVariable = new InferenceVariable(copy);
@@ -744,6 +687,8 @@ public class InferenceSession {
zVariable.addBound(lub, InferenceBound.LOWER);
}
myInferenceVariables.put(copy, zVariable);
allVars.add(zVariable);
var.addBound(elementFactory.createType(copy), InferenceBound.EQ);
}
myIncorporationPhase.forgetCaptures(vars);
if (!myIncorporationPhase.incorporate()) {
@@ -762,7 +707,7 @@ public class InferenceSession {
}, substitutor);
}
private PsiSubstitutor resolveSubset(Collection<InferenceVariable> vars, PsiSubstitutor substitutor, boolean checkResult) {
private PsiSubstitutor resolveSubset(Collection<InferenceVariable> vars, PsiSubstitutor substitutor) {
for (InferenceVariable var : vars) {
LOG.assertTrue(var.getInstantiation() == PsiType.NULL);
final PsiTypeParameter typeParameter = var.getParameter();
@@ -781,7 +726,7 @@ public class InferenceSession {
}
}
return checkResult ? myIncorporationPhase.checkIncorporated(substitutor, vars) : substitutor;
return substitutor;
}
private PsiType getUpperBound(InferenceVariable var, PsiSubstitutor substitutor) {
@@ -872,7 +817,7 @@ public class InferenceSession {
}
//resolve input variables
PsiSubstitutor substitutor = resolveSubset(varsToResolve, mySiteSubstitutor, true);
PsiSubstitutor substitutor = resolveSubset(varsToResolve, mySiteSubstitutor);
if (substitutor == null) {
return false;
@@ -48,17 +48,6 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
if (!PsiPolyExpressionUtil.isPolyExpression(myExpression)) {
return true;
}
if (myExpression instanceof PsiCallExpression) {
final PsiExpressionList argumentList = ((PsiCallExpression)myExpression).getArgumentList();
if (argumentList != null) {
for (PsiExpression expression : argumentList.getExpressions()) {
if (PsiPolyExpressionUtil.isPolyExpression(expression)) {
//todo additional constraints [JDK-8033488]
}
}
}
return true;
}
if (myExpression instanceof PsiParenthesizedExpression) {
constraints.add(new CheckedExceptionCompatibilityConstraint(((PsiParenthesizedExpression)myExpression).getExpression(), myT));
return true;
@@ -122,7 +111,7 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
final PsiSubstitutor psiSubstitutor = qualifierResolveResult.getSubstitutor();
final PsiMethod method;
if (((PsiMethodReferenceExpression)myExpression).isExact()) {
final PsiElement resolve = ((PsiMethodReferenceExpression)myExpression).resolve();
final PsiElement resolve = ((PsiMethodReferenceExpression)myExpression).getPotentiallyApplicableMember();
if (resolve instanceof PsiMethod) {
method = (PsiMethod)resolve;
} else {
@@ -22,9 +22,11 @@ import com.intellij.psi.impl.source.resolve.graphInference.PsiPolyExpressionUtil
import com.intellij.psi.impl.source.tree.java.PsiMethodCallExpressionImpl;
import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.util.containers.HashSet;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -99,22 +101,46 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm
if (typeParams != null) {
for (PsiTypeParameter typeParam : typeParams) {
session.addCapturedVariable(typeParam);
}
final HashSet<PsiTypeParameter> oldBounds = new HashSet<PsiTypeParameter>(session.getTypeParams());
final boolean sameMethodCall = session.initBounds(typeParams);
PsiSubstitutor substitutor = PsiSubstitutor.EMPTY;
final HashSet<InferenceVariable> variables = new HashSet<InferenceVariable>();
session.collectDependencies(returnType, variables);
final PsiTypeParameter[] params = new PsiTypeParameter[typeParams.length];
for (int i = 0; i < typeParams.length; i++) {
if (variables.contains(session.getInferenceVariable(typeParams[i]))) {
params[i] = JavaPsiFacade.getElementFactory(myExpression.getProject()).createTypeParameterFromText("copyOf" + myExpression.hashCode() + typeParams[i].getName(), null);
substitutor = substitutor.put(typeParams[i], JavaPsiFacade.getElementFactory(myExpression.getProject()).createType(params[i]));
}
else {
params[i] = typeParams[i];
}
}
final PsiSubstitutor siteSubstitutor = resolveResult instanceof MethodCandidateInfo ? ((MethodCandidateInfo)resolveResult).getSiteSubstitutor() : PsiSubstitutor.EMPTY;
for (PsiTypeParameter typeParameter : siteSubstitutor.getSubstitutionMap().keySet()) {
substitutor = substitutor.put(typeParameter, substitutor.substitute(siteSubstitutor.substitute(typeParameter)));
}
final Collection<PsiTypeParameter> params1 = session.getTypeParams();
final InferenceSession callSession = new InferenceSession(params1.toArray(new PsiTypeParameter[params1.size()]), substitutor, myExpression.getManager(), myExpression);
callSession.initBounds(params);
if (method != null) {
//typeParams are already included
final Collection<PsiTypeParameter> params = session.getTypeParams();
InferenceSession callSession = new InferenceSession(params.toArray(new PsiTypeParameter[params.size()]), resolveResult instanceof MethodCandidateInfo ? ((MethodCandidateInfo)resolveResult).getSiteSubstitutor()
: PsiSubstitutor.EMPTY, myExpression.getManager(), myExpression);
final PsiExpression[] args = argumentList.getExpressions();
final PsiParameter[] parameters = method.getParameterList().getParameters();
callSession.initExpressionConstraints(parameters, args, myExpression, method);
callSession.registerConstraints(returnType, myT);
if (callSession.repeatInferencePhases(true)) {
session.liftBounds(callSession.getInferenceVariables());
}
callSession.registerConstraints(returnType, myT);
if (callSession.repeatInferencePhases(true)) {
final Collection<InferenceVariable> inferenceVariables = callSession.getInferenceVariables();
if (sameMethodCall) {
for (Iterator<InferenceVariable> iterator = inferenceVariables.iterator(); iterator.hasNext(); ) {
InferenceVariable variable = iterator.next();
if (oldBounds.contains(variable.getParameter())) {
iterator.remove();
}
}
}
session.liftBounds(inferenceVariables);
}
final PsiType capturedReturnType = myExpression instanceof PsiMethodCallExpression
? PsiMethodCallExpressionImpl.captureReturnType((PsiMethodCallExpression)myExpression, method, returnType, substitutor)
@@ -109,6 +109,11 @@ public class TypeEqualityConstraint implements ConstraintFormula {
return true;
}
if (myT instanceof PsiCapturedWildcardType && myS instanceof PsiCapturedWildcardType) {
return new TypeEqualityConstraint(((PsiCapturedWildcardType)myT).getWildcard(),
((PsiCapturedWildcardType)myS).getWildcard()).reduce(session, constraints);
}
return false;
}
@@ -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.
@@ -38,7 +38,8 @@ public class ExpressionPsiElement extends CompositePsiElement {
@Override
public void replaceChildInternal(@NotNull ASTNode child, @NotNull TreeElement newElement) {
if (ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())) {
if (ElementType.EXPRESSION_BIT_SET.contains(child.getElementType()) &&
ElementType.EXPRESSION_BIT_SET.contains(newElement.getElementType())) {
boolean needParenth = ReplaceExpressionUtil.isNeedParenthesis(child, newElement);
if (needParenth) {
newElement = SourceUtil.addParenthToReplacedChild(JavaElementType.PARENTH_EXPRESSION, newElement, getManager());
@@ -499,6 +499,7 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
final PsiClass pClass = pResult.getElement();
final PsiSubstitutor receiverSubstitutor = pClass != null ? TypeConversionUtil.getClassSubstitutor(containingClass, pClass, pResult.getSubstitutor()) : null;
if (receiverSubstitutor != null) {
if (!method.hasTypeParameters() && signature.getParameterTypes().length == 1) return receiverSubstitutor;
psiSubstitutor = receiverSubstitutor;
}
}
@@ -638,20 +639,26 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
}
}
if (myQualifierResolveResult.isReferenceTypeQualified() && getReferenceNameElement() instanceof PsiIdentifier) {
//If the first search produces a static method, and no non-static method is applicable for the second search, then the result of the first search is the compile-time declaration.
CandidateInfo candidateInfo = filterStaticCorrectCandidates(firstCandidates, secondCandidates, true);
if (candidateInfo != null) {
return candidateInfo;
}
//If the second search produces a non-static method, and no static method is applicable for the first search, then the result of the second search is the compile-time declaration.
candidateInfo = filterStaticCorrectCandidates(secondCandidates, firstCandidates, false);
if (candidateInfo != null) {
return candidateInfo;
}
}
checkSpecifics(firstCandidates,
varargs ? MethodCandidateInfo.ApplicabilityLevel.VARARGS : MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY, myLanguageLevel);
checkSpecifics(secondCandidates,
varargs ? MethodCandidateInfo.ApplicabilityLevel.VARARGS : MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY, myLanguageLevel);
if (myQualifierResolveResult.isReferenceTypeQualified() && getReferenceNameElement() instanceof PsiIdentifier) {
//If the first search produces a static method, and no non-static method is applicable for the second search, then the result of the first search is the compile-time declaration.
filterStaticCorrectCandidates(firstCandidates, true);
//If the second search produces a non-static method, and no static method is applicable for the first search, then the result of the second search is the compile-time declaration.
filterStaticCorrectCandidates(secondCandidates, false);
}
final int acceptedCount = firstCandidates.size() + secondCandidates.size();
if (acceptedCount == 1) {
return !firstCandidates.isEmpty() ? firstCandidates.get(0) : secondCandidates.get(0);
@@ -684,17 +691,29 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
/**
* 15.13.1
*/
private void filterStaticCorrectCandidates(List<CandidateInfo> firstCandidates,
private CandidateInfo filterStaticCorrectCandidates(List<CandidateInfo> firstCandidates,
List<CandidateInfo> secondCandidates,
boolean shouldBeStatic) {
for (Iterator<CandidateInfo> iterator = firstCandidates.iterator(); iterator.hasNext(); ) {
final PsiElement element = iterator.next().getElement();
if (firstCandidates.size() == 1) {
final CandidateInfo candidateInfo = firstCandidates.get(0);
final PsiElement element = candidateInfo.getElement();
if (element instanceof PsiMethod) {
final boolean isStatic = ((PsiMethod)element).hasModifierProperty(PsiModifier.STATIC);
if (shouldBeStatic && !isStatic || !shouldBeStatic && isStatic) {
iterator.remove();
if (shouldBeStatic && isStatic || !shouldBeStatic && !isStatic) {
for (CandidateInfo secondCandidate : secondCandidates) {
final PsiElement psiElement = secondCandidate.getElement();
if (psiElement instanceof PsiMethod) {
final boolean oppositeStatic = ((PsiMethod)psiElement).hasModifierProperty(PsiModifier.STATIC);
if (shouldBeStatic && !oppositeStatic || !shouldBeStatic && oppositeStatic) {
return null;
}
}
}
return candidateInfo;
}
}
}
return null;
}
private boolean isCorrectAssignment(PsiType[] signatureParameterTypes2,
@@ -0,0 +1,4 @@
class Foo {{
System.out.p<caret>
System.out.p<caret>
}}
@@ -0,0 +1,4 @@
class Foo {{
System.out.append(<caret>)
System.out.append(<caret>)
}}
@@ -97,14 +97,14 @@ interface I<T> {
class FI1 {
I<? extends String> i1 = new I<<error descr="Cannot use ''<>'' with anonymous inner classes"></error>>() {
@Override
public <error descr="'m()' in 'Anonymous class derived from I' clashes with 'm()' in 'I'; attempting to use incompatible return type">String</error> m() {
public String m() {
return null;
}
};
I<?> i2 = new I<<error descr="Cannot use ''<>'' with anonymous inner classes"></error>>() {
@Override
public <error descr="'m()' in 'Anonymous class derived from I' clashes with 'm()' in 'I'; attempting to use incompatible return type">Object</error> m() {
public Object m() {
return null;
}
};
@@ -1,3 +1,41 @@
import java.util.List;
import java.util.function.Function;
abstract class Main2 {
void address(Foo sa) {
String ds = foobar(foobar(sa, Foo::getBar), Bar ::getName);
Function<Foo, Bar> f = null;
String ds1 = foobar(foobar(sa, f), null);
}
abstract <T, V> V foobar(T t, Function<T, V> mapper);
class Foo {
Bar getBar() {
return new Bar();
}
}
class Bar {
String getName(){
return null;
}
}
}
class Main0 {
<T> List<T> foo(T t){
return null;
}
{
foo(foo(""));
}
}
class Main {
static <T> T foo(T t) { return null; }
@@ -14,6 +52,6 @@ class Main1 {
static <B> B bar(B t) { return null;}
static {
long l = foo(bar(1));
//long l = foo(bar(1));
}
}
@@ -2,4 +2,5 @@ interface A {
default String <error descr="Default method 'toString' overrides a member of 'java.lang.Object'">toString</error>() {
return "";
}
default void finalize() throws Throwable { }
}
@@ -29,7 +29,7 @@ class AlienTest {
<error descr="Incompatible types. Found: '<method reference>', required: 'AlienTest.IInt'">IInt i2 = MyTest::foo;</error>
<error descr="Incompatible types. Found: '<method reference>', required: 'AlienTest.IInt'">IInt i3 = MyTest::bar;</error>
<error descr="Incompatible types. Found: '<method reference>', required: 'AlienTest.IIntInt'">IIntInt i4 = MyTest::bar;</error>
<error descr="Incompatible types. Found: '<method reference>', required: 'AlienTest.IInt'">IInt i5 = MyTest::baz;</error>
IInt i5 = <error descr="Non-static method cannot be referenced from a static context">MyTest::baz</error>;
IInt i6 = <error descr="'foo(int)' is not public in 'MyTest.Foo'. Cannot be accessed from outside package">MyTest.foo::foo</error>;
IInt i7 = MyTest.<error descr="'MyTest.Foo' has private access in 'MyTest'">Foo</error>::foo;
}
@@ -29,7 +29,7 @@ class MyTest {
}
public static void main(String[] args) {
foo<error descr="Ambiguous method call: both 'MyTest.foo(I1)' and 'MyTest.foo(I2)' match">(Foo::m)</error>;
foo<error descr="Ambiguous method call: both 'MyTest.foo(I2)' and 'MyTest.foo(I3)' match">(Foo::m)</error>;
}
}
@@ -41,14 +41,14 @@ class MyTest1 {
static void call2(I2 s) { }
static void test1() {
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest1.I1'">I1 s1 = MyTest1 ::m1;</error>
call1<error descr="'call1(MyTest1.I1)' in 'MyTest1' cannot be applied to '(<method reference>)'">(MyTest1::m1)</error>;
I1 s1 = <error descr="Non-static method cannot be referenced from a static context">MyTest1 ::m1</error>;
call1(<error descr="Non-static method cannot be referenced from a static context">MyTest1::m1</error>);
I1 s2 = MyTest1 :: m2;
call1(MyTest1::m2);
I1 s3 = MyTest1::m3;
call1(MyTest1::m3);
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest1.I1'">I1 s4 = MyTest1::m4;</error>
call1<error descr="'call1(MyTest1.I1)' in 'MyTest1' cannot be applied to '(<method reference>)'">(MyTest1::m4)</error>;
I1 s4 = <error descr="Non-static method cannot be referenced from a static context">MyTest1::m4</error>;
call1(<error descr="Non-static method cannot be referenced from a static context">MyTest1::m4</error>);
}
static void test2() {
@@ -90,14 +90,14 @@ class MyTest2 {
static void call2(I2 s) { }
static void test1() {
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest2.I1'">I1 s1 = MyTest2 ::m1;</error>
call1<error descr="'call1(MyTest2.I1)' in 'MyTest2' cannot be applied to '(<method reference>)'">(MyTest2::m1)</error>;
I1 s1 = <error descr="Non-static method cannot be referenced from a static context">MyTest2 ::m1</error>;
call1(<error descr="Non-static method cannot be referenced from a static context">MyTest2::m1</error>);
I1 s2 = MyTest2 :: m2;
call1(MyTest2::m2);
I1 s3 = MyTest2::m3;
call1(MyTest2::m3);
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest2.I1'">I1 s4 = MyTest2::m4;</error>
call1<error descr="'call1(MyTest2.I1)' in 'MyTest2' cannot be applied to '(<method reference>)'">(MyTest2::m4)</error>;
I1 s4 = <error descr="Non-static method cannot be referenced from a static context">MyTest2::m4</error>;
call1(<error descr="Non-static method cannot be referenced from a static context">MyTest2::m4</error>);
}
static void test2() {
@@ -55,7 +55,7 @@ class MyTest {
{
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i_1 = MyTest::_1;</error>
I1 i_1 = <error descr="Non-static method cannot be referenced from a static context">MyTest::_1</error>;
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i_2 = MyTest::_2;</error>
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i_3 = MyTest::_3;</error>
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest.I1'">I1 i_4 = MyTest::_4;</error>
@@ -3,7 +3,7 @@ import java.util.*;
class Test {
void test() {
Comparator<Test> r2 = Test::yyy;
<error descr="Incompatible types. Found: '<method reference>', required: 'Comparator1<Test>'">Comparator1<Test> c1 = Test::yyy;</error>
Comparator1<Test> c1 = <error descr="Non-static method cannot be referenced from a static context">Test::yyy</error>;
<error descr="Incompatible types. Found: '<method reference>', required: 'Comparator1<Test>'">Comparator1<Test> c2 = Test::xxx;</error>
}
int yyy(Test... p) { return 1; }
@@ -0,0 +1,15 @@
class Test {
static class Foo<X> {
X m() { return null;}
}
interface I {
Foo<Object> _i(Foo<String> fs);
}
static void foo(I i) { }
{
foo(<error descr="Bad return type in method reference: cannot convert java.lang.String to Test.Foo<java.lang.Object>">Foo::m</error>);
}
}
@@ -0,0 +1,15 @@
class Test {
interface I {
void m(Test rec, String s);
}
void m(Test t, String s) {}
void m(String s) {}
static void m(Test t, Object s) {}
static void test() {
<error descr="Incompatible types. Found: '<method reference>', required: 'Test.I'">I i = Test::m;</error>
}
}
@@ -52,6 +52,7 @@ import com.intellij.psi.PsiFile
import com.intellij.psi.PsiJavaFile
import com.intellij.psi.statistics.StatisticsManager
import com.intellij.psi.statistics.impl.StatisticsManagerImpl
import com.intellij.testFramework.EditorTestUtil
import com.intellij.util.containers.ContainerUtil
import org.jetbrains.annotations.NotNull
@@ -1141,6 +1142,56 @@ class Foo {{
}}'''
}
public void testMulticaret() {
doTestMulticaret """
class Foo {{
<selection>t<caret></selection>x;
<selection>t<caret></selection>x;
}}""", '\n', '''
class Foo {{
toString()<caret>x;
toString()<caret>x;
}}'''
}
public void testMulticaretTab() {
doTestMulticaret """
class Foo {{
<selection>t<caret></selection>x;
<selection>t<caret></selection>x;
}}""", '\t', '''
class Foo {{
toString()<caret>;
toString()<caret>;
}}'''
}
public void testMulticaretBackspace() {
doTestMulticaret """
class Foo {{
<selection>t<caret></selection>;
<selection>t<caret></selection>;
}}""", '\b\t', '''
class Foo {{
toString()<caret>;
toString()<caret>;
}}'''
}
private doTestMulticaret(final String textBefore, final String toType, final String textAfter) {
EditorTestUtil.enableMultipleCarets()
try {
myFixture.configureByText "a.java", textBefore
type 'toStr'
assert lookup
type toType
myFixture.checkResult textAfter
}
finally {
EditorTestUtil.disableMultipleCarets()
}
}
private doTestBlockSelection(final String textBefore, final String toType, final String textAfter) {
myFixture.configureByText "a.java", textBefore
edt {
@@ -1403,6 +1403,21 @@ class Foo {{
}
}
public void testMulticaretTyping() {
EditorTestUtil.enableMultipleCarets()
try {
configure()
assert lookup
type('p')
assert lookup
type('\n')
checkResult()
}
finally {
EditorTestUtil.disableMultipleCarets()
}
}
public void "test complete lowercase class name"() {
myFixture.addClass("package foo; public class myClass {}")
myFixture.configureByText "a.java", """
@@ -28,7 +28,7 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
doTest();
}
public void _testNestedCallsSameMethod() throws Exception {
public void testNestedCallsSameMethod() throws Exception {
doTest();
}
@@ -173,6 +173,14 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testReturnTypeCheckForRawReceiver() throws Exception {
doTest();
}
public void testStaticNonStaticReferenceTypeAmbiguity() throws Exception {
doTest();
}
private void doTest() {
doTest(false);
}
@@ -21,16 +21,22 @@ import com.intellij.openapi.util.DefaultJDOMExternalizer;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizable;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.util.xmlb.annotations.Attribute;
import com.intellij.util.xmlb.annotations.Tag;
import com.intellij.util.xmlb.annotations.Transient;
import org.jdom.Element;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Tag("class-filter")
public class ClassFilter implements JDOMExternalizable, Cloneable{
private static final Logger LOG = Logger.getInstance("#com.intellij.ui.classFilter.ClassFilter");
public static final ClassFilter[] EMPTY_ARRAY = new ClassFilter[0];
@Attribute("pattern")
public String PATTERN = "";
@Attribute("enabled")
public boolean ENABLED = true;
private Matcher myMatcher; // to speedup matching
@@ -42,9 +48,12 @@ public class ClassFilter implements JDOMExternalizable, Cloneable{
ENABLED = true;
}
@Transient
public String getPattern() {
return PATTERN;
}
@Transient
public boolean isEnabled() {
return ENABLED;
}
@@ -311,26 +311,26 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa
String suspendPolicy = readValue(comment, "suspendPolicy");
if (suspendPolicy != null) {
breakpoint.SUSPEND = !DebuggerSettings.SUSPEND_NONE.equals(suspendPolicy);
breakpoint.SUSPEND_POLICY = suspendPolicy;
//breakpoint.setSuspend(!DebuggerSettings.SUSPEND_NONE.equals(suspendPolicy));
breakpoint.setSuspendPolicy(suspendPolicy);
println("SUSPEND_POLICY = " + suspendPolicy, ProcessOutputTypes.SYSTEM);
}
String condition = readValue(comment, "Condition");
if (condition != null) {
breakpoint.CONDITION_ENABLED = true;
breakpoint.setCondition(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, condition));
//breakpoint.CONDITION_ENABLED = true;
breakpoint.setCondition(/*new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, */condition/*)*/);
println("Condition = " + condition, ProcessOutputTypes.SYSTEM);
}
String passCount = readValue(comment, "Pass count");
if (passCount != null) {
breakpoint.COUNT_FILTER_ENABLED = true;
breakpoint.COUNT_FILTER = Integer.parseInt(passCount);
breakpoint.setCountFilterEnabled(true);
breakpoint.setCountFilter(Integer.parseInt(passCount));
println("Pass count = " + passCount, ProcessOutputTypes.SYSTEM);
}
String classFilters = readValue(comment, "Class filters");
if (classFilters != null) {
breakpoint.CLASS_FILTERS_ENABLED = true;
breakpoint.setClassFiltersEnabled(true);
StringTokenizer tokenizer = new StringTokenizer(classFilters, " ,");
ArrayList<ClassFilter> lst = new ArrayList<ClassFilter>();
+1
View File
@@ -36,6 +36,7 @@
<orderEntry type="module" module-name="jps-model-serialization" />
<orderEntry type="module" module-name="jps-model-impl" />
<orderEntry type="library" scope="TEST" name="Groovy" level="project" />
<orderEntry type="module" module-name="jps-serialization-tests" scope="TEST" />
</component>
</module>
-2
View File
@@ -4,13 +4,11 @@
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="util" />
<orderEntry type="module" module-name="jps-model-api" />
<orderEntry type="module" module-name="testFramework" scope="TEST" />
</component>
</module>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/testSrc">
<sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="jps-model-impl" />
<orderEntry type="module" module-name="testFramework" exported="" scope="TEST" />
</component>
</module>
@@ -4,15 +4,12 @@
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="util" />
<orderEntry type="module" module-name="jps-model-api" />
<orderEntry type="library" exported="" name="JDOM" level="project" />
<orderEntry type="module" module-name="jps-model-impl" exported="" scope="TEST" />
<orderEntry type="module" module-name="testFramework" exported="" scope="TEST" />
</component>
</module>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/testSrc">
<sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="jps-model-serialization" />
<orderEntry type="module" module-name="jps-model-tests" exported="" scope="TEST" />
</component>
</module>
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 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.
@@ -125,6 +125,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
* @return the path
*/
@SuppressWarnings("JavadocReference")
@NotNull
public abstract String getPath();
/**
@@ -727,4 +728,12 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
public static boolean isValidName(@NotNull String name) {
return name.indexOf('\\') < 0 && name.indexOf('/') < 0;
}
private static final Key<String> DETECTED_LINE_SEPARATOR_KEY = Key.create("DETECTED_LINE_SEPARATOR_KEY");
public String getDetectedLineSeparator() {
return getUserData(DETECTED_LINE_SEPARATOR_KEY);
}
public void setDetectedLineSeparator(String separator) {
putUserData(DETECTED_LINE_SEPARATOR_KEY, separator);
}
}
@@ -520,17 +520,27 @@ public class PsiTreeUtil {
@Nullable
@Contract("null, _, _ -> null")
public static <T extends PsiElement> T getParentOfType(@Nullable PsiElement element, @NotNull Class<T> aClass, boolean strict) {
if (element == null) return null;
return getParentOfType(element, aClass, strict, -1);
}
@Contract("null, _, _, _ -> null")
public static <T extends PsiElement> T getParentOfType(@Nullable PsiElement element, @NotNull Class<T> aClass, boolean strict, int minStartOffset) {
if (element == null) {
return null;
}
if (strict) {
element = element.getParent();
}
while (element != null) {
while (element != null && (minStartOffset == -1 || element.getNode().getStartOffset() >= minStartOffset)) {
if (aClass.isInstance(element)) {
//noinspection unchecked
return (T)element;
}
if (element instanceof PsiFile) return null;
if (element instanceof PsiFile) {
return null;
}
element = element.getParent();
}

Some files were not shown because too many files have changed in this diff Show More