From 39bab822db05ee83b6623b2e2c9c46cc2e7ff519 Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Mon, 14 May 2018 14:14:18 +0300 Subject: [PATCH] use Disposer.dispose --- .../thumbnail/impl/ThumbnailManagerImpl.java | 3 ++- .../thumbnail/impl/ThumbnailViewImpl.java | 20 ++----------------- .../hint/ShowContainerInfoHandler.java | 20 +++---------------- .../navigation/MethodUpDownUtil.java | 19 +++--------------- .../StructureViewComponent.java | 2 +- .../newStructureView/TreeModelWrapper.java | 19 +++--------------- .../intellij/ide/util/FileStructurePopup.java | 2 +- 7 files changed, 15 insertions(+), 70 deletions(-) diff --git a/images/src/org/intellij/images/thumbnail/impl/ThumbnailManagerImpl.java b/images/src/org/intellij/images/thumbnail/impl/ThumbnailManagerImpl.java index 529a107870b4..5d853df016db 100644 --- a/images/src/org/intellij/images/thumbnail/impl/ThumbnailManagerImpl.java +++ b/images/src/org/intellij/images/thumbnail/impl/ThumbnailManagerImpl.java @@ -17,6 +17,7 @@ package org.intellij.images.thumbnail.impl; import com.intellij.openapi.Disposable; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Disposer; import org.intellij.images.thumbnail.ThumbnailManager; import org.intellij.images.thumbnail.ThumbnailView; import org.jetbrains.annotations.NotNull; @@ -44,7 +45,7 @@ final class ThumbnailManagerImpl extends ThumbnailManager implements Disposable public void dispose() { if (thumbnailView != null) { - thumbnailView.dispose(); + Disposer.dispose(thumbnailView); thumbnailView = null; } } diff --git a/images/src/org/intellij/images/thumbnail/impl/ThumbnailViewImpl.java b/images/src/org/intellij/images/thumbnail/impl/ThumbnailViewImpl.java index 1b9ba21a4e06..0e0089e92f1c 100644 --- a/images/src/org/intellij/images/thumbnail/impl/ThumbnailViewImpl.java +++ b/images/src/org/intellij/images/thumbnail/impl/ThumbnailViewImpl.java @@ -1,20 +1,4 @@ -/* - * 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. - */ - -/** $Id$ */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.images.thumbnail.impl; @@ -153,7 +137,7 @@ final class ThumbnailViewImpl implements ThumbnailView { getUI().refresh(); } else { - getUI().dispose(); + Disposer.dispose(getUI()); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowContainerInfoHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowContainerInfoHandler.java index d605fc66366e..8c17a8296d30 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowContainerInfoHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowContainerInfoHandler.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.hint; import com.intellij.codeInsight.CodeInsightActionHandler; @@ -24,9 +10,9 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.LogicalPosition; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.TextRange; -import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.reference.SoftReference; @@ -68,7 +54,7 @@ public class ShowContainerInfoHandler implements CodeInsightActionHandler { } } finally { - model.dispose(); + Disposer.dispose(model); } while(true) { if (container == null || container instanceof PsiFile) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/MethodUpDownUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/MethodUpDownUtil.java index a4d655ee2649..5a6beb14d49e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/MethodUpDownUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/MethodUpDownUtil.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.navigation; @@ -23,6 +9,7 @@ import com.intellij.ide.structureView.TreeBasedStructureViewBuilder; import com.intellij.ide.util.treeView.smartTree.TreeElement; import com.intellij.lang.LanguageStructureViewBuilder; import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.util.Disposer; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import gnu.trove.THashSet; @@ -68,7 +55,7 @@ public class MethodUpDownUtil { addStructureViewElements(model.getRoot(), array, element); } finally { - model.dispose(); + Disposer.dispose(model); } } } diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java index e2272a460227..c9f2b217674f 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java @@ -144,7 +144,7 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre myAsyncTreeModel.setRootImmediately(myStructureTreeModel.getRootImmediately()); myTree = new MyTree(myAsyncTreeModel); - Disposer.register(this, () -> myTreeModelWrapper.dispose()); + Disposer.register(this, () -> Disposer.dispose(myTreeModelWrapper)); registerAutoExpandListener(myTree, myTreeModel); diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/TreeModelWrapper.java b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/TreeModelWrapper.java index 997d2c394905..bc4ef137658b 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/TreeModelWrapper.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/TreeModelWrapper.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.structureView.newStructureView; @@ -21,6 +7,7 @@ import com.intellij.ide.structureView.ModelListener; import com.intellij.ide.structureView.StructureViewModel; import com.intellij.ide.structureView.StructureViewTreeElement; import com.intellij.ide.util.treeView.smartTree.*; +import com.intellij.openapi.util.Disposer; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -123,7 +110,7 @@ public class TreeModelWrapper implements StructureViewModel, ProvidingTreeModel @Override public void dispose() { - myModel.dispose(); + Disposer.dispose(myModel); } @Override diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java index 603edc30a260..a3e4f74f92d5 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java +++ b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java @@ -182,7 +182,7 @@ public class FileStructurePopup implements Disposable, TreeActionsOwner { myAsyncTreeModel.setRootImmediately(myStructureTreeModel.getRootImmediately()); myTree = new MyTree(myAsyncTreeModel); StructureViewComponent.registerAutoExpandListener(myTree, myTreeModel); - Disposer.register(this, () -> myTreeModelWrapper.dispose()); + Disposer.register(this, () -> Disposer.dispose(myTreeModelWrapper)); ModelListener modelListener = () -> rebuild(false); myTreeModel.addModelListener(modelListener);