// Path: antlr4ide.tests/src/main/java/com/github/jknack/antlr4ide/Antlr4TestInjectorProvider.java
// public class Antlr4TestInjectorProvider extends Antlr4InjectorProvider {
// 	
// 	@Override
// 	protected Injector internalCreateInjector() {
// 		Antlr4TestStandaloneSetup antlr4TestStandaloneSetup = new Antlr4TestStandaloneSetup();
// 		return antlr4TestStandaloneSetup.createInjectorAndDoEMFRegistration();
// 	}
// 
// }
// 
// Path: antlr4ide.tests/src/main/java/com/github/jknack/antlr4ide/parser/Antlr4ParseHelper.java
// @Singleton
// public class Antlr4ParseHelper<T extends EObject> {
// 	
// 	@Inject
// 	private IParser parser;
// 	
// 	public IParseResult parse(final CharSequence input) {
// 		final String content = input.toString();
// 		final StringReader stringReader = new StringReader(content);
// 		return this.parser.parse(stringReader);
// 	}
// 	
// 	@SuppressWarnings({ "hiding", "unchecked" })
// 	public <T extends Object> T build(final CharSequence input) {
// 		final String content = input.toString();
// 		final StringReader stringReader = new StringReader(content);
// 		final IParseResult parseResult = this.parser.parse(stringReader);
// 		final EObject rootAstElement = parseResult.getRootASTElement();
// 		return ((T) rootAstElement);
// 	}
// 	
// 	public String getTextFromFile(final Class<?> clazz)
// 			throws Exception {
// 		return getTextFromFile(clazz, "");
// 	}
// 	
// 	public String getTextFromFile(final Class<?> clazz, final String suffix)
// 			throws Exception {
// 		return getTextFromFile(clazz, suffix, ".g4");
// 	}
// 		
// 	public String getTextFromFile(final Class<?> clazz, final String suffix,
// 			final String fileExtension) throws Exception {
// 		final String dir = "src/main/resources/";
// 		final String dir2 = dir.replace("/", File.separator);
// 		//final Package pkg = clazz.getPackage();
// 		//final String pkgName = pkg.getName();
// 		//final String pkgName2 = pkgName.replace(".", File.separator);
// 		//final String pathAsString = (((dir2 + pkgName2) + File.separator) + fileName);
// 		final String fileName = clazz.getSimpleName() + suffix + fileExtension;
// 		final String pathAsString = dir2 + fileName;
// 		final File file = new File(pathAsString);
// 		final String content = FileUtils.readFileToString(file, "UTF-8");
// 		return content;
// 	}
// 	
// }


import com.github.jknack.antlr4ide.Antlr4TestInjectorProvider;
import com.github.jknack.antlr4ide.lang.Grammar;
import com.github.jknack.antlr4ide.lang.GrammarType;
import com.github.jknack.antlr4ide.lang.Option;
import com.github.jknack.antlr4ide.lang.OptionValue;
import com.github.jknack.antlr4ide.lang.Options;
import com.github.jknack.antlr4ide.lang.PrequelConstruct;
import com.github.jknack.antlr4ide.lang.QualifiedId;
import com.github.jknack.antlr4ide.lang.QualifiedOption;
import com.github.jknack.antlr4ide.parser.Antlr4ParseHelper;
import com.google.inject.Inject;
import java.io.File;
import org.eclipse.emf.common.util.EList;
import org.eclipse.xtext.junit4.InjectWith;
import org.eclipse.xtext.junit4.XtextRunner;
import org.eclipse.xtext.junit4.util.ParseHelper;
import org.eclipse.xtext.parser.IParseResult;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
		try {
			final String suffix = File.separator + "parserGrammar" + File.separator + "P";
			//final String content = this.parser.getTextFromFile(GrammarSyntaxTest.class, suffix);
			final String content = this.helper.getTextFromFile(GrammarSyntaxTest.class, suffix);
			final IParseResult parseResult = this.helper.parse(content);
			final boolean hasSyntaxErrors = parseResult.hasSyntaxErrors();
			Assert.assertFalse(hasSyntaxErrors);
			final Grammar grammar = this.parser.parse(content);
			Assert.assertNotNull(grammar);
			Assert.assertEquals("P", grammar.getName());
			Assert.assertEquals(GrammarType.PARSER, grammar.getType());
		} catch (final Throwable throwable) {
			throw Exceptions.sneakyThrow(throwable);
		}
	}


	@Test
	public void treeGrammar() {
		try {
			final String suffix = File.separator + "treeGrammar" + File.separator + "T";
			//final String content = this.parser.getTextFromFile(GrammarSyntaxTest.class, suffix);
			final String content = this.helper.getTextFromFile(GrammarSyntaxTest.class, suffix, ".txt");
			final IParseResult parseResult = this.helper.parse(content);
			final boolean hasSyntaxErrors = parseResult.hasSyntaxErrors();
			Assert.assertFalse(hasSyntaxErrors);
			final Grammar grammar = this.parser.parse(content);
			Assert.assertNotNull(grammar);
			Assert.assertEquals("T", grammar.getName());
			Assert.assertEquals(GrammarType.TREE, grammar.getType());
// Path: antlr4ide.tests/src/main/java/com/github/jknack/antlr4ide/Antlr4TestInjectorProvider.java
// public class Antlr4TestInjectorProvider extends Antlr4InjectorProvider {
// 	
// 	@Override
// 	protected Injector internalCreateInjector() {
// 		Antlr4TestStandaloneSetup antlr4TestStandaloneSetup = new Antlr4TestStandaloneSetup();
// 		return antlr4TestStandaloneSetup.createInjectorAndDoEMFRegistration();
// 	}
// 
// }
// 
// Path: antlr4ide.tests/src/main/java/com/github/jknack/antlr4ide/parser/Antlr4ParseHelper.java
// @Singleton
// public class Antlr4ParseHelper<T extends EObject> {
// 	
// 	@Inject
// 	private IParser parser;
// 	
// 	public IParseResult parse(final CharSequence input) {
// 		final String content = input.toString();
// 		final StringReader stringReader = new StringReader(content);
// 		return this.parser.parse(stringReader);
// 	}
// 	
// 	@SuppressWarnings({ "hiding", "unchecked" })
// 	public <T extends Object> T build(final CharSequence input) {
// 		final String content = input.toString();
// 		final StringReader stringReader = new StringReader(content);
// 		final IParseResult parseResult = this.parser.parse(stringReader);
// 		final EObject rootAstElement = parseResult.getRootASTElement();
// 		return ((T) rootAstElement);
// 	}
// 	
// 	public String getTextFromFile(final Class<?> clazz)
// 			throws Exception {
// 		return getTextFromFile(clazz, "");
// 	}
// 	
// 	public String getTextFromFile(final Class<?> clazz, final String suffix)
// 			throws Exception {
// 		return getTextFromFile(clazz, suffix, ".g4");
// 	}
// 		
// 	public String getTextFromFile(final Class<?> clazz, final String suffix,
// 			final String fileExtension) throws Exception {
// 		final String dir = "src/main/resources/";
// 		final String dir2 = dir.replace("/", File.separator);
// 		//final Package pkg = clazz.getPackage();
// 		//final String pkgName = pkg.getName();
// 		//final String pkgName2 = pkgName.replace(".", File.separator);
// 		//final String pathAsString = (((dir2 + pkgName2) + File.separator) + fileName);
// 		final String fileName = clazz.getSimpleName() + suffix + fileExtension;
// 		final String pathAsString = dir2 + fileName;
// 		final File file = new File(pathAsString);
// 		final String content = FileUtils.readFileToString(file, "UTF-8");
// 		return content;
// 	}
// 	
// }


// Path: antlr4ide.tests/src/main/java/com/github/jknack/antlr4ide/parser/GrammarSyntaxTest.java
import com.github.jknack.antlr4ide.Antlr4TestInjectorProvider;
import com.github.jknack.antlr4ide.lang.Grammar;
import com.github.jknack.antlr4ide.lang.GrammarType;
import com.github.jknack.antlr4ide.lang.Option;
import com.github.jknack.antlr4ide.lang.OptionValue;
import com.github.jknack.antlr4ide.lang.Options;
import com.github.jknack.antlr4ide.lang.PrequelConstruct;
import com.github.jknack.antlr4ide.lang.QualifiedId;
import com.github.jknack.antlr4ide.lang.QualifiedOption;
import com.github.jknack.antlr4ide.parser.Antlr4ParseHelper;
import com.google.inject.Inject;
import java.io.File;
import org.eclipse.emf.common.util.EList;
import org.eclipse.xtext.junit4.InjectWith;
import org.eclipse.xtext.junit4.XtextRunner;
import org.eclipse.xtext.junit4.util.ParseHelper;
import org.eclipse.xtext.parser.IParseResult;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

		try {
			final String suffix = File.separator + "parserGrammar" + File.separator + "P";
			//final String content = this.parser.getTextFromFile(GrammarSyntaxTest.class, suffix);
			final String content = this.helper.getTextFromFile(GrammarSyntaxTest.class, suffix);
			final IParseResult parseResult = this.helper.parse(content);
			final boolean hasSyntaxErrors = parseResult.hasSyntaxErrors();
			Assert.assertFalse(hasSyntaxErrors);
			final Grammar grammar = this.parser.parse(content);
			Assert.assertNotNull(grammar);
			Assert.assertEquals("P", grammar.getName());
			Assert.assertEquals(GrammarType.PARSER, grammar.getType());
		} catch (final Throwable throwable) {
			throw Exceptions.sneakyThrow(throwable);
		}
	}


	@Test
	public void treeGrammar() {
		try {
			final String suffix = File.separator + "treeGrammar" + File.separator + "T";
			//final String content = this.parser.getTextFromFile(GrammarSyntaxTest.class, suffix);
			final String content = this.helper.getTextFromFile(GrammarSyntaxTest.class, suffix, ".txt");
			final IParseResult parseResult = this.helper.parse(content);
			final boolean hasSyntaxErrors = parseResult.hasSyntaxErrors();
			Assert.assertFalse(hasSyntaxErrors);
			final Grammar grammar = this.parser.parse(content);
			Assert.assertNotNull(grammar);
			Assert.assertEquals("T", grammar.getName());
			Assert.assertEquals(GrammarType.TREE, grammar.getType());
		} catch (final Throwable throwable) {