package org.antlr.jetbrains.adaptor.test;

import com.intellij.lang.ParserDefinition;
import com.intellij.testFramework.ParsingTestCase;

public class TestXPath extends ParsingTestCase {
	public TestXPath(String dataPath, String fileExt, ParserDefinition... definitions) {
		super(dataPath, fileExt, definitions);
	}
}

@@ -61,32 +61,60 @@
 ij.lang.
-ParserDefinition
+Language;%0Aimport com.intellij.psi.PsiElement
 ;%0Aimport
@@ -162,183 +162,1149 @@
 se;%0A
-%0Apublic class TestXPath extends ParsingTestCase %7B%0A%09public TestXPath(String dataPath, String fileExt, ParserDefinition... definitions) %7B%0A%09%09super(dataPath, fileExt, definitions)
+import org.antlr.jetbrains.adaptor.xpath.XPath;%0Aimport org.antlr.jetbrains.sample.SampleLanguage;%0Aimport org.antlr.jetbrains.sample.SampleParserDefinition;%0A%0Aimport java.io.IOException;%0Aimport java.util.Collection;%0A%0Apublic class TestXPath extends ParsingTestCase %7B%0A%09public TestXPath() %7B%0A%09%09super(%22%22, %22Sample%22, new SampleParserDefinition());%0A%09%7D%0A%0A%09public void testVarDef() throws Exception %7B%0A%09%09checkXPathResults(SampleLanguage.INSTANCE, %22var x = 1%22, %22/script/statement%22, %22var x = 1%22);%0A%0A%09%7D%0A%0A%09protected void checkXPathResults(Language language, String code, String xpath, String allNodesText) throws IOException %7B%0A%09%09myFile = createPsiFile(%22a%22, code);%0A%09%09ensureParsed(myFile);%0A%09%09assertEquals(code, myFile.getText());%0A%09%09Collection%3C? extends PsiElement%3E nodes = XPath.findAll(language, myFile, xpath);%0A%09%09StringBuilder buf = new StringBuilder();%0A%09%09for (PsiElement t : nodes) %7B%0A%09%09%09buf.append(t.getText());%0A%09%09%7D%0A%09%09assertEquals(allNodesText, buf.toString());%0A%09%7D%0A%0A%09@Override%0A%09protected String getTestDataPath() %7B%0A%09%09return %22.%22;%0A%09%7D%0A%0A%09@Override%0A%09protected boolean skipSpaces() %7B%0A%09%09return false;%0A%09%7D%0A%0A%09@Override%0A%09protected boolean includeRanges() %7B%0A%09%09return true
 ;%0A%09%7D

add first xpath test