mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix "IDEA-221944 Deadlock on opening second project" and support preloading for project services
GitOrigin-RevId: 9f309772f9d877bda063e486f1e50693240156b4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
139737422f
commit
cdcf7be856
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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-2019 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.compiler.options;
|
||||
|
||||
import com.intellij.ide.util.ElementsChooser;
|
||||
@@ -21,7 +7,6 @@ import com.intellij.openapi.compiler.CompilerBundle;
|
||||
import com.intellij.openapi.compiler.CompilerManager;
|
||||
import com.intellij.openapi.compiler.Validator;
|
||||
import com.intellij.openapi.compiler.options.ExcludedEntriesConfigurable;
|
||||
import com.intellij.openapi.compiler.options.ExcludesConfiguration;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
@@ -71,13 +56,12 @@ public class ValidationConfigurable implements SearchableConfigurable, Configura
|
||||
myExcludedEntriesPanel.setBorder(IdeBorderFactory.createTitledBorder("Exclude from validation:", false, JBUI.insetsTop(8)).setShowLine(false));
|
||||
}
|
||||
|
||||
private static ExcludedEntriesConfigurable createExcludedConfigurable(final Project project) {
|
||||
final ExcludesConfiguration configuration = ValidationConfiguration.getExcludedEntriesConfiguration(project);
|
||||
final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
private static ExcludedEntriesConfigurable createExcludedConfigurable(@NotNull Project project) {
|
||||
ProjectFileIndex index = project.isDefault() ? null : ProjectRootManager.getInstance(project).getFileIndex();
|
||||
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true) {
|
||||
@Override
|
||||
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
|
||||
return super.isFileVisible(file, showHiddenFiles) && (project.isDefault() || !index.isExcluded(file));
|
||||
return super.isFileVisible(file, showHiddenFiles) && (index == null || !index.isExcluded(file));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -87,7 +71,7 @@ public class ValidationConfigurable implements SearchableConfigurable, Configura
|
||||
Collections.addAll(allContentRoots, moduleContentRoots);
|
||||
}
|
||||
descriptor.setRoots(allContentRoots);
|
||||
return new ExcludedEntriesConfigurable(project, descriptor, configuration);
|
||||
return new ExcludedEntriesConfigurable(project, descriptor, ValidationConfiguration.getExcludedEntriesConfiguration(project));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,10 +16,13 @@ import java.util.List;
|
||||
* @author peter
|
||||
*/
|
||||
public class NonClasspathResolveScopeEnlarger extends ResolveScopeEnlarger {
|
||||
|
||||
@Override
|
||||
public SearchScope getAdditionalResolveScope(@NotNull VirtualFile file, Project project) {
|
||||
ProjectFileIndex index = ProjectFileIndex.SERVICE.getInstance(project);
|
||||
if (project.isDefault()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ProjectFileIndex index = ProjectFileIndex.getInstance(project);
|
||||
if (index.isInLibraryClasses(file) || index.isInContent(file)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,20 +1,7 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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-2019 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.psi.impl.file;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -29,11 +16,11 @@ import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class PsiJavaDirectoryFactory extends PsiDirectoryFactory {
|
||||
public final class PsiJavaDirectoryFactory extends PsiDirectoryFactory {
|
||||
private final PsiManagerImpl myManager;
|
||||
|
||||
public PsiJavaDirectoryFactory(final PsiManagerImpl manager) {
|
||||
myManager = manager;
|
||||
public PsiJavaDirectoryFactory(@NotNull Project project) {
|
||||
myManager = (PsiManagerImpl)PsiManager.getInstance(project);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -4,8 +4,9 @@ package com.intellij.psi.refResolve;
|
||||
import com.intellij.ide.PowerSaveMode;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationListener;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationEx;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.application.ex.ApplicationUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileTypeRegistry;
|
||||
@@ -61,7 +62,7 @@ import java.util.concurrent.FutureTask;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public class RefResolveServiceImpl extends RefResolveService implements Runnable, Disposable {
|
||||
public final class RefResolveServiceImpl extends RefResolveService implements Runnable, Disposable {
|
||||
private static final Logger LOG = Logger.getInstance(RefResolveServiceImpl.class);
|
||||
|
||||
private final AtomicInteger fileCount = new AtomicInteger();
|
||||
@@ -71,7 +72,6 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable
|
||||
private final Deque<VirtualFile> filesToResolve = new ArrayDeque<>(); // guarded by filesToResolve
|
||||
private final ConcurrentBitSet fileIsInQueue = new ConcurrentBitSet();
|
||||
private final ConcurrentBitSet fileIsResolved;
|
||||
private final ApplicationEx myApplication;
|
||||
private final Project myProject;
|
||||
private volatile boolean myDisposed;
|
||||
private volatile boolean upToDate;
|
||||
@@ -79,16 +79,10 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable
|
||||
private final FileWriter log;
|
||||
private final ProjectFileIndex myProjectFileIndex;
|
||||
|
||||
public RefResolveServiceImpl(final Project project,
|
||||
final MessageBus messageBus,
|
||||
final PsiManager psiManager,
|
||||
StartupManager startupManager,
|
||||
ApplicationEx application,
|
||||
ProjectFileIndex projectFileIndex) throws IOException {
|
||||
public RefResolveServiceImpl(@NotNull Project project) throws IOException {
|
||||
myProject = project;
|
||||
((FutureTask)resolveProcess).run();
|
||||
myApplication = application;
|
||||
myProjectFileIndex = projectFileIndex;
|
||||
myProjectFileIndex = ProjectFileIndex.getInstance(project);
|
||||
if (ENABLED) {
|
||||
log = new FileWriter(new File(getStorageDirectory(), "log.txt"));
|
||||
|
||||
@@ -109,9 +103,9 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable
|
||||
fileIsResolved.clear();
|
||||
}
|
||||
Disposer.register(this, storage);
|
||||
if (!application.isUnitTestMode()) {
|
||||
startupManager.runWhenProjectIsInitialized(() -> {
|
||||
initListeners(messageBus, psiManager);
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
StartupManager.getInstance(project).runWhenProjectIsInitialized(() -> {
|
||||
initListeners(project.getMessageBus(), PsiManager.getInstance(project));
|
||||
startThread();
|
||||
});
|
||||
}
|
||||
@@ -211,7 +205,7 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable
|
||||
}
|
||||
});
|
||||
|
||||
myApplication.addApplicationListener(new ApplicationListener() {
|
||||
ApplicationManagerEx.getApplicationEx().addApplicationListener(new ApplicationListener() {
|
||||
@Override
|
||||
public void beforeWriteActionStart(@NotNull Object action) {
|
||||
disable();
|
||||
@@ -411,14 +405,14 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable
|
||||
|
||||
upToDate = false;
|
||||
|
||||
myApplication.invokeLater(() -> {
|
||||
ApplicationManagerEx.getApplicationEx().invokeLater(() -> {
|
||||
if (!resolveProcess.isDone()) return;
|
||||
log("Started to resolve " + files.size() + " files");
|
||||
|
||||
Task.Backgroundable backgroundable = new Task.Backgroundable(myProject, "Resolving files...", false) {
|
||||
@Override
|
||||
public void run(@NotNull final ProgressIndicator indicator) {
|
||||
if (!myApplication.isDisposed()) {
|
||||
if (!ApplicationManagerEx.getApplicationEx().isDisposed()) {
|
||||
processBatch(indicator, files);
|
||||
}
|
||||
}
|
||||
@@ -440,7 +434,7 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable
|
||||
|
||||
private volatile int resolvedInPreviousBatch;
|
||||
private void processBatch(@NotNull final ProgressIndicator indicator, @NotNull Set<VirtualFile> files) {
|
||||
assert !myApplication.isDispatchThread();
|
||||
assert !ApplicationManagerEx.getApplicationEx().isDispatchThread();
|
||||
final int resolvedInPreviousBatch = this.resolvedInPreviousBatch;
|
||||
final int totalSize = files.size() + resolvedInPreviousBatch;
|
||||
final IntObjectMap<int[]> fileToForwardIds = ContainerUtil.createConcurrentIntObjectMap();
|
||||
@@ -522,7 +516,8 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable
|
||||
}, indicator);
|
||||
return result[0];
|
||||
};
|
||||
List<Future<Boolean>> futures = ContainerUtil.map(Collections.nCopies(parallelism, ""), s -> myApplication.executeOnPooledThread(processFileFromSet));
|
||||
List<Future<Boolean>> futures = ContainerUtil.map(Collections.nCopies(parallelism, ""), s -> ApplicationManagerEx.getApplicationEx()
|
||||
.executeOnPooledThread(processFileFromSet));
|
||||
|
||||
List<Boolean> results = ContainerUtil.map(futures, future -> {
|
||||
try {
|
||||
@@ -669,8 +664,8 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable
|
||||
assert forwardSize == backwardSize;
|
||||
|
||||
// wrap in read action so that sudden quit (in write action) would not interrupt us
|
||||
myApplication.runReadAction(() -> {
|
||||
if (!myApplication.isDisposed()) {
|
||||
ApplicationManagerEx.getApplicationEx().runReadAction(() -> {
|
||||
if (!ApplicationManagerEx.getApplicationEx().isDisposed()) {
|
||||
fileToBackwardIds.forEachEntry(new TIntObjectProcedure<TIntArrayList>() {
|
||||
@Override
|
||||
public boolean execute(int fileId, TIntArrayList backIds) {
|
||||
|
||||
+5
-19
@@ -1,30 +1,17 @@
|
||||
/*
|
||||
* 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-2019 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.openapi.roots.impl;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.PackageIndex;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Query;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ProjectPackageIndexImpl extends PackageIndex {
|
||||
final class ProjectPackageIndexImpl extends PackageIndex {
|
||||
private final DirectoryIndex myDirectoryIndex;
|
||||
|
||||
public ProjectPackageIndexImpl(DirectoryIndex directoryIndex) {
|
||||
myDirectoryIndex = directoryIndex;
|
||||
ProjectPackageIndexImpl(@NotNull Project project) {
|
||||
myDirectoryIndex = DirectoryIndex.getInstance(project);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -38,5 +25,4 @@ public class ProjectPackageIndexImpl extends PackageIndex {
|
||||
public Query<VirtualFile> getDirsByPackageName(@NotNull String packageName, boolean includeLibrarySources) {
|
||||
return myDirectoryIndex.getDirectoriesByPackageName(packageName, includeLibrarySources);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-5
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.psi.impl.file.impl;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
@@ -38,17 +38,15 @@ import static java.util.Objects.requireNonNull;
|
||||
/**
|
||||
* @author dmitry lomov
|
||||
*/
|
||||
public class JavaFileManagerImpl implements JavaFileManager, Disposable {
|
||||
public final class JavaFileManagerImpl implements JavaFileManager, Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.file.impl.JavaFileManagerImpl");
|
||||
|
||||
private final PsiManagerEx myManager;
|
||||
private volatile Set<String> myNontrivialPackagePrefixes;
|
||||
private boolean myDisposed;
|
||||
private final PackageIndex myPackageIndex;
|
||||
|
||||
public JavaFileManagerImpl(Project project) {
|
||||
myManager = PsiManagerEx.getInstanceEx(project);
|
||||
myPackageIndex = PackageIndex.getInstance(myManager.getProject());
|
||||
project.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
|
||||
@Override
|
||||
public void rootsChanged(@NotNull final ModuleRootEvent event) {
|
||||
@@ -65,7 +63,7 @@ public class JavaFileManagerImpl implements JavaFileManager, Disposable {
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiPackage findPackage(@NotNull String packageName) {
|
||||
Query<VirtualFile> dirs = myPackageIndex.getDirsByPackageName(packageName, true);
|
||||
Query<VirtualFile> dirs = PackageIndex.getInstance(myManager.getProject()).getDirsByPackageName(packageName, true);
|
||||
if (dirs.findFirst() == null) return null;
|
||||
return new PsiPackageImpl(myManager, packageName);
|
||||
}
|
||||
|
||||
+4
-18
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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-2019 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.psi.impl.file.impl;
|
||||
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
@@ -32,15 +18,15 @@ import org.jetbrains.annotations.Nullable;
|
||||
* For example, java files from test data.
|
||||
* There is still a possibility to modify this scope choice with the ResolveScopeEnlarger.
|
||||
*/
|
||||
public class JavaOutOfSourcesResolveScopeProvider extends ResolveScopeProvider {
|
||||
public final class JavaOutOfSourcesResolveScopeProvider extends ResolveScopeProvider {
|
||||
@Nullable
|
||||
@Override
|
||||
public GlobalSearchScope getResolveScope(@NotNull VirtualFile file, Project project) {
|
||||
// For java only! For other languages resolve may be implemented with different rules, requiring larger scope.
|
||||
final FileType type = file.getFileType();
|
||||
if (type instanceof LanguageFileType && ((LanguageFileType)type).getLanguage() == JavaLanguage.INSTANCE) {
|
||||
ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
if (index.isInContent(file) && !index.isInSource(file)) {
|
||||
ProjectFileIndex index = project.isDefault() ? null : ProjectRootManager.getInstance(project).getFileIndex();
|
||||
if (index == null || (index.isInContent(file) && !index.isInSource(file))) {
|
||||
return GlobalSearchScope.fileScope(project, file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,6 @@
|
||||
/*
|
||||
* 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-2019 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.openapi.roots;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Query;
|
||||
@@ -25,8 +10,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
* Provides a possibility to query the directories corresponding to a specific Java package name.
|
||||
*/
|
||||
public abstract class PackageIndex {
|
||||
public static PackageIndex getInstance(Project project) {
|
||||
return ServiceManager.getService(project, PackageIndex.class);
|
||||
public static PackageIndex getInstance(@NotNull Project project) {
|
||||
return project.getService(PackageIndex.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,14 +36,14 @@ public class JavaCoreProjectEnvironment extends CoreProjectEnvironment {
|
||||
public JavaCoreProjectEnvironment(@NotNull Disposable parentDisposable, @NotNull CoreApplicationEnvironment applicationEnvironment) {
|
||||
super(parentDisposable, applicationEnvironment);
|
||||
|
||||
myProject.registerService(PsiElementFactory.class, new PsiElementFactoryImpl(myPsiManager));
|
||||
myProject.registerService(PsiElementFactory.class, new PsiElementFactoryImpl(myProject));
|
||||
myProject.registerService(JavaPsiImplementationHelper.class, createJavaPsiImplementationHelper());
|
||||
myProject.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(myPsiManager));
|
||||
myProject.registerService(LanguageLevelProjectExtension.class, new CoreLanguageLevelProjectExtension());
|
||||
myProject.registerService(JavaResolveCache.class, new JavaResolveCache(myMessageBus));
|
||||
myProject.registerService(JavaResolveCache.class, new JavaResolveCache(myProject));
|
||||
myProject.registerService(JavaCodeStyleSettingsFacade.class, new CoreJavaCodeStyleSettingsFacade());
|
||||
myProject.registerService(JavaCodeStyleManager.class, new CoreJavaCodeStyleManager());
|
||||
myProject.registerService(ControlFlowFactory.class, new ControlFlowFactory(myPsiManager));
|
||||
myProject.registerService(ControlFlowFactory.class, new ControlFlowFactory(myProject));
|
||||
|
||||
myPackageIndex = createCorePackageIndex();
|
||||
myProject.registerService(PackageIndex.class, myPackageIndex);
|
||||
|
||||
@@ -1,19 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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-2019 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.psi.controlFlow;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
@@ -27,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ControlFlowFactory {
|
||||
public final class ControlFlowFactory {
|
||||
// psiElements hold weakly, controlFlows softly
|
||||
private final Map<PsiElement, ConcurrentList<ControlFlowContext>> cachedFlows = ContainerUtil.createConcurrentWeakKeySoftValueMap();
|
||||
|
||||
@@ -37,9 +22,8 @@ public class ControlFlowFactory {
|
||||
return INSTANCE_KEY.getValue(project);
|
||||
}
|
||||
|
||||
|
||||
public ControlFlowFactory(PsiManagerEx psiManager) {
|
||||
psiManager.registerRunnableToRunOnChange(() -> clearCache());
|
||||
public ControlFlowFactory(@NotNull Project project) {
|
||||
PsiManagerEx.getInstanceEx(project).registerRunnableToRunOnChange(() -> clearCache());
|
||||
}
|
||||
|
||||
private void clearCache() {
|
||||
|
||||
@@ -32,13 +32,14 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements PsiElementFactory {
|
||||
public final class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements PsiElementFactory {
|
||||
private final ConcurrentMap<LanguageLevel, PsiClass> myArrayClasses = ContainerUtil.newConcurrentMap();
|
||||
private final ConcurrentMap<GlobalSearchScope, PsiClassType> myCachedObjectType = ContainerUtil.createConcurrentSoftMap();
|
||||
|
||||
public PsiElementFactoryImpl(@NotNull PsiManagerEx manager) {
|
||||
super(manager);
|
||||
manager.registerRunnableToRunOnChange(myCachedObjectType::clear);
|
||||
public PsiElementFactoryImpl(@NotNull Project project) {
|
||||
super(project);
|
||||
|
||||
((PsiManagerEx)myManager).registerRunnableToRunOnChange(myCachedObjectType::clear);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.intellij.lang.java.parser.DeclarationParser;
|
||||
import com.intellij.lang.java.parser.JavaParser;
|
||||
import com.intellij.lang.java.parser.JavaParserUtil;
|
||||
import com.intellij.lang.java.parser.ReferenceParser;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
@@ -90,8 +91,8 @@ public class PsiJavaParserFacadeImpl implements PsiJavaParserFacade {
|
||||
|
||||
protected final PsiManager myManager;
|
||||
|
||||
public PsiJavaParserFacadeImpl(PsiManager manager) {
|
||||
myManager = manager;
|
||||
public PsiJavaParserFacadeImpl(@NotNull Project project) {
|
||||
myManager = PsiManager.getInstance(project);
|
||||
}
|
||||
|
||||
protected PsiJavaFile createDummyJavaFile(String text) {
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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-2019 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.
|
||||
|
||||
/*
|
||||
* @author max
|
||||
@@ -38,7 +24,6 @@ import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -61,15 +46,13 @@ public class JavaResolveCache {
|
||||
|
||||
private static final Object NULL = Key.create("NULL");
|
||||
|
||||
public JavaResolveCache(@Nullable("can be null in com.intellij.core.JavaCoreApplicationEnvironment.JavaCoreApplicationEnvironment") MessageBus messageBus) {
|
||||
if (messageBus != null) {
|
||||
messageBus.connect().subscribe(PsiManagerImpl.ANY_PSI_CHANGE_TOPIC, new AnyPsiChangeListener.Adapter() {
|
||||
@Override
|
||||
public void beforePsiChanged(boolean isPhysical) {
|
||||
clearCaches(isPhysical);
|
||||
}
|
||||
});
|
||||
}
|
||||
public JavaResolveCache(@NotNull Project project) {
|
||||
project.getMessageBus().connect().subscribe(PsiManagerImpl.ANY_PSI_CHANGE_TOPIC, new AnyPsiChangeListener.Adapter() {
|
||||
@Override
|
||||
public void beforePsiChanged(boolean isPhysical) {
|
||||
clearCaches(isPhysical);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void clearCaches(boolean isPhysical) {
|
||||
|
||||
@@ -33,7 +33,7 @@ public final class ServiceManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates lazy caching key to store project-level service instance from {@link #getService(Project, Class)}.
|
||||
* Creates lazy caching key to store project-level service instance from {@link Project#getService(Class)}.
|
||||
*
|
||||
* @param serviceClass Service class to create key for.
|
||||
* @param <T> Service class type.
|
||||
|
||||
@@ -32,7 +32,7 @@ public abstract class PsiDocumentManager {
|
||||
* @return the document manager instance.
|
||||
*/
|
||||
public static PsiDocumentManager getInstance(@NotNull Project project) {
|
||||
return project.getComponent(PsiDocumentManager.class);
|
||||
return project.getService(PsiDocumentManager.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2019 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-2019 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.psi;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -27,7 +13,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
* The main entry point for accessing the PSI services for a project.
|
||||
*/
|
||||
public abstract class PsiManager extends UserDataHolderBase {
|
||||
|
||||
/**
|
||||
* Returns the PSI manager instance for the specified project.
|
||||
*
|
||||
@@ -36,7 +21,7 @@ public abstract class PsiManager extends UserDataHolderBase {
|
||||
*/
|
||||
@NotNull
|
||||
public static PsiManager getInstance(@NotNull Project project) {
|
||||
return project.getComponent(PsiManager.class);
|
||||
return project.getService(PsiManager.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.psi.search;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
@@ -755,9 +755,9 @@ public abstract class GlobalSearchScope extends SearchScope implements ProjectAw
|
||||
super(project);
|
||||
myVirtualFile = virtualFile;
|
||||
myDisplayName = displayName;
|
||||
final FileIndexFacade facade = FileIndexFacade.getInstance(project);
|
||||
myModule = virtualFile == null || project.isDefault() ? null : facade.getModuleForFile(virtualFile);
|
||||
mySearchOutsideContent = project.isDefault() || virtualFile != null && myModule == null && !facade.isInLibraryClasses(virtualFile) && !facade.isInLibrarySource(virtualFile);
|
||||
FileIndexFacade facade = project.isDefault() ? null : FileIndexFacade.getInstance(project);
|
||||
myModule = virtualFile == null || facade == null ? null : facade.getModuleForFile(virtualFile);
|
||||
mySearchOutsideContent = facade == null || virtualFile != null && myModule == null && !facade.isInLibraryClasses(virtualFile) && !facade.isInLibrarySource(virtualFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -53,17 +53,16 @@ public class CoreProjectEnvironment {
|
||||
myProject.registerService(ResolveCache.class, new ResolveCache(myProject));
|
||||
|
||||
myPsiManager = new PsiManagerImpl(myProject);
|
||||
registerProjectComponent(PsiManager.class, myPsiManager);
|
||||
myProject.registerService(PsiManager.class, myPsiManager);
|
||||
myProject.registerService(SmartPointerManager.class, SmartPointerManagerImpl.class);
|
||||
registerProjectComponent(PsiDocumentManager.class, new CorePsiDocumentManager(myProject, myPsiManager,
|
||||
myMessageBus,
|
||||
new MockDocumentCommitProcessor()));
|
||||
myProject.registerService(DocumentCommitProcessor.class, new MockDocumentCommitProcessor());
|
||||
myProject.registerService(PsiDocumentManager.class, new CorePsiDocumentManager(myProject));
|
||||
|
||||
myProject.registerService(ResolveScopeManager.class, createResolveScopeManager(myPsiManager));
|
||||
|
||||
myProject.registerService(PsiFileFactory.class, new PsiFileFactoryImpl(myPsiManager));
|
||||
myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
|
||||
myProject.registerService(PsiDirectoryFactory.class, new PsiDirectoryFactoryImpl(myPsiManager));
|
||||
myProject.registerService(PsiDirectoryFactory.class, new PsiDirectoryFactoryImpl(myProject));
|
||||
myProject.registerService(ProjectScopeBuilder.class, createProjectScopeBuilder());
|
||||
myProject.registerService(DumbService.class, new MockDumbService(myProject));
|
||||
myProject.registerService(CoreEncodingProjectManager.class, CoreEncodingProjectManager.class);
|
||||
|
||||
@@ -1,36 +1,15 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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-2019 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.core;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.DocumentCommitProcessor;
|
||||
import com.intellij.psi.impl.PsiDocumentManagerBase;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
class CorePsiDocumentManager extends PsiDocumentManagerBase {
|
||||
CorePsiDocumentManager(@NotNull Project project,
|
||||
@NotNull PsiManager psiManager,
|
||||
@NotNull MessageBus bus,
|
||||
@NonNls @NotNull DocumentCommitProcessor documentCommitProcessor) {
|
||||
super(project, psiManager, bus, documentCommitProcessor);
|
||||
final class CorePsiDocumentManager extends PsiDocumentManagerBase {
|
||||
CorePsiDocumentManager(@NotNull Project project) {
|
||||
super(project);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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-2019 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.psi;
|
||||
|
||||
import com.intellij.injected.editor.DocumentWindow;
|
||||
@@ -105,7 +91,7 @@ public abstract class AbstractFileViewProvider extends UserDataHolderBase implem
|
||||
if (isPhysical() && vFile.isInLocalFileSystem()) { // check directories consistency
|
||||
VirtualFile parent = vFile.getParent();
|
||||
if (parent == null) return false;
|
||||
|
||||
|
||||
PsiDirectory psiDir = getManager().findDirectory(parent);
|
||||
if (psiDir == null) {
|
||||
FileIndexFacade indexFacade = FileIndexFacade.getInstance(getManager().getProject());
|
||||
|
||||
@@ -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-2019 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.psi;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.psi.impl;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
@@ -44,7 +44,7 @@ import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
public class DocumentCommitThread implements Runnable, Disposable, DocumentCommitProcessor {
|
||||
public final class DocumentCommitThread implements Runnable, Disposable, DocumentCommitProcessor {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.DocumentCommitThread");
|
||||
private static final String SYNC_COMMIT_REASON = "Sync commit";
|
||||
|
||||
@@ -52,7 +52,6 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
|
||||
private final Object lock = new Object();
|
||||
private final HashSetQueue<CommitTask> documentsToCommit = new HashSetQueue<>(); // guarded by lock
|
||||
private final HashSetQueue<CommitTask> documentsToApplyInEDT = new HashSetQueue<>(); // guarded by lock
|
||||
private final ApplicationEx myApplication;
|
||||
private volatile boolean isDisposed;
|
||||
private CommitTask currentTask; // guarded by lock
|
||||
private boolean myEnabled; // true if we can do commits. set to false temporarily during the write action. guarded by lock
|
||||
@@ -60,8 +59,9 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
|
||||
static DocumentCommitThread getInstance() {
|
||||
return (DocumentCommitThread)ServiceManager.getService(DocumentCommitProcessor.class);
|
||||
}
|
||||
DocumentCommitThread(final ApplicationEx application) {
|
||||
myApplication = application;
|
||||
|
||||
DocumentCommitThread() {
|
||||
ApplicationEx application = (ApplicationEx)ApplicationManager.getApplication();
|
||||
// install listener in EDT to avoid missing events in case we are inside write action right now
|
||||
application.invokeLater(() -> {
|
||||
if (application.isDisposed()) return;
|
||||
@@ -248,7 +248,7 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
|
||||
|
||||
// returns true if queue changed
|
||||
private boolean pollQueue() {
|
||||
assert !myApplication.isDispatchThread() : Thread.currentThread();
|
||||
assert !ApplicationManager.getApplication().isDispatchThread() : Thread.currentThread();
|
||||
CommitTask task;
|
||||
synchronized (lock) {
|
||||
if (!myEnabled || (task = documentsToCommit.poll()) == null) {
|
||||
@@ -284,7 +284,7 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
|
||||
failureReason = result.get().second;
|
||||
|
||||
if (success) {
|
||||
assert !myApplication.isDispatchThread();
|
||||
assert !ApplicationManager.getApplication().isDispatchThread();
|
||||
TransactionGuardImpl guard = (TransactionGuardImpl)TransactionGuard.getInstance();
|
||||
guard.submitTransaction(task.project, task.myCreationContext, finishRunnable);
|
||||
}
|
||||
@@ -409,7 +409,7 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
|
||||
final List<BooleanRunnable> finishProcessors = new SmartList<>();
|
||||
List<BooleanRunnable> reparseInjectedProcessors = new SmartList<>();
|
||||
Runnable runnable = () -> {
|
||||
myApplication.assertReadAccessAllowed();
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
if (project.isDisposed()) return;
|
||||
|
||||
Lock lock = getDocumentLock(document);
|
||||
@@ -450,8 +450,10 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!myApplication.tryRunReadAction(runnable)) {
|
||||
log(project, "Could not start read action", task, myApplication.isReadAccessAllowed(), Thread.currentThread());
|
||||
|
||||
ApplicationEx app = (ApplicationEx)ApplicationManager.getApplication();
|
||||
if (!app.tryRunReadAction(runnable)) {
|
||||
log(project, "Could not start read action", task, app.isReadAccessAllowed(), Thread.currentThread());
|
||||
return new Pair<>(null, "Could not start read action");
|
||||
}
|
||||
|
||||
@@ -471,7 +473,7 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
|
||||
@NotNull List<? extends BooleanRunnable> finishProcessors,
|
||||
@NotNull List<? extends BooleanRunnable> reparseInjectedProcessors) {
|
||||
return () -> {
|
||||
myApplication.assertIsDispatchThread();
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
Document document = task.getDocument();
|
||||
Project project = task.project;
|
||||
PsiDocumentManagerBase documentManager = (PsiDocumentManagerBase)PsiDocumentManager.getInstance(project);
|
||||
@@ -530,7 +532,7 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Document commit thread; application: "+myApplication+"; isDisposed: "+isDisposed+"; myEnabled: "+isEnabled();
|
||||
return "Document commit thread; application: "+ApplicationManager.getApplication()+"; isDisposed: "+isDisposed+"; myEnabled: "+isEnabled();
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
|
||||
@@ -1,21 +1,8 @@
|
||||
/*
|
||||
* 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-2019 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.psi.impl;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.util.CachedValue;
|
||||
import com.intellij.psi.util.CachedValueProvider;
|
||||
@@ -27,9 +14,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public class PsiCachedValuesFactory implements CachedValuesFactory {
|
||||
public final class PsiCachedValuesFactory implements CachedValuesFactory {
|
||||
private final PsiManager myManager;
|
||||
|
||||
public PsiCachedValuesFactory(@NotNull Project project) {
|
||||
myManager = PsiManager.getInstance(project);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public PsiCachedValuesFactory(PsiManager manager) {
|
||||
myManager = manager;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
@@ -51,7 +50,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
|
||||
protected final Project myProject;
|
||||
private final PsiManager myPsiManager;
|
||||
private final DocumentCommitProcessor myDocumentCommitProcessor;
|
||||
protected final DocumentCommitProcessor myDocumentCommitProcessor;
|
||||
final Set<Document> myUncommittedDocuments = ContainerUtil.newConcurrentSet();
|
||||
private final Map<Document, UncommittedInfo> myUncommittedInfos = ContainerUtil.newConcurrentMap();
|
||||
boolean myStopTrackingDocuments;
|
||||
@@ -63,18 +62,16 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
|
||||
private final List<Listener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
|
||||
protected PsiDocumentManagerBase(@NotNull final Project project,
|
||||
@NotNull PsiManager psiManager,
|
||||
@NotNull MessageBus bus,
|
||||
@NotNull DocumentCommitProcessor documentCommitProcessor) {
|
||||
protected PsiDocumentManagerBase(@NotNull Project project) {
|
||||
myProject = project;
|
||||
myPsiManager = psiManager;
|
||||
myDocumentCommitProcessor = documentCommitProcessor;
|
||||
mySynchronizer = new PsiToDocumentSynchronizer(this, bus);
|
||||
myPsiManager = PsiManager.getInstance(project);
|
||||
myDocumentCommitProcessor = ApplicationManager.getApplication().getService(DocumentCommitProcessor.class);
|
||||
mySynchronizer = new PsiToDocumentSynchronizer(this, project.getMessageBus());
|
||||
myPsiManager.addPsiTreeChangeListener(mySynchronizer);
|
||||
|
||||
bus.connect(this).subscribe(PsiDocumentTransactionListener.TOPIC,
|
||||
(document, file) -> myUncommittedDocuments.remove(document));
|
||||
project.getMessageBus().connect(this).subscribe(PsiDocumentTransactionListener.TOPIC, (document, file) -> {
|
||||
myUncommittedDocuments.remove(document);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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-2019 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.psi.impl;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -32,6 +18,7 @@ public abstract class PsiManagerEx extends PsiManager {
|
||||
//noinspection SSBasedInspection
|
||||
return (PsiManagerEx)getInstance(project);
|
||||
}
|
||||
|
||||
public abstract boolean isBatchFilesProcessingMode();
|
||||
|
||||
@TestOnly
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// Copyright 2000-2019 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.psi.impl;
|
||||
|
||||
import com.intellij.lang.PsiBuilderFactory;
|
||||
@@ -14,6 +13,7 @@ import com.intellij.openapi.progress.util.ProgressWrapper;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.FileIndexFacade;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.openapi.vfs.NonPhysicalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileFilter;
|
||||
@@ -33,11 +33,11 @@ import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public class PsiManagerImpl extends PsiManagerEx {
|
||||
public final class PsiManagerImpl extends PsiManagerEx {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.PsiManagerImpl");
|
||||
|
||||
private final Project myProject;
|
||||
private final FileIndexFacade myFileIndex;
|
||||
private final NotNullLazyValue<? extends FileIndexFacade> myFileIndex;
|
||||
private final PsiModificationTracker myModificationTracker;
|
||||
|
||||
private final FileManagerImpl myFileManager;
|
||||
@@ -60,7 +60,7 @@ public class PsiManagerImpl extends PsiManagerEx {
|
||||
PsiBuilderFactory.getInstance();
|
||||
|
||||
myProject = project;
|
||||
myFileIndex = FileIndexFacade.getInstance(project);
|
||||
myFileIndex = NotNullLazyValue.createValue(() -> FileIndexFacade.getInstance(project));
|
||||
myModificationTracker = PsiModificationTracker.SERVICE.getInstance(project);
|
||||
|
||||
myFileManager = new FileManagerImpl(this, myFileIndex);
|
||||
@@ -107,7 +107,7 @@ public class PsiManagerImpl extends PsiManagerEx {
|
||||
}
|
||||
if (file != null && file.isPhysical() && virtualFile.getFileSystem() instanceof NonPhysicalFileSystem) return true;
|
||||
|
||||
return virtualFile != null && myFileIndex.isInContent(virtualFile);
|
||||
return virtualFile != null && myFileIndex.getValue().isInContent(virtualFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,8 +153,8 @@ public class PsiManagerImpl extends PsiManagerEx {
|
||||
return myFileManager.findFile(file);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@Nullable
|
||||
public FileViewProvider findViewProvider(@NotNull VirtualFile file) {
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
return myFileManager.findViewProvider(file);
|
||||
|
||||
@@ -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-2019 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.psi.impl;
|
||||
|
||||
@@ -21,6 +7,7 @@ import com.intellij.lang.Commenter;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageCommenters;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.DummyHolderFactory;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
@@ -34,11 +21,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class PsiParserFacadeImpl implements PsiParserFacade {
|
||||
protected final PsiManagerEx myManager;
|
||||
public final class PsiParserFacadeImpl implements PsiParserFacade {
|
||||
private final PsiManagerEx myManager;
|
||||
|
||||
public PsiParserFacadeImpl(PsiManagerEx manager) {
|
||||
myManager = manager;
|
||||
public PsiParserFacadeImpl(@NotNull Project project) {
|
||||
myManager = PsiManagerEx.getInstanceEx(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,7 +93,7 @@ public class PsiParserFacadeImpl implements PsiParserFacade {
|
||||
throw new IncorrectOperationException("Incorrect comment \"" + aFile.getText() + "\".");
|
||||
}
|
||||
|
||||
protected PsiFile createDummyFile(String text, final LanguageFileType fileType) {
|
||||
private PsiFile createDummyFile(String text, final LanguageFileType fileType) {
|
||||
String ext = fileType.getDefaultExtension();
|
||||
@NonNls String fileName = "_Dummy_." + ext;
|
||||
|
||||
|
||||
@@ -1,41 +1,29 @@
|
||||
/*
|
||||
* 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-2019 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.psi.impl.file;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiDirectoryContainer;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.PsiManagerImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class PsiDirectoryFactoryImpl extends PsiDirectoryFactory {
|
||||
private final PsiManagerImpl myManager;
|
||||
public final class PsiDirectoryFactoryImpl extends PsiDirectoryFactory {
|
||||
private final Project myProject;
|
||||
|
||||
public PsiDirectoryFactoryImpl(final PsiManagerImpl manager) {
|
||||
myManager = manager;
|
||||
public PsiDirectoryFactoryImpl(@NotNull Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiDirectory createDirectory(@NotNull final VirtualFile file) {
|
||||
return new PsiDirectoryImpl(myManager, file);
|
||||
public PsiDirectory createDirectory(@NotNull VirtualFile file) {
|
||||
return new PsiDirectoryImpl((PsiManagerImpl)PsiManager.getInstance(myProject), file);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,10 +12,7 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.roots.FileIndexFacade;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.LowMemoryWatcher;
|
||||
import com.intellij.openapi.util.StackOverflowPreventedException;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vfs.InvalidVirtualFileAccessException;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
@@ -43,7 +40,7 @@ public final class FileManagerImpl implements FileManager {
|
||||
private final Key<FileViewProvider> myPsiHardRefKey = Key.create("HARD_REFERENCE_TO_PSI"); //non-static!
|
||||
|
||||
private final PsiManagerImpl myManager;
|
||||
private final FileIndexFacade myFileIndex;
|
||||
private final NotNullLazyValue<? extends FileIndexFacade> myFileIndex;
|
||||
|
||||
private final AtomicReference<ConcurrentMap<VirtualFile, PsiDirectory>> myVFileToPsiDirMap = new AtomicReference<>();
|
||||
private final AtomicReference<ConcurrentMap<VirtualFile, FileViewProvider>> myVFileToViewProviderMap = new AtomicReference<>();
|
||||
@@ -57,7 +54,7 @@ public final class FileManagerImpl implements FileManager {
|
||||
|
||||
private final MessageBusConnection myConnection;
|
||||
|
||||
public FileManagerImpl(PsiManagerImpl manager, FileIndexFacade fileIndex) {
|
||||
public FileManagerImpl(@NotNull PsiManagerImpl manager, @NotNull NotNullLazyValue<? extends FileIndexFacade> fileIndex) {
|
||||
myManager = manager;
|
||||
myFileIndex = fileIndex;
|
||||
myConnection = manager.getProject().getMessageBus().connect();
|
||||
@@ -406,7 +403,8 @@ public final class FileManagerImpl implements FileManager {
|
||||
|
||||
private boolean isExcludedOrIgnored(@NotNull VirtualFile vFile) {
|
||||
if (myManager.getProject().isDefault()) return false;
|
||||
return Registry.is("ide.hide.excluded.files") ? myFileIndex.isExcludedFile(vFile) : myFileIndex.isUnderIgnored(vFile);
|
||||
FileIndexFacade fileIndexFacade = myFileIndex.getValue();
|
||||
return Registry.is("ide.hide.excluded.files") ? fileIndexFacade.isExcludedFile(vFile) : fileIndexFacade.isUnderIgnored(vFile);
|
||||
}
|
||||
|
||||
public PsiDirectory getCachedDirectory(@NotNull VirtualFile vFile) {
|
||||
|
||||
+12
-27
@@ -1,19 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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-2019 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.psi.impl.smartPointers;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -38,15 +23,15 @@ import org.jetbrains.annotations.TestOnly;
|
||||
import java.lang.ref.Reference;
|
||||
import java.util.List;
|
||||
|
||||
public class SmartPointerManagerImpl extends SmartPointerManager {
|
||||
public final class SmartPointerManagerImpl extends SmartPointerManager {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl");
|
||||
private final Project myProject;
|
||||
private final Key<SmartPointerTracker> POINTERS_KEY;
|
||||
private final PsiDocumentManagerBase myPsiDocManager;
|
||||
|
||||
public SmartPointerManagerImpl(Project project, PsiDocumentManagerBase psiDocManager) {
|
||||
public SmartPointerManagerImpl(@NotNull Project project) {
|
||||
myProject = project;
|
||||
myPsiDocManager = psiDocManager;
|
||||
myPsiDocManager = (PsiDocumentManagerBase)PsiDocumentManager.getInstance(project);
|
||||
POINTERS_KEY = Key.create("SMART_POINTERS " + (project.isDefault() ? "default" : project.hashCode()));
|
||||
}
|
||||
|
||||
@@ -63,7 +48,7 @@ public class SmartPointerManagerImpl extends SmartPointerManager {
|
||||
if (pointers != null) pointers.fastenBelts(this);
|
||||
}
|
||||
|
||||
private static final Key<Reference<SmartPsiElementPointerImpl>> CACHED_SMART_POINTER_KEY = Key.create("CACHED_SMART_POINTER_KEY");
|
||||
private static final Key<Reference<SmartPsiElementPointerImpl<?>>> CACHED_SMART_POINTER_KEY = Key.create("CACHED_SMART_POINTER_KEY");
|
||||
@Override
|
||||
@NotNull
|
||||
public <E extends PsiElement> SmartPsiElementPointer<E> createSmartPsiElementPointer(@NotNull E element) {
|
||||
@@ -116,8 +101,8 @@ public class SmartPointerManagerImpl extends SmartPointerManager {
|
||||
}
|
||||
|
||||
private static <E extends PsiElement> SmartPsiElementPointerImpl<E> getCachedPointer(@NotNull E element) {
|
||||
Reference<SmartPsiElementPointerImpl> data = element.getUserData(CACHED_SMART_POINTER_KEY);
|
||||
SmartPsiElementPointerImpl cachedPointer = SoftReference.dereference(data);
|
||||
Reference<SmartPsiElementPointerImpl<?>> data = element.getUserData(CACHED_SMART_POINTER_KEY);
|
||||
SmartPsiElementPointerImpl<?> cachedPointer = SoftReference.dereference(data);
|
||||
if (cachedPointer != null) {
|
||||
PsiElement cachedElement = cachedPointer.getElement();
|
||||
if (cachedElement != element) {
|
||||
@@ -125,7 +110,7 @@ public class SmartPointerManagerImpl extends SmartPointerManager {
|
||||
}
|
||||
}
|
||||
//noinspection unchecked
|
||||
return cachedPointer;
|
||||
return (SmartPsiElementPointerImpl<E>)cachedPointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -168,22 +153,22 @@ public class SmartPointerManagerImpl extends SmartPointerManager {
|
||||
return;
|
||||
}
|
||||
ensureMyProject(pointer.getProject());
|
||||
int refCount = ((SmartPsiElementPointerImpl)pointer).incrementAndGetReferenceCount(-1);
|
||||
int refCount = ((SmartPsiElementPointerImpl<?>)pointer).incrementAndGetReferenceCount(-1);
|
||||
if (refCount == -1) {
|
||||
LOG.error("Double smart pointer removal");
|
||||
return;
|
||||
}
|
||||
|
||||
if (refCount == 0) {
|
||||
PsiElement element = ((SmartPointerEx)pointer).getCachedElement();
|
||||
PsiElement element = ((SmartPointerEx<?>)pointer).getCachedElement();
|
||||
if (element != null) {
|
||||
element.putUserData(CACHED_SMART_POINTER_KEY, null);
|
||||
}
|
||||
|
||||
SmartPointerElementInfo info = ((SmartPsiElementPointerImpl)pointer).getElementInfo();
|
||||
SmartPointerElementInfo info = ((SmartPsiElementPointerImpl<?>)pointer).getElementInfo();
|
||||
info.cleanup();
|
||||
|
||||
SmartPointerTracker.PointerReference reference = ((SmartPsiElementPointerImpl)pointer).pointerReference;
|
||||
SmartPointerTracker.PointerReference reference = ((SmartPsiElementPointerImpl<?>)pointer).pointerReference;
|
||||
if (reference != null) {
|
||||
if (reference.get() != pointer) {
|
||||
throw new IllegalStateException("Reference points to " + reference.get());
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.dvcs.cherrypick;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -28,13 +28,11 @@ import java.util.*;
|
||||
public class VcsCherryPickManager {
|
||||
private static final Logger LOG = Logger.getInstance(VcsCherryPickManager.class);
|
||||
@NotNull private final Project myProject;
|
||||
@NotNull private final ProjectLevelVcsManager myProjectLevelVcsManager;
|
||||
@NotNull private final Set<CommitId> myIdsInProgress = ContainerUtil.newConcurrentSet();
|
||||
@NotNull private final BackgroundTaskQueue myTaskQueue;
|
||||
|
||||
public VcsCherryPickManager(@NotNull Project project, @NotNull ProjectLevelVcsManager projectLevelVcsManager) {
|
||||
public VcsCherryPickManager(@NotNull Project project) {
|
||||
myProject = project;
|
||||
myProjectLevelVcsManager = projectLevelVcsManager;
|
||||
myTaskQueue = new BackgroundTaskQueue(project, "Cherry-picking");
|
||||
}
|
||||
|
||||
@@ -53,7 +51,7 @@ public class VcsCherryPickManager {
|
||||
|
||||
@Nullable
|
||||
private VcsCherryPicker getCherryPickerForCommit(@NotNull VcsFullCommitDetails commitDetails) {
|
||||
AbstractVcs vcs = myProjectLevelVcsManager.getVcsFor(commitDetails.getRoot());
|
||||
AbstractVcs vcs = ProjectLevelVcsManager.getInstance(myProject).getVcsFor(commitDetails.getRoot());
|
||||
if (vcs == null) return null;
|
||||
VcsKey key = vcs.getKeyInstanceMethod();
|
||||
return getCherryPickerFor(key);
|
||||
|
||||
+7
-11
@@ -1,7 +1,7 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.openapi.editor.impl;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.components.Service;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -9,23 +9,19 @@ import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.util.containers.WeakList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DocumentMarkupModelManager {
|
||||
@Service
|
||||
public final class DocumentMarkupModelManager {
|
||||
private static final Logger LOG = Logger.getInstance(DocumentMarkupModelManager.class);
|
||||
|
||||
private final WeakList<Document> myDocumentSet = new WeakList<>();
|
||||
private volatile boolean myDisposed;
|
||||
|
||||
public static DocumentMarkupModelManager getInstance(Project project) {
|
||||
return project.getComponent(DocumentMarkupModelManager.class);
|
||||
public static DocumentMarkupModelManager getInstance(@NotNull Project project) {
|
||||
return project.getService(DocumentMarkupModelManager.class);
|
||||
}
|
||||
|
||||
public DocumentMarkupModelManager(@NotNull Project project) {
|
||||
Disposer.register(project, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
cleanupProjectMarkups(project);
|
||||
}
|
||||
});
|
||||
Disposer.register(project, () -> cleanupProjectMarkups(project));
|
||||
}
|
||||
|
||||
public void registerDocument(Document document) {
|
||||
|
||||
+13
-5
@@ -1,9 +1,9 @@
|
||||
// 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.
|
||||
|
||||
// Copyright 2000-2019 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.psi.impl.search;
|
||||
|
||||
import com.intellij.ide.todo.TodoConfiguration;
|
||||
import com.intellij.ide.todo.TodoIndexPatternProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
@@ -19,12 +19,20 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class PsiTodoSearchHelperImpl implements PsiTodoSearchHelper {
|
||||
public final class PsiTodoSearchHelperImpl implements PsiTodoSearchHelper {
|
||||
private final PsiManagerEx myManager;
|
||||
private static final TodoItem[] EMPTY_TODO_ITEMS = new TodoItem[0];
|
||||
|
||||
public PsiTodoSearchHelperImpl(PsiManagerEx manager) {
|
||||
myManager = manager;
|
||||
public PsiTodoSearchHelperImpl(@NotNull Project project) {
|
||||
myManager = PsiManagerEx.getInstanceEx(project);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #PsiTodoSearchHelperImpl(Project)}
|
||||
*/
|
||||
@Deprecated
|
||||
public PsiTodoSearchHelperImpl(@NotNull PsiManagerEx psiManager) {
|
||||
myManager = psiManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-6
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.psi.impl.file.impl;
|
||||
|
||||
import com.intellij.injected.editor.VirtualFileWindow;
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ResolveScopeManagerImpl extends ResolveScopeManager {
|
||||
public final class ResolveScopeManagerImpl extends ResolveScopeManager {
|
||||
private final Project myProject;
|
||||
private final ProjectRootManager myProjectRootManager;
|
||||
private final PsiManager myManager;
|
||||
@@ -32,10 +32,10 @@ public class ResolveScopeManagerImpl extends ResolveScopeManager {
|
||||
private final Map<VirtualFile, GlobalSearchScope> myDefaultResolveScopesCache;
|
||||
private final AdditionalIndexableFileSet myAdditionalIndexableFileSet;
|
||||
|
||||
public ResolveScopeManagerImpl(Project project, ProjectRootManager projectRootManager, PsiManager psiManager) {
|
||||
public ResolveScopeManagerImpl(Project project) {
|
||||
myProject = project;
|
||||
myProjectRootManager = projectRootManager;
|
||||
myManager = psiManager;
|
||||
myProjectRootManager = ProjectRootManager.getInstance(project);
|
||||
myManager = PsiManager.getInstance(project);
|
||||
myAdditionalIndexableFileSet = new AdditionalIndexableFileSet(project);
|
||||
|
||||
myDefaultResolveScopesCache = ConcurrentFactoryMap.create(
|
||||
@@ -56,7 +56,7 @@ public class ResolveScopeManagerImpl extends ResolveScopeManager {
|
||||
},
|
||||
ContainerUtil::createConcurrentWeakKeySoftValueMap);
|
||||
|
||||
((PsiManagerImpl)psiManager).registerRunnableToRunOnChange(myDefaultResolveScopesCache::clear);
|
||||
((PsiManagerImpl)myManager).registerRunnableToRunOnChange(myDefaultResolveScopesCache::clear);
|
||||
}
|
||||
|
||||
private GlobalSearchScope getResolveScopeFromProviders(@NotNull final VirtualFile vFile) {
|
||||
|
||||
@@ -78,8 +78,17 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public PsiSearchHelperImpl(@NotNull PsiManagerEx manager) {
|
||||
myManager = manager;
|
||||
public PsiSearchHelperImpl(@NotNull Project project) {
|
||||
myManager = PsiManagerEx.getInstanceEx(project);
|
||||
myDumbService = DumbService.getInstance(myManager.getProject());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #PsiSearchHelperImpl(Project)}
|
||||
*/
|
||||
@Deprecated
|
||||
public PsiSearchHelperImpl(@NotNull PsiManagerEx psiManager) {
|
||||
myManager = psiManager;
|
||||
myDumbService = DumbService.getInstance(myManager.getProject());
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -28,7 +28,6 @@ import com.intellij.testFramework.TestModeFlags;
|
||||
import com.intellij.util.PairProcessor;
|
||||
import com.intellij.util.containers.ConcurrentFactoryMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
@@ -47,9 +46,9 @@ public class TemplateManagerImpl extends TemplateManager implements Disposable {
|
||||
private static final Key<TemplateState> TEMPLATE_STATE_KEY = Key.create("TEMPLATE_STATE_KEY");
|
||||
private final TemplateManagerListener myEventPublisher;
|
||||
|
||||
public TemplateManagerImpl(@NotNull Project project, @NotNull MessageBus messageBus) {
|
||||
public TemplateManagerImpl(@NotNull Project project) {
|
||||
myProject = project;
|
||||
myEventPublisher = messageBus.syncPublisher(TEMPLATE_STARTED_TOPIC);
|
||||
myEventPublisher = project.getMessageBus().syncPublisher(TEMPLATE_STARTED_TOPIC);
|
||||
EditorFactoryListener myEditorFactoryListener = new EditorFactoryListener() {
|
||||
@Override
|
||||
public void editorReleased(@NotNull EditorFactoryEvent event) {
|
||||
|
||||
+30
-41
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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-2019 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.execution.startup;
|
||||
|
||||
import com.intellij.execution.RunManager;
|
||||
@@ -20,7 +6,6 @@ import com.intellij.execution.RunnerAndConfigurationSettings;
|
||||
import com.intellij.execution.impl.RunManagerImpl;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.impl.ProjectLifecycleListener;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
@@ -30,24 +15,21 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Irina.Chernushina on 8/19/2015.
|
||||
*/
|
||||
public class ProjectStartupTaskManager {
|
||||
public final class ProjectStartupTaskManager {
|
||||
public static final NotificationGroup NOTIFICATION_GROUP = NotificationGroup.logOnlyGroup("Project Startup Tasks Messages");
|
||||
@NonNls public static final String PREFIX = "Project Startup Tasks: ";
|
||||
private final Project myProject;
|
||||
private final ProjectStartupSharedConfiguration myShared;
|
||||
private final ProjectStartupLocalConfiguration myLocal;
|
||||
|
||||
public static ProjectStartupTaskManager getInstance(@NotNull final Project project) {
|
||||
return ServiceManager.getService(project, ProjectStartupTaskManager.class);
|
||||
public static ProjectStartupTaskManager getInstance(@NotNull Project project) {
|
||||
return project.getService(ProjectStartupTaskManager.class);
|
||||
}
|
||||
|
||||
public ProjectStartupTaskManager(Project project, ProjectStartupSharedConfiguration shared, ProjectStartupLocalConfiguration local) {
|
||||
public ProjectStartupTaskManager(@NotNull Project project) {
|
||||
myProject = project;
|
||||
myShared = shared;
|
||||
myLocal = local;
|
||||
myShared = myProject.getService(ProjectStartupSharedConfiguration.class);
|
||||
myLocal = myProject.getService(ProjectStartupLocalConfiguration.class);
|
||||
verifyState();
|
||||
}
|
||||
|
||||
@@ -68,22 +50,24 @@ public class ProjectStartupTaskManager {
|
||||
}
|
||||
|
||||
private void verifyState() {
|
||||
if (! myShared.isEmpty()) {
|
||||
final Collection<RunnerAndConfigurationSettings> sharedConfigurations = getSharedConfigurations();
|
||||
final List<RunnerAndConfigurationSettings> canNotBeShared = new ArrayList<>();
|
||||
final Iterator<RunnerAndConfigurationSettings> iterator = sharedConfigurations.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final RunnerAndConfigurationSettings configuration = iterator.next();
|
||||
if (!configuration.isShared()) {
|
||||
iterator.remove();
|
||||
canNotBeShared.add(configuration);
|
||||
}
|
||||
}
|
||||
if (! canNotBeShared.isEmpty()) {
|
||||
canNotBeShared.addAll(getLocalConfigurations());
|
||||
setStartupConfigurations(sharedConfigurations, canNotBeShared);
|
||||
if (myShared.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Collection<RunnerAndConfigurationSettings> sharedConfigurations = getSharedConfigurations();
|
||||
final List<RunnerAndConfigurationSettings> canNotBeShared = new ArrayList<>();
|
||||
final Iterator<RunnerAndConfigurationSettings> iterator = sharedConfigurations.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final RunnerAndConfigurationSettings configuration = iterator.next();
|
||||
if (!configuration.isShared()) {
|
||||
iterator.remove();
|
||||
canNotBeShared.add(configuration);
|
||||
}
|
||||
}
|
||||
if (! canNotBeShared.isEmpty()) {
|
||||
canNotBeShared.addAll(getLocalConfigurations());
|
||||
setStartupConfigurations(sharedConfigurations, canNotBeShared);
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<RunnerAndConfigurationSettings> getSharedConfigurations() {
|
||||
@@ -113,12 +97,17 @@ public class ProjectStartupTaskManager {
|
||||
}
|
||||
|
||||
public void rename(final String oldId, RunnerAndConfigurationSettings settings) {
|
||||
if (myShared.rename(oldId, settings)) return;
|
||||
if (myShared.rename(oldId, settings)) {
|
||||
return;
|
||||
}
|
||||
myLocal.rename(oldId, settings);
|
||||
|
||||
}
|
||||
|
||||
public void delete(final String id) {
|
||||
if (myShared.deleteConfiguration(id)) return;
|
||||
if (myShared.deleteConfiguration(id)) {
|
||||
return;
|
||||
}
|
||||
myLocal.deleteConfiguration(id);
|
||||
}
|
||||
|
||||
|
||||
+23
-25
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.facet.impl.ui;
|
||||
|
||||
import com.intellij.facet.*;
|
||||
@@ -12,25 +12,16 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FacetDependentToolWindowManager implements ProjectComponent {
|
||||
final class FacetDependentToolWindowManager implements ProjectComponent {
|
||||
private final Project myProject;
|
||||
private final ProjectWideFacetListenersRegistry myFacetListenersRegistry;
|
||||
private final ProjectFacetManager myFacetManager;
|
||||
private final ToolWindowManagerEx myToolWindowManager;
|
||||
|
||||
protected FacetDependentToolWindowManager(Project project,
|
||||
ProjectWideFacetListenersRegistry facetListenersRegistry,
|
||||
ProjectFacetManager facetManager,
|
||||
ToolWindowManagerEx toolWindowManager) {
|
||||
private FacetDependentToolWindowManager(@NotNull Project project) {
|
||||
myProject = project;
|
||||
myFacetListenersRegistry = facetListenersRegistry;
|
||||
myFacetManager = facetManager;
|
||||
myToolWindowManager = toolWindowManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
myFacetListenersRegistry.registerListener(new ProjectWideFacetAdapter<Facet>() {
|
||||
ProjectWideFacetListenersRegistry.getInstance(myProject).registerListener(new ProjectWideFacetAdapter<Facet>() {
|
||||
@Override
|
||||
public void facetAdded(@NotNull Facet facet) {
|
||||
for (FacetDependentToolWindow extension : getDependentExtensions(facet)) {
|
||||
@@ -40,25 +31,32 @@ public class FacetDependentToolWindowManager implements ProjectComponent {
|
||||
|
||||
@Override
|
||||
public void facetRemoved(@NotNull Facet facet) {
|
||||
if (!myFacetManager.hasFacets(facet.getTypeId())) {
|
||||
for (FacetDependentToolWindow extension : getDependentExtensions(facet)) {
|
||||
ToolWindow toolWindow = myToolWindowManager.getToolWindow(extension.id);
|
||||
if (toolWindow != null) {
|
||||
// check for other facets
|
||||
List<FacetType> facetTypes = extension.getFacetTypes();
|
||||
for (FacetType facetType : facetTypes) {
|
||||
if (myFacetManager.hasFacets(facetType.getId())) return;
|
||||
ProjectFacetManager facetManager = ProjectFacetManager.getInstance(myProject);
|
||||
if (facetManager.hasFacets(facet.getTypeId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(myProject);
|
||||
for (FacetDependentToolWindow extension : getDependentExtensions(facet)) {
|
||||
ToolWindow toolWindow = toolWindowManager.getToolWindow(extension.id);
|
||||
if (toolWindow != null) {
|
||||
// check for other facets
|
||||
List<FacetType> facetTypes = extension.getFacetTypes();
|
||||
for (FacetType facetType : facetTypes) {
|
||||
if (facetManager.hasFacets(facetType.getId())) {
|
||||
return;
|
||||
}
|
||||
myToolWindowManager.unregisterToolWindow(extension.id);
|
||||
}
|
||||
toolWindowManager.unregisterToolWindow(extension.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, myProject);
|
||||
|
||||
ProjectFacetManager facetManager = ProjectFacetManager.getInstance(myProject);
|
||||
loop: for (FacetDependentToolWindow extension : FacetDependentToolWindow.EXTENSION_POINT_NAME.getExtensionList()) {
|
||||
for (FacetType type : extension.getFacetTypes()) {
|
||||
if (myFacetManager.hasFacets(type.getId())) {
|
||||
if (facetManager.hasFacets(type.getId())) {
|
||||
ensureToolWindowExists(extension);
|
||||
continue loop;
|
||||
}
|
||||
@@ -67,9 +65,9 @@ public class FacetDependentToolWindowManager implements ProjectComponent {
|
||||
}
|
||||
|
||||
private void ensureToolWindowExists(FacetDependentToolWindow extension) {
|
||||
ToolWindow toolWindow = myToolWindowManager.getToolWindow(extension.id);
|
||||
ToolWindow toolWindow = ToolWindowManagerEx.getInstanceEx(myProject).getToolWindow(extension.id);
|
||||
if (toolWindow == null) {
|
||||
myToolWindowManager.initToolWindow(extension);
|
||||
ToolWindowManagerEx.getInstanceEx(myProject).initToolWindow(extension);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-2
@@ -1,5 +1,4 @@
|
||||
// Copyright 2000-2019 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.projectView.impl.nodes;
|
||||
|
||||
import com.intellij.ide.projectView.ProjectViewSettings;
|
||||
@@ -50,6 +49,12 @@ public class ProjectViewDirectoryHelper {
|
||||
return ServiceManager.getService(project, ProjectViewDirectoryHelper.class);
|
||||
}
|
||||
|
||||
public ProjectViewDirectoryHelper(Project project) {
|
||||
myProject = project;
|
||||
myIndex = DirectoryIndex.getInstance(project);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ProjectViewDirectoryHelper(Project project, DirectoryIndex index) {
|
||||
myProject = project;
|
||||
myIndex = index;
|
||||
@@ -93,7 +98,7 @@ public class ProjectViewDirectoryHelper {
|
||||
if (result.length() > 0) result.append(",").append(FontUtil.spaceAndThinSpace());
|
||||
result.append(FileUtil.getLocationRelativeToUserHome(directory.getPresentableUrl()));
|
||||
}
|
||||
|
||||
|
||||
return result.length() == 0 ? null : result.toString();
|
||||
}
|
||||
|
||||
|
||||
+2
-5
@@ -9,7 +9,6 @@ import com.intellij.openapi.roots.impl.storage.ClassPathStorageUtil;
|
||||
import com.intellij.openapi.roots.impl.storage.ClasspathStorage;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager;
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
@@ -31,10 +30,8 @@ import java.util.List;
|
||||
public class ModuleRootManagerComponent extends ModuleRootManagerImpl implements
|
||||
PersistentStateComponentWithModificationTracker<ModuleRootManagerImpl.ModuleRootManagerState>,
|
||||
StateStorageChooserEx {
|
||||
public ModuleRootManagerComponent(Module module,
|
||||
ProjectRootManagerImpl projectRootManager,
|
||||
VirtualFilePointerManager filePointerManager) {
|
||||
super(module, projectRootManager, filePointerManager);
|
||||
public ModuleRootManagerComponent(Module module) {
|
||||
super(module);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+7
-3
@@ -225,7 +225,7 @@ public class ProjectRootManagerComponent extends ProjectRootManagerImpl implemen
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<String> recursiveUrls = ContainerUtil.map(recursivePaths, VfsUtilCore::pathToUrl);
|
||||
Set<String> excludedUrls = new THashSet<>();
|
||||
// changes in files provided by this method should be watched manually because no-one's bothered to set up correct pointers for them
|
||||
@@ -247,7 +247,7 @@ public class ProjectRootManagerComponent extends ProjectRootManagerImpl implemen
|
||||
|
||||
// module roots already fire validity change events, see usages of ProjectRootManagerComponent.getRootsValidityChangedListener
|
||||
collectModuleWatchRoots(recursivePaths, flatPaths);
|
||||
|
||||
|
||||
return Pair.create(recursivePaths, flatPaths);
|
||||
}
|
||||
|
||||
@@ -300,7 +300,11 @@ public class ProjectRootManagerComponent extends ProjectRootManagerImpl implemen
|
||||
@Override
|
||||
protected void clearScopesCaches() {
|
||||
super.clearScopesCaches();
|
||||
LibraryScopeCache.getInstance(myProject).clear();
|
||||
|
||||
LibraryScopeCache libraryScopeCache = myProject.getServiceIfCreated(LibraryScopeCache.class);
|
||||
if (libraryScopeCache != null) {
|
||||
libraryScopeCache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.psi.impl;
|
||||
|
||||
@@ -27,14 +27,12 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.core.impl.PomModelImpl;
|
||||
import com.intellij.psi.FileViewProvider;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageManagerImpl;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.FileContentUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -44,20 +42,15 @@ import org.jetbrains.annotations.TestOnly;
|
||||
import java.util.*;
|
||||
|
||||
//todo listen & notifyListeners readonly events?
|
||||
public class PsiDocumentManagerImpl extends PsiDocumentManagerBase {
|
||||
private final DocumentCommitProcessor myDocumentCommitThread;
|
||||
public final class PsiDocumentManagerImpl extends PsiDocumentManagerBase {
|
||||
private final boolean myUnitTestMode = ApplicationManager.getApplication().isUnitTestMode();
|
||||
|
||||
public PsiDocumentManagerImpl(@NotNull final Project project,
|
||||
@NotNull PsiManager psiManager,
|
||||
@NotNull EditorFactory editorFactory,
|
||||
@NotNull MessageBus bus,
|
||||
@NotNull final DocumentCommitProcessor documentCommitThread) {
|
||||
super(project, psiManager, bus, documentCommitThread);
|
||||
myDocumentCommitThread = documentCommitThread;
|
||||
editorFactory.getEventMulticaster().addDocumentListener(this, this);
|
||||
((EditorEventMulticasterImpl)editorFactory.getEventMulticaster()).addPrioritizedDocumentListener(new PriorityEventCollector(), this);
|
||||
MessageBusConnection connection = bus.connect(this);
|
||||
public PsiDocumentManagerImpl(@NotNull Project project) {
|
||||
super(project);
|
||||
|
||||
EditorFactory.getInstance().getEventMulticaster().addDocumentListener(this, this);
|
||||
((EditorEventMulticasterImpl)EditorFactory.getInstance().getEventMulticaster()).addPrioritizedDocumentListener(new PriorityEventCollector(), this);
|
||||
MessageBusConnection connection = project.getMessageBus().connect(this);
|
||||
connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerListener() {
|
||||
@Override
|
||||
public void fileContentLoaded(@NotNull final VirtualFile virtualFile, @NotNull Document document) {
|
||||
@@ -65,7 +58,7 @@ public class PsiDocumentManagerImpl extends PsiDocumentManagerBase {
|
||||
fireDocumentCreated(document, psiFile);
|
||||
}
|
||||
});
|
||||
Disposer.register(this, () -> ((DocumentCommitThread)myDocumentCommitThread).cancelTasksOnProjectDispose(project));
|
||||
Disposer.register(this, () -> ((DocumentCommitThread)myDocumentCommitProcessor).cancelTasksOnProjectDispose(project));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -155,7 +148,7 @@ public class PsiDocumentManagerImpl extends PsiDocumentManagerBase {
|
||||
@TestOnly
|
||||
public void clearUncommittedDocuments() {
|
||||
super.clearUncommittedDocuments();
|
||||
((DocumentCommitThread)myDocumentCommitThread).clearQueue();
|
||||
((DocumentCommitThread)myDocumentCommitProcessor).clearQueue();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.psi.search;
|
||||
|
||||
import com.intellij.core.CoreProjectScopeBuilder;
|
||||
@@ -68,8 +68,10 @@ public class ProjectScopeBuilderImpl extends ProjectScopeBuilder {
|
||||
@NotNull
|
||||
@Override
|
||||
public GlobalSearchScope buildAllScope() {
|
||||
final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(myProject);
|
||||
if (projectRootManager == null) return new EverythingGlobalScope(myProject);
|
||||
ProjectRootManager projectRootManager = myProject.isDefault() ? null : ProjectRootManager.getInstance(myProject);
|
||||
if (projectRootManager == null) {
|
||||
return new EverythingGlobalScope(myProject);
|
||||
}
|
||||
|
||||
boolean searchOutsideRootModel = false;
|
||||
for (SearchScopeEnlarger each : SearchScopeEnlarger.EXTENSION.getExtensionList()) {
|
||||
|
||||
@@ -49,7 +49,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@State(name = "ActionMacroManager", storages = @Storage("macros.xml"))
|
||||
public class ActionMacroManager implements PersistentStateComponent<Element>, Disposable {
|
||||
public final class ActionMacroManager implements PersistentStateComponent<Element>, Disposable {
|
||||
private static final Logger LOG = Logger.getInstance(ActionMacroManager.class);
|
||||
|
||||
private static final String TYPING_SAMPLE = "WWWWWWWWWWWWWWWWWWWW";
|
||||
@@ -108,9 +108,9 @@ public class ActionMacroManager implements PersistentStateComponent<Element>, Di
|
||||
registerActions();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Element getState() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Element getState() {
|
||||
Element element = new Element("state");
|
||||
for (ActionMacro macro : myMacros) {
|
||||
Element macroElement = new Element(ELEMENT_MACRO);
|
||||
|
||||
@@ -125,13 +125,14 @@ private fun startApp(app: ApplicationImpl, starter: ApplicationStarter, initAppA
|
||||
}
|
||||
|
||||
// preload services only after icon activation
|
||||
val future = registerRegistryAndInitStoreFuture.thenCompose {
|
||||
val preloadServiceActivity = StartUpMeasurer.start("preload services")
|
||||
preloadServices(app, it)
|
||||
.thenRun(Runnable {
|
||||
preloadServiceActivity.end()
|
||||
})
|
||||
}
|
||||
val future = registerRegistryAndInitStoreFuture
|
||||
.thenCompose {
|
||||
val preloadServiceActivity = StartUpMeasurer.start("preload services")
|
||||
app.preloadServices(it)
|
||||
.thenRun(Runnable {
|
||||
preloadServiceActivity.end()
|
||||
})
|
||||
}
|
||||
|
||||
if (!headless) {
|
||||
if (SystemInfo.isMac) {
|
||||
@@ -204,7 +205,7 @@ private fun preloadIcons() {
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun registerRegistryAndInitStore(registerFuture: CompletableFuture<List<IdeaPluginDescriptor>>, app: ApplicationImpl): CompletableFuture<List<IdeaPluginDescriptor>> {
|
||||
fun registerRegistryAndInitStore(registerFuture: CompletableFuture<List<IdeaPluginDescriptor>>, app: ApplicationImpl): CompletableFuture<List<IdeaPluginDescriptorImpl>> {
|
||||
return registerFuture
|
||||
.thenCompose { plugins ->
|
||||
val future = CompletableFuture.runAsync(Runnable {
|
||||
@@ -217,7 +218,10 @@ fun registerRegistryAndInitStore(registerFuture: CompletableFuture<List<IdeaPlug
|
||||
initConfigurationStore(app, null)
|
||||
|
||||
future
|
||||
.thenApply { plugins }
|
||||
.thenApply {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
plugins as List<IdeaPluginDescriptorImpl>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,22 +527,6 @@ private fun processProgramArguments(args: Array<String>): List<String> {
|
||||
return arguments
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun preloadServices(app: ApplicationImpl, plugins: List<IdeaPluginDescriptor>): CompletableFuture<*> {
|
||||
val futures = mutableListOf<CompletableFuture<Void>>()
|
||||
val executor = AppExecutorUtil.createBoundedApplicationPoolExecutor("preload services", Runtime.getRuntime().availableProcessors(), false)
|
||||
for (plugin in plugins) {
|
||||
for (service in (plugin as IdeaPluginDescriptorImpl).app.services) {
|
||||
if (service.preload) {
|
||||
futures.add(CompletableFuture.runAsync(Runnable { app.precreateService(service.getInterface()) }, executor))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
executor.shutdown()
|
||||
return CompletableFuture.allOf(*futures.toTypedArray())
|
||||
}
|
||||
|
||||
private fun CompletableFuture<*>.thenRunOrHandleError(handler: () -> Unit): CompletableFuture<Void>? {
|
||||
return thenRun(handler)
|
||||
.exceptionally {
|
||||
|
||||
@@ -102,8 +102,8 @@ public final class UndoManagerImpl extends UndoManager implements Disposable {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public UndoManagerImpl(@Nullable ProjectEx project) {
|
||||
myProject = project;
|
||||
public UndoManagerImpl(@Nullable Project project) {
|
||||
myProject = (ProjectEx)project;
|
||||
myMerger = new CommandMerger(this);
|
||||
|
||||
if (myProject != null && myProject.isDefault()) {
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.openapi.editor.impl;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class VisibleEditorsTracker implements CommandListener {
|
||||
public final class VisibleEditorsTracker implements CommandListener {
|
||||
private final Set<Editor> myEditorsVisibleOnCommandStart = new HashSet<>();
|
||||
private long myCurrentCommandStart;
|
||||
private long myLastCommandFinish;
|
||||
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
|
||||
// Copyright 2000-2019 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.openapi.fileEditor.ex;
|
||||
|
||||
@@ -12,7 +11,7 @@ import java.util.List;
|
||||
|
||||
public abstract class IdeDocumentHistory {
|
||||
public static IdeDocumentHistory getInstance(Project project) {
|
||||
return project.getComponent(IdeDocumentHistory.class);
|
||||
return project.getService(IdeDocumentHistory.class);
|
||||
}
|
||||
|
||||
public abstract void includeCurrentCommandAsNavigation();
|
||||
|
||||
+8
-12
@@ -54,7 +54,6 @@ import com.intellij.util.text.DateFormatUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -75,7 +74,6 @@ public class IdeDocumentHistoryImpl extends IdeDocumentHistory implements Dispos
|
||||
private final Project myProject;
|
||||
|
||||
private FileDocumentManager myFileDocumentManager;
|
||||
private FileEditorManagerEx myFileEditorManager;
|
||||
|
||||
private final LinkedList<PlaceInfo> myBackPlaces = new LinkedList<>(); // LinkedList of PlaceInfo's
|
||||
private final LinkedList<PlaceInfo> myForwardPlaces = new LinkedList<>(); // LinkedList of PlaceInfo's
|
||||
@@ -98,9 +96,8 @@ public class IdeDocumentHistoryImpl extends IdeDocumentHistory implements Dispos
|
||||
|
||||
private RecentlyChangedFilesState myRecentlyChangedFiles = new RecentlyChangedFilesState();
|
||||
|
||||
public IdeDocumentHistoryImpl(@NotNull Project project, @NotNull FileEditorManagerEx fileEditorManager) {
|
||||
public IdeDocumentHistoryImpl(@NotNull Project project) {
|
||||
myProject = project;
|
||||
myFileEditorManager = fileEditorManager;
|
||||
|
||||
MessageBusConnection busConnection = project.getMessageBus().connect(this);
|
||||
busConnection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() {
|
||||
@@ -165,6 +162,10 @@ public class IdeDocumentHistoryImpl extends IdeDocumentHistory implements Dispos
|
||||
myRecentFilesTimestampsMap = initRecentFilesTimestampMap(project);
|
||||
}
|
||||
|
||||
protected FileEditorManagerEx getFileEditorManager() {
|
||||
return FileEditorManagerEx.getInstanceEx(myProject);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private PersistentHashMap<String, Long> initRecentFilesTimestampMap(@NotNull Project project) {
|
||||
File file = ProjectUtil.getProjectCachePath(project, "recentFilesTimeStamps.dat").toFile();
|
||||
@@ -195,11 +196,6 @@ public class IdeDocumentHistoryImpl extends IdeDocumentHistory implements Dispos
|
||||
return map;
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public void setFileEditorManager(@NotNull FileEditorManagerEx value) {
|
||||
myFileEditorManager = value;
|
||||
}
|
||||
|
||||
private void registerViewed(@NotNull VirtualFile file) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
return;
|
||||
@@ -554,7 +550,7 @@ public class IdeDocumentHistoryImpl extends IdeDocumentHistory implements Dispos
|
||||
public void gotoPlaceInfo(@NotNull PlaceInfo info) {
|
||||
final boolean wasActive = ToolWindowManager.getInstance(myProject).isEditorComponentActive();
|
||||
EditorWindow wnd = info.getWindow();
|
||||
FileEditorManagerEx editorManager = myFileEditorManager;
|
||||
FileEditorManagerEx editorManager = getFileEditorManager();
|
||||
final Pair<FileEditor[], FileEditorProvider[]> editorsWithProviders = wnd != null && wnd.isValid()
|
||||
? editorManager.openFileWithProviders(info.getFile(), wasActive, wnd)
|
||||
: editorManager.openFileWithProviders(info.getFile(), wasActive, false);
|
||||
@@ -576,7 +572,7 @@ public class IdeDocumentHistoryImpl extends IdeDocumentHistory implements Dispos
|
||||
*/
|
||||
@Nullable
|
||||
protected FileEditorWithProvider getSelectedEditor() {
|
||||
FileEditorManagerEx editorManager = myFileEditorManager;
|
||||
FileEditorManagerEx editorManager = getFileEditorManager();
|
||||
VirtualFile file = editorManager.getCurrentFile();
|
||||
return file == null ? null : editorManager.getSelectedEditorWithProvider(file);
|
||||
}
|
||||
@@ -586,7 +582,7 @@ public class IdeDocumentHistoryImpl extends IdeDocumentHistory implements Dispos
|
||||
return null;
|
||||
}
|
||||
|
||||
FileEditorManagerEx editorManager = myFileEditorManager;
|
||||
FileEditorManagerEx editorManager = getFileEditorManager();
|
||||
final VirtualFile file = editorManager.getFile(fileEditor);
|
||||
LOG.assertTrue(file != null);
|
||||
FileEditorState state = fileEditor.getState(FileEditorStateLevel.NAVIGATION);
|
||||
|
||||
@@ -39,12 +39,14 @@ import com.intellij.openapi.wm.impl.FrameTitleBuilder;
|
||||
import com.intellij.project.ProjectStoreOwner;
|
||||
import com.intellij.psi.impl.DebugUtil;
|
||||
import com.intellij.serviceContainer.PlatformComponentManagerImpl;
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.TimedReference;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class ProjectImpl extends PlatformComponentManagerImpl implements ProjectEx, ProjectStoreOwner {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.project.impl.ProjectImpl");
|
||||
@@ -240,7 +242,21 @@ public class ProjectImpl extends PlatformComponentManagerImpl implements Project
|
||||
|
||||
public void init(@Nullable ProgressIndicator indicator) {
|
||||
Application application = ApplicationManager.getApplication();
|
||||
|
||||
// before components
|
||||
if (!isDefault()) {
|
||||
Activity activity = StartUpMeasurer.start("preload project services");
|
||||
try {
|
||||
preloadServices(PluginManagerCore.getLoadedPlugins()).get();
|
||||
}
|
||||
catch (InterruptedException | ExecutionException e) {
|
||||
ExceptionUtil.rethrow(e);
|
||||
}
|
||||
activity.end();
|
||||
}
|
||||
|
||||
createComponents(indicator);
|
||||
|
||||
if (indicator != null && !application.isHeadlessEnvironment()) {
|
||||
distributeProgress(indicator);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,11 @@
|
||||
serviceImplementation="com.intellij.facet.impl.FacetTypeRegistryImpl"/>
|
||||
|
||||
<projectService serviceInterface="com.intellij.openapi.roots.impl.DirectoryIndex"
|
||||
serviceImplementation="com.intellij.openapi.roots.impl.DirectoryIndexImpl"/>
|
||||
serviceImplementation="com.intellij.openapi.roots.impl.DirectoryIndexImpl" preload="true"/>
|
||||
<projectService serviceInterface="com.intellij.psi.PsiManager"
|
||||
serviceImplementation="com.intellij.psi.impl.PsiManagerImpl" preload="true"/>
|
||||
<projectService serviceInterface="com.intellij.psi.PsiDocumentManager"
|
||||
serviceImplementation="com.intellij.psi.impl.PsiDocumentManagerImpl" preload="true"/>
|
||||
|
||||
<projectService serviceInterface="com.intellij.util.indexing.FileBasedIndexScanRunnableCollector"
|
||||
serviceImplementation="com.intellij.util.indexing.FileBasedIndexScanRunnableCollectorImpl"/>
|
||||
|
||||
@@ -10,14 +10,8 @@
|
||||
<implementation-class>com.intellij.openapi.keymap.impl.ModifierKeyDoubleClickHandler</implementation-class>
|
||||
</component>
|
||||
</application-components>
|
||||
|
||||
<project-components>
|
||||
<component>
|
||||
<implementation-class>com.intellij.openapi.editor.impl.DocumentMarkupModelManager</implementation-class>
|
||||
</component>
|
||||
<component>
|
||||
<interface-class>com.intellij.openapi.fileEditor.ex.IdeDocumentHistory</interface-class>
|
||||
<implementation-class>com.intellij.openapi.fileEditor.impl.IdeDocumentHistoryImpl</implementation-class>
|
||||
</component>
|
||||
</project-components>
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<projectService serviceInterface="com.intellij.openapi.fileEditor.ex.IdeDocumentHistory"
|
||||
serviceImplementation="com.intellij.openapi.fileEditor.impl.IdeDocumentHistoryImpl" preload="true"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -6,19 +6,9 @@
|
||||
<loadForDefaultProject/>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<interface-class>com.intellij.psi.PsiManager</interface-class>
|
||||
<implementation-class>com.intellij.psi.impl.PsiManagerImpl</implementation-class>
|
||||
<loadForDefaultProject/>
|
||||
</component>
|
||||
<component>
|
||||
<implementation-class>com.intellij.psi.impl.file.impl.PsiVFSListener</implementation-class>
|
||||
</component>
|
||||
<component>
|
||||
<interface-class>com.intellij.psi.PsiDocumentManager</interface-class>
|
||||
<implementation-class>com.intellij.psi.impl.PsiDocumentManagerImpl</implementation-class>
|
||||
<loadForDefaultProject/>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<interface-class>com.intellij.openapi.module.ModuleManager</interface-class>
|
||||
|
||||
+4
-5
@@ -1,9 +1,8 @@
|
||||
// Copyright 2000-2019 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.openapi.fileEditor;
|
||||
|
||||
import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory;
|
||||
import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl;
|
||||
import com.intellij.openapi.fileEditor.impl.IdeDocumentHistoryImpl;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
@@ -24,9 +23,9 @@ public abstract class HeavyFileEditorManagerTestCase extends CodeInsightFixtureT
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
FileEditorManagerImpl manager = new FileEditorManagerImpl(getProject());
|
||||
((IdeDocumentHistoryImpl)IdeDocumentHistory.getInstance(getProject())).setFileEditorManager(manager);
|
||||
ServiceContainerUtil.registerComponentInstance(getProject(), FileEditorManager.class, manager, getTestRootDisposable());
|
||||
Project project = getProject();
|
||||
FileEditorManagerImpl manager = new FileEditorManagerImpl(project);
|
||||
ServiceContainerUtil.registerComponentInstance(project, FileEditorManager.class, manager, getTestRootDisposable());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ public class NewDocumentHistoryTest extends HeavyFileEditorManagerTestCase {
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myHistory = new IdeDocumentHistoryImpl(getProject(), FileEditorManagerEx.getInstanceEx(getProject()));
|
||||
myHistory = new IdeDocumentHistoryImpl(getProject());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+9
-2
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.openapi.fileEditor.impl;
|
||||
|
||||
import com.intellij.mock.Mock;
|
||||
@@ -6,6 +6,7 @@ import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorProvider;
|
||||
import com.intellij.openapi.fileEditor.FileEditorState;
|
||||
import com.intellij.openapi.fileEditor.FileEditorStateLevel;
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorWithProvider;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -42,7 +43,13 @@ public class IdeDocumentHistoryTest extends HeavyPlatformTestCase {
|
||||
}
|
||||
};
|
||||
|
||||
myHistory = new IdeDocumentHistoryImpl(getProject(), new EditorManager()) {
|
||||
EditorManager editorManager = new EditorManager();
|
||||
myHistory = new IdeDocumentHistoryImpl(getProject()) {
|
||||
@Override
|
||||
protected FileEditorManagerEx getFileEditorManager() {
|
||||
return editorManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FileEditorWithProvider getSelectedEditor() {
|
||||
return mySelectedEditor == null ? null : new FileEditorWithProvider(mySelectedEditor, myProvider);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2017 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.
|
||||
// Copyright 2000-2019 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.openapi.module;
|
||||
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
@@ -66,7 +66,10 @@ public class ModuleUtilCore {
|
||||
|
||||
@Nullable
|
||||
public static Module findModuleForFile(@NotNull VirtualFile file, @NotNull Project project) {
|
||||
return ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(file);
|
||||
if (project.isDefault()) {
|
||||
return null;
|
||||
}
|
||||
return ProjectFileIndex.getInstance(project).getModuleForFile(file);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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-2019 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.openapi.roots;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
@@ -43,7 +29,7 @@ public interface ProjectFileIndex extends FileIndex {
|
||||
|
||||
@NotNull
|
||||
static ProjectFileIndex getInstance(@NotNull Project project) {
|
||||
return ServiceManager.getService(project, ProjectFileIndex.class);
|
||||
return project.getService(ProjectFileIndex.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,14 +12,11 @@ import com.intellij.openapi.module.impl.ModuleScopeProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleFileIndex;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.impl.DirectoryIndex;
|
||||
import com.intellij.openapi.roots.impl.ModuleFileIndexImpl;
|
||||
import com.intellij.openapi.roots.impl.ModuleRootManagerImpl;
|
||||
import com.intellij.openapi.roots.impl.ProjectRootManagerImpl;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.PathUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -43,9 +40,7 @@ public class CoreModule extends MockComponentManager implements ModuleEx {
|
||||
initModuleExtensions();
|
||||
|
||||
final ModuleRootManagerImpl moduleRootManager =
|
||||
new ModuleRootManagerImpl(this,
|
||||
ProjectRootManagerImpl.getInstanceImpl(project),
|
||||
VirtualFilePointerManager.getInstance()) {
|
||||
new ModuleRootManagerImpl(this) {
|
||||
@Override
|
||||
public void loadState(@NotNull ModuleRootManagerState object) {
|
||||
loadState(object, false);
|
||||
@@ -54,7 +49,7 @@ public class CoreModule extends MockComponentManager implements ModuleEx {
|
||||
Disposer.register(parentDisposable, moduleRootManager);
|
||||
getPicoContainer().registerComponentInstance(ModuleRootManager.class, moduleRootManager);
|
||||
getPicoContainer().registerComponentInstance(PathMacroManager.class, createModulePathMacroManager(project));
|
||||
getPicoContainer().registerComponentInstance(ModuleFileIndex.class, createModuleFileIndex(project));
|
||||
getPicoContainer().registerComponentInstance(ModuleFileIndex.class, createModuleFileIndex());
|
||||
myModuleScopeProvider = createModuleScopeProvider();
|
||||
}
|
||||
|
||||
@@ -75,8 +70,8 @@ public class CoreModule extends MockComponentManager implements ModuleEx {
|
||||
return new ModulePathMacroManager(this);
|
||||
}
|
||||
|
||||
protected ModuleFileIndex createModuleFileIndex(@NotNull Project project) {
|
||||
return new ModuleFileIndexImpl(this, DirectoryIndex.getInstance(project));
|
||||
protected ModuleFileIndex createModuleFileIndex() {
|
||||
return new ModuleFileIndexImpl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
package com.intellij.openapi.roots.impl;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
@@ -23,8 +22,9 @@ import java.util.Set;
|
||||
@ApiStatus.Internal
|
||||
public abstract class DirectoryIndex {
|
||||
public static DirectoryIndex getInstance(Project project) {
|
||||
assert !project.isDefault() : "Must not call DirectoryIndex for default project";
|
||||
return ServiceManager.getService(project, DirectoryIndex.class);
|
||||
// todo enable later when all usages will be fixed
|
||||
//assert !project.isDefault() : "Must not call DirectoryIndex for default project";
|
||||
return project.getService(DirectoryIndex.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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-2019 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.openapi.roots.impl;
|
||||
|
||||
import com.intellij.injected.editor.VirtualFileWindow;
|
||||
@@ -39,9 +25,9 @@ abstract class FileIndexBase implements FileIndex {
|
||||
private final FileTypeRegistry myFileTypeRegistry;
|
||||
final DirectoryIndex myDirectoryIndex;
|
||||
|
||||
FileIndexBase(@NotNull DirectoryIndex directoryIndex, @NotNull FileTypeRegistry fileTypeManager) {
|
||||
FileIndexBase(@NotNull DirectoryIndex directoryIndex) {
|
||||
myDirectoryIndex = directoryIndex;
|
||||
myFileTypeRegistry = fileTypeManager;
|
||||
myFileTypeRegistry = FileTypeRegistry.getInstance();
|
||||
}
|
||||
|
||||
protected abstract boolean isScopeDisposed();
|
||||
|
||||
+4
-5
@@ -1,9 +1,7 @@
|
||||
// Copyright 2000-2019 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.openapi.roots.impl;
|
||||
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.fileTypes.FileTypeRegistry;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -15,12 +13,13 @@ import org.jetbrains.jps.model.module.JpsModuleSourceRootType;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ModuleFileIndexImpl extends FileIndexBase implements ModuleFileIndex {
|
||||
public final class ModuleFileIndexImpl extends FileIndexBase implements ModuleFileIndex {
|
||||
@NotNull
|
||||
private final Module myModule;
|
||||
|
||||
public ModuleFileIndexImpl(@NotNull Module module, @NotNull DirectoryIndex directoryIndex) {
|
||||
super(directoryIndex, FileTypeRegistry.getInstance());
|
||||
public ModuleFileIndexImpl(@NotNull Module module) {
|
||||
super(DirectoryIndex.getInstance(module.getProject()));
|
||||
|
||||
myModule = module;
|
||||
}
|
||||
|
||||
|
||||
+5
-9
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
// Copyright 2000-2019 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.openapi.roots.impl;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -48,14 +46,12 @@ public class ModuleRootManagerImpl extends ModuleRootManagerEx implements Dispos
|
||||
|
||||
protected final SimpleModificationTracker myModificationTracker = new SimpleModificationTracker();
|
||||
|
||||
public ModuleRootManagerImpl(@NotNull Module module,
|
||||
@NotNull ProjectRootManagerImpl projectRootManager,
|
||||
@NotNull VirtualFilePointerManager filePointerManager) {
|
||||
public ModuleRootManagerImpl(@NotNull Module module) {
|
||||
myModule = module;
|
||||
myProjectRootManager = projectRootManager;
|
||||
myFilePointerManager = filePointerManager;
|
||||
myProjectRootManager = ProjectRootManagerImpl.getInstanceImpl(module.getProject());
|
||||
myFilePointerManager = VirtualFilePointerManager.getInstance();
|
||||
|
||||
myRootModel = new RootModelImpl(this, projectRootManager, filePointerManager);
|
||||
myRootModel = new RootModelImpl(this, myProjectRootManager, myFilePointerManager);
|
||||
myOrderRootsCache = new OrderRootsCache(module);
|
||||
}
|
||||
|
||||
|
||||
+4
-5
@@ -10,7 +10,6 @@ import com.intellij.openapi.roots.FileIndexFacade;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -21,14 +20,14 @@ import java.util.Collection;
|
||||
* @author yole
|
||||
*/
|
||||
public final class ProjectFileIndexFacade extends FileIndexFacade {
|
||||
// PsiManagerImpl is created for default project, but DirectoryIndex must be not created for default project.
|
||||
private final NotNullLazyValue<DirectoryIndex> myDirectoryIndex = NotNullLazyValue.createValue(() -> DirectoryIndex.getInstance(myProject));
|
||||
private final DirectoryIndex myDirectoryIndex;
|
||||
private final ProjectFileIndex myFileIndex;
|
||||
|
||||
ProjectFileIndexFacade(@NotNull Project project) {
|
||||
super(project);
|
||||
|
||||
myFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
myDirectoryIndex = DirectoryIndex.getInstance(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,7 +79,7 @@ public final class ProjectFileIndexFacade extends FileIndexFacade {
|
||||
while (true) {
|
||||
if (childDir == null) return false;
|
||||
if (childDir.equals(baseDir)) return true;
|
||||
if (!myDirectoryIndex.getValue().getInfoForFile(childDir).isInProject(childDir)) return false;
|
||||
if (!myDirectoryIndex.getInfoForFile(childDir).isInProject(childDir)) return false;
|
||||
childDir = childDir.getParent();
|
||||
}
|
||||
}
|
||||
@@ -101,7 +100,7 @@ public final class ProjectFileIndexFacade extends FileIndexFacade {
|
||||
public boolean isInProjectScope(@NotNull VirtualFile file) {
|
||||
// optimization: equivalent to the super method but has fewer getInfoForFile() calls
|
||||
if (file instanceof VirtualFileWindow) return true;
|
||||
DirectoryInfo info = myDirectoryIndex.getValue().getInfoForFile(file);
|
||||
DirectoryInfo info = myDirectoryIndex.getInfoForFile(file);
|
||||
if (!info.isInProject(file)) return false;
|
||||
if (info.hasLibraryClassRoot() && !info.isInModuleSource(file)) return false;
|
||||
return info.getModule() != null;
|
||||
|
||||
+16
-6
@@ -1,5 +1,4 @@
|
||||
// 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.
|
||||
|
||||
// Copyright 2000-2019 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.openapi.roots.impl;
|
||||
|
||||
import com.intellij.injected.editor.VirtualFileWindow;
|
||||
@@ -23,11 +22,22 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIndex {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.impl.ProjectFileIndexImpl");
|
||||
private static final Logger LOG = Logger.getInstance(ProjectFileIndexImpl.class);
|
||||
private final Project myProject;
|
||||
|
||||
public ProjectFileIndexImpl(@NotNull Project project, @NotNull DirectoryIndex directoryIndex, @NotNull FileTypeRegistry fileTypeManager) {
|
||||
super(directoryIndex, fileTypeManager);
|
||||
public ProjectFileIndexImpl(@NotNull Project project) {
|
||||
super(DirectoryIndex.getInstance(project));
|
||||
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Do not pass DirectoryIndex explicitly.
|
||||
*/
|
||||
@Deprecated
|
||||
public ProjectFileIndexImpl(@NotNull Project project, @NotNull DirectoryIndex index, @NotNull FileTypeRegistry fileTypeManager) {
|
||||
super(index);
|
||||
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@@ -218,7 +228,7 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn
|
||||
public SourceFolder getSourceFolder(@NotNull VirtualFile fileOrDir) {
|
||||
return myDirectoryIndex.getSourceRootFolder(getInfoForFileOrDirectory(fileOrDir));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean isScopeDisposed() {
|
||||
return myProject.isDisposed();
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Pers
|
||||
@Override
|
||||
@NotNull
|
||||
public ProjectFileIndex getFileIndex() {
|
||||
return ProjectFileIndex.SERVICE.getInstance(myProject);
|
||||
return ProjectFileIndex.getInstance(myProject);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-5
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.openapi.roots.impl;
|
||||
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
@@ -20,13 +20,11 @@ import org.jetbrains.annotations.Nullable;
|
||||
@State(name = "TestModuleProperties")
|
||||
class TestModulePropertiesImpl extends TestModuleProperties implements PersistentStateComponent<TestModulePropertiesImpl.TestModulePropertiesState>,
|
||||
ProjectModelElement {
|
||||
private final ModulePointerManager myModulePointerManager;
|
||||
private ModulePointer myProductionModulePointer;
|
||||
private final Module myModule;
|
||||
|
||||
TestModulePropertiesImpl(@NotNull Module module, @NotNull ModulePointerManager modulePointerManager) {
|
||||
TestModulePropertiesImpl(@NotNull Module module) {
|
||||
myModule = module;
|
||||
myModulePointerManager = modulePointerManager;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -43,7 +41,7 @@ class TestModulePropertiesImpl extends TestModuleProperties implements Persisten
|
||||
|
||||
@Override
|
||||
public void setProductionModuleName(@Nullable String moduleName) {
|
||||
myProductionModulePointer = moduleName != null ? myModulePointerManager.create(moduleName) : null;
|
||||
myProductionModulePointer = moduleName != null ? ModulePointerManager.getInstance(myModule.getProject()).create(moduleName) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+23
-2
@@ -8,8 +8,10 @@ import org.picocontainer.PicoInitializationException
|
||||
import org.picocontainer.PicoIntrospectionException
|
||||
import org.picocontainer.defaults.AmbiguousComponentResolutionException
|
||||
import org.picocontainer.defaults.TooManySatisfiableConstructorsException
|
||||
import java.io.File
|
||||
import java.lang.reflect.Constructor
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
import java.nio.file.Path
|
||||
|
||||
internal fun <T> instantiateUsingPicoContainer(aClass: Class<*>, requestorKey: Any, componentManager: PlatformComponentManagerImpl, parameterResolver: ConstructorParameterResolver): T {
|
||||
val result = getGreediestSatisfiableConstructor(aClass, requestorKey, componentManager, parameterResolver)
|
||||
@@ -45,7 +47,9 @@ private fun getGreediestSatisfiableConstructor(aClass: Class<*>, requestorKey: A
|
||||
val parameterTypes = constructor.parameterTypes
|
||||
|
||||
for (expectedType in parameterTypes) {
|
||||
if (expectedType.isPrimitive || expectedType.isEnum || expectedType.isArray || Collection::class.java.isAssignableFrom(expectedType)) {
|
||||
if (expectedType.isPrimitive || expectedType.isEnum || expectedType.isArray ||
|
||||
Collection::class.java.isAssignableFrom(expectedType) ||
|
||||
expectedType === File::class.java || expectedType === Path::class.java) {
|
||||
continue@loop
|
||||
}
|
||||
|
||||
@@ -98,7 +102,7 @@ private fun getGreediestSatisfiableConstructor(aClass: Class<*>, requestorKey: A
|
||||
return Pair(greediestConstructor, greediestConstructorParameterTypes!!)
|
||||
}
|
||||
!unsatisfiableDependencyTypes.isNullOrEmpty() -> {
|
||||
throw PicoIntrospectionException("$requestorKey has unsatisfied dependency: $unsatisfiedDependencyType among unsatisfiable dependencies: " +
|
||||
throw PicoIntrospectionException("${aClass.name} has unsatisfied dependency: $unsatisfiedDependencyType among unsatisfiable dependencies: " +
|
||||
"$unsatisfiableDependencyTypes where $componentManager was the leaf container being asked for dependencies.")
|
||||
}
|
||||
else -> {
|
||||
@@ -156,6 +160,23 @@ internal abstract class ConstructorParameterResolver {
|
||||
return byKey
|
||||
}
|
||||
|
||||
// see UndoManagerImpl / RunManager / JavaModuleExternalPathsImpl for example
|
||||
val expectedClassName = expectedType.name
|
||||
|
||||
if (container.parent == null) {
|
||||
if (expectedClassName == "com.intellij.openapi.project.Project") {
|
||||
return null
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (expectedClassName == "com.intellij.configurationStore.StreamProvider" ||
|
||||
expectedClassName == "com.intellij.openapi.roots.LanguageLevelModuleExtensionImpl" ||
|
||||
expectedClassName == "com.intellij.openapi.roots.impl.CompilerModuleExtensionImpl" ||
|
||||
expectedClassName == "com.intellij.openapi.roots.impl.JavaModuleExternalPathsImpl") {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
val found = container.getComponentAdaptersOfType(expectedType)
|
||||
found.removeIf { it.componentKey == excludeKey }
|
||||
return when {
|
||||
|
||||
+65
-54
@@ -21,17 +21,20 @@ import com.intellij.openapi.progress.ProgressManager
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.util.IncorrectOperationException
|
||||
import com.intellij.util.SmartList
|
||||
import com.intellij.util.concurrency.AppExecutorUtil
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import com.intellij.util.io.storage.HeavyProcessLatch
|
||||
import com.intellij.util.messages.*
|
||||
import com.intellij.util.messages.impl.MessageBusImpl
|
||||
import com.intellij.util.pico.DefaultPicoContainer
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import java.lang.reflect.Constructor
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
import java.lang.reflect.Modifier
|
||||
import java.util.*
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import java.util.concurrent.ConcurrentMap
|
||||
|
||||
abstract class PlatformComponentManagerImpl @JvmOverloads constructor(internal val parent: ComponentManager?, setExtensionsRootArea: Boolean = parent == null) : ComponentManagerImpl(parent), LazyListenerCreator {
|
||||
@@ -104,6 +107,14 @@ abstract class PlatformComponentManagerImpl @JvmOverloads constructor(internal v
|
||||
plugins as List<IdeaPluginDescriptorImpl>
|
||||
val activityNamePrefix = activityNamePrefix()
|
||||
val parallelActivity = if (activityNamePrefix == null) null else ParallelActivity.PREPARE_APP_INIT
|
||||
|
||||
val app = getApplication()
|
||||
val headless = app == null || app.isHeadlessEnvironment
|
||||
var componentConfigCount = 0
|
||||
var map: ConcurrentMap<String, MutableList<ListenerDescriptor>>? = null
|
||||
val isHeadlessMode = app?.isHeadlessEnvironment == true
|
||||
val isUnitTestMode = app?.isUnitTestMode == true
|
||||
|
||||
parallelActivity.run("${activityNamePrefix}service and ep registration") {
|
||||
// register services before registering extensions because plugins can access services in their
|
||||
// extensions which can be invoked right away if the plugin is loaded dynamically
|
||||
@@ -111,6 +122,35 @@ abstract class PlatformComponentManagerImpl @JvmOverloads constructor(internal v
|
||||
val containerDescriptor = getContainerDescriptor(plugin)
|
||||
registerServices(containerDescriptor.services, plugin)
|
||||
|
||||
for (descriptor in containerDescriptor.components) {
|
||||
if (!descriptor.prepareClasses(headless) || !isComponentSuitable(descriptor)) {
|
||||
continue
|
||||
}
|
||||
|
||||
try {
|
||||
registerComponent(descriptor, plugin)
|
||||
componentConfigCount++
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
handleInitComponentError(e, null, plugin.pluginId)
|
||||
}
|
||||
}
|
||||
|
||||
val listeners = getContainerDescriptor(plugin).listeners
|
||||
if (listeners.isNotEmpty()) {
|
||||
if (map == null) {
|
||||
map = ContainerUtil.newConcurrentMap()
|
||||
}
|
||||
|
||||
for (listener in listeners) {
|
||||
if ((isUnitTestMode && !listener.activeInTestMode) || (isHeadlessMode && !listener.activeInHeadlessMode)) {
|
||||
continue
|
||||
}
|
||||
|
||||
map!!.getOrPut(listener.topicClassName) { SmartList() }.add(listener)
|
||||
}
|
||||
}
|
||||
|
||||
containerDescriptor.extensionPoints?.let {
|
||||
extensionArea.registerExtensionPoints(plugin, it, this)
|
||||
}
|
||||
@@ -124,47 +164,6 @@ abstract class PlatformComponentManagerImpl @JvmOverloads constructor(internal v
|
||||
}
|
||||
}
|
||||
|
||||
val app = getApplication()
|
||||
val headless = app == null || app.isHeadlessEnvironment
|
||||
|
||||
var map: ConcurrentMap<String, MutableList<ListenerDescriptor>>? = null
|
||||
val isHeadlessMode = app?.isHeadlessEnvironment == true
|
||||
val isUnitTestMode = app?.isUnitTestMode == true
|
||||
|
||||
var componentConfigCount = 0
|
||||
for (plugin in plugins) {
|
||||
val containerDescriptor = getContainerDescriptor(plugin)
|
||||
|
||||
for (config in containerDescriptor.components) {
|
||||
if (!config.prepareClasses(headless) || !isComponentSuitable(config)) {
|
||||
continue
|
||||
}
|
||||
|
||||
try {
|
||||
registerComponent(config, plugin)
|
||||
componentConfigCount++
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
handleInitComponentError(e, null, plugin.pluginId)
|
||||
}
|
||||
}
|
||||
|
||||
val listeners = containerDescriptor.listeners
|
||||
if (listeners.isNotEmpty()) {
|
||||
if (map == null) {
|
||||
map = ContainerUtil.newConcurrentMap()
|
||||
}
|
||||
|
||||
for (listener in listeners) {
|
||||
if ((isUnitTestMode && !listener.activeInTestMode) || (isHeadlessMode && !listener.activeInHeadlessMode)) {
|
||||
continue
|
||||
}
|
||||
|
||||
map.getOrPut(listener.topicClassName) { SmartList() }.add(listener)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (myComponentConfigCount <= 0) {
|
||||
myComponentConfigCount = componentConfigCount
|
||||
}
|
||||
@@ -178,7 +177,7 @@ abstract class PlatformComponentManagerImpl @JvmOverloads constructor(internal v
|
||||
// ensure that messageBus is created, regardless of lazy listeners map state
|
||||
val messageBus = messageBus as MessageBusImpl
|
||||
if (map != null) {
|
||||
messageBus.setLazyListeners(map)
|
||||
messageBus.setLazyListeners(map!!)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +216,7 @@ abstract class PlatformComponentManagerImpl @JvmOverloads constructor(internal v
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
fun <T : Any> registerComponentInstance(componentKey: Class<T>, componentImplementation: T, parentDisposable: Disposable?): T? {
|
||||
fun <T : Any> replaceComponentInstance(componentKey: Class<T>, componentImplementation: T, parentDisposable: Disposable?): T? {
|
||||
val adapter = myPicoContainer.getComponentAdapter(componentKey) as MyComponentAdapter
|
||||
return adapter.replaceInstance(componentImplementation, parentDisposable)
|
||||
}
|
||||
@@ -529,7 +528,7 @@ abstract class PlatformComponentManagerImpl @JvmOverloads constructor(internal v
|
||||
final override fun <T : Any> instantiateClassWithConstructorInjection(aClass: Class<T>, key: Any, pluginId: PluginId?): T {
|
||||
// constructorParameterResolver is very expensive, because pico container behaviour is to find greediest satisfiable constructor,
|
||||
// so, if class has constructors (Project) and (Project, Foo, Bar), then Foo and Bar unrelated classes will be searched for.
|
||||
// To avoid this expensive nearly linear search of extension, first resolve without our logic, and in case of error try expensive.
|
||||
// To avoid this expensive nearly linear search of extension, first resolve without our logic to resolve extensions, and in case of error try expensive.
|
||||
try {
|
||||
return instantiateUsingPicoContainer(aClass, key, this, constructorParameterResolver)
|
||||
}
|
||||
@@ -539,11 +538,8 @@ abstract class PlatformComponentManagerImpl @JvmOverloads constructor(internal v
|
||||
catch (e: ExtensionNotApplicableException) {
|
||||
throw e
|
||||
}
|
||||
catch (e: IncorrectOperationException) {
|
||||
throw e
|
||||
}
|
||||
catch (e: Exception) {
|
||||
if (lightServices == null) {
|
||||
if (lightServices == null || e is IncorrectOperationException) {
|
||||
throw e
|
||||
}
|
||||
else {
|
||||
@@ -557,7 +553,7 @@ abstract class PlatformComponentManagerImpl @JvmOverloads constructor(internal v
|
||||
val app = getApplication()
|
||||
@Suppress("SpellCheckingInspection")
|
||||
if (app != null && app.isUnitTestMode && pluginId?.idString != "org.jetbrains.kotlin" && pluginId?.idString != "Lombook Plugin") {
|
||||
throw UnsupportedOperationException("In tests deprecated constructor injection for extension is disabled", e)
|
||||
throw UnsupportedOperationException("In tests, extension classes are not resolved for constructor injection, to enforce removing such deprecated references.", e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -648,13 +644,28 @@ abstract class PlatformComponentManagerImpl @JvmOverloads constructor(internal v
|
||||
return unloadedInstances
|
||||
}
|
||||
|
||||
@Internal
|
||||
fun precreateService(serviceClass: String) {
|
||||
(myPicoContainer.getServiceAdapter(serviceClass) as ServiceComponentAdapter?)?.getInstance<Any>(this)
|
||||
}
|
||||
|
||||
@Internal
|
||||
open fun activityNamePrefix(): String? = null
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun preloadServices(plugins: List<IdeaPluginDescriptor>): CompletableFuture<*> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
plugins as List<IdeaPluginDescriptorImpl>
|
||||
|
||||
val futures = mutableListOf<CompletableFuture<Void>>()
|
||||
val executor = AppExecutorUtil.createBoundedApplicationPoolExecutor("preload services", Runtime.getRuntime().availableProcessors(), false)
|
||||
for (plugin in plugins) {
|
||||
for (service in getContainerDescriptor(plugin).services) {
|
||||
if (service.preload) {
|
||||
futures.add(CompletableFuture.runAsync(Runnable {
|
||||
(myPicoContainer.getServiceAdapter(service.getInterface()) as ServiceComponentAdapter?)?.getInstance<Any>(this)
|
||||
}, executor))
|
||||
}
|
||||
}
|
||||
}
|
||||
executor.shutdown()
|
||||
return CompletableFuture.allOf(*futures.toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
private fun createPluginExceptionIfNeeded(error: Throwable, pluginId: PluginId): RuntimeException {
|
||||
|
||||
+1
-2
@@ -9,7 +9,6 @@ import com.intellij.openapi.components.ServiceDescriptor
|
||||
import com.intellij.openapi.components.impl.stores.IComponentStore
|
||||
import com.intellij.openapi.extensions.DefaultPluginDescriptor
|
||||
import com.intellij.openapi.extensions.PluginId
|
||||
import com.intellij.openapi.extensions.impl.ExtensionsAreaImpl
|
||||
import com.intellij.util.messages.MessageBus
|
||||
import org.junit.Test
|
||||
|
||||
@@ -19,7 +18,7 @@ class ConstructorInjectionTest {
|
||||
@Test
|
||||
fun `interface extension`() {
|
||||
val componentManager = TestComponentManager()
|
||||
val area = componentManager.extensionArea as ExtensionsAreaImpl
|
||||
val area = componentManager.extensionArea
|
||||
val point = area.registerPoint("bar", Bar::class.java, pluginDescriptor)
|
||||
@Suppress("DEPRECATION")
|
||||
point.registerExtension(BarImpl())
|
||||
|
||||
@@ -100,7 +100,7 @@ public final class IdeaTestApplication implements Disposable {
|
||||
app.registerComponents(it);
|
||||
return it;
|
||||
}), app)
|
||||
.thenCompose(it -> ApplicationLoader.preloadServices(app, it))
|
||||
.thenCompose(it -> app.preloadServices(it))
|
||||
.get(20, TimeUnit.SECONDS);
|
||||
}
|
||||
catch (TimeoutException e) {
|
||||
|
||||
@@ -108,11 +108,11 @@ public abstract class ParsingTestCase extends UsefulTestCase {
|
||||
app.registerService(FileDocumentManager.class, new MockFileDocumentManagerImpl(charSequence -> {
|
||||
return editorFactory.createDocument(charSequence);
|
||||
}, FileDocumentManagerImpl.HARD_REF_TO_DOCUMENT_KEY));
|
||||
appContainer.registerComponentInstance(PsiDocumentManager.class, new MockPsiDocumentManager());
|
||||
|
||||
app.registerService(PsiBuilderFactory.class, new PsiBuilderFactoryImpl());
|
||||
app.registerService(DefaultASTFactory.class, new DefaultASTFactoryImpl());
|
||||
app.registerService(ReferenceProvidersRegistry.class, new ReferenceProvidersRegistryImpl());
|
||||
myProject.registerService(PsiDocumentManager.class, new MockPsiDocumentManager());
|
||||
myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
|
||||
myProject.registerService(PsiManager.class, myPsiManager);
|
||||
myProject.registerService(StartupManager.class, new StartupManagerImpl(myProject));
|
||||
|
||||
@@ -24,14 +24,14 @@ fun <T : Any> ComponentManager.replaceService(serviceInterface: Class<T>, instan
|
||||
*/
|
||||
@TestOnly
|
||||
fun <T : Any> ComponentManager.registerComponentInstance(componentInterface: Class<T>, instance: T, parentDisposable: Disposable?): T? {
|
||||
return (this as PlatformComponentManagerImpl).registerComponentInstance(componentInterface, instance, parentDisposable)
|
||||
return (this as PlatformComponentManagerImpl).replaceComponentInstance(componentInterface, instance, parentDisposable)
|
||||
}
|
||||
|
||||
@Suppress("DeprecatedCallableAddReplaceWith")
|
||||
@TestOnly
|
||||
@Deprecated("Pass parentDisposable")
|
||||
fun <T : Any> ComponentManager.registerComponentInstance(componentInterface: Class<T>, instance: T): T? {
|
||||
return (this as PlatformComponentManagerImpl).registerComponentInstance(componentInterface, instance, null)
|
||||
return (this as PlatformComponentManagerImpl).replaceComponentInstance(componentInterface, instance, null)
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
|
||||
+2
-16
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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-2019 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.openapi.vcs.configurable;
|
||||
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
@@ -36,6 +22,6 @@ public final class VcsManagerConfigurableProvider extends ConfigurableProvider {
|
||||
|
||||
@Override
|
||||
public boolean canCreateConfigurable() {
|
||||
return ProjectLevelVcsManager.getInstance(myProject).getAllVcss().length > 0;
|
||||
return !myProject.isDefault() && ProjectLevelVcsManager.getInstance(myProject).getAllVcss().length > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.intellij.openapi.editor.ex.EditorEx
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.impl.DirectoryIndex
|
||||
import com.intellij.openapi.startup.StartupManager
|
||||
import com.intellij.openapi.util.io.FileUtilRt
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
@@ -58,7 +57,7 @@ import java.nio.charset.Charset
|
||||
import java.util.*
|
||||
import java.util.concurrent.Future
|
||||
|
||||
class LineStatusTrackerManager(private val project: Project, @Suppress("UNUSED_PARAMETER") makeSureIndexIsInitializedFirst: DirectoryIndex) : LineStatusTrackerManagerI, Disposable {
|
||||
class LineStatusTrackerManager(private val project: Project) : LineStatusTrackerManagerI, Disposable {
|
||||
private val LOCK = Any()
|
||||
private var isDisposed = false
|
||||
|
||||
|
||||
+8
-9
@@ -1,8 +1,11 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.openapi.vcs.impl
|
||||
|
||||
import com.intellij.diff.util.Range
|
||||
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.project.Project
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager
|
||||
@@ -17,10 +20,7 @@ private typealias TrackerState = ChangelistsLocalLineStatusTracker.State
|
||||
private typealias FullTrackerState = ChangelistsLocalLineStatusTracker.FullState
|
||||
|
||||
@State(name = "LineStatusTrackerManager", storages = [(Storage(value = StoragePathMacros.WORKSPACE_FILE))])
|
||||
class PartialLineStatusTrackerManagerState(
|
||||
private val project: Project,
|
||||
private val lineStatusTracker: LineStatusTrackerManager
|
||||
) : ProjectComponent, PersistentStateComponent<Element> {
|
||||
class PartialLineStatusTrackerManagerState(private val project: Project) : PersistentStateComponent<Element> {
|
||||
private val NODE_PARTIAL_FILE = "file"
|
||||
private val ATT_PATH = "path"
|
||||
|
||||
@@ -36,10 +36,9 @@ class PartialLineStatusTrackerManagerState(
|
||||
private val ATT_END_2 = "end2"
|
||||
private val ATT_CHANGELIST_ID = "changelist"
|
||||
|
||||
|
||||
override fun getState(): Element {
|
||||
val element = Element("state")
|
||||
val fileStates = lineStatusTracker.collectPartiallyChangedFilesStates()
|
||||
val fileStates = (LineStatusTrackerManager.getInstance(project) as LineStatusTrackerManager).collectPartiallyChangedFilesStates()
|
||||
for (state in fileStates) {
|
||||
element.addContent(writePartialFileState(state))
|
||||
}
|
||||
@@ -57,7 +56,7 @@ class PartialLineStatusTrackerManagerState(
|
||||
if (fileStates.isNotEmpty()) {
|
||||
ChangeListManager.getInstance(project).invokeAfterUpdate(
|
||||
{
|
||||
lineStatusTracker.restoreTrackersForPartiallyChangedFiles(fileStates)
|
||||
(LineStatusTrackerManager.getInstance(project) as LineStatusTrackerManager).restoreTrackersForPartiallyChangedFiles(fileStates)
|
||||
}, InvokeAfterUpdateMode.SILENT, null, null)
|
||||
}
|
||||
}
|
||||
|
||||
+4
-18
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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-2019 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.jetbrains.plugins.groovy.compiler;
|
||||
|
||||
@@ -83,13 +69,13 @@ public class GroovyCompilerConfigurable implements SearchableConfigurable, Confi
|
||||
return myExcludes;
|
||||
}
|
||||
|
||||
private ExcludedEntriesConfigurable createExcludedConfigurable(final Project project) {
|
||||
private ExcludedEntriesConfigurable createExcludedConfigurable(@NotNull Project project) {
|
||||
final ExcludesConfiguration configuration = myConfig.getExcludeFromStubGeneration();
|
||||
final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
ProjectFileIndex index = project.isDefault() ? null : ProjectRootManager.getInstance(project).getFileIndex();
|
||||
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true) {
|
||||
@Override
|
||||
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
|
||||
return super.isFileVisible(file, showHiddenFiles) && !index.isExcluded(file);
|
||||
return super.isFileVisible(file, showHiddenFiles) && (index == null || !index.isExcluded(file));
|
||||
}
|
||||
};
|
||||
descriptor.setRoots(ContainerUtil.concat(ContainerUtil.<Module, List<VirtualFile>>map(ModuleManager.getInstance(project).getModules(),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.uiDesigner;
|
||||
|
||||
@@ -15,7 +15,6 @@ import com.intellij.uiDesigner.lw.StringDescriptor;
|
||||
import com.intellij.uiDesigner.radComponents.RadComponent;
|
||||
import com.intellij.uiDesigner.radComponents.RadRootContainer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -29,9 +28,9 @@ public class StringDescriptorManager {
|
||||
private Module myModule;
|
||||
private final Map<Pair<Locale, String>, PropertiesFile> myPropertiesFileCache = ContainerUtil.createSoftValueMap();
|
||||
|
||||
public StringDescriptorManager(final Module module, MessageBus bus) {
|
||||
public StringDescriptorManager(@NotNull Module module) {
|
||||
myModule = module;
|
||||
bus.connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
|
||||
module.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
|
||||
@Override
|
||||
public void rootsChanged(@NotNull final ModuleRootEvent event) {
|
||||
synchronized(myPropertiesFileCache) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.javaee;
|
||||
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
@@ -7,27 +7,26 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
|
||||
public class PsiExternalResourceNotifier {
|
||||
public final class PsiExternalResourceNotifier {
|
||||
private final PsiManagerEx myPsiManager;
|
||||
private final ExternalResourceManagerEx myExternalResourceManager;
|
||||
private final DaemonCodeAnalyzer myDaemonCodeAnalyzer;
|
||||
|
||||
public PsiExternalResourceNotifier(PsiManagerEx psiManager, ExternalResourceManager externalResourceManager,
|
||||
final DaemonCodeAnalyzer daemonCodeAnalyzer, Project project) {
|
||||
myPsiManager = psiManager;
|
||||
myExternalResourceManager = (ExternalResourceManagerEx)externalResourceManager;
|
||||
myDaemonCodeAnalyzer = daemonCodeAnalyzer;
|
||||
public PsiExternalResourceNotifier(Project project) {
|
||||
myPsiManager = PsiManagerEx.getInstanceEx(project);
|
||||
|
||||
ExternalResourceManagerEx externalResourceManager = ExternalResourceManagerEx.getInstanceEx();
|
||||
myDaemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(project);
|
||||
final ExternalResourceListener myExternalResourceListener = new MyExternalResourceListener();
|
||||
myExternalResourceManager.addExternalResourceListener(myExternalResourceListener);
|
||||
externalResourceManager.addExternalResourceListener(myExternalResourceListener);
|
||||
Disposer.register(project, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
myExternalResourceManager.removeExternalResourceListener(myExternalResourceListener);
|
||||
externalResourceManager.removeExternalResourceListener(myExternalResourceListener);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class MyExternalResourceListener implements ExternalResourceListener {
|
||||
private final class MyExternalResourceListener implements ExternalResourceListener {
|
||||
@Override
|
||||
public void externalResourceChanged() {
|
||||
myPsiManager.beforeChange(true);
|
||||
|
||||
Reference in New Issue
Block a user