package com.intellij.structuralsearch;

import com.intellij.testFramework.IdeaTestCase;
import com.intellij.psi.PsiManager;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.structuralsearch.impl.matcher.MatcherImplUtil;
import com.intellij.structuralsearch.impl.matcher.MatcherImpl;

/**
 * Created by IntelliJ IDEA.
 * User: maxim.mossienko
 * Date: Oct 11, 2005
 * Time: 10:05:31 PM
 * To change this template use File | Settings | File Templates.
 */
abstract class StructuralSearchTestCase extends IdeaTestCase {
  protected MatchOptions options;
  protected Matcher testMatcher;

  protected void setUp() throws Exception {
    super.setUp();

    testMatcher = new Matcher(myProject);
    options = new MatchOptions();
    options.setLooseMatching( true );
    options.setRecursiveSearch(true);
    PsiManager.getInstance(myProject).setEffectiveLanguageLevel(LanguageLevel.JDK_1_4);
  }

  protected int findMatchesCount(String in, String pattern, boolean filePattern, FileType fileType) {
    options.clearVariableConstraints();
    options.setSearchPattern(pattern);
    MatcherImplUtil.transform(options);
    pattern = options.getSearchPattern();
    options.setFileType(fileType);

    MatcherImpl.validate(myProject, options);
    return testMatcher.testFindMatches(in,pattern,options,filePattern).size();
  }

  protected int findMatchesCount(String in, String pattern, boolean filePattern) {
    return findMatchesCount(in, pattern,filePattern, StdFileTypes.JAVA);
  }

  protected int findMatchesCount(String in, String pattern) {
    return findMatchesCount(in,pattern,false);
  }
}

@@ -57,214 +57,166 @@
 lij.
-testFramework.IdeaTestCase;%0Aimport com.intellij.psi.PsiManager;%0Aimport com.intellij.pom.java.LanguageLevel;%0Aimport com.intellij.openapi.fileTypes.FileType;%0Aimport com.intellij.openapi.fileTypes.StdFileTypes
+openapi.fileTypes.FileType;%0Aimport com.intellij.openapi.fileTypes.StdFileTypes;%0Aimport com.intellij.pom.java.LanguageLevel;%0Aimport com.intellij.psi.PsiManager
 ;%0Aim
@@ -274,20 +274,16 @@
 cherImpl
-Util
 ;%0Aimport
@@ -341,180 +341,62 @@
 Impl
-;%0A%0A/**%0A * Created by IntelliJ IDEA.%0A * User: maxim.mossienko%0A * Date: Oct 11, 2005%0A * Time: 10:05:31 PM%0A * To change this template use File %7C Settings %7C File Templates.%0A */
+Util;%0Aimport com.intellij.testFramework.IdeaTestCase;%0A
 %0Aabs
@@ -824,32 +824,162 @@
 .JDK_1_4);%0A  %7D%0A%0A
+  @Override%0A  protected void tearDown() throws Exception %7B%0A    testMatcher = null;%0A    options = null;%0A    super.tearDown();%0A  %7D%0A%0A
   protected int 

Test memleak.