provide mock implementation of DumbService

This commit is contained in:
Dmitry Jemerov
2011-10-04 16:05:10 +02:00
parent d7af1c6a91
commit 2d3fba752a
2 changed files with 65 additions and 0 deletions
@@ -30,6 +30,7 @@ import com.intellij.openapi.extensions.ExtensionsArea;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeRegistry;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Getter;
@@ -118,6 +119,7 @@ public class CoreEnvironment {
myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
myProject.registerService(PsiDirectoryFactory.class, new PsiDirectoryFactoryImpl(myPsiManager));
myProject.registerService(ProjectScopeBuilder.class, new CoreProjectScopeBuilder(myProject, myFileIndexFacade));
myProject.registerService(DumbService.class, new MockDumbService(myProject));
}
public Project getProject() {
@@ -0,0 +1,63 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.mock;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* @author yole
*/
public class MockDumbService extends DumbService {
private final Project myProject;
public MockDumbService(Project project) {
myProject = project;
}
@Override
public boolean isDumb() {
return false;
}
@Override
public void runWhenSmart(Runnable runnable) {
runnable.run();
}
@Override
public void waitForSmartMode() {
}
@Override
public JComponent wrapGently(@NotNull JComponent dumbUnawareContent, @NotNull Disposable parentDisposable) {
throw new UnsupportedOperationException();
}
@Override
public void showDumbModeNotification(String message) {
throw new UnsupportedOperationException();
}
@Override
public Project getProject() {
return myProject;
}
}