use of org.eclipse.xtext.linking.langATestLanguage.Main in project xtext-core by eclipse.
the class InjectableValidatorTest method testCorrectResource.
@Test
public void testCorrectResource() throws Exception {
Main main = LangATestLanguageFactory.eINSTANCE.createMain();
xtextResource.getContents().add(main);
assertFalse(languageSpecificValidator.validate(main, new BasicDiagnostic(), null));
assertFalse(languageSpecificValidator.validate(main, new BasicDiagnostic(), context));
assertEquals(xtextResource.getLanguageName(), context.get(AbstractInjectableValidator.CURRENT_LANGUAGE_NAME));
context.clear();
assertFalse(languageAgnosticValidator.validate(main, new BasicDiagnostic(), null));
assertFalse(languageAgnosticValidator.validate(main, new BasicDiagnostic(), context));
assertNull(context.get(AbstractInjectableValidator.CURRENT_LANGUAGE_NAME));
}
use of org.eclipse.xtext.linking.langATestLanguage.Main in project xtext-core by eclipse.
the class CrossRefTest method testNonDefaultLinkText.
/* see https://bugs.eclipse.org/bugs/show_bug.cgi?id=287813 */
@Test
public void testNonDefaultLinkText() throws Exception {
XtextResource r = getResourceFromString("type TypeA extends ^TypeB type TypeB");
Main model = (Main) r.getContents().get(0);
assertEquals(2, model.getTypes().size());
Type type = model.getTypes().get(0);
assertEquals("TypeA", type.getName());
Type superType = type.getExtends();
assertEquals("TypeB", superType.getName());
INode node = getCrossReferenceNode(type, GrammarUtil.getReference(grammar.getTypeAccess().getExtendsTypeCrossReference_2_1_0()), superType);
String linkText = crossRefSerializer.serializeCrossRef(type, grammar.getTypeAccess().getExtendsTypeCrossReference_2_1_0(), superType, node);
assertTrue(ITokenSerializer.KEEP_VALUE_FROM_NODE_MODEL == linkText);
}
use of org.eclipse.xtext.linking.langATestLanguage.Main in project xtext-core by eclipse.
the class CrossRefTest method testSerializingProxiedCrossReference.
/* see https://bugs.eclipse.org/bugs/show_bug.cgi?id=325435 */
@Test
public void testSerializingProxiedCrossReference() throws Exception {
XtextResource r = getResourceFromString("type TypeA extends ^TypeB type TypeB ");
Main model = (Main) r.getContents().get(0);
Type type = model.getTypes().get(0);
Type superType = type.getExtends();
CrossRefLinkingService linkingService = (CrossRefLinkingService) get(ILinkingService.class);
InternalEObject typeProxy = (InternalEObject) LangATestLanguageFactory.eINSTANCE.createType();
typeProxy.eSetProxyURI(EcoreUtil.getURI(superType));
linkingService.returnOnceForGetLinkedObjects(typeProxy);
INode node = getCrossReferenceNode(type, GrammarUtil.getReference(grammar.getTypeAccess().getExtendsTypeCrossReference_2_1_0()), superType);
String linkText = crossRefSerializer.serializeCrossRef(type, grammar.getTypeAccess().getExtendsTypeCrossReference_2_1_0(), superType, node);
assertEquals(ITokenSerializer.KEEP_VALUE_FROM_NODE_MODEL, linkText);
}
use of org.eclipse.xtext.linking.langATestLanguage.Main in project xtext-core by eclipse.
the class CrossRefTest method testSimple.
@Test
public void testSimple() throws Exception {
Main model = (Main) getModel("type A extends B type B extends A");
assertEquals("B", model.getTypes().get(0).getExtends().getName());
assertEquals(model.getTypes().get(0), model.getTypes().get(0).getExtends().getExtends());
}
use of org.eclipse.xtext.linking.langATestLanguage.Main in project xtext-core by eclipse.
the class LinkingErrorTest method testNoErrors.
@Test
public void testNoErrors() throws Exception {
XtextResource resource = getResourceFromString(" type A extends B \n type B extends A");
Main model = (Main) getModel(resource);
assertEquals(2, model.getTypes().size());
assertEquals(0, resource.getErrors().size());
assertEquals(0, resource.getWarnings().size());
}
Aggregations