mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
deprecate disposeComponent in favour of our Disposable contract
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -20,13 +20,11 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.compiler.*;
|
||||
import com.intellij.openapi.compiler.Compiler;
|
||||
import com.intellij.openapi.compiler.generic.GenericCompiler;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -39,7 +37,7 @@ import java.util.Map;
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: May 4, 2008
|
||||
*/
|
||||
public class CompilerCacheManager implements ProjectComponent {
|
||||
public class CompilerCacheManager implements Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.CompilerCacheManager");
|
||||
private final Map<Compiler, Object> myCompilerToCacheMap = new HashMap<>();
|
||||
private final Map<GenericCompiler<?,?,?>, GenericCompilerCache<?,?,?>> myGenericCachesMap = new HashMap<>();
|
||||
@@ -55,27 +53,9 @@ public class CompilerCacheManager implements ProjectComponent {
|
||||
public static CompilerCacheManager getInstance(Project project) {
|
||||
return project.getComponent(CompilerCacheManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "CompilerCacheManager";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
public void dispose() {
|
||||
flushCaches();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -171,18 +171,6 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
myBreakpointManager.init();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -103,24 +103,12 @@ public class DebuggerPanelsManager implements ProjectComponent {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "DebuggerPanelsManager";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
public static DebuggerPanelsManager getInstance(Project project) {
|
||||
return project.getComponent(DebuggerPanelsManager.class);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.compiler.CompilerManager;
|
||||
import com.intellij.openapi.compiler.CompilerTopics;
|
||||
import com.intellij.openapi.compiler.ex.CompilerPathsEx;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -58,12 +57,7 @@ import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* User: lex
|
||||
* Date: Oct 2, 2003
|
||||
* Time: 6:00:55 PM
|
||||
*/
|
||||
public class HotSwapUIImpl extends HotSwapUI implements ProjectComponent {
|
||||
public class HotSwapUIImpl extends HotSwapUI {
|
||||
private final List<HotSwapVetoableListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
private boolean myAskBeforeHotswap = true;
|
||||
private final Project myProject;
|
||||
@@ -95,29 +89,13 @@ public class HotSwapUIImpl extends HotSwapUI implements ProjectComponent {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void projectOpened() {
|
||||
}
|
||||
|
||||
public void projectClosed() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "HotSwapUI";
|
||||
}
|
||||
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
public void disposeComponent() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addListener(HotSwapVetoableListener listener) {
|
||||
myListeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(HotSwapVetoableListener listener) {
|
||||
myListeners.remove(listener);
|
||||
}
|
||||
@@ -265,6 +243,7 @@ public class HotSwapUIImpl extends HotSwapUI implements ProjectComponent {
|
||||
}, progress.getProgressIndicator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadChangedClasses(final DebuggerSession session, boolean compileBeforeHotswap) {
|
||||
dontAskHotswapAfterThisCompilation();
|
||||
if (compileBeforeHotswap) {
|
||||
@@ -277,6 +256,7 @@ public class HotSwapUIImpl extends HotSwapUI implements ProjectComponent {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dontPerformHotswapAfterThisCompilation() {
|
||||
myPerformHotswapAfterThisCompilation = false;
|
||||
}
|
||||
@@ -297,6 +277,7 @@ public class HotSwapUIImpl extends HotSwapUI implements ProjectComponent {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileGenerated(String outputRoot, String relativePath) {
|
||||
if (StringUtil.endsWith(relativePath, ".class") && JpsPathUtil.isUnder(myOutputRoots, new File(outputRoot))) {
|
||||
// collect only classes
|
||||
@@ -304,6 +285,7 @@ public class HotSwapUIImpl extends HotSwapUI implements ProjectComponent {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void compilationFinished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
|
||||
final Map<String, List<String>> generated = myGeneratedPaths.getAndSet(new HashMap<>());
|
||||
if (myProject.isDisposed()) {
|
||||
|
||||
+23
-51
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -19,7 +19,6 @@ import com.intellij.compiler.options.CompileStepBeforeRun;
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.compiler.*;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.JavaSdk;
|
||||
@@ -35,7 +34,6 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
@@ -46,9 +44,8 @@ import java.util.*;
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 08-Sep-15
|
||||
*/
|
||||
public class JavaScratchCompilationSupport implements ProjectComponent, CompileTask{
|
||||
|
||||
public JavaScratchCompilationSupport(Project project, CompilerManager compileManager) {
|
||||
public class JavaScratchCompilationSupport implements CompileTask {
|
||||
public JavaScratchCompilationSupport(CompilerManager compileManager) {
|
||||
compileManager.addAfterTask(this);
|
||||
}
|
||||
|
||||
@@ -113,34 +110,31 @@ public class JavaScratchCompilationSupport implements ProjectComponent, CompileT
|
||||
}
|
||||
FileUtil.delete(srcDir); // perform cleanup
|
||||
|
||||
final String srcFileName = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
final VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(scratchUrl);
|
||||
if (vFile != null) {
|
||||
final PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
|
||||
if (psiFile instanceof PsiJavaFile) {
|
||||
String name = null;
|
||||
// take the name of the first found public top-level class, otherwise the name of any available top-level class
|
||||
for (PsiClass aClass : ((PsiJavaFile)psiFile).getClasses()) {
|
||||
if (name == null) {
|
||||
name = aClass.getName();
|
||||
if (isPublic(aClass)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (isPublic(aClass)){
|
||||
name = aClass.getName();
|
||||
final String srcFileName = ApplicationManager.getApplication().runReadAction((Computable<String>)() -> {
|
||||
final VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(scratchUrl);
|
||||
if (vFile != null) {
|
||||
final PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
|
||||
if (psiFile instanceof PsiJavaFile) {
|
||||
String name = null;
|
||||
// take the name of the first found public top-level class, otherwise the name of any available top-level class
|
||||
for (PsiClass aClass : ((PsiJavaFile)psiFile).getClasses()) {
|
||||
if (name == null) {
|
||||
name = aClass.getName();
|
||||
if (isPublic(aClass)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (name != null) {
|
||||
return name;
|
||||
else if (isPublic(aClass)){
|
||||
name = aClass.getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (name != null) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
return FileUtil.getNameWithoutExtension(scratchFile);
|
||||
}
|
||||
return FileUtil.getNameWithoutExtension(scratchFile);
|
||||
});
|
||||
srcFile = new File(srcDir, srcFileName + ".java");
|
||||
FileUtil.copy(scratchFile, srcFile);
|
||||
@@ -151,8 +145,8 @@ public class JavaScratchCompilationSupport implements ProjectComponent, CompileT
|
||||
final Set<File> cp = new LinkedHashSet<>();
|
||||
final List<File> platformCp = new ArrayList<>();
|
||||
|
||||
final Computable<OrderEnumerator> orderEnumerator = module != null ? (Computable<OrderEnumerator>)() -> ModuleRootManager.getInstance(module).orderEntries()
|
||||
: (Computable<OrderEnumerator>)() -> ProjectRootManager.getInstance(project).orderEntries();
|
||||
final Computable<OrderEnumerator> orderEnumerator = module != null ? () -> ModuleRootManager.getInstance(module).orderEntries()
|
||||
: () -> ProjectRootManager.getInstance(project).orderEntries();
|
||||
|
||||
ApplicationManager.getApplication().runReadAction(() -> {
|
||||
for (String s : orderEnumerator.compute().compileOnly().recursively().exportedOnly().withoutSdk().getPathsList().getPathList()) {
|
||||
@@ -200,26 +194,4 @@ public class JavaScratchCompilationSupport implements ProjectComponent, CompileT
|
||||
final PsiModifierList modifiers = aClass.getModifierList();
|
||||
return modifiers != null && modifiers.hasModifierProperty(PsiModifier.PUBLIC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return "JavaScratchCompilationSupport";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.intellij.util.indexing;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.BaseComponent;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -31,7 +30,6 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -42,7 +40,7 @@ import java.util.Set;
|
||||
/**
|
||||
* Author: dmitrylomov
|
||||
*/
|
||||
public abstract class FileBasedIndex implements BaseComponent {
|
||||
public abstract class FileBasedIndex {
|
||||
public abstract void iterateIndexableFiles(@NotNull ContentIterator processor, @NotNull Project project, ProgressIndicator indicator);
|
||||
|
||||
public void iterateIndexableFilesConcurrently(@NotNull ContentIterator processor, @NotNull Project project, ProgressIndicator indicator) {
|
||||
@@ -71,15 +69,7 @@ public abstract class FileBasedIndex implements BaseComponent {
|
||||
public void requestRebuild(@NotNull ID<?, ?> indexId) {
|
||||
requestRebuild(indexId, new Throwable());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@NonNls
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "FileBasedIndex";
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public abstract <K, V> List<V> getValues(@NotNull ID<K, V> indexId, @NotNull K dataKey, @NotNull GlobalSearchScope filter);
|
||||
|
||||
|
||||
+4
-13
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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,12 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.codeInsight.folding.impl;
|
||||
|
||||
import com.intellij.codeInsight.folding.CodeFoldingManager;
|
||||
import com.intellij.codeInsight.hint.EditorFragmentComponent;
|
||||
import com.intellij.codeInsight.hint.HintManager;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
@@ -48,7 +48,7 @@ import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.List;
|
||||
|
||||
public class CodeFoldingManagerImpl extends CodeFoldingManager implements ProjectComponent {
|
||||
public class CodeFoldingManagerImpl extends CodeFoldingManager implements ProjectComponent, Disposable {
|
||||
private final Project myProject;
|
||||
|
||||
private final List<Document> myDocumentsWithFoldingInfo = new WeakList<>();
|
||||
@@ -61,16 +61,7 @@ public class CodeFoldingManagerImpl extends CodeFoldingManager implements Projec
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "CodeFoldingManagerImpl";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() { }
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
public void dispose() {
|
||||
for (Document document : myDocumentsWithFoldingInfo) {
|
||||
if (document != null) {
|
||||
document.putUserData(myFoldingInfoInDocumentKey, null);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -435,14 +435,6 @@ public class FacetManagerImpl extends FacetManager implements ModuleComponent, P
|
||||
return COMPONENT_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
private static class FacetManagerModel extends FacetModelBase {
|
||||
private Facet[] myAllFacets = Facet.EMPTY_ARRAY;
|
||||
|
||||
|
||||
+3
-2
@@ -27,6 +27,7 @@ import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.AbstractProjectComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -57,7 +58,7 @@ import java.util.*;
|
||||
* @author nik
|
||||
*/
|
||||
public class FrameworkDetectionManager extends AbstractProjectComponent implements FrameworkDetectionIndexListener,
|
||||
TextEditorHighlightingPassFactory {
|
||||
TextEditorHighlightingPassFactory, Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.framework.detection.impl.FrameworkDetectionManager");
|
||||
private static final NotificationGroup FRAMEWORK_DETECTION_NOTIFICATION = NotificationGroup.balloonGroup("Framework Detection");
|
||||
private final Update myDetectionUpdate = new Update("detection") {
|
||||
@@ -121,7 +122,7 @@ public class FrameworkDetectionManager extends AbstractProjectComponent implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
public void dispose() {
|
||||
doDispose();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -27,7 +27,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.ui.InputValidator;
|
||||
@@ -35,7 +35,7 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.TreeItem;
|
||||
@@ -424,23 +424,7 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable {
|
||||
if (toReorder == index + 1 && !above) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
@@ -588,14 +572,11 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable {
|
||||
public boolean contains(@NotNull String name, @NotNull final VirtualFile vFile) {
|
||||
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
final Set<Boolean> find = new HashSet<>();
|
||||
final ContentIterator contentIterator = new ContentIterator() {
|
||||
@Override
|
||||
public boolean processFile(VirtualFile fileOrDir) {
|
||||
if (fileOrDir != null && fileOrDir.getPath().equals(vFile.getPath())) {
|
||||
find.add(Boolean.TRUE);
|
||||
}
|
||||
return true;
|
||||
final ContentIterator contentIterator = fileOrDir -> {
|
||||
if (fileOrDir != null && fileOrDir.getPath().equals(vFile.getPath())) {
|
||||
find.add(Boolean.TRUE);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
Collection<TreeItem<Pair<AbstractUrl, String>>> urls = getFavoritesListRootUrls(name);
|
||||
@@ -610,7 +591,7 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable {
|
||||
}
|
||||
Object element = path[path.length - 1];
|
||||
if (element instanceof SmartPsiElementPointer) {
|
||||
final VirtualFile virtualFile = PsiUtilBase.getVirtualFile(((SmartPsiElementPointer)element).getElement());
|
||||
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(((SmartPsiElementPointer)element).getElement());
|
||||
if (virtualFile == null) continue;
|
||||
if (vFile.getPath().equals(virtualFile.getPath())) {
|
||||
return true;
|
||||
@@ -622,7 +603,7 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable {
|
||||
}
|
||||
|
||||
if (element instanceof PsiElement) {
|
||||
final VirtualFile virtualFile = PsiUtilBase.getVirtualFile((PsiElement)element);
|
||||
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile((PsiElement)element);
|
||||
if (virtualFile == null) continue;
|
||||
if (vFile.getPath().equals(virtualFile.getPath())) {
|
||||
return true;
|
||||
@@ -693,7 +674,7 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable {
|
||||
final PsiElement newParent = event.getNewParent();
|
||||
final PsiElement child = event.getChild();
|
||||
if (newParent instanceof PsiDirectory) {
|
||||
final Module module = ModuleUtil.findModuleForPsiElement(newParent);
|
||||
final Module module = ModuleUtilCore.findModuleForPsiElement(newParent);
|
||||
if (module == null) return;
|
||||
AbstractUrl childUrl = null;
|
||||
if (child instanceof PsiFile) {
|
||||
@@ -733,7 +714,7 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable {
|
||||
event.getPropertyName().equals(PsiTreeChangeEvent.PROP_DIRECTORY_NAME)) {
|
||||
final PsiElement psiElement = event.getChild();
|
||||
if (psiElement instanceof PsiFile || psiElement instanceof PsiDirectory) {
|
||||
final Module module = ModuleUtil.findModuleForPsiElement(psiElement);
|
||||
final Module module = ModuleUtilCore.findModuleForPsiElement(psiElement);
|
||||
if (module == null) return;
|
||||
final String url = ((PsiDirectory)psiElement.getParent()).getVirtualFile().getUrl() + "/" + event.getNewValue();
|
||||
final AbstractUrl childUrl = psiElement instanceof PsiFile ? new PsiFileUrl(url) : new DirectoryUrl(url, module.getName());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -24,8 +24,10 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.notification.NotificationDisplayType;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.ex.ActionUtil;
|
||||
import com.intellij.openapi.application.*;
|
||||
import com.intellij.openapi.components.BaseComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.impl.EditorHighlighterCache;
|
||||
@@ -39,7 +41,8 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator;
|
||||
import com.intellij.openapi.project.*;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.CollectingContentIterator;
|
||||
import com.intellij.openapi.roots.ContentIterator;
|
||||
import com.intellij.openapi.roots.impl.PushedFilePropertiesUpdaterImpl;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -108,7 +111,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
* @author Eugene Zhuravlev
|
||||
* @since Dec 20, 2007
|
||||
*/
|
||||
public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
public class FileBasedIndexImpl extends FileBasedIndex implements BaseComponent, Disposable {
|
||||
static final Logger LOG = Logger.getInstance("#com.intellij.util.indexing.FileBasedIndexImpl");
|
||||
private static final String CORRUPTION_MARKER_NAME = "corruption.marker";
|
||||
private static final NotificationGroup NOTIFICATIONS = new NotificationGroup("Indexing", NotificationDisplayType.BALLOON, false);
|
||||
@@ -466,7 +469,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
public void dispose() {
|
||||
performShutdown();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -46,7 +46,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static com.intellij.history.integration.LocalHistoryUtil.findRevisionIndexToRevert;
|
||||
|
||||
public class LocalHistoryImpl extends LocalHistory implements ApplicationComponent {
|
||||
public class LocalHistoryImpl extends LocalHistory implements ApplicationComponent, Disposable {
|
||||
private final MessageBus myBus;
|
||||
private MessageBusConnection myConnection;
|
||||
private ChangeList myChangeList;
|
||||
@@ -70,7 +70,7 @@ public class LocalHistoryImpl extends LocalHistory implements ApplicationCompone
|
||||
public void initComponent() {
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode() && ApplicationManager.getApplication().isHeadlessEnvironment()) return;
|
||||
|
||||
myShutdownTask = () -> disposeComponent();
|
||||
myShutdownTask = () -> doDispose();
|
||||
ShutDownTracker.getInstance().registerShutdownTask(myShutdownTask);
|
||||
|
||||
initHistory();
|
||||
@@ -93,13 +93,13 @@ public class LocalHistoryImpl extends LocalHistory implements ApplicationCompone
|
||||
|
||||
myEventDispatcher = new LocalHistoryEventDispatcher(myVcs, myGateway);
|
||||
|
||||
CommandProcessor.getInstance().addCommandListener(myEventDispatcher);
|
||||
CommandProcessor.getInstance().addCommandListener(myEventDispatcher, this);
|
||||
|
||||
myConnection = myBus.connect();
|
||||
myConnection.subscribe(VirtualFileManager.VFS_CHANGES, myEventDispatcher);
|
||||
|
||||
VirtualFileManager fm = VirtualFileManager.getInstance();
|
||||
fm.addVirtualFileManagerListener(myEventDispatcher);
|
||||
fm.addVirtualFileManagerListener(myEventDispatcher, this);
|
||||
}
|
||||
|
||||
public File getStorageDir() {
|
||||
@@ -111,16 +111,17 @@ public class LocalHistoryImpl extends LocalHistory implements ApplicationCompone
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
public void dispose() {
|
||||
doDispose();
|
||||
}
|
||||
|
||||
private void doDispose() {
|
||||
if (!isInitialized.getAndSet(false)) return;
|
||||
|
||||
long period = Registry.intValue("localHistory.daysToKeep") * 1000L * 60L * 60L * 24L;
|
||||
|
||||
myConnection.disconnect();
|
||||
myConnection = null;
|
||||
VirtualFileManager fm = VirtualFileManager.getInstance();
|
||||
fm.removeVirtualFileManagerListener(myEventDispatcher);
|
||||
CommandProcessor.getInstance().removeCommandListener(myEventDispatcher);
|
||||
|
||||
LocalHistoryLog.LOG.debug("Purging local history...");
|
||||
myChangeList.purgeObsolete(period);
|
||||
@@ -132,7 +133,7 @@ public class LocalHistoryImpl extends LocalHistory implements ApplicationCompone
|
||||
|
||||
@TestOnly
|
||||
public void cleanupForNextTest() {
|
||||
disposeComponent();
|
||||
doDispose();
|
||||
FileUtil.delete(getStorageDir());
|
||||
initComponent();
|
||||
}
|
||||
@@ -198,13 +199,7 @@ public class LocalHistoryImpl extends LocalHistory implements ApplicationCompone
|
||||
private boolean isInitialized() {
|
||||
return isInitialized.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "Local History";
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public LocalHistoryFacade getFacade() {
|
||||
return myVcs;
|
||||
|
||||
+8
-22
@@ -17,8 +17,12 @@ package com.intellij.openapi.fileEditor.impl;
|
||||
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.ide.ui.UISettingsListener;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.openapi.components.StoragePathMacros;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileEditor.*;
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
|
||||
@@ -46,7 +50,7 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
@State(name = "editorHistoryManager", storages = @Storage(StoragePathMacros.WORKSPACE_FILE))
|
||||
public final class EditorHistoryManager implements PersistentStateComponent<Element>, ProjectComponent {
|
||||
public final class EditorHistoryManager implements PersistentStateComponent<Element>, Disposable {
|
||||
private static final Logger LOG = Logger.getInstance(EditorHistoryManager.class);
|
||||
|
||||
private final Project myProject;
|
||||
@@ -333,31 +337,13 @@ public final class EditorHistoryManager implements PersistentStateComponent<Elem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void disposeComponent() {
|
||||
public synchronized void dispose() {
|
||||
for (HistoryEntry entry : myEntriesList) {
|
||||
entry.destroy();
|
||||
}
|
||||
myEntriesList.clear();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return "editorHistoryManager";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates history
|
||||
*/
|
||||
|
||||
-6
@@ -540,7 +540,6 @@ public class IdeDocumentHistoryImpl extends IdeDocumentHistory implements Projec
|
||||
public String toString() {
|
||||
return getFile().getName() + " " + getNavigationState();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -549,9 +548,6 @@ public class IdeDocumentHistoryImpl extends IdeDocumentHistory implements Projec
|
||||
return myBackPlaces;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void initComponent() { }
|
||||
|
||||
@Override
|
||||
public final void disposeComponent() {
|
||||
myLastGroupId = null;
|
||||
@@ -570,6 +566,4 @@ public class IdeDocumentHistoryImpl extends IdeDocumentHistory implements Projec
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+3
-15
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -55,7 +55,7 @@ import java.util.Map;
|
||||
/**
|
||||
* @author mike
|
||||
*/
|
||||
public class FileStatusManagerImpl extends FileStatusManager implements ProjectComponent {
|
||||
public class FileStatusManagerImpl extends FileStatusManager implements ProjectComponent, Disposable {
|
||||
private final Map<VirtualFile, FileStatus> myCachedStatuses = Collections.synchronizedMap(new HashMap<VirtualFile, FileStatus>());
|
||||
private final Map<VirtualFile, Boolean> myWhetherExactlyParentToChanged =
|
||||
Collections.synchronizedMap(new HashMap<VirtualFile, Boolean>());
|
||||
@@ -153,15 +153,7 @@ public class FileStatusManagerImpl extends FileStatusManager implements ProjectC
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
public void dispose() {
|
||||
myCachedStatuses.clear();
|
||||
}
|
||||
|
||||
@@ -171,10 +163,6 @@ public class FileStatusManagerImpl extends FileStatusManager implements ProjectC
|
||||
return "FileStatusManager";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFileStatusListener(@NotNull FileStatusListener listener) {
|
||||
myListeners.add(listener);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -334,14 +334,6 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
return "ChangeListManager";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
/**
|
||||
* update itself might produce actions done on AWT thread (invoked-after),
|
||||
* so waiting for its completion on AWT thread is not good runnable is invoked on AWT thread
|
||||
|
||||
+1
-13
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -96,10 +96,6 @@ public class OutdatedVersionNotifier implements ProjectComponent {
|
||||
myFileEditorManager.addFileEditorManagerListener(myFileEditorManagerListener, myProject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNls
|
||||
@NotNull
|
||||
@@ -107,14 +103,6 @@ public class OutdatedVersionNotifier implements ProjectComponent {
|
||||
return "OutdatedVersionNotifier";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
private void updateAllEditorsLater() {
|
||||
debug("Queueing update of editors");
|
||||
ApplicationManager.getApplication().invokeLater(() -> updateAllEditors(), myProject.getDisposed());
|
||||
|
||||
+1
-13
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -92,10 +92,6 @@ public class CreatePatchCommitExecutor extends LocalCommitExecutor implements Pr
|
||||
myChangeListManager.registerCommitExecutor(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNls
|
||||
@NotNull
|
||||
@@ -103,14 +99,6 @@ public class CreatePatchCommitExecutor extends LocalCommitExecutor implements Pr
|
||||
return "CreatePatchCommitExecutor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
private class CreatePatchCommitSession implements CommitSession, CommitSessionContextAware {
|
||||
private final CreatePatchConfigurationPanel myPanel = new CreatePatchConfigurationPanel(myProject);
|
||||
private CommitContext myCommitContext;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -40,7 +40,6 @@ import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.impl.DirectoryIndex;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
@@ -51,7 +50,6 @@ import com.intellij.openapi.vcs.ex.LineStatusTracker;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.concurrency.QueueProcessorRemovePartner;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
@@ -99,12 +97,7 @@ public class LineStatusTrackerManager implements ProjectComponent, LineStatusTra
|
||||
myFileEditorManager = fileEditorManager;
|
||||
|
||||
myLineStatusTrackers = new HashMap<>();
|
||||
myPartner = new QueueProcessorRemovePartner<>(myProject, new Consumer<BaseRevisionLoader>() {
|
||||
@Override
|
||||
public void consume(BaseRevisionLoader baseRevisionLoader) {
|
||||
baseRevisionLoader.run();
|
||||
}
|
||||
});
|
||||
myPartner = new QueueProcessorRemovePartner<>(myProject, baseRevisionLoader -> baseRevisionLoader.run());
|
||||
|
||||
MessageBusConnection busConnection = project.getMessageBus().connect();
|
||||
busConnection.subscribe(DocumentBulkUpdateListener.TOPIC, new DocumentBulkUpdateListener.Adapter() {
|
||||
@@ -150,22 +143,19 @@ public class LineStatusTrackerManager implements ProjectComponent, LineStatusTra
|
||||
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
StartupManager.getInstance(myProject).registerPreStartupActivity(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final MyFileStatusListener fileStatusListener = new MyFileStatusListener();
|
||||
final EditorFactoryListener editorFactoryListener = new MyEditorFactoryListener();
|
||||
final MyVirtualFileListener virtualFileListener = new MyVirtualFileListener();
|
||||
StartupManager.getInstance(myProject).registerPreStartupActivity(() -> {
|
||||
final MyFileStatusListener fileStatusListener = new MyFileStatusListener();
|
||||
final EditorFactoryListener editorFactoryListener = new MyEditorFactoryListener();
|
||||
final MyVirtualFileListener virtualFileListener = new MyVirtualFileListener();
|
||||
|
||||
final FileStatusManager fsManager = FileStatusManager.getInstance(myProject);
|
||||
fsManager.addFileStatusListener(fileStatusListener, myDisposable);
|
||||
final FileStatusManager fsManager = FileStatusManager.getInstance(myProject);
|
||||
fsManager.addFileStatusListener(fileStatusListener, myDisposable);
|
||||
|
||||
final EditorFactory editorFactory = EditorFactory.getInstance();
|
||||
editorFactory.addEditorFactoryListener(editorFactoryListener, myDisposable);
|
||||
final EditorFactory editorFactory = EditorFactory.getInstance();
|
||||
editorFactory.addEditorFactoryListener(editorFactoryListener, myDisposable);
|
||||
|
||||
final VirtualFileManager virtualFileManager = VirtualFileManager.getInstance();
|
||||
virtualFileManager.addVirtualFileListener(virtualFileListener, myDisposable);
|
||||
}
|
||||
final VirtualFileManager virtualFileManager = VirtualFileManager.getInstance();
|
||||
virtualFileManager.addVirtualFileListener(virtualFileListener, myDisposable);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -180,14 +170,6 @@ public class LineStatusTrackerManager implements ProjectComponent, LineStatusTra
|
||||
return "LineStatusTrackerManager";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
public boolean isDisabled() {
|
||||
return !myProject.isOpen() || myProject.isDisposed();
|
||||
}
|
||||
@@ -374,36 +356,28 @@ public class LineStatusTrackerManager implements ProjectComponent, LineStatusTra
|
||||
}
|
||||
|
||||
final String converted = StringUtil.convertLineSeparators(lastUpToDateContent);
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (myLock) {
|
||||
final TrackerData data = myLineStatusTrackers.get(myDocument);
|
||||
if (data == null) {
|
||||
log("BaseRevisionLoader initializing: tracker already released", myVirtualFile);
|
||||
return;
|
||||
}
|
||||
if (!data.shouldBeUpdated(revisionNumber, charset, loadCounter)) {
|
||||
log("BaseRevisionLoader initializing: canceled", myVirtualFile);
|
||||
return;
|
||||
}
|
||||
|
||||
log("BaseRevisionLoader initializing: success", myVirtualFile);
|
||||
myLineStatusTrackers.put(myDocument, new TrackerData(data.tracker, revisionNumber, charset, loadCounter));
|
||||
data.tracker.setBaseRevision(converted);
|
||||
final Runnable runnable = () -> {
|
||||
synchronized (myLock) {
|
||||
final TrackerData data = myLineStatusTrackers.get(myDocument);
|
||||
if (data == null) {
|
||||
log("BaseRevisionLoader initializing: tracker already released", myVirtualFile);
|
||||
return;
|
||||
}
|
||||
if (!data.shouldBeUpdated(revisionNumber, charset, loadCounter)) {
|
||||
log("BaseRevisionLoader initializing: canceled", myVirtualFile);
|
||||
return;
|
||||
}
|
||||
|
||||
log("BaseRevisionLoader initializing: success", myVirtualFile);
|
||||
myLineStatusTrackers.put(myDocument, new TrackerData(data.tracker, revisionNumber, charset, loadCounter));
|
||||
data.tracker.setBaseRevision(converted);
|
||||
}
|
||||
};
|
||||
nonModalAliveInvokeLater(runnable);
|
||||
}
|
||||
|
||||
private void nonModalAliveInvokeLater(@NotNull Runnable runnable) {
|
||||
myApplication.invokeLater(runnable, ModalityState.NON_MODAL, new Condition() {
|
||||
@Override
|
||||
public boolean value(final Object ignore) {
|
||||
return isDisabled();
|
||||
}
|
||||
});
|
||||
myApplication.invokeLater(runnable, ModalityState.NON_MODAL, ignore -> isDisabled());
|
||||
}
|
||||
|
||||
private void reportTrackerBaseLoadFailed() {
|
||||
@@ -474,7 +448,7 @@ public class LineStatusTrackerManager implements ProjectComponent, LineStatusTra
|
||||
|
||||
public TrackerData(@NotNull LineStatusTracker tracker) {
|
||||
this.tracker = tracker;
|
||||
this.currentContent = null;
|
||||
currentContent = null;
|
||||
}
|
||||
|
||||
public TrackerData(@NotNull LineStatusTracker tracker,
|
||||
@@ -482,7 +456,7 @@ public class LineStatusTrackerManager implements ProjectComponent, LineStatusTra
|
||||
@NotNull Charset charset,
|
||||
long loadCounter) {
|
||||
this.tracker = tracker;
|
||||
this.currentContent = new ContentInfo(revision, charset, loadCounter);
|
||||
currentContent = new ContentInfo(revision, charset, loadCounter);
|
||||
}
|
||||
|
||||
public boolean shouldBeUpdated(@NotNull VcsRevisionNumber revision, @NotNull Charset charset, long loadCounter) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.intellij.openapi.vcs.impl;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -43,7 +44,7 @@ import java.util.*;
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class ModuleVcsDetector implements ProjectComponent {
|
||||
public class ModuleVcsDetector implements ProjectComponent, Disposable {
|
||||
private final Project myProject;
|
||||
private final MessageBus myMessageBus;
|
||||
private final ProjectLevelVcsManagerImpl myVcsManager;
|
||||
@@ -60,24 +61,18 @@ public class ModuleVcsDetector implements ProjectComponent {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) return;
|
||||
|
||||
final StartupManager manager = StartupManager.getInstance(myProject);
|
||||
manager.registerStartupActivity(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (myVcsManager.needAutodetectMappings()) {
|
||||
autoDetectVcsMappings(true);
|
||||
}
|
||||
myVcsManager.updateActiveVcss();
|
||||
manager.registerStartupActivity(() -> {
|
||||
if (myVcsManager.needAutodetectMappings()) {
|
||||
autoDetectVcsMappings(true);
|
||||
}
|
||||
myVcsManager.updateActiveVcss();
|
||||
});
|
||||
manager.registerPostStartupActivity(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (myMessageBus != null) {
|
||||
myConnection = myMessageBus.connect();
|
||||
final MyModulesListener listener = new MyModulesListener();
|
||||
myConnection.subscribe(ProjectTopics.MODULES, listener);
|
||||
myConnection.subscribe(ProjectTopics.PROJECT_ROOTS, listener);
|
||||
}
|
||||
manager.registerPostStartupActivity(() -> {
|
||||
if (myMessageBus != null) {
|
||||
myConnection = myMessageBus.connect(this);
|
||||
final MyModulesListener listener = new MyModulesListener();
|
||||
myConnection.subscribe(ProjectTopics.MODULES, listener);
|
||||
myConnection.subscribe(ProjectTopics.PROJECT_ROOTS, listener);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -113,11 +108,7 @@ public class ModuleVcsDetector implements ProjectComponent {
|
||||
myMappingsForRemovedModules.addAll(getMappings(module));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@NonNls
|
||||
@NotNull
|
||||
@@ -126,14 +117,7 @@ public class ModuleVcsDetector implements ProjectComponent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
if (myConnection != null) {
|
||||
myConnection.disconnect();
|
||||
}
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
private void autoDetectVcsMappings(final boolean tryMapPieces) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -83,7 +83,7 @@ import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
@State(name = "ProjectLevelVcsManager", storages = @Storage(StoragePathMacros.WORKSPACE_FILE))
|
||||
public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx implements ProjectComponent, PersistentStateComponent<Element> {
|
||||
public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx implements ProjectComponent, PersistentStateComponent<Element>, Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl");
|
||||
@NonNls private static final String SETTINGS_EDITED_MANUALLY = "settingsEditedManually";
|
||||
|
||||
@@ -220,7 +220,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
public void dispose() {
|
||||
releaseConsole();
|
||||
myMappings.disposeMe();
|
||||
Disposer.dispose(myAnnotationLocalChangesListener);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -98,6 +98,7 @@ public class CoverageDataManagerImpl extends CoverageDataManager {
|
||||
private final Object myLock = new Object();
|
||||
private boolean mySubCoverageIsActive;
|
||||
|
||||
@Override
|
||||
public CoverageSuitesBundle getCurrentSuitesBundle() {
|
||||
return myCurrentSuitesBundle;
|
||||
}
|
||||
@@ -127,17 +128,13 @@ public class CoverageDataManagerImpl extends CoverageDataManager {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@NotNull @NonNls
|
||||
public String getComponentName() {
|
||||
return "CoverageDataManager";
|
||||
}
|
||||
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
//noinspection unchecked
|
||||
for (Element suiteElement : element.getChildren(SUITE)) {
|
||||
@@ -176,6 +173,7 @@ public class CoverageDataManagerImpl extends CoverageDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(final Element element) throws WriteExternalException {
|
||||
for (CoverageSuite coverageSuite : myCoverageSuites) {
|
||||
final Element suiteElement = new Element(SUITE);
|
||||
@@ -184,6 +182,7 @@ public class CoverageDataManagerImpl extends CoverageDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CoverageSuite addCoverageSuite(final String name, final CoverageFileProvider fileProvider, final String[] filters, final long lastCoverageTimeStamp,
|
||||
@Nullable final String suiteToMergeWith,
|
||||
final CoverageRunner coverageRunner,
|
||||
@@ -228,6 +227,7 @@ public class CoverageDataManagerImpl extends CoverageDataManager {
|
||||
return suite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCoverageSuite(final CoverageSuite suite) {
|
||||
final String fileName = suite.getCoverageDataFileName();
|
||||
|
||||
@@ -260,11 +260,13 @@ public class CoverageDataManagerImpl extends CoverageDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public CoverageSuite[] getSuites() {
|
||||
return myCoverageSuites.toArray(new CoverageSuite[myCoverageSuites.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chooseSuitesBundle(final CoverageSuitesBundle suite) {
|
||||
if (myCurrentSuitesBundle == suite && suite == null) {
|
||||
return;
|
||||
@@ -300,6 +302,7 @@ public class CoverageDataManagerImpl extends CoverageDataManager {
|
||||
fireAfterSuiteChosen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void coverageGathered(@NotNull final CoverageSuite suite) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
if (myProject.isDisposed()) return;
|
||||
@@ -353,6 +356,7 @@ public class CoverageDataManagerImpl extends CoverageDataManager {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void triggerPresentationUpdate() {
|
||||
renewInformationInEditors();
|
||||
UIUtil.invokeLaterIfNeeded(() -> {
|
||||
@@ -362,10 +366,12 @@ public class CoverageDataManagerImpl extends CoverageDataManager {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachToProcess(@NotNull final ProcessHandler handler,
|
||||
@NotNull final RunConfigurationBase configuration,
|
||||
final RunnerSettings runnerSettings) {
|
||||
handler.addProcessListener(new ProcessAdapter() {
|
||||
@Override
|
||||
public void processTerminated(final ProcessEvent event) {
|
||||
processGatheredCoverage(configuration, runnerSettings);
|
||||
}
|
||||
@@ -448,9 +454,11 @@ public class CoverageDataManagerImpl extends CoverageDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
EditorFactory.getInstance().addEditorFactoryListener(new CoverageEditorFactoryListener(), myProject);
|
||||
ProjectManagerAdapter projectManagerListener = new ProjectManagerAdapter() {
|
||||
@Override
|
||||
public void projectClosing(Project project) {
|
||||
synchronized (myLock) {
|
||||
myIsProjectClosing = true;
|
||||
@@ -460,9 +468,11 @@ public class CoverageDataManagerImpl extends CoverageDataManager {
|
||||
ProjectManager.getInstance().addProjectManagerListener(myProject, projectManagerListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T doInReadActionIfProjectOpen(Computable<T> computation) {
|
||||
synchronized(myLock) {
|
||||
if (myIsProjectClosing) return null;
|
||||
@@ -470,6 +480,7 @@ public class CoverageDataManagerImpl extends CoverageDataManager {
|
||||
return ApplicationManager.getApplication().runReadAction(computation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectSubCoverage(@NotNull final CoverageSuitesBundle suite, final List<String> testNames) {
|
||||
suite.restoreCoverageData();
|
||||
final ProjectData data = suite.getCoverageData();
|
||||
@@ -557,6 +568,7 @@ public class CoverageDataManagerImpl extends CoverageDataManager {
|
||||
return new File(new File(fileName).getParentFile(), FileUtil.getNameWithoutExtension(new File(fileName)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreMergedCoverage(@NotNull final CoverageSuitesBundle suite) {
|
||||
mySubCoverageIsActive = false;
|
||||
suite.restoreCoverageData();
|
||||
@@ -567,6 +579,7 @@ public class CoverageDataManagerImpl extends CoverageDataManager {
|
||||
public void addSuiteListener(final CoverageSuiteListener listener, Disposable parentDisposable) {
|
||||
myListeners.add(listener);
|
||||
Disposer.register(parentDisposable, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
myListeners.remove(listener);
|
||||
}
|
||||
@@ -585,6 +598,7 @@ public class CoverageDataManagerImpl extends CoverageDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSubCoverageActive() {
|
||||
return mySubCoverageIsActive;
|
||||
}
|
||||
@@ -654,6 +668,7 @@ public class CoverageDataManagerImpl extends CoverageDataManager {
|
||||
private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, myProject);
|
||||
private final Map<Editor, Runnable> myCurrentEditors = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void editorCreated(@NotNull EditorFactoryEvent event) {
|
||||
synchronized (myLock) {
|
||||
if (myIsProjectClosing) return;
|
||||
@@ -702,6 +717,7 @@ public class CoverageDataManagerImpl extends CoverageDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editorReleased(@NotNull EditorFactoryEvent event) {
|
||||
final Editor editor = event.getEditor();
|
||||
if (editor.getProject() != myProject) return;
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@ package org.jetbrains.idea.maven.indices;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.components.BaseComponent;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -45,7 +46,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class MavenProjectIndicesManager extends MavenSimpleProjectComponent {
|
||||
public class MavenProjectIndicesManager extends MavenSimpleProjectComponent implements BaseComponent {
|
||||
private volatile List<MavenIndex> myProjectIndices = new ArrayList<>();
|
||||
private final MergingUpdateQueue myUpdateQueue;
|
||||
|
||||
|
||||
+4
-2
@@ -20,6 +20,7 @@ import com.intellij.execution.RunManagerEx;
|
||||
import com.intellij.execution.RunManagerListener;
|
||||
import com.intellij.execution.RunnerAndConfigurationSettings;
|
||||
import com.intellij.ide.util.treeView.TreeState;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.*;
|
||||
@@ -59,7 +60,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@State(name = "MavenProjectNavigator", storages = {@Storage(StoragePathMacros.WORKSPACE_FILE)})
|
||||
public class MavenProjectsNavigator extends MavenSimpleProjectComponent implements PersistentStateComponent<MavenProjectsNavigatorState> {
|
||||
public class MavenProjectsNavigator extends MavenSimpleProjectComponent implements PersistentStateComponent<MavenProjectsNavigatorState>,
|
||||
Disposable, ProjectComponent {
|
||||
public static final String TOOL_WINDOW_ID = "Maven Projects";
|
||||
|
||||
private static final URL ADD_ICON_URL = MavenProjectsNavigator.class.getResource("/general/add.png");
|
||||
@@ -191,7 +193,7 @@ public class MavenProjectsNavigator extends MavenSimpleProjectComponent implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
public void dispose() {
|
||||
myToolWindow = null;
|
||||
myProjectsManager = null;
|
||||
}
|
||||
|
||||
+5
-5
@@ -20,6 +20,7 @@ import com.intellij.ide.startup.StartupManagerEx;
|
||||
import com.intellij.notification.*;
|
||||
import com.intellij.notification.impl.NotificationSettings;
|
||||
import com.intellij.notification.impl.NotificationsConfigurationImpl;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
@@ -27,6 +28,7 @@ import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.compiler.CompileTask;
|
||||
import com.intellij.openapi.compiler.CompilerManager;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.components.SettingsSavingComponent;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider;
|
||||
@@ -76,7 +78,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@State(name = "MavenProjectsManager")
|
||||
public class MavenProjectsManager extends MavenSimpleProjectComponent
|
||||
implements PersistentStateComponent<MavenProjectsManagerState>, SettingsSavingComponent {
|
||||
implements PersistentStateComponent<MavenProjectsManagerState>, SettingsSavingComponent, Disposable, ProjectComponent {
|
||||
private static final int IMPORT_DELAY = 1000;
|
||||
private static final String NON_MANAGED_POM_NOTIFICATION_GROUP_ID = "Maven: non-managed pom.xml";
|
||||
private static final NotificationGroup NON_MANAGED_POM_NOTIFICATION_GROUP =
|
||||
@@ -127,7 +129,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent
|
||||
myEmbeddersManager = new MavenEmbeddersManager(project);
|
||||
myModificationTracker = new MavenModificationTracker(this);
|
||||
myInitializationAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, project);
|
||||
mySaveQueue = new MavenMergingUpdateQueue("Maven save queue", SAVE_DELAY, !isUnitTestMode(), null);
|
||||
mySaveQueue = new MavenMergingUpdateQueue("Maven save queue", SAVE_DELAY, !isUnitTestMode(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,9 +150,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
super.disposeComponent();
|
||||
Disposer.dispose(mySaveQueue);
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
public ModificationTracker getModificationTracker() {
|
||||
|
||||
+3
-2
@@ -17,6 +17,7 @@ package org.jetbrains.idea.maven.tasks;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.Shortcut;
|
||||
import com.intellij.openapi.components.BaseComponent;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.keymap.KeymapManagerListener;
|
||||
@@ -48,7 +49,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class MavenShortcutsManager extends MavenSimpleProjectComponent implements Disposable {
|
||||
public class MavenShortcutsManager extends MavenSimpleProjectComponent implements Disposable, BaseComponent {
|
||||
private static final String ACTION_ID_PREFIX = "Maven_";
|
||||
|
||||
private final AtomicBoolean isInitialized = new AtomicBoolean();
|
||||
@@ -189,7 +190,7 @@ public class MavenShortcutsManager extends MavenSimpleProjectComponent implement
|
||||
|
||||
private class MyProjectsTreeListener implements MavenProjectsManager.Listener, MavenProjectsTree.Listener {
|
||||
private final Map<MavenProject, Boolean> mySheduledProjects = new THashMap<>();
|
||||
private final MergingUpdateQueue myUpdateQueue = new MavenMergingUpdateQueue(getComponentName() + ": Keymap Update",
|
||||
private final MergingUpdateQueue myUpdateQueue = new MavenMergingUpdateQueue("MavenShortcutsManager: Keymap Update",
|
||||
500, true, myProject);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.compiler.CompileTask;
|
||||
import com.intellij.openapi.compiler.CompilerManager;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -43,7 +44,8 @@ import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@State(name = "MavenCompilerTasksManager")
|
||||
public class MavenTasksManager extends MavenSimpleProjectComponent implements PersistentStateComponent<MavenTasksManagerState> {
|
||||
public class MavenTasksManager extends MavenSimpleProjectComponent implements PersistentStateComponent<MavenTasksManagerState>,
|
||||
ProjectComponent {
|
||||
private final AtomicBoolean isInitialized = new AtomicBoolean();
|
||||
|
||||
private MavenTasksManagerState myState = new MavenTasksManagerState();
|
||||
@@ -76,6 +78,7 @@ public class MavenTasksManager extends MavenSimpleProjectComponent implements Pe
|
||||
myRunner = runner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized MavenTasksManagerState getState() {
|
||||
MavenTasksManagerState result = new MavenTasksManagerState();
|
||||
result.afterCompileTasks = new THashSet<>(myState.afterCompileTasks);
|
||||
@@ -85,6 +88,7 @@ public class MavenTasksManager extends MavenSimpleProjectComponent implements Pe
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(MavenTasksManagerState state) {
|
||||
synchronized (this) {
|
||||
myState = state;
|
||||
|
||||
+2
-2
@@ -13,9 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.idea.maven.utils;
|
||||
|
||||
import com.intellij.openapi.components.BaseComponent;
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.idea.maven.project.MavenProjectsTree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MavenEditorTabTitleUpdater extends MavenSimpleProjectComponent {
|
||||
public class MavenEditorTabTitleUpdater extends MavenSimpleProjectComponent implements BaseComponent {
|
||||
public MavenEditorTabTitleUpdater(Project project) {
|
||||
super(project);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.idea.maven.utils;
|
||||
|
||||
import com.intellij.notification.*;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.ui.update.MergingUpdateQueue;
|
||||
import com.intellij.util.ui.update.Update;
|
||||
@@ -25,7 +26,7 @@ import org.jetbrains.idea.maven.project.ProjectBundle;
|
||||
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
|
||||
public class MavenImportNotifier extends MavenSimpleProjectComponent {
|
||||
public class MavenImportNotifier extends MavenSimpleProjectComponent implements Disposable {
|
||||
private static final String MAVEN_IMPORT_NOTIFICATION_GROUP = "Maven Import";
|
||||
|
||||
private MavenProjectsManager myMavenProjectsManager;
|
||||
@@ -44,13 +45,15 @@ public class MavenImportNotifier extends MavenSimpleProjectComponent {
|
||||
|
||||
myMavenProjectsManager = mavenProjectsManager;
|
||||
|
||||
myUpdatesQueue = new MergingUpdateQueue(getComponentName(), 500, false, MergingUpdateQueue.ANY_COMPONENT, myProject);
|
||||
myUpdatesQueue = new MergingUpdateQueue("MavenImportNotifier", 500, false, MergingUpdateQueue.ANY_COMPONENT, myProject);
|
||||
|
||||
myMavenProjectsManager.addManagerListener(new MavenProjectsManager.Listener() {
|
||||
@Override
|
||||
public void activated() {
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectsScheduled() {
|
||||
scheduleUpdate(false);
|
||||
}
|
||||
@@ -67,12 +70,13 @@ public class MavenImportNotifier extends MavenSimpleProjectComponent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
public void dispose() {
|
||||
if (myNotification != null) myNotification.expire();
|
||||
}
|
||||
|
||||
private void scheduleUpdate(final boolean close) {
|
||||
myUpdatesQueue.queue(new Update(myUpdatesQueue) {
|
||||
@Override
|
||||
public void run() {
|
||||
doUpdateNotifications(close);
|
||||
}
|
||||
|
||||
+5
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -16,12 +16,13 @@
|
||||
package org.jetbrains.idea.maven.utils;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.AbstractProjectComponent;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
public abstract class MavenSimpleProjectComponent extends AbstractProjectComponent {
|
||||
public abstract class MavenSimpleProjectComponent {
|
||||
protected final Project myProject;
|
||||
|
||||
protected MavenSimpleProjectComponent(Project project) {
|
||||
super(project);
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
protected boolean isNormalProject() {
|
||||
|
||||
+4
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -17,6 +17,7 @@ package com.intellij.uiDesigner.propertyInspector;
|
||||
|
||||
import com.intellij.designer.DesignerEditorPanelFacade;
|
||||
import com.intellij.designer.LightToolWindow;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -35,7 +36,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class DesignerToolWindowManager extends AbstractToolWindowManager {
|
||||
public class DesignerToolWindowManager extends AbstractToolWindowManager implements Disposable {
|
||||
private final DesignerToolWindow myToolWindowPanel;
|
||||
|
||||
public DesignerToolWindowManager(Project project, FileEditorManager fileEditorManager) {
|
||||
@@ -117,7 +118,7 @@ public class DesignerToolWindowManager extends AbstractToolWindowManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
public void dispose() {
|
||||
if (myToolWindowPanel != null) {
|
||||
myToolWindowPanel.dispose();
|
||||
}
|
||||
|
||||
+16
-13
@@ -16,6 +16,7 @@
|
||||
package org.intellij.lang.xpath.xslt.associations.impl;
|
||||
|
||||
import com.intellij.ide.projectView.ProjectView;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
@@ -37,7 +38,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class FileAssociationsManagerImpl extends FileAssociationsManager implements ProjectComponent, JDOMExternalizable {
|
||||
class FileAssociationsManagerImpl extends FileAssociationsManager implements ProjectComponent, Disposable, JDOMExternalizable {
|
||||
private static final Logger LOG = Logger.getInstance(FileAssociationsManagerImpl.class);
|
||||
|
||||
private final Project myProject;
|
||||
@@ -55,6 +56,7 @@ class FileAssociationsManagerImpl extends FileAssociationsManager implements Pro
|
||||
myTempCopy = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
final List<Element> children = element.getChildren("file");
|
||||
@@ -69,6 +71,7 @@ class FileAssociationsManagerImpl extends FileAssociationsManager implements Pro
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
for (VirtualFilePointer pointer : myAssociations.keySet()) {
|
||||
final Element e = new Element("file");
|
||||
@@ -82,23 +85,16 @@ class FileAssociationsManagerImpl extends FileAssociationsManager implements Pro
|
||||
public TransactionalManager getTempManager() {
|
||||
return new TempManager(this, myProject, myFilePointerManager);
|
||||
}
|
||||
|
||||
public void projectOpened() {
|
||||
}
|
||||
|
||||
public void projectClosed() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@NonNls
|
||||
public String getComponentName() {
|
||||
return "XSLT-Support.FileAssociationsManager";
|
||||
}
|
||||
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
public void disposeComponent() {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
clear();
|
||||
}
|
||||
|
||||
@@ -138,6 +134,7 @@ class FileAssociationsManagerImpl extends FileAssociationsManager implements Pro
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAssociations(PsiFile file) {
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile == null) return;
|
||||
@@ -151,6 +148,7 @@ class FileAssociationsManagerImpl extends FileAssociationsManager implements Pro
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAssociation(PsiFile file, PsiFile assoc) {
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile == null) return;
|
||||
@@ -175,6 +173,7 @@ class FileAssociationsManagerImpl extends FileAssociationsManager implements Pro
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAssociation(PsiFile file, PsiFile assoc) {
|
||||
final VirtualFile virtualFile = assoc.getVirtualFile();
|
||||
if (virtualFile == null) {
|
||||
@@ -184,6 +183,7 @@ class FileAssociationsManagerImpl extends FileAssociationsManager implements Pro
|
||||
addAssociation(file, virtualFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAssociation(PsiFile file, VirtualFile assoc) {
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile == null) {
|
||||
@@ -211,6 +211,7 @@ class FileAssociationsManagerImpl extends FileAssociationsManager implements Pro
|
||||
touch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<VirtualFile, VirtualFile[]> getAssociations() {
|
||||
final HashMap<VirtualFile, VirtualFile[]> map = new LinkedHashMap<>();
|
||||
final Set<VirtualFilePointer> set = myAssociations.keySet();
|
||||
@@ -223,10 +224,12 @@ class FileAssociationsManagerImpl extends FileAssociationsManager implements Pro
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiFile[] getAssociationsFor(PsiFile file) {
|
||||
return getAssociationsFor(file, FileType.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiFile[] getAssociationsFor(PsiFile file, FileType... fileTypes) {
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile == null) return PsiFile.EMPTY_ARRAY;
|
||||
|
||||
+7
-10
@@ -8,6 +8,7 @@ import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.execution.filters.UrlFilter;
|
||||
import com.intellij.execution.process.KillableColoredProcessHandler;
|
||||
import com.intellij.execution.process.UnixProcessManager;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
@@ -59,7 +60,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class IpnbConnectionManager implements ProjectComponent {
|
||||
public final class IpnbConnectionManager implements ProjectComponent, Disposable {
|
||||
private static final Logger LOG = Logger.getInstance(IpnbConnectionManager.class);
|
||||
private final Project myProject;
|
||||
private final Map<String, IpnbConnection> myKernels = new HashMap<>();
|
||||
@@ -539,11 +540,8 @@ public final class IpnbConnectionManager implements ProjectComponent {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void projectOpened() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
shutdownKernels();
|
||||
}
|
||||
@@ -562,15 +560,14 @@ public final class IpnbConnectionManager implements ProjectComponent {
|
||||
myKernels.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "IpnbConnectionManager";
|
||||
}
|
||||
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
public void disposeComponent() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
shutdownKernels();
|
||||
}
|
||||
|
||||
|
||||
@@ -96,24 +96,12 @@ class NoNamespaceConfigImpl extends NoNamespaceConfig implements PersistentState
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "RELAX-NG.NoNamespaceConfig";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
reset();
|
||||
|
||||
Reference in New Issue
Block a user