mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
leaked CmdMerger in UndoManager in tests
This commit is contained in:
@@ -78,6 +78,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
public CompilerConfigurationImpl(Project project) {
|
||||
myProject = project;
|
||||
myExcludedEntriesConfiguration = new ExcludedEntriesConfiguration();
|
||||
Disposer.register(project, myExcludedEntriesConfiguration);
|
||||
}
|
||||
|
||||
public Element getState() {
|
||||
@@ -156,7 +157,6 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
}
|
||||
|
||||
public void disposeComponent() {
|
||||
Disposer.dispose(myExcludedEntriesConfiguration);
|
||||
}
|
||||
|
||||
public void initComponent() { }
|
||||
|
||||
@@ -30,10 +30,12 @@ import com.intellij.openapi.projectRoots.JdkUtil;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.ex.JavaSdkUtil;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import com.intellij.util.Function;
|
||||
@@ -80,8 +82,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx {
|
||||
}
|
||||
}
|
||||
};
|
||||
private static final @NonNls String DEBUG_KEY_NAME = "idea.xdebug.key";
|
||||
private final EditorColorsListener myColorsListener;
|
||||
@NonNls private static final String DEBUG_KEY_NAME = "idea.xdebug.key";
|
||||
|
||||
public void addClassNameMapper(final NameMapper mapper) {
|
||||
myNameMappers.add(mapper);
|
||||
@@ -109,15 +110,20 @@ public class DebuggerManagerImpl extends DebuggerManagerEx {
|
||||
myDispatcher.removeListener(listener);
|
||||
}
|
||||
|
||||
public DebuggerManagerImpl(Project project, StartupManager startupManager, EditorColorsManager colorsManager) {
|
||||
public DebuggerManagerImpl(Project project, StartupManager startupManager, final EditorColorsManager colorsManager) {
|
||||
myProject = project;
|
||||
myBreakpointManager = new BreakpointManager(myProject, startupManager, this);
|
||||
myColorsListener = new EditorColorsListener() {
|
||||
final EditorColorsListener myColorsListener = new EditorColorsListener() {
|
||||
public void globalSchemeChange(EditorColorsScheme scheme) {
|
||||
getBreakpointManager().updateBreakpointsUI();
|
||||
}
|
||||
};
|
||||
colorsManager.addEditorColorsListener(myColorsListener);
|
||||
Disposer.register(project, new Disposable() {
|
||||
public void dispose() {
|
||||
colorsManager.removeEditorColorsListener(myColorsListener);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public DebuggerSession getSession(DebugProcess process) {
|
||||
@@ -131,12 +137,11 @@ public class DebuggerManagerImpl extends DebuggerManagerEx {
|
||||
public Collection<DebuggerSession> getSessions() {
|
||||
synchronized (mySessions) {
|
||||
final Collection<DebuggerSession> values = mySessions.values();
|
||||
return values.size() > 0 ? new ArrayList<DebuggerSession>(values) : Collections.<DebuggerSession>emptyList();
|
||||
return values.isEmpty() ? Collections.<DebuggerSession>emptyList() : new ArrayList<DebuggerSession>(values);
|
||||
}
|
||||
}
|
||||
|
||||
public void disposeComponent() {
|
||||
EditorColorsManager.getInstance().removeEditorColorsListener(myColorsListener);
|
||||
}
|
||||
|
||||
public void initComponent() {
|
||||
@@ -301,7 +306,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx {
|
||||
myCustomPositionManagerFactories.remove(factory);
|
||||
}
|
||||
|
||||
static private boolean hasWhitespace(String string) {
|
||||
private static boolean hasWhitespace(String string) {
|
||||
int length = string.length();
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (Character.isWhitespace(string.charAt(i))) {
|
||||
@@ -318,10 +323,10 @@ public class DebuggerManagerImpl extends DebuggerManagerEx {
|
||||
throw new ExecutionException(DebuggerBundle.message("error.jdk.not.specified"));
|
||||
}
|
||||
final String versionString = jdk.getVersionString();
|
||||
if (versionString.indexOf("1.0") > -1 || versionString.indexOf("1.1") > -1) {
|
||||
if (versionString.contains("1.0") || versionString.contains("1.1")) {
|
||||
throw new ExecutionException(DebuggerBundle.message("error.unsupported.jdk.version", versionString));
|
||||
}
|
||||
if (SystemInfo.isWindows && versionString.indexOf("1.2") > -1) {
|
||||
if (SystemInfo.isWindows && versionString.contains("1.2")) {
|
||||
final VirtualFile homeDirectory = jdk.getHomeDirectory();
|
||||
if (homeDirectory == null || !homeDirectory.isValid()) {
|
||||
throw new ExecutionException(DebuggerBundle.message("error.invalid.jdk.home", versionString));
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -44,22 +45,28 @@ public class DebuggerPanelsManager implements ProjectComponent {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.DebuggerPanelsManager");
|
||||
|
||||
private final Project myProject;
|
||||
private final ExecutionManager myExecutionManager;
|
||||
|
||||
private final PositionHighlighter myEditorManager;
|
||||
private final HashMap<ProcessHandler, DebuggerSessionTab> mySessionTabs = new HashMap<ProcessHandler, DebuggerSessionTab>();
|
||||
private final EditorColorsListener myColorsListener;
|
||||
|
||||
public DebuggerPanelsManager(Project project, EditorColorsManager colorsManager) {
|
||||
public DebuggerPanelsManager(Project project, final EditorColorsManager colorsManager, ExecutionManager executionManager) {
|
||||
myProject = project;
|
||||
myExecutionManager = executionManager;
|
||||
|
||||
myEditorManager = new PositionHighlighter(myProject, getContextManager());
|
||||
|
||||
myColorsListener = new EditorColorsListener() {
|
||||
final EditorColorsListener myColorsListener = new EditorColorsListener() {
|
||||
public void globalSchemeChange(EditorColorsScheme scheme) {
|
||||
myEditorManager.updateContextPointDescription();
|
||||
}
|
||||
};
|
||||
colorsManager.addEditorColorsListener(myColorsListener);
|
||||
Disposer.register(project, new Disposable() {
|
||||
public void dispose() {
|
||||
colorsManager.removeEditorColorsListener(myColorsListener);
|
||||
}
|
||||
});
|
||||
|
||||
getContextManager().addListener(new DebuggerContextListener() {
|
||||
public void changeEvent(final DebuggerContextImpl newContext, int event) {
|
||||
@@ -78,31 +85,8 @@ public class DebuggerPanelsManager implements ProjectComponent {
|
||||
return DebuggerManagerEx.getInstanceEx(myProject).getContextManager();
|
||||
}
|
||||
|
||||
private final RunContentListener myContentListener = new RunContentListener() {
|
||||
public void contentSelected(RunContentDescriptor descriptor) {
|
||||
DebuggerSessionTab sessionTab = descriptor != null ? getSessionTab(descriptor.getProcessHandler()) : null;
|
||||
|
||||
if (sessionTab != null) {
|
||||
getContextManager()
|
||||
.setState(sessionTab.getContextManager().getContext(), sessionTab.getSession().getState(), DebuggerSession.EVENT_CONTEXT, null);
|
||||
}
|
||||
else {
|
||||
getContextManager()
|
||||
.setState(DebuggerContextImpl.EMPTY_CONTEXT, DebuggerSession.STATE_DISPOSED, DebuggerSession.EVENT_CONTEXT, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void contentRemoved(RunContentDescriptor descriptor) {
|
||||
DebuggerSessionTab sessionTab = getSessionTab(descriptor.getProcessHandler());
|
||||
if (sessionTab != null) {
|
||||
mySessionTabs.remove(descriptor.getProcessHandler());
|
||||
Disposer.dispose(sessionTab);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public
|
||||
@Nullable
|
||||
public
|
||||
RunContentDescriptor attachVirtualMachine(Executor executor,
|
||||
ProgramRunner runner,
|
||||
ExecutionEnvironment environment,
|
||||
@@ -146,14 +130,41 @@ public class DebuggerPanelsManager implements ProjectComponent {
|
||||
|
||||
|
||||
public void projectOpened() {
|
||||
RunContentManager contentManager = ExecutionManager.getInstance(myProject).getContentManager();
|
||||
final RunContentManager contentManager = myExecutionManager.getContentManager();
|
||||
LOG.assertTrue(contentManager != null, "Content manager is null");
|
||||
|
||||
final RunContentListener myContentListener = new RunContentListener() {
|
||||
public void contentSelected(RunContentDescriptor descriptor) {
|
||||
DebuggerSessionTab sessionTab = descriptor != null ? getSessionTab(descriptor.getProcessHandler()) : null;
|
||||
|
||||
if (sessionTab != null) {
|
||||
getContextManager()
|
||||
.setState(sessionTab.getContextManager().getContext(), sessionTab.getSession().getState(), DebuggerSession.EVENT_CONTEXT, null);
|
||||
}
|
||||
else {
|
||||
getContextManager()
|
||||
.setState(DebuggerContextImpl.EMPTY_CONTEXT, DebuggerSession.STATE_DISPOSED, DebuggerSession.EVENT_CONTEXT, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void contentRemoved(RunContentDescriptor descriptor) {
|
||||
DebuggerSessionTab sessionTab = getSessionTab(descriptor.getProcessHandler());
|
||||
if (sessionTab != null) {
|
||||
mySessionTabs.remove(descriptor.getProcessHandler());
|
||||
Disposer.dispose(sessionTab);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
contentManager.addRunContentListener(myContentListener, DefaultDebugExecutor.getDebugExecutorInstance());
|
||||
Disposer.register(myProject, new Disposable() {
|
||||
public void dispose() {
|
||||
contentManager.removeRunContentListener(myContentListener);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void projectClosed() {
|
||||
final RunContentManager contentManager = ExecutionManager.getInstance(myProject).getContentManager();
|
||||
contentManager.removeRunContentListener(myContentListener);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -165,7 +176,6 @@ public class DebuggerPanelsManager implements ProjectComponent {
|
||||
}
|
||||
|
||||
public void disposeComponent() {
|
||||
EditorColorsManager.getInstance().removeEditorColorsListener(myColorsListener);
|
||||
}
|
||||
|
||||
public static DebuggerPanelsManager getInstance(Project project) {
|
||||
@@ -181,8 +191,7 @@ public class DebuggerPanelsManager implements ProjectComponent {
|
||||
@Nullable
|
||||
public DebuggerSessionTab getSessionTab() {
|
||||
DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(myProject).getContext();
|
||||
DebuggerSessionTab sessionTab = getSessionTab(context.getDebuggerSession());
|
||||
return sessionTab;
|
||||
return getSessionTab(context.getDebuggerSession());
|
||||
}
|
||||
|
||||
public void showFramePanel() {
|
||||
|
||||
+40
-34
@@ -76,36 +76,11 @@ public class BreakpointManager implements JDOMExternalizable {
|
||||
private final Map<Key<? extends Breakpoint>, String> myDefaultSuspendPolicies = new HashMap<Key<? extends Breakpoint>, String>();
|
||||
|
||||
private BreakpointsConfigurationDialogFactory myBreakpointsConfigurable;
|
||||
private EditorMouseListener myEditorMouseListener;
|
||||
|
||||
private final EventDispatcher<BreakpointManagerListener> myDispatcher = EventDispatcher.create(BreakpointManagerListener.class);
|
||||
|
||||
private final StartupManager myStartupManager;
|
||||
|
||||
private final DocumentListener myDocumentListener = new DocumentAdapter() {
|
||||
private final Alarm myUpdateAlarm = new Alarm();
|
||||
|
||||
public void documentChanged(final DocumentEvent e) {
|
||||
final Document document = e.getDocument();
|
||||
synchronized (BreakpointManager.this) {
|
||||
List<BreakpointWithHighlighter> breakpoints = myDocumentBreakpoints.get(document);
|
||||
|
||||
if(breakpoints != null) {
|
||||
myUpdateAlarm.cancelAllRequests();
|
||||
// must create new array in order to avoid "concurrent modification" errors
|
||||
final List<BreakpointWithHighlighter> breakpointsToUpdate = new ArrayList<BreakpointWithHighlighter>(breakpoints);
|
||||
myUpdateAlarm.addRequest(new Runnable() {
|
||||
public void run() {
|
||||
if (!myProject.isDisposed()) {
|
||||
PsiDocumentManager.getInstance(myProject).commitDocument(document);
|
||||
update(breakpointsToUpdate);
|
||||
}
|
||||
}
|
||||
}, 300, ModalityState.NON_MODAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@NonNls private static final String MASTER_BREAKPOINT_TAGNAME = "master_breakpoint";
|
||||
@NonNls private static final String SLAVE_BREAKPOINT_TAGNAME = "slave_breakpoint";
|
||||
@NonNls private static final String DEFAULT_SUSPEND_POLICY_ATTRIBUTE_NAME = "default_suspend_policy";
|
||||
@@ -179,7 +154,7 @@ public class BreakpointManager implements JDOMExternalizable {
|
||||
|
||||
public void init() {
|
||||
EditorEventMulticaster eventMulticaster = EditorFactory.getInstance().getEventMulticaster();
|
||||
myEditorMouseListener = new EditorMouseAdapter() {
|
||||
EditorMouseAdapter myEditorMouseListener = new EditorMouseAdapter() {
|
||||
private EditorMouseEvent myMousePressedEvent;
|
||||
|
||||
@Nullable
|
||||
@@ -202,7 +177,7 @@ public class BreakpointManager implements JDOMExternalizable {
|
||||
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
int editorLine = editor.getDocument().getLineNumber(offset);
|
||||
if(editorLine != line) {
|
||||
if (editorLine != line) {
|
||||
if (line < 0 || line >= document.getLineCount()) {
|
||||
return null;
|
||||
}
|
||||
@@ -213,7 +188,7 @@ public class BreakpointManager implements JDOMExternalizable {
|
||||
|
||||
Breakpoint breakpoint = findBreakpoint(document, offset, null);
|
||||
if (breakpoint == null) {
|
||||
if(mostSuitingBreakpoint || isInsideCompiledClass) {
|
||||
if (mostSuitingBreakpoint || isInsideCompiledClass) {
|
||||
breakpoint = addFieldBreakpoint(document, offset);
|
||||
if (breakpoint == null) {
|
||||
breakpoint = addMethodBreakpoint(document, line);
|
||||
@@ -230,7 +205,7 @@ public class BreakpointManager implements JDOMExternalizable {
|
||||
}
|
||||
}
|
||||
|
||||
if(breakpoint != null) {
|
||||
if (breakpoint != null) {
|
||||
RequestManagerImpl.createRequests(breakpoint);
|
||||
}
|
||||
return breakpoint;
|
||||
@@ -267,7 +242,7 @@ public class BreakpointManager implements JDOMExternalizable {
|
||||
}
|
||||
|
||||
public void mouseReleased(EditorMouseEvent e) {
|
||||
if(myMousePressedEvent != null) {
|
||||
if (myMousePressedEvent != null) {
|
||||
mouseClicked(e);
|
||||
}
|
||||
myMousePressedEvent = null;
|
||||
@@ -303,16 +278,21 @@ public class BreakpointManager implements JDOMExternalizable {
|
||||
public void run() {
|
||||
Breakpoint breakpoint = toggleBreakpoint(e.getMouseEvent().isAltDown(), line);
|
||||
|
||||
if(e.getMouseEvent().isShiftDown() && breakpoint != null) {
|
||||
if (e.getMouseEvent().isShiftDown() && breakpoint != null) {
|
||||
breakpoint.LOG_EXPRESSION_ENABLED = true;
|
||||
final TextWithImports logMessage = DebuggerUtilsEx.getEditorText(editor);
|
||||
breakpoint.setLogMessage(logMessage != null? logMessage : new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, DebuggerBundle.message("breakpoint.log.message", breakpoint.getDisplayName())));
|
||||
breakpoint.setLogMessage(logMessage != null
|
||||
? logMessage
|
||||
: new TextWithImportsImpl(CodeFragmentKind.EXPRESSION,
|
||||
DebuggerBundle.message("breakpoint.log.message",
|
||||
breakpoint.getDisplayName())));
|
||||
breakpoint.SUSPEND_POLICY = DebuggerSettings.SUSPEND_NONE;
|
||||
|
||||
DialogWrapper dialog = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().createConfigurationDialog(breakpoint, BreakpointPropertiesPanel.CONTROL_LOG_MESSAGE);
|
||||
DialogWrapper dialog = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager()
|
||||
.createConfigurationDialog(breakpoint, BreakpointPropertiesPanel.CONTROL_LOG_MESSAGE);
|
||||
dialog.show();
|
||||
|
||||
if(!dialog.isOK()) {
|
||||
if (!dialog.isOK()) {
|
||||
removeBreakpoint(breakpoint);
|
||||
}
|
||||
}
|
||||
@@ -325,6 +305,32 @@ public class BreakpointManager implements JDOMExternalizable {
|
||||
};
|
||||
|
||||
eventMulticaster.addEditorMouseListener(myEditorMouseListener, myProject);
|
||||
|
||||
final DocumentListener myDocumentListener = new DocumentAdapter() {
|
||||
private final Alarm myUpdateAlarm = new Alarm();
|
||||
|
||||
public void documentChanged(final DocumentEvent e) {
|
||||
final Document document = e.getDocument();
|
||||
synchronized (BreakpointManager.this) {
|
||||
List<BreakpointWithHighlighter> breakpoints = myDocumentBreakpoints.get(document);
|
||||
|
||||
if(breakpoints != null) {
|
||||
myUpdateAlarm.cancelAllRequests();
|
||||
// must create new array in order to avoid "concurrent modification" errors
|
||||
final List<BreakpointWithHighlighter> breakpointsToUpdate = new ArrayList<BreakpointWithHighlighter>(breakpoints);
|
||||
myUpdateAlarm.addRequest(new Runnable() {
|
||||
public void run() {
|
||||
if (!myProject.isDisposed()) {
|
||||
PsiDocumentManager.getInstance(myProject).commitDocument(document);
|
||||
update(breakpointsToUpdate);
|
||||
}
|
||||
}
|
||||
}, 300, ModalityState.NON_MODAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
eventMulticaster.addDocumentListener(myDocumentListener, myProject);
|
||||
}
|
||||
|
||||
|
||||
+4
-6
@@ -13,7 +13,6 @@ import com.intellij.facet.autodetecting.UnderlyingFacetSelector;
|
||||
import com.intellij.facet.impl.autodetecting.model.FacetInfo2;
|
||||
import com.intellij.facet.impl.autodetecting.model.ProjectFacetInfoSet;
|
||||
import com.intellij.facet.pointers.FacetPointersManager;
|
||||
import com.intellij.ide.impl.convert.ProjectFileVersion;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
@@ -58,7 +57,6 @@ public class FacetAutodetectingManagerImpl extends FacetAutodetectingManager imp
|
||||
private final PsiManager myPsiManager;
|
||||
private final FacetPointersManager myFacetPointersManager;
|
||||
private FacetDetectionIndex myFileIndex;
|
||||
private MyPsiTreeChangeListener myPsiTreeChangeListener;
|
||||
private MergingUpdateQueue myMergingUpdateQueue;
|
||||
private final ProjectFacetInfoSet myDetectedFacetSet;
|
||||
private DetectedFacetManager myDetectedFacetManager;
|
||||
@@ -116,8 +114,8 @@ public class FacetAutodetectingManagerImpl extends FacetAutodetectingManager imp
|
||||
}
|
||||
myFileIndex = new FacetDetectionIndex(myProject, this, myDetectors.keySet());
|
||||
myFileIndex.initialize();
|
||||
myPsiTreeChangeListener = new MyPsiTreeChangeListener();
|
||||
myPsiManager.addPsiTreeChangeListener(myPsiTreeChangeListener, myProject);
|
||||
MyPsiTreeChangeListener psiTreeChangeListener = new MyPsiTreeChangeListener();
|
||||
myPsiManager.addPsiTreeChangeListener(psiTreeChangeListener, myProject);
|
||||
myMergingUpdateQueue = new MergingUpdateQueue("FacetAutodetectionQueue", 500, true, null, myProject);
|
||||
}
|
||||
|
||||
@@ -146,7 +144,7 @@ public class FacetAutodetectingManagerImpl extends FacetAutodetectingManager imp
|
||||
public void processFile(VirtualFile virtualFile) {
|
||||
if (!virtualFile.isValid() || virtualFile.isDirectory() || myProject.isDisposed()
|
||||
|| !virtualFile.exists() || !myFileIndex.getProjectFileIndex().isInContent(virtualFile)) return;
|
||||
|
||||
|
||||
FileType fileType = virtualFile.getFileType();
|
||||
Collection<FacetDetectorWrapper> detectors = myDetectors.get(fileType);
|
||||
if (detectors == null) return;
|
||||
@@ -319,7 +317,7 @@ public class FacetAutodetectingManagerImpl extends FacetAutodetectingManager imp
|
||||
return myDetectedFacetManager;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Nullable
|
||||
public FacetDetector<?,?> findDetector(final String detectorId) {
|
||||
return myId2Detector.get(detectorId);
|
||||
}
|
||||
|
||||
@@ -61,10 +61,6 @@ public abstract class ModuleTestCase extends IdeaTestCase {
|
||||
return createModule(path, moduleType);
|
||||
}
|
||||
|
||||
protected Module createModule(final String path) {
|
||||
return createModule(path, StdModuleTypes.JAVA);
|
||||
}
|
||||
|
||||
protected Module createModule(final String path, final ModuleType moduleType) {
|
||||
Module module = ApplicationManager.getApplication().runWriteAction(
|
||||
new Computable<Module>() {
|
||||
|
||||
Reference in New Issue
Block a user