From 744c8ad7fab7accbb9c1814eae47371e64b2f198 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 30 Aug 2010 15:33:47 +0400 Subject: [PATCH] reverted check --- .../testFramework/LightPlatformTestCase.java | 20 +++++------------- .../testFramework/PlatformTestCase.java | 21 +++++++------------ .../testFramework/UsefulTestCase.java | 14 ------------- .../impl/HeavyIdeaTestFixtureImpl.java | 2 +- .../impl/LightIdeaTestFixtureImpl.java | 2 +- 5 files changed, 14 insertions(+), 45 deletions(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java index 2d691cbdc4f9..d60978a1d2c0 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java @@ -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 availableInspectionTools, - UsefulTestCase usefulTestCase) throws Exception { + final LocalInspectionTool[] localInspectionTools, final Map 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() { diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java index f2f16d594b55..7143907b1132 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java @@ -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) { diff --git a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java index 2b1c9820e0a7..6cd2908b3dce 100644 --- a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java @@ -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); - } - }); - } } diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java index 4ce57a38e159..7ff1b0d91313 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java @@ -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(); diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/LightIdeaTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/LightIdeaTestFixtureImpl.java index 2bfaf7165acd..995b6cafd1b6 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/LightIdeaTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/LightIdeaTestFixtureImpl.java @@ -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(); }