reverted check

This commit is contained in:
Alexey Kudravtsev
2010-08-30 15:40:57 +04:00
parent a1a69d1c1b
commit 744c8ad7fa
5 changed files with 14 additions and 45 deletions
@@ -83,7 +83,6 @@ import com.intellij.util.containers.CollectionFactory;
import com.intellij.util.indexing.FileBasedIndex;
import com.intellij.util.indexing.IndexableFileSet;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.ui.UIUtil;
import gnu.trove.THashMap;
import junit.framework.TestCase;
import org.jetbrains.annotations.NonNls;
@@ -171,7 +170,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
((PersistentFS)ManagingFS.getInstance()).cleanPersistedContents();
}
private static void initProject(final LightProjectDescriptor descriptor, final UsefulTestCase usefulTestCase) throws Exception {
private static void initProject(final LightProjectDescriptor descriptor) throws Exception {
ourProjectDescriptor = descriptor;
final File projectFile = File.createTempFile("lighttemp", ProjectFileType.DOT_DEFAULT_EXTENSION);
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@@ -189,7 +188,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
new Throwable(projectFile.getPath()).printStackTrace(new PrintStream(buffer));
ourProject = PlatformTestCase.createProject(projectFile, buffer.toString(), usefulTestCase);
ourProject = PlatformTestCase.createProject(projectFile, buffer.toString());
if (!ourHaveShutdownHook) {
ourHaveShutdownHook = true;
@@ -289,8 +288,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
protected void setUp() throws Exception {
super.setUp();
initApplication(this);
doSetup(new SimpleLightProjectDescriptor(getModuleType(), getProjectJDK()), configureLocalInspectionTools(), myAvailableInspectionTools,
this);
doSetup(new SimpleLightProjectDescriptor(getModuleType(), getProjectJDK()), configureLocalInspectionTools(), myAvailableInspectionTools);
((InjectedLanguageManagerImpl)InjectedLanguageManager.getInstance(getProject())).pushInjectors();
storeSettings();
@@ -299,14 +297,12 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
}
public static void doSetup(final LightProjectDescriptor descriptor,
final LocalInspectionTool[] localInspectionTools,
final Map<String, InspectionTool> availableInspectionTools,
UsefulTestCase usefulTestCase) throws Exception {
final LocalInspectionTool[] localInspectionTools, final Map<String, InspectionTool> availableInspectionTools) throws Exception {
assertNull("Previous test " + ourTestCase + " hasn't called tearDown(). Probably overriden without super call.", ourTestCase);
IdeaLogger.ourErrorsOccurred = null;
if (ourProject == null || !ourProjectDescriptor.equals(descriptor)) {
initProject(descriptor, usefulTestCase);
initProject(descriptor);
}
ProjectManagerEx.getInstanceEx().setCurrentTestProject(ourProject);
@@ -466,12 +462,6 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
if (checkForEditors) {
checkEditorsReleased();
}
if (SwingUtilities.isEventDispatchThread()) {
UIUtil.dispatchAllInvocationEvents();
}
else {
UIUtil.pump();
}
}
public static void checkEditorsReleased() {
@@ -56,7 +56,9 @@ import com.intellij.openapi.vfs.newvfs.ManagingFS;
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl;
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager;
import com.intellij.psi.*;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.impl.PsiDocumentManagerImpl;
@@ -66,7 +68,6 @@ import com.intellij.util.indexing.IndexableSetContributor;
import com.intellij.util.indexing.IndexedRootsProvider;
import junit.framework.TestCase;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -179,7 +180,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
File projectFile = getIprFile();
LocalFileSystem.getInstance().refreshIoFiles(myFilesToDelete);
myProject = createProject(projectFile, getClass().getName() + "." + getName(), this);
myProject = createProject(projectFile, getClass().getName() + "." + getName());
setUpModule();
@@ -192,21 +193,13 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
}
@Nullable
public static Project createProject(@NotNull File projectFile, @NotNull String creationPlace, @NotNull final UsefulTestCase usefulTestCase) {
public static Project createProject(File projectFile, String creationPlace) {
try {
Project project = ProjectManagerEx.getInstanceEx().newProject(FileUtil.getNameWithoutExtension(projectFile), projectFile.getPath(), false, false);
Project project =
ProjectManagerEx.getInstanceEx().newProject(FileUtil.getNameWithoutExtension(projectFile), projectFile.getPath(), false, false);
assert project != null;
project.putUserData(CREATION_PLACE, creationPlace);
PsiManager.getInstance(project).addPsiTreeChangeListener(new PsiTreeChangeAdapter() {
@Override
public void childrenChanged(PsiTreeChangeEvent event) {
PsiFile psiFile = event.getFile();
usefulTestCase.checkPsiElementsAreStillValid(psiFile);
}
});
return project;
}
catch (TooManyProjectLeakedException e) {
@@ -28,9 +28,6 @@ import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiRecursiveElementVisitor;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
@@ -605,15 +602,4 @@ public abstract class UsefulTestCase extends TestCase {
}
}
public void checkPsiElementsAreStillValid(PsiFile psiFile) {
if (psiFile == null || !psiFile.isValid() || isPerformanceTest()) return;
psiFile.accept(new PsiRecursiveElementVisitor() {
@Override
public void visitElement(PsiElement element) {
assertTrue(element.toString(), element.isValid());
super.visitElement(element);
}
});
}
}
@@ -133,7 +133,7 @@ class HeavyIdeaTestFixtureImpl extends BaseFixture implements HeavyIdeaTestFixtu
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(projectFile);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
new Throwable(projectFile.getPath()).printStackTrace(new PrintStream(buffer));
myProject = PlatformTestCase.createProject(projectFile, buffer.toString(), this);
myProject = PlatformTestCase.createProject(projectFile, buffer.toString());
for (ModuleFixtureBuilder moduleFixtureBuilder: myModuleFixtureBuilders) {
moduleFixtureBuilder.getFixture().setUp();
@@ -45,7 +45,7 @@ class LightIdeaTestFixtureImpl extends BaseFixture implements LightIdeaTestFixtu
super.setUp();
LightPlatformTestCase.initApplication(new MyDataProvider());
LightPlatformTestCase.doSetup(myProjectDescriptor, new LocalInspectionTool[0], null, this);
LightPlatformTestCase.doSetup(myProjectDescriptor, new LocalInspectionTool[0], null);
storeSettings();
}