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);
    }

}

@@ -340,16 +340,58 @@
 .NonNls;
+%0Aimport org.jetbrains.annotations.NotNull;
 %0A%0Aimport
@@ -1442,16 +1442,25 @@
         
+@NotNull 
 @NonNls 
@@ -1504,16 +1504,25 @@
         
+@NotNull 
 final Ps
@@ -1551,32 +1551,112 @@
 s IOException %7B%0A
+        final String fullTargetDataName = %22%22 + File.separator + targetDataName;%0A
         doCheckR
@@ -1661,16 +1661,29 @@
 kResult(
+%0A            
 myFullDa
@@ -1693,14 +1693,38 @@
 ath,
- file,
+%0A            file,%0A           
  che
@@ -1752,39 +1752,21 @@
         
-%22%22 + File.separator + t
+fullT
 argetDat
@@ -1771,16 +1771,28 @@
 ataName,
+%0A           
  skipSpa

Fix warning, missing annotation