Search in sources :

Example 1 with ImportUriTestLanguageStandaloneSetup

use of org.eclipse.xtext.linking.ImportUriTestLanguageStandaloneSetup in project xtext-core by eclipse.

the class UriBasedReaderTest method testTransitiveReferences.

@SuppressWarnings("unchecked")
@Test
public void testTransitiveReferences() throws Exception {
    UriBasedReader reader = new UriBasedReader();
    reader.addRegister(new ImportUriTestLanguageStandaloneSetup());
    reader.addUri(pathTo2("importUriSubfolder/Start.importuritestlanguage"));
    SlotEntry slotEntry = new SlotEntry();
    slotEntry.setType("Type");
    reader.addLoad(slotEntry);
    WorkflowContext ctx = new WorkflowContextDefaultImpl();
    IssuesImpl issues = new IssuesImpl();
    reader.checkConfiguration(issues);
    try {
        reader.invoke(ctx, new NullProgressMonitor(), issues);
    } catch (Exception e) {
        System.out.println(issues);
        throw e;
    }
    List<Type> types = (List<Type>) ctx.get(slotEntry.getSlot());
    assertEquals(3, types.size());
    for (Type type : types) {
        if (type.getName().equals("Foo")) {
            assertEquals("Bar", type.getExtends().getName());
        } else if (type.getName().equals("Bar")) {
            assertEquals("Baz", type.getExtends().getName());
        } else {
            assertNull(type.getExtends());
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.emf.mwe.core.monitor.NullProgressMonitor) Type(org.eclipse.xtext.linking.importedURI.Type) ImportUriTestLanguageStandaloneSetup(org.eclipse.xtext.linking.ImportUriTestLanguageStandaloneSetup) WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) WorkflowContextDefaultImpl(org.eclipse.emf.mwe.core.WorkflowContextDefaultImpl) IssuesImpl(org.eclipse.emf.mwe.core.issues.IssuesImpl) List(java.util.List) Test(org.junit.Test)

Aggregations

List (java.util.List)1 WorkflowContext (org.eclipse.emf.mwe.core.WorkflowContext)1 WorkflowContextDefaultImpl (org.eclipse.emf.mwe.core.WorkflowContextDefaultImpl)1 IssuesImpl (org.eclipse.emf.mwe.core.issues.IssuesImpl)1 NullProgressMonitor (org.eclipse.emf.mwe.core.monitor.NullProgressMonitor)1 ImportUriTestLanguageStandaloneSetup (org.eclipse.xtext.linking.ImportUriTestLanguageStandaloneSetup)1 Type (org.eclipse.xtext.linking.importedURI.Type)1 Test (org.junit.Test)1