use of org.eclipse.xtext.linking.LangATestLanguageStandaloneSetup in project xtext-core by eclipse.
the class ResourceValidatorImplTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
with(new LangATestLanguageStandaloneSetup());
EValidator.Registry.INSTANCE.put(LangATestLanguagePackage.eINSTANCE, new EValidator() {
@Override
public boolean validate(EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) {
if (eObject instanceof Type) {
String name = ((Type) eObject).getName();
if (name.equals("Foo"))
diagnostics.add(new BasicDiagnostic(Diagnostic.ERROR, "", 12, "Foo", null));
if (name.equals("Bar"))
diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, "", 12, "Foo", null));
}
return true;
}
@Override
public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) {
return validate(eObject, diagnostics, context);
}
@Override
public boolean validate(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context) {
return false;
}
});
}
use of org.eclipse.xtext.linking.LangATestLanguageStandaloneSetup in project xtext-core by eclipse.
the class DefaultReferenceDescriptionTest method testgetReferenceDescriptions.
@Test
public void testgetReferenceDescriptions() throws Exception {
with(new LangATestLanguageStandaloneSetup());
XtextResource targetResource = getResource("type C", "bar.langatestlanguage");
EObject typeC = targetResource.getContents().get(0).eContents().get(0);
XtextResource resource = (XtextResource) targetResource.getResourceSet().createResource(URI.createURI("foo.langatestlanguage"));
resource.load(new StringInputStream("type A extends C type B extends A"), null);
EcoreUtil2.resolveLazyCrossReferences(resource, CancelIndicator.NullImpl);
IResourceDescription resDesc = resource.getResourceServiceProvider().getResourceDescriptionManager().getResourceDescription(resource);
Iterable<IReferenceDescription> descriptions = resDesc.getReferenceDescriptions();
Collection<IReferenceDescription> collection = Lists.newArrayList(descriptions);
assertEquals(1, collection.size());
IReferenceDescription refDesc = descriptions.iterator().next();
Main m = (Main) resource.getParseResult().getRootASTElement();
assertEquals(m.getTypes().get(0), resource.getResourceSet().getEObject(refDesc.getSourceEObjectUri(), false));
assertEquals(typeC, resource.getResourceSet().getEObject(refDesc.getTargetEObjectUri(), false));
assertEquals(-1, refDesc.getIndexInList());
assertEquals(LangATestLanguagePackage.Literals.TYPE__EXTENDS, refDesc.getEReference());
}
use of org.eclipse.xtext.linking.LangATestLanguageStandaloneSetup in project xtext-core by eclipse.
the class DefaultResourceDescription2Test method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
with(new LangATestLanguageStandaloneSetup());
}
use of org.eclipse.xtext.linking.LangATestLanguageStandaloneSetup in project xtext-core by eclipse.
the class DefaultReferenceDescriptionTest method testgetReferenceDescriptionForMultiValue.
@Test
public void testgetReferenceDescriptionForMultiValue() throws Exception {
with(new LangATestLanguageStandaloneSetup());
XtextResource targetResource = getResource("type C type D", "bar.langatestlanguage");
EObject typeC = targetResource.getContents().get(0).eContents().get(0);
EObject typeD = targetResource.getContents().get(0).eContents().get(1);
XtextResource resource = (XtextResource) targetResource.getResourceSet().createResource(URI.createURI("foo.langatestlanguage"));
resource.load(new StringInputStream("type A implements B,C,D type B"), null);
EcoreUtil2.resolveLazyCrossReferences(resource, CancelIndicator.NullImpl);
IResourceDescription resDesc = resource.getResourceServiceProvider().getResourceDescriptionManager().getResourceDescription(resource);
Iterable<IReferenceDescription> descriptions = resDesc.getReferenceDescriptions();
Collection<IReferenceDescription> collection = Lists.newArrayList(descriptions);
assertEquals(2, collection.size());
Iterator<IReferenceDescription> iterator = descriptions.iterator();
IReferenceDescription refDesc1 = iterator.next();
IReferenceDescription refDesc2 = iterator.next();
Main m = (Main) resource.getParseResult().getRootASTElement();
assertEquals(m.getTypes().get(0), resource.getResourceSet().getEObject(refDesc1.getSourceEObjectUri(), false));
assertEquals(typeC, resource.getResourceSet().getEObject(refDesc1.getTargetEObjectUri(), false));
assertEquals(1, refDesc1.getIndexInList());
assertEquals(LangATestLanguagePackage.Literals.TYPE__IMPLEMENTS, refDesc1.getEReference());
assertEquals(m.getTypes().get(0), resource.getResourceSet().getEObject(refDesc2.getSourceEObjectUri(), false));
assertEquals(typeD, resource.getResourceSet().getEObject(refDesc2.getTargetEObjectUri(), false));
assertEquals(2, refDesc2.getIndexInList());
assertEquals(LangATestLanguagePackage.Literals.TYPE__IMPLEMENTS, refDesc2.getEReference());
}
use of org.eclipse.xtext.linking.LangATestLanguageStandaloneSetup in project xtext-core by eclipse.
the class PortableURIsTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
LangATestLanguageStandaloneSetup _langATestLanguageStandaloneSetup = new LangATestLanguageStandaloneSetup();
this.with(_langATestLanguageStandaloneSetup);
}
Aggregations