本文整理匯總了Java中org.eclipse.xtext.resource.XtextResource.getErrors方法的典型用法代碼示例。如果您正苦於以下問題:Java XtextResource.getErrors方法的具體用法?Java XtextResource.getErrors怎麽用?Java XtextResource.getErrors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.xtext.resource.XtextResource
的用法示例。
在下文中一共展示了XtextResource.getErrors方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getResourceAndExpect
import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
public final XtextResource getResourceAndExpect(InputStream in, URI uri, int expectedErrors) throws Exception {
XtextResource resource = doGetResource(in, uri);
checkNodeModel(resource);
if (expectedErrors != UNKNOWN_EXPECTATION) {
if (expectedErrors == EXPECT_ERRORS)
assertFalse(Joiner.on('\n').join(resource.getErrors()), resource.getErrors().isEmpty());
else
assertEquals(Joiner.on('\n').join(resource.getErrors()), expectedErrors, resource.getErrors().size());
}
for(Diagnostic d: resource.getErrors()) {
if (d instanceof ExceptionDiagnostic)
fail(d.getMessage());
}
if (expectedErrors == 0 && resource.getContents().size() > 0 && shouldTestSerializer(resource)) {
SerializerTestHelper tester = get(SerializerTestHelper.class);
EObject obj = resource.getContents().get(0);
tester.assertSerializeWithNodeModel(obj);
tester.assertSerializeWithoutNodeModel(obj);
}
return resource;
}
示例2: testAbstractLanguageToMetamodel
import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
@Test public void testAbstractLanguageToMetamodel() throws Exception {
XtextResource r = getResource("classpath:/" + AbstractTestLanguage.class.getName().replace('.', '/') + ".xtext");
Grammar element = (Grammar) r.getParseResult().getRootASTElement();
if (!r.getErrors().isEmpty()) {
EList<Diagnostic> errors = r.getErrors();
for (Diagnostic syntaxError : errors) {
logger.debug(syntaxError.getMessage() + " - " + syntaxError.getLine());
}
fail(errors.toString());
}
List<TerminalRule> lexerRules = GrammarUtil.allTerminalRules(element);
assertEquals(8, lexerRules.size());
List<EPackage> list = Xtext2EcoreTransformer.doGetGeneratedPackages(element);
assertNotNull(list);
assertEquals(0, list.size());
}
示例3: testNoException_01
import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
@Test
public void testNoException_01() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar test with org.eclipse.xtext.common.Terminals import \'http://www.eclipse.org/emf/2002/Ecore\' as ecore generate test \'http://test\'");
_builder.newLine();
_builder.append("CompositeModel: (model+=Model)+;");
_builder.newLine();
_builder.append("Model: id=NestedModelId (\':\' value=Fraction)? (\'#\' vector=Vector)? (\'+\' dots=Dots)? \';\'");
_builder.newLine();
_builder.append("ModelId returns ecore::EString: ID \'.\' ID;");
_builder.newLine();
_builder.append("NestedModelId : ModelId \'.\' ModelId;");
_builder.newLine();
_builder.append("Fraction returns EBigDecimal: INT (\'/\' INT)?;");
_builder.newLine();
_builder.append("Vector : \'(\' INT I");
String grammar = _builder.toString();
final XtextResource resource = this.getResourceFromStringAndExpect(grammar, 10);
EList<Resource.Diagnostic> _errors = resource.getErrors();
for (final Resource.Diagnostic d : _errors) {
Assert.assertFalse((d instanceof ExceptionDiagnostic));
}
}
示例4: testNoException_02
import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
@Test
public void testNoException_02() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar test with org.eclipse.xtext.common.Terminals generate test \'http://test\'");
_builder.newLine();
_builder.append("Model: (children+=Element)*;");
_builder.newLine();
_builder.append("Element returns Type: Item ( { Item.items+=current } items+=Item );");
_builder.newLine();
_builder.append("Item returns Type:\t{ T");
String grammar = _builder.toString();
final XtextResource resource = this.getResourceFromStringAndExpect(grammar, 1);
EList<Resource.Diagnostic> _errors = resource.getErrors();
for (final Resource.Diagnostic d : _errors) {
Assert.assertFalse((d instanceof ExceptionDiagnostic));
}
}
示例5: testBug_266807
import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
@Test
public void testBug_266807() throws Exception {
final XtextResourceSet rs = this.<XtextResourceSet>get(XtextResourceSet.class);
rs.setClasspathURIContext(this.getClass());
StringConcatenation _builder = new StringConcatenation();
_builder.append("classpath:/");
String _replace = this.getClass().getPackage().getName().replace(Character.valueOf('.').charValue(), Character.valueOf('/').charValue());
_builder.append(_replace);
_builder.append("/Test.xtext");
Resource _createResource = rs.createResource(
URI.createURI(_builder.toString()),
ContentHandler.UNSPECIFIED_CONTENT_TYPE);
final XtextResource resource = ((XtextResource) _createResource);
resource.load(null);
EList<Resource.Diagnostic> _errors = resource.getErrors();
for (final Resource.Diagnostic d : _errors) {
Assert.fail(d.getMessage());
}
}
示例6: testBug_272566_3
import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
@Test
public void testBug_272566_3() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar test with org.eclipse.xtext.common.Terminals");
_builder.newLine();
_builder.append("generate test \'http://test\'");
_builder.newLine();
_builder.append("Model:");
_builder.newLine();
_builder.append(" ");
_builder.append("test=Test");
_builder.newLine();
_builder.append(";");
_builder.newLine();
_builder.newLine();
_builder.append("Test:");
_builder.newLine();
_builder.append(" ");
_builder.append("\"keyword\" MyEnum name=ID");
_builder.newLine();
_builder.append(";");
_builder.newLine();
_builder.append("enum MyEnum:");
_builder.newLine();
_builder.append("\t");
_builder.append("A | B;");
_builder.newLine();
String grammar = _builder.toString();
final XtextResource resource = this.getResourceFromStringAndExpect(grammar, 1);
Assert.assertFalse(resource.getErrors().toString(), resource.getErrors().isEmpty());
EList<Resource.Diagnostic> _errors = resource.getErrors();
for (final Resource.Diagnostic d : _errors) {
Assert.assertFalse((d instanceof ExceptionDiagnostic));
}
}