package net.kenro.ji.jin.purescript.parser;

import com.intellij.lang.ParserDefinition;
import com.intellij.mock.MockVirtualFile;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.testFramework.ParsingTestCase;
import com.intellij.testFramework.TestDataFile;
import org.jetbrains.annotations.NonNls;

import java.io.File;
import java.io.IOException;


public abstract class PSLanguageParserTestBase extends ParsingTestCase {

    public PSLanguageParserTestBase(String dataPath, String fileExt, ParserDefinition... definitions) {
        super(dataPath, fileExt, definitions);
    }

    @Override
    protected String getTestDataPath() {
        return this.getClass().getClassLoader().getResource("gold").getPath();
    }

    @Override
    protected boolean skipSpaces() {
        return true;
    }

    /**
     * Perform a test. Add tests that should work but does not work yet with
     * doTest(false, false).
     */
    protected void doTestOld(boolean checkResult, boolean shouldPass) {
        doTest(true);
        if (shouldPass) {
            assertFalse(
                    "PsiFile contains error elements",
                    toParseTreeText(myFile, skipSpaces(), includeRanges()).contains("PsiErrorElement")
            );
        }
    }


    @Override
    protected void checkResult(@NonNls @TestDataFile String targetDataName,
                               final PsiFile file) throws IOException {
        doCheckResult(myFullDataPath, file, checkAllPsiRoots(),
                "" + File.separator + targetDataName, skipSpaces(),
                includeRanges());
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        VirtualFile m = new MockVirtualFile(true,myFullDataPath);
        myProject.setBaseDir(m);
    }

}

@@ -503,16 +503,25 @@
 estBase(
+%0A        
 String d
@@ -528,16 +528,24 @@
 ataPath,
+%0A       
  String 
@@ -552,16 +552,24 @@
 fileExt,
+%0A       
  ParserD
@@ -592,16 +592,21 @@
 initions
+%0A    
 ) %7B%0A    
@@ -1158,20 +1158,16 @@
         
-    
 %22PsiFile
@@ -1193,20 +1193,16 @@
 ments%22,%0A
-    
         
@@ -1273,16 +1273,37 @@
 ontains(
+%0A                    
 %22PsiErro
@@ -1391,16 +1391,25 @@
 kResult(
+%0A        
 @NonNls 
@@ -1445,39 +1445,16 @@
 taName,%0A
-                       
         
@@ -1471,16 +1471,21 @@
 ile file
+%0A    
 ) throws
@@ -1575,20 +1575,16 @@
         
-    
 %22%22 + Fil
@@ -1639,20 +1639,16 @@
         
-    
 includeR
@@ -1654,16 +1654,25 @@
 Ranges()
+%0A        
 );%0A    %7D
@@ -1805,16 +1805,17 @@
 le(true,
+ 
 myFullDa

Reformat file before editing